diff --git a/README.md b/README.md index 16a6a26..3005f0d 100644 --- a/README.md +++ b/README.md @@ -8,26 +8,13 @@ A component to keep track of release checking. + *Author*: [Joomla! Project](mailto:admin@joomla.org) + *Name*: [Track Release Checking](http://www.joomla.org) + *First Build*: 29th July, 2020 -+ *Last Build*: 10th December, 2020 ++ *Last Build*: 8th March, 2021 + *Version*: 1.0.x + *Copyright*: (C) 2020 Open Source Matters, Inc. + *License*: GNU General Public License version 2 or later; see LICENSE.txt ## Some Fun Numbers -+ *Line count*: **21121** ++ *Line count*: **21151** + *File count*: **200** + *Folder count*: **56** - -**59 Hours** or **7 Eight Hour Days** (actual time the author saved - -due to [Automated Component Builder](http://joomlacomponentbuilder.com)) - -> (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.) - -## Maintenance of the Source Code - -The [Joomla! Component Builder](http://joomlacomponentbuilder.com) project will be used to facilitate the maintenance of the source code of this component. - -More details, with tutorials to follow. - diff --git a/admin/README.txt b/admin/README.txt index 16a6a26..3005f0d 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -8,26 +8,13 @@ A component to keep track of release checking. + *Author*: [Joomla! Project](mailto:admin@joomla.org) + *Name*: [Track Release Checking](http://www.joomla.org) + *First Build*: 29th July, 2020 -+ *Last Build*: 10th December, 2020 ++ *Last Build*: 8th March, 2021 + *Version*: 1.0.x + *Copyright*: (C) 2020 Open Source Matters, Inc. + *License*: GNU General Public License version 2 or later; see LICENSE.txt ## Some Fun Numbers -+ *Line count*: **21121** ++ *Line count*: **21151** + *File count*: **200** + *Folder count*: **56** - -**59 Hours** or **7 Eight Hour Days** (actual time the author saved - -due to [Automated Component Builder](http://joomlacomponentbuilder.com)) - -> (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.) - -## Maintenance of the Source Code - -The [Joomla! Component Builder](http://joomlacomponentbuilder.com) project will be used to facilitate the maintenance of the source code of this component. - -More details, with tutorials to follow. - diff --git a/admin/access.xml b/admin/access.xml index 0f3e462..ed151b6 100644 --- a/admin/access.xml +++ b/admin/access.xml @@ -1,5 +1,5 @@ - - + +
@@ -60,5 +60,5 @@
-
+
\ No newline at end of file diff --git a/admin/assets/css/action.css b/admin/assets/css/action.css index 11b352c..1bbbbc8 100644 --- a/admin/assets/css/action.css +++ b/admin/assets/css/action.css @@ -4,8 +4,8 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -/* CSS Document */ - - + */ + +/* CSS Document */ + + diff --git a/admin/assets/css/actions.css b/admin/assets/css/actions.css index 11b352c..1bbbbc8 100644 --- a/admin/assets/css/actions.css +++ b/admin/assets/css/actions.css @@ -4,8 +4,8 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -/* CSS Document */ - - + */ + +/* CSS Document */ + + diff --git a/admin/assets/css/admin.css b/admin/assets/css/admin.css index 1777e25..54acefa 100644 --- a/admin/assets/css/admin.css +++ b/admin/assets/css/admin.css @@ -4,10 +4,10 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -/* CSS Document */ -.no-click { - pointer-events: none; -} - + */ + +/* CSS Document */ +.no-click { + pointer-events: none; +} + diff --git a/admin/assets/css/context.css b/admin/assets/css/context.css index 11b352c..1bbbbc8 100644 --- a/admin/assets/css/context.css +++ b/admin/assets/css/context.css @@ -4,8 +4,8 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -/* CSS Document */ - - + */ + +/* CSS Document */ + + diff --git a/admin/assets/css/contexts.css b/admin/assets/css/contexts.css index 11b352c..1bbbbc8 100644 --- a/admin/assets/css/contexts.css +++ b/admin/assets/css/contexts.css @@ -4,8 +4,8 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -/* CSS Document */ - - + */ + +/* CSS Document */ + + diff --git a/admin/assets/css/joomla_version.css b/admin/assets/css/joomla_version.css index 11b352c..1bbbbc8 100644 --- a/admin/assets/css/joomla_version.css +++ b/admin/assets/css/joomla_version.css @@ -4,8 +4,8 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -/* CSS Document */ - - + */ + +/* CSS Document */ + + diff --git a/admin/assets/css/joomla_versions.css b/admin/assets/css/joomla_versions.css index 11b352c..1bbbbc8 100644 --- a/admin/assets/css/joomla_versions.css +++ b/admin/assets/css/joomla_versions.css @@ -4,8 +4,8 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -/* CSS Document */ - - + */ + +/* CSS Document */ + + diff --git a/admin/assets/css/release_check.css b/admin/assets/css/release_check.css index 4fa40f8..7837457 100644 --- a/admin/assets/css/release_check.css +++ b/admin/assets/css/release_check.css @@ -4,10 +4,10 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -/* CSS Document */ - + */ + +/* CSS Document */ + .control-wrapper-context .input-append { width: 85% !important; @@ -20,4 +20,4 @@ } .control-wrapper-action .input-append #jform_action_chzn { width: 100% !important; -} +} diff --git a/admin/assets/css/release_checks.css b/admin/assets/css/release_checks.css index 2479f3d..4f0271e 100644 --- a/admin/assets/css/release_checks.css +++ b/admin/assets/css/release_checks.css @@ -4,10 +4,10 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -/* CSS Document */ - + */ + +/* CSS Document */ + .outcome { padding: 10px; @@ -26,4 +26,4 @@ } .outcome-undecided { background-color: blue; -} +} diff --git a/admin/config.xml b/admin/config.xml index 79f268f..a258f76 100644 --- a/admin/config.xml +++ b/admin/config.xml @@ -1,5 +1,5 @@ - - + +
COM_RELEASE_CHECKING_CONFIG_DEACTIVATE -
-
- -
+ +
+ +
\ No newline at end of file diff --git a/admin/controller.php b/admin/controller.php index 921af97..a8247ca 100644 --- a/admin/controller.php +++ b/admin/controller.php @@ -5,109 +5,109 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\Utilities\ArrayHelper; - -/** - * General Controller of Release_checking component - */ -class Release_checkingController extends JControllerLegacy -{ - /** - * Constructor. - * - * @param array $config An optional associative array of configuration settings. - * Recognized key values include 'name', 'default_task', 'model_path', and - * 'view_path' (this list is not meant to be comprehensive). - * - * @since 3.0 - */ - public function __construct($config = array()) - { - // set the default view - $config['default_view'] = 'release_checks'; - - parent::__construct($config); - } - - /** - * display task - * - * @return void - */ - function display($cachable = false, $urlparams = false) - { - // set default view if not set - $view = $this->input->getCmd('view', 'release_checks'); - $data = $this->getViewRelation($view); - $layout = $this->input->get('layout', null, 'WORD'); - $id = $this->input->getInt('id'); - - // Check for edit form. - if(Release_checkingHelper::checkArray($data)) - { - if ($data['edit'] && $layout == 'edit' && !$this->checkEditId('com_release_checking.edit.'.$data['view'], $id)) - { - // Somehow the person just went to the form - we don't allow that. - $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); - $this->setMessage($this->getError(), 'error'); - // check if item was opend from other then its own list view - $ref = $this->input->getCmd('ref', 0); - $refid = $this->input->getInt('refid', 0); - // set redirect - if ($refid > 0 && Release_checkingHelper::checkString($ref)) - { - // redirect to item of ref - $this->setRedirect(JRoute::_('index.php?option=com_release_checking&view='.(string)$ref.'&layout=edit&id='.(int)$refid, false)); - } - elseif (Release_checkingHelper::checkString($ref)) - { - - // redirect to ref - $this->setRedirect(JRoute::_('index.php?option=com_release_checking&view='.(string)$ref, false)); - } - else - { - // normal redirect back to the list view - $this->setRedirect(JRoute::_('index.php?option=com_release_checking&view='.$data['views'], false)); - } - - return false; - } - } - - return parent::display($cachable, $urlparams); - } - - protected function getViewRelation($view) - { - // check the we have a value - if (Release_checkingHelper::checkString($view)) - { - // the view relationships + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\Utilities\ArrayHelper; + +/** + * General Controller of Release_checking component + */ +class Release_checkingController extends JControllerLegacy +{ + /** + * Constructor. + * + * @param array $config An optional associative array of configuration settings. + * Recognized key values include 'name', 'default_task', 'model_path', and + * 'view_path' (this list is not meant to be comprehensive). + * + * @since 3.0 + */ + public function __construct($config = array()) + { + // set the default view + $config['default_view'] = 'release_checks'; + + parent::__construct($config); + } + + /** + * display task + * + * @return void + */ + function display($cachable = false, $urlparams = false) + { + // set default view if not set + $view = $this->input->getCmd('view', 'release_checks'); + $data = $this->getViewRelation($view); + $layout = $this->input->get('layout', null, 'WORD'); + $id = $this->input->getInt('id'); + + // Check for edit form. + if(Release_checkingHelper::checkArray($data)) + { + if ($data['edit'] && $layout == 'edit' && !$this->checkEditId('com_release_checking.edit.'.$data['view'], $id)) + { + // Somehow the person just went to the form - we don't allow that. + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); + $this->setMessage($this->getError(), 'error'); + // check if item was opend from other then its own list view + $ref = $this->input->getCmd('ref', 0); + $refid = $this->input->getInt('refid', 0); + // set redirect + if ($refid > 0 && Release_checkingHelper::checkString($ref)) + { + // redirect to item of ref + $this->setRedirect(JRoute::_('index.php?option=com_release_checking&view='.(string)$ref.'&layout=edit&id='.(int)$refid, false)); + } + elseif (Release_checkingHelper::checkString($ref)) + { + + // redirect to ref + $this->setRedirect(JRoute::_('index.php?option=com_release_checking&view='.(string)$ref, false)); + } + else + { + // normal redirect back to the list view + $this->setRedirect(JRoute::_('index.php?option=com_release_checking&view='.$data['views'], false)); + } + + return false; + } + } + + return parent::display($cachable, $urlparams); + } + + protected function getViewRelation($view) + { + // check the we have a value + if (Release_checkingHelper::checkString($view)) + { + // the view relationships $views = array( 'release_check' => 'release_checks', 'joomla_version' => 'joomla_versions', 'context' => 'contexts', - 'action' => 'actions' - ); - // check if this is a list view - if (in_array($view, $views)) - { - // this is a list view - return array('edit' => false, 'view' => array_search($view,$views), 'views' => $view); - } - // check if it is an edit view - elseif (array_key_exists($view, $views)) - { - // this is a edit view - return array('edit' => true, 'view' => $view, 'views' => $views[$view]); - } - } - return false; - } -} + 'action' => 'actions' + ); + // check if this is a list view + if (in_array($view, $views)) + { + // this is a list view + return array('edit' => false, 'view' => array_search($view,$views), 'views' => $view); + } + // check if it is an edit view + elseif (array_key_exists($view, $views)) + { + // this is a edit view + return array('edit' => true, 'view' => $view, 'views' => $views[$view]); + } + } + return false; + } +} diff --git a/admin/controllers/action.php b/admin/controllers/action.php index 9295ffc..1efb97f 100644 --- a/admin/controllers/action.php +++ b/admin/controllers/action.php @@ -5,50 +5,50 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\Utilities\ArrayHelper; - -/** - * Action Controller - */ -class Release_checkingControllerAction extends JControllerForm -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Actions'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\Utilities\ArrayHelper; + +/** + * Action Controller + */ +class Release_checkingControllerAction extends JControllerForm +{ + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * Class constructor. + * + * @param array $config A named array of configuration variables. + * + * @since 1.6 + */ + public function __construct($config = array()) + { + $this->view_list = 'Actions'; // safeguard for setting the return view listing to the main view. + parent::__construct($config); + } + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = array()) { // Get user object. $user = JFactory::getUser(); @@ -60,20 +60,20 @@ class Release_checkingControllerAction extends JControllerForm } // In the absense of better information, revert to the component permissions. - return parent::allowAdd($data); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') + return parent::allowAdd($data); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = array(), $key = 'id') { // get user object. $user = JFactory::getUser(); @@ -116,199 +116,199 @@ class Release_checkingControllerAction extends JControllerForm } } // Since there is no permission, revert to the component permissions. - return parent::allowEdit($data, $key); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // 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'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Action', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_release_checking&view=actions' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // 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 (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $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( - 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 - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // 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'); - $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'; - } - - $saved = parent::save($key, $urlVar); - - // 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 = 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( - 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 - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) + return parent::allowEdit($data, $key); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') { - return; - } - -} + // 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'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string)$ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Action', '', array()); + + // Preset the redirect + $this->setRedirect(JRoute::_('index.php?option=com_release_checking&view=actions' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // 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 (!is_null($return) && JUri::isInternal(base64_decode($return))) + { + $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( + 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 + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // 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'); + $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'; + } + + $saved = parent::save($key, $urlVar); + + // 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 = 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( + 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 + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param JModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(JModelLegacy $model, $validData = array()) + { + return; + } + +} diff --git a/admin/controllers/actions.php b/admin/controllers/actions.php index 3eb401a..94be96a 100644 --- a/admin/controllers/actions.php +++ b/admin/controllers/actions.php @@ -5,40 +5,40 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\Utilities\ArrayHelper; - -/** - * Actions Controller - */ -class Release_checkingControllerActions extends JControllerAdmin -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_RELEASE_CHECKING_ACTIONS'; - - /** - * 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 = 'Action', $prefix = 'Release_checkingModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\Utilities\ArrayHelper; + +/** + * Actions Controller + */ +class Release_checkingControllerActions extends JControllerAdmin +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_RELEASE_CHECKING_ACTIONS'; + + /** + * 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 = 'Action', $prefix = 'Release_checkingModel', $config = array('ignore_request' => true)) + { + return parent::getModel($name, $prefix, $config); } public function exportData() @@ -102,5 +102,5 @@ class Release_checkingControllerActions extends JControllerAdmin $message = JText::_('COM_RELEASE_CHECKING_IMPORT_FAILED'); $this->setRedirect(JRoute::_('index.php?option=com_release_checking&view=actions', false), $message, 'error'); return; - } -} + } +} diff --git a/admin/controllers/ajax.json.php b/admin/controllers/ajax.json.php index 8cdfef9..fa13cc6 100644 --- a/admin/controllers/ajax.json.php +++ b/admin/controllers/ajax.json.php @@ -5,41 +5,41 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\Utilities\ArrayHelper; - -/** - * Release_checking Ajax Controller - */ -class Release_checkingControllerAjax extends JControllerLegacy -{ - public function __construct($config) - { - parent::__construct($config); - // make sure all json stuff are set - JFactory::getDocument()->setMimeEncoding( 'application/json' ); - JResponse::setHeader('Content-Disposition','attachment;filename="getajax.json"'); - JResponse::setHeader("Access-Control-Allow-Origin", "*"); + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\Utilities\ArrayHelper; + +/** + * Release_checking Ajax Controller + */ +class Release_checkingControllerAjax extends JControllerLegacy +{ + public function __construct($config) + { + parent::__construct($config); + // make sure all json stuff are set + JFactory::getDocument()->setMimeEncoding( 'application/json' ); + JResponse::setHeader('Content-Disposition','attachment;filename="getajax.json"'); + JResponse::setHeader("Access-Control-Allow-Origin", "*"); // load the tasks $this->registerTask('getAction', 'ajax'); - $this->registerTask('getActionDescription', 'ajax'); - } - - public function ajax() - { - $user = JFactory::getUser(); - $jinput = JFactory::getApplication()->input; - // Check Token! - $token = JSession::getFormToken(); - $call_token = $jinput->get('token', 0, 'ALNUM'); - if($jinput->get($token, 0, 'ALNUM') || $token === $call_token) - { - $task = $this->getTask(); - switch($task) + $this->registerTask('getActionDescription', 'ajax'); + } + + public function ajax() + { + $user = JFactory::getUser(); + $jinput = JFactory::getApplication()->input; + // Check Token! + $token = JSession::getFormToken(); + $call_token = $jinput->get('token', 0, 'ALNUM'); + if($jinput->get($token, 0, 'ALNUM') || $token === $call_token) + { + $task = $this->getTask(); + switch($task) { case 'getAction': try @@ -118,19 +118,19 @@ class Release_checkingControllerAjax extends JControllerLegacy echo "(".json_encode($e).");"; } } - break; - } - } - else - { - if($callback = $jinput->get('callback', null, 'CMD')) - { - echo $callback."(".json_encode(false).");"; - } - else - { - echo "(".json_encode(false).");"; - } - } - } -} + break; + } + } + else + { + if($callback = $jinput->get('callback', null, 'CMD')) + { + echo $callback."(".json_encode(false).");"; + } + else + { + echo "(".json_encode(false).");"; + } + } + } +} diff --git a/admin/controllers/context.php b/admin/controllers/context.php index ff4ceb7..bc73015 100644 --- a/admin/controllers/context.php +++ b/admin/controllers/context.php @@ -5,50 +5,50 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\Utilities\ArrayHelper; - -/** - * Context Controller - */ -class Release_checkingControllerContext extends JControllerForm -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Contexts'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\Utilities\ArrayHelper; + +/** + * Context Controller + */ +class Release_checkingControllerContext extends JControllerForm +{ + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * Class constructor. + * + * @param array $config A named array of configuration variables. + * + * @since 1.6 + */ + public function __construct($config = array()) + { + $this->view_list = 'Contexts'; // safeguard for setting the return view listing to the main view. + parent::__construct($config); + } + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = array()) { // Get user object. $user = JFactory::getUser(); @@ -60,20 +60,20 @@ class Release_checkingControllerContext extends JControllerForm } // In the absense of better information, revert to the component permissions. - return parent::allowAdd($data); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') + return parent::allowAdd($data); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = array(), $key = 'id') { // get user object. $user = JFactory::getUser(); @@ -116,199 +116,199 @@ class Release_checkingControllerContext extends JControllerForm } } // Since there is no permission, revert to the component permissions. - return parent::allowEdit($data, $key); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // 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'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Context', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_release_checking&view=contexts' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // 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 (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $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( - 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 - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // 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'); - $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'; - } - - $saved = parent::save($key, $urlVar); - - // 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 = 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( - 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 - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) + return parent::allowEdit($data, $key); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') { - return; - } - -} + // 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'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string)$ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Context', '', array()); + + // Preset the redirect + $this->setRedirect(JRoute::_('index.php?option=com_release_checking&view=contexts' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // 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 (!is_null($return) && JUri::isInternal(base64_decode($return))) + { + $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( + 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 + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // 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'); + $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'; + } + + $saved = parent::save($key, $urlVar); + + // 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 = 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( + 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 + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param JModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(JModelLegacy $model, $validData = array()) + { + return; + } + +} diff --git a/admin/controllers/contexts.php b/admin/controllers/contexts.php index 89acc50..85ace06 100644 --- a/admin/controllers/contexts.php +++ b/admin/controllers/contexts.php @@ -5,40 +5,40 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\Utilities\ArrayHelper; - -/** - * Contexts Controller - */ -class Release_checkingControllerContexts extends JControllerAdmin -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_RELEASE_CHECKING_CONTEXTS'; - - /** - * 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 = 'Context', $prefix = 'Release_checkingModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\Utilities\ArrayHelper; + +/** + * Contexts Controller + */ +class Release_checkingControllerContexts extends JControllerAdmin +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_RELEASE_CHECKING_CONTEXTS'; + + /** + * 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 = 'Context', $prefix = 'Release_checkingModel', $config = array('ignore_request' => true)) + { + return parent::getModel($name, $prefix, $config); } public function exportData() @@ -102,5 +102,5 @@ class Release_checkingControllerContexts extends JControllerAdmin $message = JText::_('COM_RELEASE_CHECKING_IMPORT_FAILED'); $this->setRedirect(JRoute::_('index.php?option=com_release_checking&view=contexts', false), $message, 'error'); return; - } -} + } +} diff --git a/admin/controllers/import.php b/admin/controllers/import.php index 6ea8bfa..85a626c 100644 --- a/admin/controllers/import.php +++ b/admin/controllers/import.php @@ -5,49 +5,49 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\Utilities\ArrayHelper; - -/** - * Release_checking Import Controller - */ -class Release_checkingControllerImport extends JControllerLegacy -{ - /** - * Import an spreadsheet. - * - * @return void - */ - public function import() - { - // Check for request forgeries - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - $model = $this->getModel('import'); - if ($model->import()) - { - $cache = JFactory::getCache('mod_menu'); - $cache->clean(); - // TODO: Reset the users acl here as well to kill off any missing bits - } - - $app = JFactory::getApplication(); - $redirect_url = $app->getUserState('com_release_checking.redirect_url'); - if (empty($redirect_url)) - { - $redirect_url = JRoute::_('index.php?option=com_release_checking&view=import', false); - } - else - { - // wipe out the user state when we're going to redirect - $app->setUserState('com_release_checking.redirect_url', ''); - $app->setUserState('com_release_checking.message', ''); - $app->setUserState('com_release_checking.extension_message', ''); - } - $this->setRedirect($redirect_url); - } -} + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\Utilities\ArrayHelper; + +/** + * Release_checking Import Controller + */ +class Release_checkingControllerImport extends JControllerLegacy +{ + /** + * Import an spreadsheet. + * + * @return void + */ + public function import() + { + // Check for request forgeries + JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + + $model = $this->getModel('import'); + if ($model->import()) + { + $cache = JFactory::getCache('mod_menu'); + $cache->clean(); + // TODO: Reset the users acl here as well to kill off any missing bits + } + + $app = JFactory::getApplication(); + $redirect_url = $app->getUserState('com_release_checking.redirect_url'); + if (empty($redirect_url)) + { + $redirect_url = JRoute::_('index.php?option=com_release_checking&view=import', false); + } + else + { + // wipe out the user state when we're going to redirect + $app->setUserState('com_release_checking.redirect_url', ''); + $app->setUserState('com_release_checking.message', ''); + $app->setUserState('com_release_checking.extension_message', ''); + } + $this->setRedirect($redirect_url); + } +} diff --git a/admin/controllers/joomla_version.php b/admin/controllers/joomla_version.php index aeb2233..75caad1 100644 --- a/admin/controllers/joomla_version.php +++ b/admin/controllers/joomla_version.php @@ -5,50 +5,50 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\Utilities\ArrayHelper; - -/** - * Joomla_version Controller - */ -class Release_checkingControllerJoomla_version extends JControllerForm -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Joomla_versions'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\Utilities\ArrayHelper; + +/** + * Joomla_version Controller + */ +class Release_checkingControllerJoomla_version extends JControllerForm +{ + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * Class constructor. + * + * @param array $config A named array of configuration variables. + * + * @since 1.6 + */ + public function __construct($config = array()) + { + $this->view_list = 'Joomla_versions'; // safeguard for setting the return view listing to the main view. + parent::__construct($config); + } + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = array()) { // Get user object. $user = JFactory::getUser(); @@ -60,20 +60,20 @@ class Release_checkingControllerJoomla_version extends JControllerForm } // In the absense of better information, revert to the component permissions. - return parent::allowAdd($data); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') + return parent::allowAdd($data); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = array(), $key = 'id') { // get user object. $user = JFactory::getUser(); @@ -116,199 +116,199 @@ class Release_checkingControllerJoomla_version extends JControllerForm } } // Since there is no permission, revert to the component permissions. - return parent::allowEdit($data, $key); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // 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'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Joomla_version', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_release_checking&view=joomla_versions' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // 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 (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $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( - 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 - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // 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'); - $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'; - } - - $saved = parent::save($key, $urlVar); - - // 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 = 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( - 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 - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) + return parent::allowEdit($data, $key); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') { - return; - } - -} + // 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'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string)$ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Joomla_version', '', array()); + + // Preset the redirect + $this->setRedirect(JRoute::_('index.php?option=com_release_checking&view=joomla_versions' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // 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 (!is_null($return) && JUri::isInternal(base64_decode($return))) + { + $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( + 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 + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // 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'); + $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'; + } + + $saved = parent::save($key, $urlVar); + + // 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 = 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( + 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 + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param JModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(JModelLegacy $model, $validData = array()) + { + return; + } + +} diff --git a/admin/controllers/joomla_versions.php b/admin/controllers/joomla_versions.php index e8a293d..c03a347 100644 --- a/admin/controllers/joomla_versions.php +++ b/admin/controllers/joomla_versions.php @@ -5,40 +5,40 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\Utilities\ArrayHelper; - -/** - * Joomla_versions Controller - */ -class Release_checkingControllerJoomla_versions extends JControllerAdmin -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_RELEASE_CHECKING_JOOMLA_VERSIONS'; - - /** - * 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 = 'Joomla_version', $prefix = 'Release_checkingModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\Utilities\ArrayHelper; + +/** + * Joomla_versions Controller + */ +class Release_checkingControllerJoomla_versions extends JControllerAdmin +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_RELEASE_CHECKING_JOOMLA_VERSIONS'; + + /** + * 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 = 'Joomla_version', $prefix = 'Release_checkingModel', $config = array('ignore_request' => true)) + { + return parent::getModel($name, $prefix, $config); } public function exportData() @@ -102,5 +102,5 @@ class Release_checkingControllerJoomla_versions extends JControllerAdmin $message = JText::_('COM_RELEASE_CHECKING_IMPORT_FAILED'); $this->setRedirect(JRoute::_('index.php?option=com_release_checking&view=joomla_versions', false), $message, 'error'); return; - } -} + } +} diff --git a/admin/controllers/release_check.php b/admin/controllers/release_check.php index d31ee6e..592bdd9 100644 --- a/admin/controllers/release_check.php +++ b/admin/controllers/release_check.php @@ -5,50 +5,50 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\Utilities\ArrayHelper; - -/** - * Release_check Controller - */ -class Release_checkingControllerRelease_check extends JControllerForm -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Release_checks'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\Utilities\ArrayHelper; + +/** + * Release_check Controller + */ +class Release_checkingControllerRelease_check extends JControllerForm +{ + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * Class constructor. + * + * @param array $config A named array of configuration variables. + * + * @since 1.6 + */ + public function __construct($config = array()) + { + $this->view_list = 'Release_checks'; // safeguard for setting the return view listing to the main view. + parent::__construct($config); + } + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = array()) { // Get user object. $user = JFactory::getUser(); @@ -60,20 +60,20 @@ class Release_checkingControllerRelease_check extends JControllerForm } // In the absense of better information, revert to the component permissions. - return parent::allowAdd($data); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') + return parent::allowAdd($data); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = array(), $key = 'id') { // get user object. $user = JFactory::getUser(); @@ -116,199 +116,199 @@ class Release_checkingControllerRelease_check extends JControllerForm } } // Since there is no permission, revert to the component permissions. - return parent::allowEdit($data, $key); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // 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'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Release_check', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_release_checking&view=release_checks' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // 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 (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $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( - 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 - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // 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'); - $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'; - } - - $saved = parent::save($key, $urlVar); - - // 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 = 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( - 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 - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) + return parent::allowEdit($data, $key); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') { - return; - } - -} + // 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'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string)$ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Release_check', '', array()); + + // Preset the redirect + $this->setRedirect(JRoute::_('index.php?option=com_release_checking&view=release_checks' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // 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 (!is_null($return) && JUri::isInternal(base64_decode($return))) + { + $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( + 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 + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // 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'); + $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'; + } + + $saved = parent::save($key, $urlVar); + + // 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 = 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( + 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 + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param JModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(JModelLegacy $model, $validData = array()) + { + return; + } + +} diff --git a/admin/controllers/release_checks.php b/admin/controllers/release_checks.php index 5f20b3d..7e34a9c 100644 --- a/admin/controllers/release_checks.php +++ b/admin/controllers/release_checks.php @@ -5,40 +5,40 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\Utilities\ArrayHelper; - -/** - * Release_checks Controller - */ -class Release_checkingControllerRelease_checks extends JControllerAdmin -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_RELEASE_CHECKING_RELEASE_CHECKS'; - - /** - * 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 = 'Release_check', $prefix = 'Release_checkingModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\Utilities\ArrayHelper; + +/** + * Release_checks Controller + */ +class Release_checkingControllerRelease_checks extends JControllerAdmin +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_RELEASE_CHECKING_RELEASE_CHECKS'; + + /** + * 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 = 'Release_check', $prefix = 'Release_checkingModel', $config = array('ignore_request' => true)) + { + return parent::getModel($name, $prefix, $config); } public function exportData() @@ -102,5 +102,5 @@ class Release_checkingControllerRelease_checks extends JControllerAdmin $message = JText::_('COM_RELEASE_CHECKING_IMPORT_FAILED'); $this->setRedirect(JRoute::_('index.php?option=com_release_checking&view=release_checks', false), $message, 'error'); return; - } -} + } +} diff --git a/admin/helpers/headercheck.php b/admin/helpers/headercheck.php index bc9f28c..34bf333 100644 --- a/admin/helpers/headercheck.php +++ b/admin/helpers/headercheck.php @@ -5,65 +5,65 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -class release_checkingHeaderCheck -{ - function js_loaded($script_name) - { - // UIkit check point - if (strpos($script_name,'uikit') !== false) - { - $app = JFactory::getApplication(); - $getTemplateName = $app->getTemplate('template')->template; - - if (strpos($getTemplateName,'yoo') !== false) - { - return true; - } - } - - $document = JFactory::getDocument(); - $head_data = $document->getHeadData(); - foreach (array_keys($head_data['scripts']) as $script) - { - if (stristr($script, $script_name)) - { - return true; - } - } - - return false; - } - - function css_loaded($script_name) - { - // UIkit check point - if (strpos($script_name,'uikit') !== false) - { - $app = JFactory::getApplication(); - $getTemplateName = $app->getTemplate('template')->template; - - if (strpos($getTemplateName,'yoo') !== false) - { - return true; - } - } - - $document = JFactory::getDocument(); - $head_data = $document->getHeadData(); - - foreach (array_keys($head_data['styleSheets']) as $script) - { - if (stristr($script, $script_name)) - { - return true; - } - } - - return false; - } + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +class release_checkingHeaderCheck +{ + function js_loaded($script_name) + { + // UIkit check point + if (strpos($script_name,'uikit') !== false) + { + $app = JFactory::getApplication(); + $getTemplateName = $app->getTemplate('template')->template; + + if (strpos($getTemplateName,'yoo') !== false) + { + return true; + } + } + + $document = JFactory::getDocument(); + $head_data = $document->getHeadData(); + foreach (array_keys($head_data['scripts']) as $script) + { + if (stristr($script, $script_name)) + { + return true; + } + } + + return false; + } + + function css_loaded($script_name) + { + // UIkit check point + if (strpos($script_name,'uikit') !== false) + { + $app = JFactory::getApplication(); + $getTemplateName = $app->getTemplate('template')->template; + + if (strpos($getTemplateName,'yoo') !== false) + { + return true; + } + } + + $document = JFactory::getDocument(); + $head_data = $document->getHeadData(); + + foreach (array_keys($head_data['styleSheets']) as $script) + { + if (stristr($script, $script_name)) + { + return true; + } + } + + return false; + } } \ No newline at end of file diff --git a/admin/helpers/html/batch_.php b/admin/helpers/html/batch_.php index 84d3831..d56d573 100644 --- a/admin/helpers/html/batch_.php +++ b/admin/helpers/html/batch_.php @@ -5,72 +5,72 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('JPATH_PLATFORM') or die; - -/** - * Utility class to render a list view batch selection options - * - * @since 3.0 - */ -abstract class JHtmlBatch_ -{ - /** - * ListSelection - * - * @var array - * @since 3.0 - */ - protected static $ListSelection = array(); - - /** - * Render the batch selection options. - * - * @return string The necessary HTML to display the batch selection options - * - * @since 3.0 - */ - public static function render() - { - // Collect display data - $data = new stdClass; - $data->ListSelection = static::getListSelection(); - - // Create a layout object and ask it to render the batch selection options - $layout = new JLayoutFile('batchselection'); - $batchHtml = $layout->render($data); - - return $batchHtml; - } - - /** - * Method to add a list selection to the batch modal - * - * @param string $label Label for the menu item. - * @param string $name Name for the filter. Also used as id. - * @param string $options Options for the select field. - * @param bool $noDefault Don't the label as the empty option - * - * @return void - * - * @since 3.0 - */ - public static function addListSelection($label, $name, $options, $noDefault = false) - { - array_push(static::$ListSelection, array('label' => $label, 'name' => $name, 'options' => $options, 'noDefault' => $noDefault)); - } - - /** - * Returns an array of all ListSelection - * - * @return array - * - * @since 3.0 - */ - public static function getListSelection() - { - return static::$ListSelection; - } -} + */ + +// No direct access to this file +defined('JPATH_PLATFORM') or die; + +/** + * Utility class to render a list view batch selection options + * + * @since 3.0 + */ +abstract class JHtmlBatch_ +{ + /** + * ListSelection + * + * @var array + * @since 3.0 + */ + protected static $ListSelection = array(); + + /** + * Render the batch selection options. + * + * @return string The necessary HTML to display the batch selection options + * + * @since 3.0 + */ + public static function render() + { + // Collect display data + $data = new stdClass; + $data->ListSelection = static::getListSelection(); + + // Create a layout object and ask it to render the batch selection options + $layout = new JLayoutFile('batchselection'); + $batchHtml = $layout->render($data); + + return $batchHtml; + } + + /** + * Method to add a list selection to the batch modal + * + * @param string $label Label for the menu item. + * @param string $name Name for the filter. Also used as id. + * @param string $options Options for the select field. + * @param bool $noDefault Don't the label as the empty option + * + * @return void + * + * @since 3.0 + */ + public static function addListSelection($label, $name, $options, $noDefault = false) + { + array_push(static::$ListSelection, array('label' => $label, 'name' => $name, 'options' => $options, 'noDefault' => $noDefault)); + } + + /** + * Returns an array of all ListSelection + * + * @return array + * + * @since 3.0 + */ + public static function getListSelection() + { + return static::$ListSelection; + } +} diff --git a/admin/helpers/release_checking.php b/admin/helpers/release_checking.php index 5a0afaa..d3cb81b 100644 --- a/admin/helpers/release_checking.php +++ b/admin/helpers/release_checking.php @@ -5,121 +5,122 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Language\Language; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\Filesystem\File; +use Joomla\CMS\Language\Language; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; use Joomla\Utilities\ArrayHelper; use PhpOffice\PhpSpreadsheet\IOFactory; use PhpOffice\PhpSpreadsheet\Spreadsheet; -use PhpOffice\PhpSpreadsheet\Writer\Xlsx; - -/** - * Release_checking component helper. - */ -abstract class Release_checkingHelper -{ - /** - * Composer Switch - * - * @var array - */ - protected static $composer = array(); - - /** - * The Main Active Language - * - * @var string - */ - public static $langTag; - - /** - * Load the Composer Vendors - */ - public static function composerAutoload($target) - { - // insure we load the composer vendor only once - if (!isset(self::$composer[$target])) - { - // get the function name - $functionName = self::safeString('compose' . $target); - // check if method exist - if (method_exists(__CLASS__, $functionName)) - { - return self::{$functionName}(); - } - return false; - } - return self::$composer[$target]; - } - - /** - * Load the Component xml manifest. - */ - public static function manifest() - { - $manifestUrl = JPATH_ADMINISTRATOR."/components/com_release_checking/release_checking.xml"; - return simplexml_load_file($manifestUrl); - } - - /** - * Joomla version object - */ - protected static $JVersion; - - /** - * set/get Joomla version - */ - public static function jVersion() - { - // check if set - if (!self::checkObject(self::$JVersion)) - { - self::$JVersion = new JVersion(); - } - return self::$JVersion; - } - - /** - * Load the Contributors details. - */ - public static function getContributors() - { - // get params - $params = JComponentHelper::getParams('com_release_checking'); - // start contributors array - $contributors = array(); - // get all Contributors (max 20) - $searchArray = range('0','20'); - foreach($searchArray as $nr) - { - if ((NULL !== $params->get("showContributor".$nr)) && ($params->get("showContributor".$nr) == 1 || $params->get("showContributor".$nr) == 3)) - { - // set link based of selected option - if($params->get("useContributor".$nr) == 1) - { - $link_front = ''; - $link_back = ''; - } - elseif($params->get("useContributor".$nr) == 2) - { - $link_front = ''; - $link_back = ''; - } - else - { - $link_front = ''; - $link_back = ''; - } - $contributors[$nr]['title'] = self::htmlEscape($params->get("titleContributor".$nr)); - $contributors[$nr]['name'] = $link_front.self::htmlEscape($params->get("nameContributor".$nr)).$link_back; - } - } - return $contributors; +use PhpOffice\PhpSpreadsheet\Writer\Xlsx; + +/** + * Release_checking component helper. + */ +abstract class Release_checkingHelper +{ + /** + * Composer Switch + * + * @var array + */ + protected static $composer = array(); + + /** + * The Main Active Language + * + * @var string + */ + public static $langTag; + + /** + * Load the Composer Vendors + */ + public static function composerAutoload($target) + { + // insure we load the composer vendor only once + if (!isset(self::$composer[$target])) + { + // get the function name + $functionName = self::safeString('compose' . $target); + // check if method exist + if (method_exists(__CLASS__, $functionName)) + { + return self::{$functionName}(); + } + return false; + } + return self::$composer[$target]; + } + + /** + * Load the Component xml manifest. + */ + public static function manifest() + { + $manifestUrl = JPATH_ADMINISTRATOR."/components/com_release_checking/release_checking.xml"; + return simplexml_load_file($manifestUrl); + } + + /** + * Joomla version object + */ + protected static $JVersion; + + /** + * set/get Joomla version + */ + public static function jVersion() + { + // check if set + if (!self::checkObject(self::$JVersion)) + { + self::$JVersion = new JVersion(); + } + return self::$JVersion; + } + + /** + * Load the Contributors details. + */ + public static function getContributors() + { + // get params + $params = JComponentHelper::getParams('com_release_checking'); + // start contributors array + $contributors = array(); + // get all Contributors (max 20) + $searchArray = range('0','20'); + foreach($searchArray as $nr) + { + if ((NULL !== $params->get("showContributor".$nr)) && ($params->get("showContributor".$nr) == 1 || $params->get("showContributor".$nr) == 3)) + { + // set link based of selected option + if($params->get("useContributor".$nr) == 1) + { + $link_front = ''; + $link_back = ''; + } + elseif($params->get("useContributor".$nr) == 2) + { + $link_front = ''; + $link_back = ''; + } + else + { + $link_front = ''; + $link_back = ''; + } + $contributors[$nr]['title'] = self::htmlEscape($params->get("titleContributor".$nr)); + $contributors[$nr]['name'] = $link_front.self::htmlEscape($params->get("nameContributor".$nr)).$link_back; + } + } + return $contributors; } /** @@ -128,16 +129,16 @@ abstract class Release_checkingHelper public static function getHelpUrl($view) { return false; - } - - /** - * Configure the Linkbar. - */ - public static function addSubmenu($submenu) - { - // load user for access menus - $user = JFactory::getUser(); - // load the submenus to sidebar + } + + /** + * Configure the Linkbar. + */ + public static function addSubmenu($submenu) + { + // load user for access menus + $user = JFactory::getUser(); + // load the submenus to sidebar if ($user->authorise('release_check.access', 'com_release_checking') && $user->authorise('release_check.submenu', 'com_release_checking')) { @@ -146,13 +147,13 @@ abstract class Release_checkingHelper if ($user->authorise('joomla_version.access', 'com_release_checking') && $user->authorise('joomla_version.submenu', 'com_release_checking')) { JHtmlSidebar::addEntry(JText::_('COM_RELEASE_CHECKING_SUBMENU_JOOMLA_VERSIONS'), 'index.php?option=com_release_checking&view=joomla_versions', $submenu === 'joomla_versions'); - } + } } /** * Prepares the xml document */ - public static function xls($rows, $fileName = null, $title = null, $subjectTab = null, $creator = 'Joomla Component Builder', $description = null, $category = null,$keywords = null, $modified = null) + public static function xls($rows, $fileName = null, $title = null, $subjectTab = null, $creator = 'Open Source Matters', $description = null, $category = null,$keywords = null, $modified = null) { // set the user $user = JFactory::getUser(); @@ -186,7 +187,7 @@ abstract class Release_checkingHelper // Set document properties $spreadsheet->getProperties() ->setCreator($creator) - ->setCompany('Joomla Component Builder') + ->setCompany('Open Source Matters') ->setLastModifiedBy($modified) ->setTitle($title) ->setSubject($subjectTab); @@ -366,1210 +367,1210 @@ abstract class Release_checkingHelper self::$composer['phpspreadsheet'] = true; return true; - } - - /** - * Get a Variable - * - * @param string $table The table from which to get the variable - * @param string $where The value where - * @param string $whereString The target/field string where/name - * @param string $what The return field - * @param string $operator The operator between $whereString/field and $where/value - * @param string $main The component in which the table is found - * - * @return mix string/int/float - * - */ - public static function getVar($table, $where = null, $whereString = 'user', $what = 'id', $operator = '=', $main = 'release_checking') - { - if(!$where) - { - $where = JFactory::getUser()->id; - } - // Get a db connection. - $db = JFactory::getDbo(); - // Create a new query object. - $query = $db->getQuery(true); - $query->select($db->quoteName(array($what))); - if (empty($table)) - { - $query->from($db->quoteName('#__'.$main)); - } - else - { - $query->from($db->quoteName('#__'.$main.'_'.$table)); - } - if (is_numeric($where)) - { - $query->where($db->quoteName($whereString) . ' '.$operator.' '.(int) $where); - } - elseif (is_string($where)) - { - $query->where($db->quoteName($whereString) . ' '.$operator.' '. $db->quote((string)$where)); - } - else - { - return false; - } - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - return $db->loadResult(); - } - return false; - } - - /** - * Get array of variables - * - * @param string $table The table from which to get the variables - * @param string $where The value where - * @param string $whereString The target/field string where/name - * @param string $what The return field - * @param string $operator The operator between $whereString/field and $where/value - * @param string $main The component in which the table is found - * @param bool $unique The switch to return a unique array - * - * @return array - * - */ - public static function getVars($table, $where = null, $whereString = 'user', $what = 'id', $operator = 'IN', $main = 'release_checking', $unique = true) - { - if(!$where) - { - $where = JFactory::getUser()->id; - } - - if (!self::checkArray($where) && $where > 0) - { - $where = array($where); - } - - if (self::checkArray($where)) - { - // prep main <-- why? well if $main='' is empty then $table can be categories or users - if (self::checkString($main)) - { - $main = '_'.ltrim($main, '_'); - } - // Get a db connection. - $db = JFactory::getDbo(); - // Create a new query object. - $query = $db->getQuery(true); - - $query->select($db->quoteName(array($what))); - if (empty($table)) - { - $query->from($db->quoteName('#__'.$main)); - } - else - { - $query->from($db->quoteName('#_'.$main.'_'.$table)); - } - // add strings to array search - if ('IN_STRINGS' === $operator || 'NOT IN_STRINGS' === $operator) - { - $query->where($db->quoteName($whereString) . ' ' . str_replace('_STRINGS', '', $operator) . ' ("' . implode('","',$where) . '")'); - } - else - { - $query->where($db->quoteName($whereString) . ' ' . $operator . ' (' . implode(',',$where) . ')'); - } - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - if ($unique) - { - return array_unique($db->loadColumn()); - } - return $db->loadColumn(); - } - } - return false; - } - - public static function jsonToString($value, $sperator = ", ", $table = null, $id = 'id', $name = 'name') - { - // do some table foot work - $external = false; - if (strpos($table, '#__') !== false) - { - $external = true; - $table = str_replace('#__', '', $table); - } - // check if string is JSON - $result = json_decode($value, true); - if (json_last_error() === JSON_ERROR_NONE) - { - // is JSON - if (self::checkArray($result)) - { - if (self::checkString($table)) - { - $names = array(); - foreach ($result as $val) - { - if ($external) - { - if ($_name = self::getVar(null, $val, $id, $name, '=', $table)) - { - $names[] = $_name; - } - } - else - { - if ($_name = self::getVar($table, $val, $id, $name)) - { - $names[] = $_name; - } - } - } - if (self::checkArray($names)) - { - return (string) implode($sperator,$names); - } - } - return (string) implode($sperator,$result); - } - return (string) json_decode($value); - } - return $value; - } - - public static function isPublished($id,$type) - { - if ($type == 'raw') - { - $type = 'item'; - } - $db = JFactory::getDbo(); - $query = $db->getQuery(true); - $query->select(array('a.published')); - $query->from('#__release_checking_'.$type.' AS a'); - $query->where('a.id = '. (int) $id); - $query->where('a.published = 1'); - $db->setQuery($query); - $db->execute(); - $found = $db->getNumRows(); - if($found) - { - return true; - } - return false; - } - - public static function getGroupName($id) - { - $db = JFactory::getDBO(); - $query = $db->getQuery(true); - $query->select(array('a.title')); - $query->from('#__usergroups AS a'); - $query->where('a.id = '. (int) $id); - $db->setQuery($query); - $db->execute(); - $found = $db->getNumRows(); - if($found) - { - return $db->loadResult(); - } - return $id; - } - - /** - * Get the action permissions - * - * @param string $view The related view name - * @param int $record The item to act upon - * @param string $views The related list view name - * @param mixed $target Only get this permission (like edit, create, delete) - * @param string $component The target component - * @param object $user The user whose permissions we are loading - * - * @return object The JObject of permission/authorised actions - * - */ - public static function getActions($view, &$record = null, $views = null, $target = null, $component = 'release_checking', $user = 'null') - { - // load the user if not given - if (!self::checkObject($user)) - { - // get the user object - $user = JFactory::getUser(); - } - // load the JObject - $result = new JObject; - // make view name safe (just incase) - $view = self::safeString($view); - if (self::checkString($views)) - { - $views = self::safeString($views); - } - // get all actions from component - $actions = JAccess::getActionsFromFile( - JPATH_ADMINISTRATOR . '/components/com_' . $component . '/access.xml', - "/access/section[@name='component']/" - ); - // if non found then return empty JObject - if (empty($actions)) - { - return $result; - } - // get created by if not found - if (self::checkObject($record) && !isset($record->created_by) && isset($record->id)) - { - $record->created_by = self::getVar($view, $record->id, 'id', 'created_by', '=', $component); - } - // set actions only set in component settings - $componentActions = array('core.admin', 'core.manage', 'core.options', 'core.export'); - // check if we have a target - $checkTarget = false; - if ($target) - { - // convert to an array - if (self::checkString($target)) - { - $target = array($target); - } - // check if we are good to go - if (self::checkArray($target)) - { - $checkTarget = true; - } - } - // loop the actions and set the permissions - foreach ($actions as $action) - { - // check target action filter - if ($checkTarget && self::filterActions($view, $action->name, $target)) - { - continue; - } - // set to use component default - $fallback = true; - // reset permission per/action - $permission = false; - $catpermission = false; - // set area - $area = 'comp'; - // check if the record has an ID and the action is item related (not a component action) - if (self::checkObject($record) && isset($record->id) && $record->id > 0 && !in_array($action->name, $componentActions) && - (strpos($action->name, 'core.') !== false || strpos($action->name, $view . '.') !== false)) - { - // we are in item - $area = 'item'; - // The record has been set. Check the record permissions. - $permission = $user->authorise($action->name, 'com_' . $component . '.' . $view . '.' . (int) $record->id); - // if no permission found, check edit own - if (!$permission) - { - // With edit, if the created_by matches current user then dig deeper. - if (($action->name === 'core.edit' || $action->name === $view . '.edit') && $record->created_by > 0 && ($record->created_by == $user->id)) - { - // the correct target - $coreCheck = (array) explode('.', $action->name); - // check that we have both local and global access - if ($user->authorise($coreCheck[0] . '.edit.own', 'com_' . $component . '.' . $view . '.' . (int) $record->id) && - $user->authorise($coreCheck[0] . '.edit.own', 'com_' . $component)) - { - // allow edit - $result->set($action->name, true); - // set not to use global default - // because we already validated it - $fallback = false; - } - else - { - // do not allow edit - $result->set($action->name, false); - $fallback = false; - } - } - } - elseif (self::checkString($views) && isset($record->catid) && $record->catid > 0) - { - // we are in item - $area = 'category'; - // set the core check - $coreCheck = explode('.', $action->name); - $core = $coreCheck[0]; - // make sure we use the core. action check for the categories - if (strpos($action->name, $view) !== false && strpos($action->name, 'core.') === false ) - { - $coreCheck[0] = 'core'; - $categoryCheck = implode('.', $coreCheck); - } - else - { - $categoryCheck = $action->name; - } - // The record has a category. Check the category permissions. - $catpermission = $user->authorise($categoryCheck, 'com_' . $component . '.' . $views . '.category.' . (int) $record->catid); - if (!$catpermission && !is_null($catpermission)) - { - // With edit, if the created_by matches current user then dig deeper. - if (($action->name === 'core.edit' || $action->name === $view . '.edit') && $record->created_by > 0 && ($record->created_by == $user->id)) - { - // check that we have both local and global access - if ($user->authorise('core.edit.own', 'com_' . $component . '.' . $views . '.category.' . (int) $record->catid) && - $user->authorise($core . '.edit.own', 'com_' . $component)) - { - // allow edit - $result->set($action->name, true); - // set not to use global default - // because we already validated it - $fallback = false; - } - else - { - // do not allow edit - $result->set($action->name, false); - $fallback = false; - } - } - } - } - } - // if allowed then fallback on component global settings - if ($fallback) - { - // if item/category blocks access then don't fall back on global - if ((($area === 'item') && !$permission) || (($area === 'category') && !$catpermission)) - { - // do not allow - $result->set($action->name, false); - } - // Finally remember the global settings have the final say. (even if item allow) - // The local item permissions can block, but it can't open and override of global permissions. - // Since items are created by users and global permissions is set by system admin. - else - { - $result->set($action->name, $user->authorise($action->name, 'com_' . $component)); - } - } - } - return $result; - } - - /** - * Filter the action permissions - * - * @param string $action The action to check - * @param array $targets The array of target actions - * - * @return boolean true if action should be filtered out - * - */ - protected static function filterActions(&$view, &$action, &$targets) - { - foreach ($targets as $target) - { - if (strpos($action, $view . '.' . $target) !== false || - strpos($action, 'core.' . $target) !== false) - { - return false; - break; - } - } - return true; - } - - /** - * Get any component's model - */ - public static function getModel($name, $path = JPATH_COMPONENT_ADMINISTRATOR, $Component = 'Release_checking', $config = array()) - { - // fix the name - $name = self::safeString($name); - // full path to models - $fullPathModels = $path . '/models'; - // load the model file - JModelLegacy::addIncludePath($fullPathModels, $Component . 'Model'); - // make sure the table path is loaded - if (!isset($config['table_path']) || !self::checkString($config['table_path'])) - { - // This is the JCB default path to tables in Joomla 3.x - $config['table_path'] = JPATH_ADMINISTRATOR . '/components/com_' . strtolower($Component) . '/tables'; - } - // get instance - $model = JModelLegacy::getInstance($name, $Component . 'Model', $config); - // if model not found (strange) - if ($model == false) - { - jimport('joomla.filesystem.file'); - // get file path - $filePath = $path . '/' . $name . '.php'; - $fullPathModel = $fullPathModels . '/' . $name . '.php'; - // check if it exists - if (JFile::exists($filePath)) - { - // get the file - require_once $filePath; - } - elseif (JFile::exists($fullPathModel)) - { - // get the file - require_once $fullPathModel; - } - // build class names - $modelClass = $Component . 'Model' . $name; - if (class_exists($modelClass)) - { - // initialize the model - return new $modelClass($config); - } - } - return $model; - } - - /** - * Add to asset Table - */ - public static function setAsset($id, $table, $inherit = true) - { - $parent = JTable::getInstance('Asset'); - $parent->loadByName('com_release_checking'); - - $parentId = $parent->id; - $name = 'com_release_checking.'.$table.'.'.$id; - $title = ''; - - $asset = JTable::getInstance('Asset'); - $asset->loadByName($name); - - // Check for an error. - $error = $asset->getError(); - - if ($error) - { - return false; - } - else - { - // Specify how a new or moved node asset is inserted into the tree. - if ($asset->parent_id != $parentId) - { - $asset->setLocation($parentId, 'last-child'); - } - - // Prepare the asset to be stored. - $asset->parent_id = $parentId; - $asset->name = $name; - $asset->title = $title; - // get the default asset rules - $rules = self::getDefaultAssetRules('com_release_checking', $table, $inherit); - if ($rules instanceof JAccessRules) - { - $asset->rules = (string) $rules; - } - - if (!$asset->check() || !$asset->store()) - { - JFactory::getApplication()->enqueueMessage($asset->getError(), 'warning'); - return false; - } - else - { - // Create an asset_id or heal one that is corrupted. - $object = new stdClass(); - - // Must be a valid primary key value. - $object->id = $id; - $object->asset_id = (int) $asset->id; - - // Update their asset_id to link to the asset table. - return JFactory::getDbo()->updateObject('#__release_checking_'.$table, $object, 'id'); - } - } - return false; - } - - /** - * Gets the default asset Rules for a component/view. - */ - protected static function getDefaultAssetRules($component, $view, $inherit = true) - { - // if new or inherited - $assetId = 0; - // Only get the actual item rules if not inheriting - if (!$inherit) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - // check that there is a value - if ($db->getNumRows()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - } - } - // get asset rules - $result = JAccess::getAssetRules($assetId); - if ($result instanceof JAccessRules) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($view !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - elseif ($inherit) - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count((array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules($_result); - // return filtered rules - return $rules; - } - } - return $result; - } - - /** - * xmlAppend - * - * @param SimpleXMLElement $xml The XML element reference in which to inject a comment - * @param mixed $node A SimpleXMLElement node to append to the XML element reference, or a stdClass object containing a comment attribute to be injected before the XML node and a fieldXML attribute containing a SimpleXMLElement - * - * @return null - * - */ - public static function xmlAppend(&$xml, $node) - { - if (!$node) - { - // element was not returned - return; - } - switch (get_class($node)) - { - case 'stdClass': - if (property_exists($node, 'comment')) - { - self::xmlComment($xml, $node->comment); - } - if (property_exists($node, 'fieldXML')) - { - self::xmlAppend($xml, $node->fieldXML); - } - break; - case 'SimpleXMLElement': - $domXML = dom_import_simplexml($xml); - $domNode = dom_import_simplexml($node); - $domXML->appendChild($domXML->ownerDocument->importNode($domNode, true)); - $xml = simplexml_import_dom($domXML); - break; - } - } - - /** - * xmlComment - * - * @param SimpleXMLElement $xml The XML element reference in which to inject a comment - * @param string $comment The comment to inject - * - * @return null - * - */ - public static function xmlComment(&$xml, $comment) - { - $domXML = dom_import_simplexml($xml); - $domComment = new DOMComment($comment); - $nodeTarget = $domXML->ownerDocument->importNode($domComment, true); - $domXML->appendChild($nodeTarget); - $xml = simplexml_import_dom($domXML); - } - - /** - * xmlAddAttributes - * - * @param SimpleXMLElement $xml The XML element reference in which to inject a comment - * @param array $attributes The attributes to apply to the XML element - * - * @return null - * - */ - public static function xmlAddAttributes(&$xml, $attributes = array()) - { - foreach ($attributes as $key => $value) - { - $xml->addAttribute($key, $value); - } - } - - /** - * xmlAddOptions - * - * @param SimpleXMLElement $xml The XML element reference in which to inject a comment - * @param array $options The options to apply to the XML element - * - * @return void - * - */ - public static function xmlAddOptions(&$xml, $options = array()) - { - foreach ($options as $key => $value) - { - $addOption = $xml->addChild('option'); - $addOption->addAttribute('value', $key); - $addOption[] = $value; - } - } - - /** - * 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); - // get field xml - $XML = self::getFieldXML($attributes, $options); - // setup the field - $field->setup($XML, $default); - // return the field object - return $field; - } - return false; - } - - /** - * get the field xml - * - * @param array $attributes The array of attributes - * @param array $options The options to apply to the XML element - * - * @return object - * - */ - public static function getFieldXML(&$attributes, $options = null) - { - // make sure we have attributes and a type value - if (self::checkArray($attributes)) - { - // 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); - } - // return the field xml - return $XML; - } - return false; - } - - /** - * Render Bool Button - * - * @param array $args All the args for the button - * 0) name - * 1) additional (options class) // not used at this time - * 2) default - * 3) yes (name) - * 4) no (name) - * - * @return string The input html of the button - * - */ - public static function renderBoolButton() - { - $args = func_get_args(); - // check if there is additional button class - $additional = isset($args[1]) ? (string) $args[1] : ''; // not used at this time - // button attributes - $buttonAttributes = array( - 'type' => 'radio', - 'name' => isset($args[0]) ? self::htmlEscape($args[0]) : 'bool_button', - 'label' => isset($args[0]) ? self::safeString(self::htmlEscape($args[0]), 'Ww') : 'Bool Button', // not seen anyway - 'class' => 'btn-group', - 'filter' => 'INT', - 'default' => isset($args[2]) ? (int) $args[2] : 0); - // set the button options - $buttonOptions = array( - '1' => isset($args[3]) ? self::htmlEscape($args[3]) : 'JYES', - '0' => isset($args[4]) ? self::htmlEscape($args[4]) : 'JNO'); - // return the input - return self::getFieldObject($buttonAttributes, $buttonAttributes['default'], $buttonOptions)->input; - } - - /** - * Check if have an json string - * - * @input string The json string to check - * - * @returns bool true on success - */ - public static function checkJson($string) - { - if (self::checkString($string)) - { - json_decode($string); - return (json_last_error() === JSON_ERROR_NONE); - } - return false; - } - - /** - * Check if have an object with a length - * - * @input object The object to check - * - * @returns bool true on success - */ - public static function checkObject($object) - { - if (isset($object) && is_object($object)) - { - return count((array)$object) > 0; - } - return false; - } - - /** - * Check if have an array with a length - * - * @input array The array to check - * - * @returns bool/int number of items in array on success - */ - public static function checkArray($array, $removeEmptyString = false) - { - if (isset($array) && is_array($array) && ($nr = count((array)$array)) > 0) - { - // also make sure the empty strings are removed - if ($removeEmptyString) - { - foreach ($array as $key => $string) - { - if (empty($string)) - { - unset($array[$key]); - } - } - return self::checkArray($array, false); - } - return $nr; - } - return false; - } - - /** - * Check if have a string with a length - * - * @input string The string to check - * - * @returns bool true on success - */ - public static function checkString($string) - { - if (isset($string) && is_string($string) && strlen($string) > 0) - { - return true; - } - return false; - } - - /** - * Check if we are connected - * Thanks https://stackoverflow.com/a/4860432/1429677 - * - * @returns bool true on success - */ - public static function isConnected() - { - // If example.com is down, then probably the whole internet is down, since IANA maintains the domain. Right? - $connected = @fsockopen("www.example.com", 80); - // website, port (try 80 or 443) - if ($connected) - { - //action when connected - $is_conn = true; - fclose($connected); - } - else - { - //action in connection failure - $is_conn = false; - } - return $is_conn; - } - - /** - * Merge an array of array's - * - * @input array The arrays you would like to merge - * - * @returns array on success - */ - public static function mergeArrays($arrays) - { - if(self::checkArray($arrays)) - { - $arrayBuket = array(); - foreach ($arrays as $array) - { - if (self::checkArray($array)) - { - $arrayBuket = array_merge($arrayBuket, $array); - } - } - return $arrayBuket; - } - return false; - } - - // typo sorry! - public static function sorten($string, $length = 40, $addTip = true) - { - return self::shorten($string, $length, $addTip); - } - - /** - * Shorten a string - * - * @input string The you would like to shorten - * - * @returns string on success - */ - public static function shorten($string, $length = 40, $addTip = true) - { - if (self::checkString($string)) - { - $initial = strlen($string); - $words = preg_split('/([\s\n\r]+)/', $string, null, PREG_SPLIT_DELIM_CAPTURE); - $words_count = count((array)$words); - - $word_length = 0; - $last_word = 0; - for (; $last_word < $words_count; ++$last_word) - { - $word_length += strlen($words[$last_word]); - if ($word_length > $length) - { - break; - } - } - - $newString = implode(array_slice($words, 0, $last_word)); - $final = strlen($newString); - if ($initial != $final && $addTip) - { - $title = self::shorten($string, 400 , false); - return ''.trim($newString).'...'; - } - elseif ($initial != $final && !$addTip) - { - return trim($newString).'...'; - } - } - return $string; - } - - /** - * Making strings safe (various ways) - * - * @input string The you would like to make safe - * - * @returns string on success - */ - public static function safeString($string, $type = 'L', $spacer = '_', $replaceNumbers = true, $keepOnlyCharacters = true) - { - if ($replaceNumbers === true) - { - // remove all numbers and replace with english text version (works well only up to millions) - $string = self::replaceNumbers($string); - } - // 0nly continue if we have a string - if (self::checkString($string)) - { - // create file name without the extention that is safe - if ($type === 'filename') - { - // make sure VDM is not in the string - $string = str_replace('VDM', 'vDm', $string); - // Remove anything which isn't a word, whitespace, number - // or any of the following caracters -_() - // If you don't need to handle multi-byte characters - // you can use preg_replace rather than mb_ereg_replace - // Thanks @Łukasz Rysiak! - // $string = mb_ereg_replace("([^\w\s\d\-_\(\)])", '', $string); - $string = preg_replace("([^\w\s\d\-_\(\)])", '', $string); - // http://stackoverflow.com/a/2021729/1429677 - return preg_replace('/\s+/', ' ', $string); - } - // remove all other characters - $string = trim($string); - $string = preg_replace('/'.$spacer.'+/', ' ', $string); - $string = preg_replace('/\s+/', ' ', $string); - // Transliterate string - $string = self::transliterate($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') - { - // replace white space with underscore - $string = preg_replace('/\s+/', $spacer, $string); - // default is to return lower - return strtolower($string); - } - elseif ($type === 'W') - { - // return a string with all first letter of each word uppercase(no undersocre) - return ucwords(strtolower($string)); - } - elseif ($type === 'w' || $type === 'word') - { - // return a string with all lowercase(no undersocre) - return strtolower($string); - } - elseif ($type === 'Ww' || $type === 'Word') - { - // return a string with first letter of the first word uppercase and all the rest lowercase(no undersocre) - return ucfirst(strtolower($string)); - } - elseif ($type === 'WW' || $type === 'WORD') - { - // return a string with all the uppercase(no undersocre) - return strtoupper($string); - } - elseif ($type === 'U' || $type === 'strtoupper') - { - // replace white space with underscore - $string = preg_replace('/\s+/', $spacer, $string); - // return all upper - return strtoupper($string); - } - elseif ($type === 'F' || $type === 'ucfirst') - { - // replace white space with underscore - $string = preg_replace('/\s+/', $spacer, $string); - // return with first caracter to upper - return ucfirst(strtolower($string)); - } - elseif ($type === 'cA' || $type === 'cAmel' || $type === 'camelcase') - { - // convert all words to first letter uppercase - $string = ucwords(strtolower($string)); - // remove white space - $string = preg_replace('/\s+/', '', $string); - // now return first letter lowercase - return lcfirst($string); - } - // return string - return $string; - } - // not a string - return ''; - } - - public static function transliterate($string) - { - // set tag only once - if (!self::checkString(self::$langTag)) - { - // get global value - self::$langTag = JComponentHelper::getParams('com_release_checking')->get('language', 'en-GB'); - } - // Transliterate on the language requested - $lang = Language::getInstance(self::$langTag); - return $lang->transliterate($string); - } - - public static function htmlEscape($var, $charset = 'UTF-8', $shorten = false, $length = 40) - { - if (self::checkString($var)) - { - $filter = new JFilterInput(); - $string = $filter->clean(html_entity_decode(htmlentities($var, ENT_COMPAT, $charset)), 'HTML'); - if ($shorten) - { - return self::shorten($string,$length); - } - return $string; - } - else - { - return ''; - } - } - - public static function replaceNumbers($string) - { - // set numbers array - $numbers = array(); - // first get all numbers - preg_match_all('!\d+!', $string, $numbers); - // check if we have any numbers - if (isset($numbers[0]) && self::checkArray($numbers[0])) - { - foreach ($numbers[0] as $number) - { - $searchReplace[$number] = self::numberToString((int)$number); - } - // now replace numbers in string - $string = str_replace(array_keys($searchReplace), array_values($searchReplace),$string); - // check if we missed any, strange if we did. - return self::replaceNumbers($string); - } - // return the string with no numbers remaining. - return $string; - } - - /** - * Convert an integer into an English word string - * Thanks to Tom Nicholson - * - * @input an int - * @returns a string - */ - public static function numberToString($x) - { - $nwords = array( "zero", "one", "two", "three", "four", "five", "six", "seven", - "eight", "nine", "ten", "eleven", "twelve", "thirteen", - "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", - "nineteen", "twenty", 30 => "thirty", 40 => "forty", - 50 => "fifty", 60 => "sixty", 70 => "seventy", 80 => "eighty", - 90 => "ninety" ); - - if(!is_numeric($x)) - { - $w = $x; - } - elseif(fmod($x, 1) != 0) - { - $w = $x; - } - else - { - if($x < 0) - { - $w = 'minus '; - $x = -$x; - } - else - { - $w = ''; - // ... now $x is a non-negative integer. - } - - if($x < 21) // 0 to 20 - { - $w .= $nwords[$x]; - } - elseif($x < 100) // 21 to 99 - { - $w .= $nwords[10 * floor($x/10)]; - $r = fmod($x, 10); - if($r > 0) - { - $w .= ' '. $nwords[$r]; - } - } - elseif($x < 1000) // 100 to 999 - { - $w .= $nwords[floor($x/100)] .' hundred'; - $r = fmod($x, 100); - if($r > 0) - { - $w .= ' and '. self::numberToString($r); - } - } - elseif($x < 1000000) // 1000 to 999999 - { - $w .= self::numberToString(floor($x/1000)) .' thousand'; - $r = fmod($x, 1000); - if($r > 0) - { - $w .= ' '; - if($r < 100) - { - $w .= 'and '; - } - $w .= self::numberToString($r); - } - } - else // millions - { - $w .= self::numberToString(floor($x/1000000)) .' million'; - $r = fmod($x, 1000000); - if($r > 0) - { - $w .= ' '; - if($r < 100) - { - $w .= 'and '; - } - $w .= self::numberToString($r); - } - } - } - return $w; - } - - /** - * Random Key - * - * @returns a string - */ - public static function randomkey($size) - { - $bag = "abcefghijknopqrstuwxyzABCDDEFGHIJKLLMMNOPQRSTUVVWXYZabcddefghijkllmmnopqrstuvvwxyzABCEFGHIJKNOPQRSTUWXYZ"; - $key = array(); - $bagsize = strlen($bag) - 1; - for ($i = 0; $i < $size; $i++) - { - $get = rand(0, $bagsize); - $key[] = $bag[$get]; - } - return implode($key); - } -} + } + + /** + * Get a Variable + * + * @param string $table The table from which to get the variable + * @param string $where The value where + * @param string $whereString The target/field string where/name + * @param string $what The return field + * @param string $operator The operator between $whereString/field and $where/value + * @param string $main The component in which the table is found + * + * @return mix string/int/float + * + */ + public static function getVar($table, $where = null, $whereString = 'user', $what = 'id', $operator = '=', $main = 'release_checking') + { + if(!$where) + { + $where = JFactory::getUser()->id; + } + // Get a db connection. + $db = JFactory::getDbo(); + // Create a new query object. + $query = $db->getQuery(true); + $query->select($db->quoteName(array($what))); + if (empty($table)) + { + $query->from($db->quoteName('#__'.$main)); + } + else + { + $query->from($db->quoteName('#__'.$main.'_'.$table)); + } + if (is_numeric($where)) + { + $query->where($db->quoteName($whereString) . ' '.$operator.' '.(int) $where); + } + elseif (is_string($where)) + { + $query->where($db->quoteName($whereString) . ' '.$operator.' '. $db->quote((string)$where)); + } + else + { + return false; + } + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + return $db->loadResult(); + } + return false; + } + + /** + * Get array of variables + * + * @param string $table The table from which to get the variables + * @param string $where The value where + * @param string $whereString The target/field string where/name + * @param string $what The return field + * @param string $operator The operator between $whereString/field and $where/value + * @param string $main The component in which the table is found + * @param bool $unique The switch to return a unique array + * + * @return array + * + */ + public static function getVars($table, $where = null, $whereString = 'user', $what = 'id', $operator = 'IN', $main = 'release_checking', $unique = true) + { + if(!$where) + { + $where = JFactory::getUser()->id; + } + + if (!self::checkArray($where) && $where > 0) + { + $where = array($where); + } + + if (self::checkArray($where)) + { + // prep main <-- why? well if $main='' is empty then $table can be categories or users + if (self::checkString($main)) + { + $main = '_'.ltrim($main, '_'); + } + // Get a db connection. + $db = JFactory::getDbo(); + // Create a new query object. + $query = $db->getQuery(true); + + $query->select($db->quoteName(array($what))); + if (empty($table)) + { + $query->from($db->quoteName('#__'.$main)); + } + else + { + $query->from($db->quoteName('#_'.$main.'_'.$table)); + } + // add strings to array search + if ('IN_STRINGS' === $operator || 'NOT IN_STRINGS' === $operator) + { + $query->where($db->quoteName($whereString) . ' ' . str_replace('_STRINGS', '', $operator) . ' ("' . implode('","',$where) . '")'); + } + else + { + $query->where($db->quoteName($whereString) . ' ' . $operator . ' (' . implode(',',$where) . ')'); + } + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + if ($unique) + { + return array_unique($db->loadColumn()); + } + return $db->loadColumn(); + } + } + return false; + } + + public static function jsonToString($value, $sperator = ", ", $table = null, $id = 'id', $name = 'name') + { + // do some table foot work + $external = false; + if (strpos($table, '#__') !== false) + { + $external = true; + $table = str_replace('#__', '', $table); + } + // check if string is JSON + $result = json_decode($value, true); + if (json_last_error() === JSON_ERROR_NONE) + { + // is JSON + if (self::checkArray($result)) + { + if (self::checkString($table)) + { + $names = array(); + foreach ($result as $val) + { + if ($external) + { + if ($_name = self::getVar(null, $val, $id, $name, '=', $table)) + { + $names[] = $_name; + } + } + else + { + if ($_name = self::getVar($table, $val, $id, $name)) + { + $names[] = $_name; + } + } + } + if (self::checkArray($names)) + { + return (string) implode($sperator,$names); + } + } + return (string) implode($sperator,$result); + } + return (string) json_decode($value); + } + return $value; + } + + public static function isPublished($id,$type) + { + if ($type == 'raw') + { + $type = 'item'; + } + $db = JFactory::getDbo(); + $query = $db->getQuery(true); + $query->select(array('a.published')); + $query->from('#__release_checking_'.$type.' AS a'); + $query->where('a.id = '. (int) $id); + $query->where('a.published = 1'); + $db->setQuery($query); + $db->execute(); + $found = $db->getNumRows(); + if($found) + { + return true; + } + return false; + } + + public static function getGroupName($id) + { + $db = JFactory::getDBO(); + $query = $db->getQuery(true); + $query->select(array('a.title')); + $query->from('#__usergroups AS a'); + $query->where('a.id = '. (int) $id); + $db->setQuery($query); + $db->execute(); + $found = $db->getNumRows(); + if($found) + { + return $db->loadResult(); + } + return $id; + } + + /** + * Get the action permissions + * + * @param string $view The related view name + * @param int $record The item to act upon + * @param string $views The related list view name + * @param mixed $target Only get this permission (like edit, create, delete) + * @param string $component The target component + * @param object $user The user whose permissions we are loading + * + * @return object The JObject of permission/authorised actions + * + */ + public static function getActions($view, &$record = null, $views = null, $target = null, $component = 'release_checking', $user = 'null') + { + // load the user if not given + if (!self::checkObject($user)) + { + // get the user object + $user = JFactory::getUser(); + } + // load the JObject + $result = new JObject; + // make view name safe (just incase) + $view = self::safeString($view); + if (self::checkString($views)) + { + $views = self::safeString($views); + } + // get all actions from component + $actions = JAccess::getActionsFromFile( + JPATH_ADMINISTRATOR . '/components/com_' . $component . '/access.xml', + "/access/section[@name='component']/" + ); + // if non found then return empty JObject + if (empty($actions)) + { + return $result; + } + // get created by if not found + if (self::checkObject($record) && !isset($record->created_by) && isset($record->id)) + { + $record->created_by = self::getVar($view, $record->id, 'id', 'created_by', '=', $component); + } + // set actions only set in component settings + $componentActions = array('core.admin', 'core.manage', 'core.options', 'core.export'); + // check if we have a target + $checkTarget = false; + if ($target) + { + // convert to an array + if (self::checkString($target)) + { + $target = array($target); + } + // check if we are good to go + if (self::checkArray($target)) + { + $checkTarget = true; + } + } + // loop the actions and set the permissions + foreach ($actions as $action) + { + // check target action filter + if ($checkTarget && self::filterActions($view, $action->name, $target)) + { + continue; + } + // set to use component default + $fallback = true; + // reset permission per/action + $permission = false; + $catpermission = false; + // set area + $area = 'comp'; + // check if the record has an ID and the action is item related (not a component action) + if (self::checkObject($record) && isset($record->id) && $record->id > 0 && !in_array($action->name, $componentActions) && + (strpos($action->name, 'core.') !== false || strpos($action->name, $view . '.') !== false)) + { + // we are in item + $area = 'item'; + // The record has been set. Check the record permissions. + $permission = $user->authorise($action->name, 'com_' . $component . '.' . $view . '.' . (int) $record->id); + // if no permission found, check edit own + if (!$permission) + { + // With edit, if the created_by matches current user then dig deeper. + if (($action->name === 'core.edit' || $action->name === $view . '.edit') && $record->created_by > 0 && ($record->created_by == $user->id)) + { + // the correct target + $coreCheck = (array) explode('.', $action->name); + // check that we have both local and global access + if ($user->authorise($coreCheck[0] . '.edit.own', 'com_' . $component . '.' . $view . '.' . (int) $record->id) && + $user->authorise($coreCheck[0] . '.edit.own', 'com_' . $component)) + { + // allow edit + $result->set($action->name, true); + // set not to use global default + // because we already validated it + $fallback = false; + } + else + { + // do not allow edit + $result->set($action->name, false); + $fallback = false; + } + } + } + elseif (self::checkString($views) && isset($record->catid) && $record->catid > 0) + { + // we are in item + $area = 'category'; + // set the core check + $coreCheck = explode('.', $action->name); + $core = $coreCheck[0]; + // make sure we use the core. action check for the categories + if (strpos($action->name, $view) !== false && strpos($action->name, 'core.') === false ) + { + $coreCheck[0] = 'core'; + $categoryCheck = implode('.', $coreCheck); + } + else + { + $categoryCheck = $action->name; + } + // The record has a category. Check the category permissions. + $catpermission = $user->authorise($categoryCheck, 'com_' . $component . '.' . $views . '.category.' . (int) $record->catid); + if (!$catpermission && !is_null($catpermission)) + { + // With edit, if the created_by matches current user then dig deeper. + if (($action->name === 'core.edit' || $action->name === $view . '.edit') && $record->created_by > 0 && ($record->created_by == $user->id)) + { + // check that we have both local and global access + if ($user->authorise('core.edit.own', 'com_' . $component . '.' . $views . '.category.' . (int) $record->catid) && + $user->authorise($core . '.edit.own', 'com_' . $component)) + { + // allow edit + $result->set($action->name, true); + // set not to use global default + // because we already validated it + $fallback = false; + } + else + { + // do not allow edit + $result->set($action->name, false); + $fallback = false; + } + } + } + } + } + // if allowed then fallback on component global settings + if ($fallback) + { + // if item/category blocks access then don't fall back on global + if ((($area === 'item') && !$permission) || (($area === 'category') && !$catpermission)) + { + // do not allow + $result->set($action->name, false); + } + // Finally remember the global settings have the final say. (even if item allow) + // The local item permissions can block, but it can't open and override of global permissions. + // Since items are created by users and global permissions is set by system admin. + else + { + $result->set($action->name, $user->authorise($action->name, 'com_' . $component)); + } + } + } + return $result; + } + + /** + * Filter the action permissions + * + * @param string $action The action to check + * @param array $targets The array of target actions + * + * @return boolean true if action should be filtered out + * + */ + protected static function filterActions(&$view, &$action, &$targets) + { + foreach ($targets as $target) + { + if (strpos($action, $view . '.' . $target) !== false || + strpos($action, 'core.' . $target) !== false) + { + return false; + break; + } + } + return true; + } + + /** + * Get any component's model + */ + public static function getModel($name, $path = JPATH_COMPONENT_ADMINISTRATOR, $Component = 'Release_checking', $config = array()) + { + // fix the name + $name = self::safeString($name); + // full path to models + $fullPathModels = $path . '/models'; + // load the model file + JModelLegacy::addIncludePath($fullPathModels, $Component . 'Model'); + // make sure the table path is loaded + if (!isset($config['table_path']) || !self::checkString($config['table_path'])) + { + // This is the JCB default path to tables in Joomla 3.x + $config['table_path'] = JPATH_ADMINISTRATOR . '/components/com_' . strtolower($Component) . '/tables'; + } + // get instance + $model = JModelLegacy::getInstance($name, $Component . 'Model', $config); + // if model not found (strange) + if ($model == false) + { + jimport('joomla.filesystem.file'); + // get file path + $filePath = $path . '/' . $name . '.php'; + $fullPathModel = $fullPathModels . '/' . $name . '.php'; + // check if it exists + if (File::exists($filePath)) + { + // get the file + require_once $filePath; + } + elseif (File::exists($fullPathModel)) + { + // get the file + require_once $fullPathModel; + } + // build class names + $modelClass = $Component . 'Model' . $name; + if (class_exists($modelClass)) + { + // initialize the model + return new $modelClass($config); + } + } + return $model; + } + + /** + * Add to asset Table + */ + public static function setAsset($id, $table, $inherit = true) + { + $parent = JTable::getInstance('Asset'); + $parent->loadByName('com_release_checking'); + + $parentId = $parent->id; + $name = 'com_release_checking.'.$table.'.'.$id; + $title = ''; + + $asset = JTable::getInstance('Asset'); + $asset->loadByName($name); + + // Check for an error. + $error = $asset->getError(); + + if ($error) + { + return false; + } + else + { + // Specify how a new or moved node asset is inserted into the tree. + if ($asset->parent_id != $parentId) + { + $asset->setLocation($parentId, 'last-child'); + } + + // Prepare the asset to be stored. + $asset->parent_id = $parentId; + $asset->name = $name; + $asset->title = $title; + // get the default asset rules + $rules = self::getDefaultAssetRules('com_release_checking', $table, $inherit); + if ($rules instanceof JAccessRules) + { + $asset->rules = (string) $rules; + } + + if (!$asset->check() || !$asset->store()) + { + JFactory::getApplication()->enqueueMessage($asset->getError(), 'warning'); + return false; + } + else + { + // Create an asset_id or heal one that is corrupted. + $object = new stdClass(); + + // Must be a valid primary key value. + $object->id = $id; + $object->asset_id = (int) $asset->id; + + // Update their asset_id to link to the asset table. + return JFactory::getDbo()->updateObject('#__release_checking_'.$table, $object, 'id'); + } + } + return false; + } + + /** + * Gets the default asset Rules for a component/view. + */ + protected static function getDefaultAssetRules($component, $view, $inherit = true) + { + // if new or inherited + $assetId = 0; + // Only get the actual item rules if not inheriting + if (!$inherit) + { + // Need to find the asset id by the name of the component. + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + // check that there is a value + if ($db->getNumRows()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + } + } + // get asset rules + $result = JAccess::getAssetRules($assetId); + if ($result instanceof JAccessRules) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($view !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + elseif ($inherit) + { + // clear the value since we inherit + $rule = array(); + } + } + // check if there are any view values remaining + if (count((array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the JAccessRules object for the asset rules. + $rules = new JAccessRules($_result); + // return filtered rules + return $rules; + } + } + return $result; + } + + /** + * xmlAppend + * + * @param SimpleXMLElement $xml The XML element reference in which to inject a comment + * @param mixed $node A SimpleXMLElement node to append to the XML element reference, or a stdClass object containing a comment attribute to be injected before the XML node and a fieldXML attribute containing a SimpleXMLElement + * + * @return null + * + */ + public static function xmlAppend(&$xml, $node) + { + if (!$node) + { + // element was not returned + return; + } + switch (get_class($node)) + { + case 'stdClass': + if (property_exists($node, 'comment')) + { + self::xmlComment($xml, $node->comment); + } + if (property_exists($node, 'fieldXML')) + { + self::xmlAppend($xml, $node->fieldXML); + } + break; + case 'SimpleXMLElement': + $domXML = dom_import_simplexml($xml); + $domNode = dom_import_simplexml($node); + $domXML->appendChild($domXML->ownerDocument->importNode($domNode, true)); + $xml = simplexml_import_dom($domXML); + break; + } + } + + /** + * xmlComment + * + * @param SimpleXMLElement $xml The XML element reference in which to inject a comment + * @param string $comment The comment to inject + * + * @return null + * + */ + public static function xmlComment(&$xml, $comment) + { + $domXML = dom_import_simplexml($xml); + $domComment = new DOMComment($comment); + $nodeTarget = $domXML->ownerDocument->importNode($domComment, true); + $domXML->appendChild($nodeTarget); + $xml = simplexml_import_dom($domXML); + } + + /** + * xmlAddAttributes + * + * @param SimpleXMLElement $xml The XML element reference in which to inject a comment + * @param array $attributes The attributes to apply to the XML element + * + * @return null + * + */ + public static function xmlAddAttributes(&$xml, $attributes = array()) + { + foreach ($attributes as $key => $value) + { + $xml->addAttribute($key, $value); + } + } + + /** + * xmlAddOptions + * + * @param SimpleXMLElement $xml The XML element reference in which to inject a comment + * @param array $options The options to apply to the XML element + * + * @return void + * + */ + public static function xmlAddOptions(&$xml, $options = array()) + { + foreach ($options as $key => $value) + { + $addOption = $xml->addChild('option'); + $addOption->addAttribute('value', $key); + $addOption[] = $value; + } + } + + /** + * 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); + // get field xml + $XML = self::getFieldXML($attributes, $options); + // setup the field + $field->setup($XML, $default); + // return the field object + return $field; + } + return false; + } + + /** + * get the field xml + * + * @param array $attributes The array of attributes + * @param array $options The options to apply to the XML element + * + * @return object + * + */ + public static function getFieldXML(&$attributes, $options = null) + { + // make sure we have attributes and a type value + if (self::checkArray($attributes)) + { + // 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); + } + // return the field xml + return $XML; + } + return false; + } + + /** + * Render Bool Button + * + * @param array $args All the args for the button + * 0) name + * 1) additional (options class) // not used at this time + * 2) default + * 3) yes (name) + * 4) no (name) + * + * @return string The input html of the button + * + */ + public static function renderBoolButton() + { + $args = func_get_args(); + // check if there is additional button class + $additional = isset($args[1]) ? (string) $args[1] : ''; // not used at this time + // button attributes + $buttonAttributes = array( + 'type' => 'radio', + 'name' => isset($args[0]) ? self::htmlEscape($args[0]) : 'bool_button', + 'label' => isset($args[0]) ? self::safeString(self::htmlEscape($args[0]), 'Ww') : 'Bool Button', // not seen anyway + 'class' => 'btn-group', + 'filter' => 'INT', + 'default' => isset($args[2]) ? (int) $args[2] : 0); + // set the button options + $buttonOptions = array( + '1' => isset($args[3]) ? self::htmlEscape($args[3]) : 'JYES', + '0' => isset($args[4]) ? self::htmlEscape($args[4]) : 'JNO'); + // return the input + return self::getFieldObject($buttonAttributes, $buttonAttributes['default'], $buttonOptions)->input; + } + + /** + * Check if have an json string + * + * @input string The json string to check + * + * @returns bool true on success + */ + public static function checkJson($string) + { + if (self::checkString($string)) + { + json_decode($string); + return (json_last_error() === JSON_ERROR_NONE); + } + return false; + } + + /** + * Check if have an object with a length + * + * @input object The object to check + * + * @returns bool true on success + */ + public static function checkObject($object) + { + if (isset($object) && is_object($object)) + { + return count((array)$object) > 0; + } + return false; + } + + /** + * Check if have an array with a length + * + * @input array The array to check + * + * @returns bool/int number of items in array on success + */ + public static function checkArray($array, $removeEmptyString = false) + { + if (isset($array) && is_array($array) && ($nr = count((array)$array)) > 0) + { + // also make sure the empty strings are removed + if ($removeEmptyString) + { + foreach ($array as $key => $string) + { + if (empty($string)) + { + unset($array[$key]); + } + } + return self::checkArray($array, false); + } + return $nr; + } + return false; + } + + /** + * Check if have a string with a length + * + * @input string The string to check + * + * @returns bool true on success + */ + public static function checkString($string) + { + if (isset($string) && is_string($string) && strlen($string) > 0) + { + return true; + } + return false; + } + + /** + * Check if we are connected + * Thanks https://stackoverflow.com/a/4860432/1429677 + * + * @returns bool true on success + */ + public static function isConnected() + { + // If example.com is down, then probably the whole internet is down, since IANA maintains the domain. Right? + $connected = @fsockopen("www.example.com", 80); + // website, port (try 80 or 443) + if ($connected) + { + //action when connected + $is_conn = true; + fclose($connected); + } + else + { + //action in connection failure + $is_conn = false; + } + return $is_conn; + } + + /** + * Merge an array of array's + * + * @input array The arrays you would like to merge + * + * @returns array on success + */ + public static function mergeArrays($arrays) + { + if(self::checkArray($arrays)) + { + $arrayBuket = array(); + foreach ($arrays as $array) + { + if (self::checkArray($array)) + { + $arrayBuket = array_merge($arrayBuket, $array); + } + } + return $arrayBuket; + } + return false; + } + + // typo sorry! + public static function sorten($string, $length = 40, $addTip = true) + { + return self::shorten($string, $length, $addTip); + } + + /** + * Shorten a string + * + * @input string The you would like to shorten + * + * @returns string on success + */ + public static function shorten($string, $length = 40, $addTip = true) + { + if (self::checkString($string)) + { + $initial = strlen($string); + $words = preg_split('/([\s\n\r]+)/', $string, null, PREG_SPLIT_DELIM_CAPTURE); + $words_count = count((array)$words); + + $word_length = 0; + $last_word = 0; + for (; $last_word < $words_count; ++$last_word) + { + $word_length += strlen($words[$last_word]); + if ($word_length > $length) + { + break; + } + } + + $newString = implode(array_slice($words, 0, $last_word)); + $final = strlen($newString); + if ($initial != $final && $addTip) + { + $title = self::shorten($string, 400 , false); + return ''.trim($newString).'...'; + } + elseif ($initial != $final && !$addTip) + { + return trim($newString).'...'; + } + } + return $string; + } + + /** + * Making strings safe (various ways) + * + * @input string The you would like to make safe + * + * @returns string on success + */ + public static function safeString($string, $type = 'L', $spacer = '_', $replaceNumbers = true, $keepOnlyCharacters = true) + { + if ($replaceNumbers === true) + { + // remove all numbers and replace with english text version (works well only up to millions) + $string = self::replaceNumbers($string); + } + // 0nly continue if we have a string + if (self::checkString($string)) + { + // create file name without the extention that is safe + if ($type === 'filename') + { + // make sure VDM is not in the string + $string = str_replace('VDM', 'vDm', $string); + // Remove anything which isn't a word, whitespace, number + // or any of the following caracters -_() + // If you don't need to handle multi-byte characters + // you can use preg_replace rather than mb_ereg_replace + // Thanks @Łukasz Rysiak! + // $string = mb_ereg_replace("([^\w\s\d\-_\(\)])", '', $string); + $string = preg_replace("([^\w\s\d\-_\(\)])", '', $string); + // http://stackoverflow.com/a/2021729/1429677 + return preg_replace('/\s+/', ' ', $string); + } + // remove all other characters + $string = trim($string); + $string = preg_replace('/'.$spacer.'+/', ' ', $string); + $string = preg_replace('/\s+/', ' ', $string); + // Transliterate string + $string = self::transliterate($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') + { + // replace white space with underscore + $string = preg_replace('/\s+/', $spacer, $string); + // default is to return lower + return strtolower($string); + } + elseif ($type === 'W') + { + // return a string with all first letter of each word uppercase(no undersocre) + return ucwords(strtolower($string)); + } + elseif ($type === 'w' || $type === 'word') + { + // return a string with all lowercase(no undersocre) + return strtolower($string); + } + elseif ($type === 'Ww' || $type === 'Word') + { + // return a string with first letter of the first word uppercase and all the rest lowercase(no undersocre) + return ucfirst(strtolower($string)); + } + elseif ($type === 'WW' || $type === 'WORD') + { + // return a string with all the uppercase(no undersocre) + return strtoupper($string); + } + elseif ($type === 'U' || $type === 'strtoupper') + { + // replace white space with underscore + $string = preg_replace('/\s+/', $spacer, $string); + // return all upper + return strtoupper($string); + } + elseif ($type === 'F' || $type === 'ucfirst') + { + // replace white space with underscore + $string = preg_replace('/\s+/', $spacer, $string); + // return with first caracter to upper + return ucfirst(strtolower($string)); + } + elseif ($type === 'cA' || $type === 'cAmel' || $type === 'camelcase') + { + // convert all words to first letter uppercase + $string = ucwords(strtolower($string)); + // remove white space + $string = preg_replace('/\s+/', '', $string); + // now return first letter lowercase + return lcfirst($string); + } + // return string + return $string; + } + // not a string + return ''; + } + + public static function transliterate($string) + { + // set tag only once + if (!self::checkString(self::$langTag)) + { + // get global value + self::$langTag = JComponentHelper::getParams('com_release_checking')->get('language', 'en-GB'); + } + // Transliterate on the language requested + $lang = Language::getInstance(self::$langTag); + return $lang->transliterate($string); + } + + public static function htmlEscape($var, $charset = 'UTF-8', $shorten = false, $length = 40) + { + if (self::checkString($var)) + { + $filter = new JFilterInput(); + $string = $filter->clean(html_entity_decode(htmlentities($var, ENT_COMPAT, $charset)), 'HTML'); + if ($shorten) + { + return self::shorten($string,$length); + } + return $string; + } + else + { + return ''; + } + } + + public static function replaceNumbers($string) + { + // set numbers array + $numbers = array(); + // first get all numbers + preg_match_all('!\d+!', $string, $numbers); + // check if we have any numbers + if (isset($numbers[0]) && self::checkArray($numbers[0])) + { + foreach ($numbers[0] as $number) + { + $searchReplace[$number] = self::numberToString((int)$number); + } + // now replace numbers in string + $string = str_replace(array_keys($searchReplace), array_values($searchReplace),$string); + // check if we missed any, strange if we did. + return self::replaceNumbers($string); + } + // return the string with no numbers remaining. + return $string; + } + + /** + * Convert an integer into an English word string + * Thanks to Tom Nicholson + * + * @input an int + * @returns a string + */ + public static function numberToString($x) + { + $nwords = array( "zero", "one", "two", "three", "four", "five", "six", "seven", + "eight", "nine", "ten", "eleven", "twelve", "thirteen", + "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", + "nineteen", "twenty", 30 => "thirty", 40 => "forty", + 50 => "fifty", 60 => "sixty", 70 => "seventy", 80 => "eighty", + 90 => "ninety" ); + + if(!is_numeric($x)) + { + $w = $x; + } + elseif(fmod($x, 1) != 0) + { + $w = $x; + } + else + { + if($x < 0) + { + $w = 'minus '; + $x = -$x; + } + else + { + $w = ''; + // ... now $x is a non-negative integer. + } + + if($x < 21) // 0 to 20 + { + $w .= $nwords[$x]; + } + elseif($x < 100) // 21 to 99 + { + $w .= $nwords[10 * floor($x/10)]; + $r = fmod($x, 10); + if($r > 0) + { + $w .= ' '. $nwords[$r]; + } + } + elseif($x < 1000) // 100 to 999 + { + $w .= $nwords[floor($x/100)] .' hundred'; + $r = fmod($x, 100); + if($r > 0) + { + $w .= ' and '. self::numberToString($r); + } + } + elseif($x < 1000000) // 1000 to 999999 + { + $w .= self::numberToString(floor($x/1000)) .' thousand'; + $r = fmod($x, 1000); + if($r > 0) + { + $w .= ' '; + if($r < 100) + { + $w .= 'and '; + } + $w .= self::numberToString($r); + } + } + else // millions + { + $w .= self::numberToString(floor($x/1000000)) .' million'; + $r = fmod($x, 1000000); + if($r > 0) + { + $w .= ' '; + if($r < 100) + { + $w .= 'and '; + } + $w .= self::numberToString($r); + } + } + } + return $w; + } + + /** + * Random Key + * + * @returns a string + */ + public static function randomkey($size) + { + $bag = "abcefghijknopqrstuwxyzABCDDEFGHIJKLLMMNOPQRSTUVVWXYZabcddefghijkllmmnopqrstuvvwxyzABCEFGHIJKNOPQRSTUWXYZ"; + $key = array(); + $bagsize = strlen($bag) - 1; + for ($i = 0; $i < $size; $i++) + { + $get = rand(0, $bagsize); + $key[] = $bag[$get]; + } + return implode($key); + } +} diff --git a/admin/language/en-GB/en-GB.com_release_checking.ini b/admin/language/en-GB/en-GB.com_release_checking.ini index 799e630..285edc6 100644 --- a/admin/language/en-GB/en-GB.com_release_checking.ini +++ b/admin/language/en-GB/en-GB.com_release_checking.ini @@ -32,17 +32,14 @@ COM_RELEASE_CHECKING_ACTIONS_N_ITEMS_UNFEATURED="%s Actions unfeatured." COM_RELEASE_CHECKING_ACTIONS_N_ITEMS_UNFEATURED_1="%s Action unfeatured." COM_RELEASE_CHECKING_ACTIONS_N_ITEMS_UNPUBLISHED="%s Actions unpublished." COM_RELEASE_CHECKING_ACTIONS_N_ITEMS_UNPUBLISHED_1="%s Action unpublished." -COM_RELEASE_CHECKING_ACTION_ALIAS="Alias" COM_RELEASE_CHECKING_ACTION_ALIAS_HINT="Auto-generated from name" COM_RELEASE_CHECKING_ACTION_ALIAS_LABEL="Alias" -COM_RELEASE_CHECKING_ACTION_CONTEXT="Context" COM_RELEASE_CHECKING_ACTION_CONTEXT_DESCRIPTION="Select the context." COM_RELEASE_CHECKING_ACTION_CONTEXT_LABEL="Context" COM_RELEASE_CHECKING_ACTION_CREATED_BY_DESC="The user that created this Action." COM_RELEASE_CHECKING_ACTION_CREATED_BY_LABEL="Created By" COM_RELEASE_CHECKING_ACTION_CREATED_DATE_DESC="The date this Action was created." COM_RELEASE_CHECKING_ACTION_CREATED_DATE_LABEL="Created Date" -COM_RELEASE_CHECKING_ACTION_DESCRIPTION="Description" COM_RELEASE_CHECKING_ACTION_DESCRIPTION_DESCRIPTION="Add Description Here" COM_RELEASE_CHECKING_ACTION_DESCRIPTION_HINT="Add Description Here" COM_RELEASE_CHECKING_ACTION_DESCRIPTION_LABEL="Description" @@ -54,9 +51,8 @@ COM_RELEASE_CHECKING_ACTION_MODIFIED_BY_DESC="The last user that modified this A COM_RELEASE_CHECKING_ACTION_MODIFIED_BY_LABEL="Modified By" COM_RELEASE_CHECKING_ACTION_MODIFIED_DATE_DESC="The date this Action was modified." COM_RELEASE_CHECKING_ACTION_MODIFIED_DATE_LABEL="Modified Date" -COM_RELEASE_CHECKING_ACTION_NAME="Name" COM_RELEASE_CHECKING_ACTION_NAME_DESCRIPTION="Enter Name Here" -COM_RELEASE_CHECKING_ACTION_NAME_HINT="Name Here" +COM_RELEASE_CHECKING_ACTION_NAME_HINT="Name here" COM_RELEASE_CHECKING_ACTION_NAME_LABEL="Name" COM_RELEASE_CHECKING_ACTION_NAME_MESSAGE="Error! Please add name here." COM_RELEASE_CHECKING_ACTION_NEW="A New Action" @@ -121,7 +117,6 @@ COM_RELEASE_CHECKING_CONTEXTS_N_ITEMS_UNFEATURED="%s Contexts unfeatured." COM_RELEASE_CHECKING_CONTEXTS_N_ITEMS_UNFEATURED_1="%s Context unfeatured." COM_RELEASE_CHECKING_CONTEXTS_N_ITEMS_UNPUBLISHED="%s Contexts unpublished." COM_RELEASE_CHECKING_CONTEXTS_N_ITEMS_UNPUBLISHED_1="%s Context unpublished." -COM_RELEASE_CHECKING_CONTEXT_ALIAS="Alias" COM_RELEASE_CHECKING_CONTEXT_ALIAS_HINT="Auto-generated from name" COM_RELEASE_CHECKING_CONTEXT_ALIAS_LABEL="Alias" COM_RELEASE_CHECKING_CONTEXT_CREATED_BY_DESC="The user that created this Context." @@ -136,9 +131,8 @@ COM_RELEASE_CHECKING_CONTEXT_MODIFIED_BY_DESC="The last user that modified this COM_RELEASE_CHECKING_CONTEXT_MODIFIED_BY_LABEL="Modified By" COM_RELEASE_CHECKING_CONTEXT_MODIFIED_DATE_DESC="The date this Context was modified." COM_RELEASE_CHECKING_CONTEXT_MODIFIED_DATE_LABEL="Modified Date" -COM_RELEASE_CHECKING_CONTEXT_NAME="Name" COM_RELEASE_CHECKING_CONTEXT_NAME_DESCRIPTION="Enter Name Here" -COM_RELEASE_CHECKING_CONTEXT_NAME_HINT="Name Here" +COM_RELEASE_CHECKING_CONTEXT_NAME_HINT="Name here" COM_RELEASE_CHECKING_CONTEXT_NAME_LABEL="Name" COM_RELEASE_CHECKING_CONTEXT_NAME_MESSAGE="Error! Please add name here." COM_RELEASE_CHECKING_CONTEXT_NEW="A New Context" @@ -271,7 +265,6 @@ COM_RELEASE_CHECKING_JOOMLA_VERSIONS_N_ITEMS_UNPUBLISHED="%s Joomla Versions unp COM_RELEASE_CHECKING_JOOMLA_VERSIONS_N_ITEMS_UNPUBLISHED_1="%s Joomla Version unpublished." COM_RELEASE_CHECKING_JOOMLA_VERSIONS_SUBMENU="Joomla Versions Submenu" COM_RELEASE_CHECKING_JOOMLA_VERSIONS_SUBMENU_DESC="Allows the users in this group to submenu of joomla version" -COM_RELEASE_CHECKING_JOOMLA_VERSION_ALIAS="Alias" COM_RELEASE_CHECKING_JOOMLA_VERSION_ALIAS_HINT="Auto-generated from name" COM_RELEASE_CHECKING_JOOMLA_VERSION_ALIAS_LABEL="Alias" COM_RELEASE_CHECKING_JOOMLA_VERSION_CREATED_BY_DESC="The user that created this Joomla Version." @@ -286,9 +279,8 @@ COM_RELEASE_CHECKING_JOOMLA_VERSION_MODIFIED_BY_DESC="The last user that modifie COM_RELEASE_CHECKING_JOOMLA_VERSION_MODIFIED_BY_LABEL="Modified By" COM_RELEASE_CHECKING_JOOMLA_VERSION_MODIFIED_DATE_DESC="The date this Joomla Version was modified." COM_RELEASE_CHECKING_JOOMLA_VERSION_MODIFIED_DATE_LABEL="Modified Date" -COM_RELEASE_CHECKING_JOOMLA_VERSION_NAME="Name" COM_RELEASE_CHECKING_JOOMLA_VERSION_NAME_DESCRIPTION="Enter Name Here" -COM_RELEASE_CHECKING_JOOMLA_VERSION_NAME_HINT="Name Here" +COM_RELEASE_CHECKING_JOOMLA_VERSION_NAME_HINT="Name here" COM_RELEASE_CHECKING_JOOMLA_VERSION_NAME_LABEL="Name" COM_RELEASE_CHECKING_JOOMLA_VERSION_NAME_MESSAGE="Error! Please add name here." COM_RELEASE_CHECKING_JOOMLA_VERSION_NEW="A New Joomla Version" @@ -361,14 +353,11 @@ COM_RELEASE_CHECKING_RELEASE_CHECKS_N_ITEMS_UNPUBLISHED="%s Release Checks unpub COM_RELEASE_CHECKING_RELEASE_CHECKS_N_ITEMS_UNPUBLISHED_1="%s Release Check unpublished." COM_RELEASE_CHECKING_RELEASE_CHECKS_SUBMENU="Release Checks Submenu" COM_RELEASE_CHECKING_RELEASE_CHECKS_SUBMENU_DESC="Allows the users in this group to submenu of release check" -COM_RELEASE_CHECKING_RELEASE_CHECK_ACTION="Action" COM_RELEASE_CHECKING_RELEASE_CHECK_ACTION_DESCRIPTION="Please select the action this release_check belongs to." COM_RELEASE_CHECKING_RELEASE_CHECK_ACTION_LABEL="Action" COM_RELEASE_CHECKING_RELEASE_CHECK_CHECKING="Checking" -COM_RELEASE_CHECKING_RELEASE_CHECK_CONTEXT="Context" COM_RELEASE_CHECKING_RELEASE_CHECK_CONTEXT_DESCRIPTION="Select the context." COM_RELEASE_CHECKING_RELEASE_CHECK_CONTEXT_LABEL="Context" -COM_RELEASE_CHECKING_RELEASE_CHECK_CREATED_BY="Created By" COM_RELEASE_CHECKING_RELEASE_CHECK_CREATED_BY_DESC="The user that created this Release Check." COM_RELEASE_CHECKING_RELEASE_CHECK_CREATED_BY_DESCRIPTION="The user that created this." COM_RELEASE_CHECKING_RELEASE_CHECK_CREATED_BY_LABEL="Created By" @@ -378,7 +367,6 @@ COM_RELEASE_CHECKING_RELEASE_CHECK_EDIT="Editing the Release Check" COM_RELEASE_CHECKING_RELEASE_CHECK_ERROR_UNIQUE_ALIAS="Another Release Check has the same alias." COM_RELEASE_CHECKING_RELEASE_CHECK_FAILURE="Failure" COM_RELEASE_CHECKING_RELEASE_CHECK_ID="Id" -COM_RELEASE_CHECKING_RELEASE_CHECK_JOOMLA_VERSION="Joomla Version" COM_RELEASE_CHECKING_RELEASE_CHECK_JOOMLA_VERSION_DESCRIPTION="Select the Joomla version being tested" COM_RELEASE_CHECKING_RELEASE_CHECK_JOOMLA_VERSION_LABEL="Joomla Version" COM_RELEASE_CHECKING_RELEASE_CHECK_MODIFIED_BY_DESC="The last user that modified this Release Check." @@ -387,7 +375,6 @@ COM_RELEASE_CHECKING_RELEASE_CHECK_MODIFIED_DATE_DESC="The date this Release Che COM_RELEASE_CHECKING_RELEASE_CHECK_MODIFIED_DATE_LABEL="Modified Date" COM_RELEASE_CHECKING_RELEASE_CHECK_NEW="A New Release Check" COM_RELEASE_CHECKING_RELEASE_CHECK_ORDERING_LABEL="Ordering" -COM_RELEASE_CHECKING_RELEASE_CHECK_OUTCOME="Outcome" COM_RELEASE_CHECKING_RELEASE_CHECK_OUTCOME_DESCRIPTION="Select the test outcome" COM_RELEASE_CHECKING_RELEASE_CHECK_OUTCOME_LABEL="Outcome" COM_RELEASE_CHECKING_RELEASE_CHECK_PERMISSION="Permissions" diff --git a/admin/layouts/action/details_above.php b/admin/layouts/action/details_above.php index 3bac9b4..82c31e2 100644 --- a/admin/layouts/action/details_above.php +++ b/admin/layouts/action/details_above.php @@ -5,39 +5,39 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -// get the form -$form = $displayData->getForm(); - -// get the layout fields override method name (from layout path/ID) -$layout_path_array = explode('.', $this->getLayoutId()); -// Since we cannot pass the layout and tab names as parameters to the model method -// this name combination of tab and layout in the method name is the only work around -// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. -// example of layout name: details_left.php -// example of method name: getFields_details_left() -$fields_tab_layout = 'fields_' . $layout_path_array[1]; - -// get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( 'name', - 'alias' -); - -$hiddenFields = $displayData->get('hidden_fields') ?: array(); - -?> - -
- - - setFieldAttribute($field, 'type', 'hidden'); ?> - - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> - -
- + 'alias' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + +
+ + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + +
+ diff --git a/admin/layouts/action/details_fullwidth.php b/admin/layouts/action/details_fullwidth.php index 0591a24..9ade903 100644 --- a/admin/layouts/action/details_fullwidth.php +++ b/admin/layouts/action/details_fullwidth.php @@ -5,38 +5,38 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -// get the form -$form = $displayData->getForm(); - -// get the layout fields override method name (from layout path/ID) -$layout_path_array = explode('.', $this->getLayoutId()); -// Since we cannot pass the layout and tab names as parameters to the model method -// this name combination of tab and layout in the method name is the only work around -// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. -// example of layout name: details_left.php -// example of method name: getFields_details_left() -$fields_tab_layout = 'fields_' . $layout_path_array[1]; - -// get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( - 'description' -); - -$hiddenFields = $displayData->get('hidden_fields') ?: array(); - -?> - -
- - - setFieldAttribute($field, 'type', 'hidden'); ?> - - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> - -
- + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'description' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + +
+ + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + +
+ diff --git a/admin/layouts/action/details_left.php b/admin/layouts/action/details_left.php index 00eb5fc..66790c5 100644 --- a/admin/layouts/action/details_left.php +++ b/admin/layouts/action/details_left.php @@ -5,36 +5,36 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -// get the form -$form = $displayData->getForm(); - -// get the layout fields override method name (from layout path/ID) -$layout_path_array = explode('.', $this->getLayoutId()); -// Since we cannot pass the layout and tab names as parameters to the model method -// this name combination of tab and layout in the method name is the only work around -// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. -// example of layout name: details_left.php -// example of method name: getFields_details_left() -$fields_tab_layout = 'fields_' . $layout_path_array[1]; - -// get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( - 'context' -); - -$hiddenFields = $displayData->get('hidden_fields') ?: array(); - -?> - - - - setFieldAttribute($field, 'type', 'hidden'); ?> - - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> - - + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'context' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/action/publishing.php b/admin/layouts/action/publishing.php index 52f874c..879c1d4 100644 --- a/admin/layouts/action/publishing.php +++ b/admin/layouts/action/publishing.php @@ -5,39 +5,40 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -// get the form -$form = $displayData->getForm(); - -// get the layout fields override method name (from layout path/ID) -$layout_path_array = explode('.', $this->getLayoutId()); -// Since we cannot pass the layout and tab names as parameters to the model method -// this name combination of tab and layout in the method name is the only work around -// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. -// example of layout name: details_left.php -// example of method name: getFields_details_left() -$fields_tab_layout = 'fields_' . $layout_path_array[1]; - -// get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'title', 'created', 'created_by', 'modified', - 'modified_by' -); - -$hiddenFields = $displayData->get('hidden_fields') ?: array(); - -?> - - - - setFieldAttribute($field, 'type', 'hidden'); ?> - - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> - - + 'modified_by' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/action/publlshing.php b/admin/layouts/action/publlshing.php index d80aab7..72504ed 100644 --- a/admin/layouts/action/publlshing.php +++ b/admin/layouts/action/publlshing.php @@ -5,41 +5,41 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -// get the form -$form = $displayData->getForm(); - -// get the layout fields override method name (from layout path/ID) -$layout_path_array = explode('.', $this->getLayoutId()); -// Since we cannot pass the layout and tab names as parameters to the model method -// this name combination of tab and layout in the method name is the only work around -// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. -// example of layout name: details_left.php -// example of method name: getFields_details_left() -$fields_tab_layout = 'fields_' . $layout_path_array[1]; - -// get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( 'published', 'ordering', 'access', 'version', 'hits', - 'id' -); - -$hiddenFields = $displayData->get('hidden_fields') ?: array(); - -?> - - - - setFieldAttribute($field, 'type', 'hidden'); ?> - - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> - - + 'id' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/batchselection.php b/admin/layouts/batchselection.php index 64bb489..66abfc2 100644 --- a/admin/layouts/batchselection.php +++ b/admin/layouts/batchselection.php @@ -5,42 +5,42 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('JPATH_BASE') or die; - -JHtmlBehavior::core(); -$divWrapper = range(1,120,2); -$counter = 0; -?> -ListSelection) : ?> -
- ListSelection as $ListSelection) : ?> -
-
- - -
-
- -
-
- - - -
-
-
- - -
-
+ */ + +// No direct access to this file +defined('JPATH_BASE') or die; + +JHtmlBehavior::core(); +$divWrapper = range(1,120,2); +$counter = 0; +?> +ListSelection) : ?> +
+ ListSelection as $ListSelection) : ?> +
+
+ + +
+
+ +
+
+ + + +
+
+
+ + +
+
\ No newline at end of file diff --git a/admin/layouts/context/details_left.php b/admin/layouts/context/details_left.php index 82352ad..96338a1 100644 --- a/admin/layouts/context/details_left.php +++ b/admin/layouts/context/details_left.php @@ -5,36 +5,36 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -// get the form -$form = $displayData->getForm(); - -// get the layout fields override method name (from layout path/ID) -$layout_path_array = explode('.', $this->getLayoutId()); -// Since we cannot pass the layout and tab names as parameters to the model method -// this name combination of tab and layout in the method name is the only work around -// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. -// example of layout name: details_left.php -// example of method name: getFields_details_left() -$fields_tab_layout = 'fields_' . $layout_path_array[1]; - -// get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( - 'name' -); - -$hiddenFields = $displayData->get('hidden_fields') ?: array(); - -?> - - - - setFieldAttribute($field, 'type', 'hidden'); ?> - - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> - - + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'name' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/context/details_right.php b/admin/layouts/context/details_right.php index 3118483..e9296b2 100644 --- a/admin/layouts/context/details_right.php +++ b/admin/layouts/context/details_right.php @@ -5,36 +5,36 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -// get the form -$form = $displayData->getForm(); - -// get the layout fields override method name (from layout path/ID) -$layout_path_array = explode('.', $this->getLayoutId()); -// Since we cannot pass the layout and tab names as parameters to the model method -// this name combination of tab and layout in the method name is the only work around -// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. -// example of layout name: details_left.php -// example of method name: getFields_details_left() -$fields_tab_layout = 'fields_' . $layout_path_array[1]; - -// get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( - 'alias' -); - -$hiddenFields = $displayData->get('hidden_fields') ?: array(); - -?> - - - - setFieldAttribute($field, 'type', 'hidden'); ?> - - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> - - + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'alias' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/context/publishing.php b/admin/layouts/context/publishing.php index 52f874c..879c1d4 100644 --- a/admin/layouts/context/publishing.php +++ b/admin/layouts/context/publishing.php @@ -5,39 +5,40 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -// get the form -$form = $displayData->getForm(); - -// get the layout fields override method name (from layout path/ID) -$layout_path_array = explode('.', $this->getLayoutId()); -// Since we cannot pass the layout and tab names as parameters to the model method -// this name combination of tab and layout in the method name is the only work around -// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. -// example of layout name: details_left.php -// example of method name: getFields_details_left() -$fields_tab_layout = 'fields_' . $layout_path_array[1]; - -// get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'title', 'created', 'created_by', 'modified', - 'modified_by' -); - -$hiddenFields = $displayData->get('hidden_fields') ?: array(); - -?> - - - - setFieldAttribute($field, 'type', 'hidden'); ?> - - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> - - + 'modified_by' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/context/publlshing.php b/admin/layouts/context/publlshing.php index d80aab7..72504ed 100644 --- a/admin/layouts/context/publlshing.php +++ b/admin/layouts/context/publlshing.php @@ -5,41 +5,41 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -// get the form -$form = $displayData->getForm(); - -// get the layout fields override method name (from layout path/ID) -$layout_path_array = explode('.', $this->getLayoutId()); -// Since we cannot pass the layout and tab names as parameters to the model method -// this name combination of tab and layout in the method name is the only work around -// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. -// example of layout name: details_left.php -// example of method name: getFields_details_left() -$fields_tab_layout = 'fields_' . $layout_path_array[1]; - -// get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( 'published', 'ordering', 'access', 'version', 'hits', - 'id' -); - -$hiddenFields = $displayData->get('hidden_fields') ?: array(); - -?> - - - - setFieldAttribute($field, 'type', 'hidden'); ?> - - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> - - + 'id' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/joomla_version/details_left.php b/admin/layouts/joomla_version/details_left.php index 82352ad..96338a1 100644 --- a/admin/layouts/joomla_version/details_left.php +++ b/admin/layouts/joomla_version/details_left.php @@ -5,36 +5,36 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -// get the form -$form = $displayData->getForm(); - -// get the layout fields override method name (from layout path/ID) -$layout_path_array = explode('.', $this->getLayoutId()); -// Since we cannot pass the layout and tab names as parameters to the model method -// this name combination of tab and layout in the method name is the only work around -// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. -// example of layout name: details_left.php -// example of method name: getFields_details_left() -$fields_tab_layout = 'fields_' . $layout_path_array[1]; - -// get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( - 'name' -); - -$hiddenFields = $displayData->get('hidden_fields') ?: array(); - -?> - - - - setFieldAttribute($field, 'type', 'hidden'); ?> - - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> - - + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'name' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/joomla_version/details_right.php b/admin/layouts/joomla_version/details_right.php index 3118483..e9296b2 100644 --- a/admin/layouts/joomla_version/details_right.php +++ b/admin/layouts/joomla_version/details_right.php @@ -5,36 +5,36 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -// get the form -$form = $displayData->getForm(); - -// get the layout fields override method name (from layout path/ID) -$layout_path_array = explode('.', $this->getLayoutId()); -// Since we cannot pass the layout and tab names as parameters to the model method -// this name combination of tab and layout in the method name is the only work around -// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. -// example of layout name: details_left.php -// example of method name: getFields_details_left() -$fields_tab_layout = 'fields_' . $layout_path_array[1]; - -// get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( - 'alias' -); - -$hiddenFields = $displayData->get('hidden_fields') ?: array(); - -?> - - - - setFieldAttribute($field, 'type', 'hidden'); ?> - - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> - - + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'alias' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/joomla_version/publishing.php b/admin/layouts/joomla_version/publishing.php index 52f874c..879c1d4 100644 --- a/admin/layouts/joomla_version/publishing.php +++ b/admin/layouts/joomla_version/publishing.php @@ -5,39 +5,40 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -// get the form -$form = $displayData->getForm(); - -// get the layout fields override method name (from layout path/ID) -$layout_path_array = explode('.', $this->getLayoutId()); -// Since we cannot pass the layout and tab names as parameters to the model method -// this name combination of tab and layout in the method name is the only work around -// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. -// example of layout name: details_left.php -// example of method name: getFields_details_left() -$fields_tab_layout = 'fields_' . $layout_path_array[1]; - -// get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'title', 'created', 'created_by', 'modified', - 'modified_by' -); - -$hiddenFields = $displayData->get('hidden_fields') ?: array(); - -?> - - - - setFieldAttribute($field, 'type', 'hidden'); ?> - - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> - - + 'modified_by' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/joomla_version/publlshing.php b/admin/layouts/joomla_version/publlshing.php index d80aab7..72504ed 100644 --- a/admin/layouts/joomla_version/publlshing.php +++ b/admin/layouts/joomla_version/publlshing.php @@ -5,41 +5,41 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -// get the form -$form = $displayData->getForm(); - -// get the layout fields override method name (from layout path/ID) -$layout_path_array = explode('.', $this->getLayoutId()); -// Since we cannot pass the layout and tab names as parameters to the model method -// this name combination of tab and layout in the method name is the only work around -// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. -// example of layout name: details_left.php -// example of method name: getFields_details_left() -$fields_tab_layout = 'fields_' . $layout_path_array[1]; - -// get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( 'published', 'ordering', 'access', 'version', 'hits', - 'id' -); - -$hiddenFields = $displayData->get('hidden_fields') ?: array(); - -?> - - - - setFieldAttribute($field, 'type', 'hidden'); ?> - - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> - - + 'id' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/release_check/checking_above.php b/admin/layouts/release_check/checking_above.php index 69e26f8..aa31c52 100644 --- a/admin/layouts/release_check/checking_above.php +++ b/admin/layouts/release_check/checking_above.php @@ -5,38 +5,38 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -// get the form -$form = $displayData->getForm(); - -// get the layout fields override method name (from layout path/ID) -$layout_path_array = explode('.', $this->getLayoutId()); -// Since we cannot pass the layout and tab names as parameters to the model method -// this name combination of tab and layout in the method name is the only work around -// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. -// example of layout name: details_left.php -// example of method name: getFields_details_left() -$fields_tab_layout = 'fields_' . $layout_path_array[1]; - -// get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( - 'joomla_version' -); - -$hiddenFields = $displayData->get('hidden_fields') ?: array(); - -?> - -
- - - setFieldAttribute($field, 'type', 'hidden'); ?> - - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> - -
- + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'joomla_version' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + +
+ + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + +
+ diff --git a/admin/layouts/release_check/checking_left.php b/admin/layouts/release_check/checking_left.php index 4c3f99c..14149fe 100644 --- a/admin/layouts/release_check/checking_left.php +++ b/admin/layouts/release_check/checking_left.php @@ -5,37 +5,37 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -// get the form -$form = $displayData->getForm(); - -// get the layout fields override method name (from layout path/ID) -$layout_path_array = explode('.', $this->getLayoutId()); -// Since we cannot pass the layout and tab names as parameters to the model method -// this name combination of tab and layout in the method name is the only work around -// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. -// example of layout name: details_left.php -// example of method name: getFields_details_left() -$fields_tab_layout = 'fields_' . $layout_path_array[1]; - -// get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( 'context', - 'action' -); - -$hiddenFields = $displayData->get('hidden_fields') ?: array(); - -?> - - - - setFieldAttribute($field, 'type', 'hidden'); ?> - - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> - - + 'action' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/release_check/checking_right.php b/admin/layouts/release_check/checking_right.php index 0dd6ba7..8beb05f 100644 --- a/admin/layouts/release_check/checking_right.php +++ b/admin/layouts/release_check/checking_right.php @@ -5,36 +5,36 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -// get the form -$form = $displayData->getForm(); - -// get the layout fields override method name (from layout path/ID) -$layout_path_array = explode('.', $this->getLayoutId()); -// Since we cannot pass the layout and tab names as parameters to the model method -// this name combination of tab and layout in the method name is the only work around -// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. -// example of layout name: details_left.php -// example of method name: getFields_details_left() -$fields_tab_layout = 'fields_' . $layout_path_array[1]; - -// get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( - 'outcome' -); - -$hiddenFields = $displayData->get('hidden_fields') ?: array(); - -?> - - - - setFieldAttribute($field, 'type', 'hidden'); ?> - - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> - - + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'outcome' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/release_check/publishing.php b/admin/layouts/release_check/publishing.php index 52f874c..879c1d4 100644 --- a/admin/layouts/release_check/publishing.php +++ b/admin/layouts/release_check/publishing.php @@ -5,39 +5,40 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -// get the form -$form = $displayData->getForm(); - -// get the layout fields override method name (from layout path/ID) -$layout_path_array = explode('.', $this->getLayoutId()); -// Since we cannot pass the layout and tab names as parameters to the model method -// this name combination of tab and layout in the method name is the only work around -// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. -// example of layout name: details_left.php -// example of method name: getFields_details_left() -$fields_tab_layout = 'fields_' . $layout_path_array[1]; - -// get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'title', 'created', 'created_by', 'modified', - 'modified_by' -); - -$hiddenFields = $displayData->get('hidden_fields') ?: array(); - -?> - - - - setFieldAttribute($field, 'type', 'hidden'); ?> - - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> - - + 'modified_by' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/release_check/publlshing.php b/admin/layouts/release_check/publlshing.php index d80aab7..72504ed 100644 --- a/admin/layouts/release_check/publlshing.php +++ b/admin/layouts/release_check/publlshing.php @@ -5,41 +5,41 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -// get the form -$form = $displayData->getForm(); - -// get the layout fields override method name (from layout path/ID) -$layout_path_array = explode('.', $this->getLayoutId()); -// Since we cannot pass the layout and tab names as parameters to the model method -// this name combination of tab and layout in the method name is the only work around -// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. -// example of layout name: details_left.php -// example of method name: getFields_details_left() -$fields_tab_layout = 'fields_' . $layout_path_array[1]; - -// get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( 'published', 'ordering', 'access', 'version', 'hits', - 'id' -); - -$hiddenFields = $displayData->get('hidden_fields') ?: array(); - -?> - - - - setFieldAttribute($field, 'type', 'hidden'); ?> - - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> - - + 'id' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/models/action.php b/admin/models/action.php index 259ff73..fde55d7 100644 --- a/admin/models/action.php +++ b/admin/models/action.php @@ -5,25 +5,25 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + use Joomla\Registry\Registry; use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Release_checking Action Model - */ -class Release_checkingModelAction extends JModelAdmin -{ - /** - * The tab layout fields array. - * - * @var array - */ +use Joomla\Utilities\ArrayHelper; + +/** + * Release_checking Action Model + */ +class Release_checkingModelAction extends JModelAdmin +{ + /** + * The tab layout fields array. + * + * @var array + */ protected $tabLayoutFields = array( 'details' => array( 'left' => array( @@ -37,94 +37,94 @@ class Release_checkingModelAction extends JModelAdmin 'alias' ) ) - ); - - /** - * @var string The prefix to use with controller messages. - * @since 1.6 - */ - protected $text_prefix = 'COM_RELEASE_CHECKING'; - - /** - * The type alias for this content type. - * - * @var string - * @since 3.2 - */ - public $typeAlias = 'com_release_checking.action'; - - /** - * Returns a Table object, always creating it - * - * @param type $type The table type to instantiate - * @param string $prefix A prefix for the table class name. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JTable A database object - * - * @since 1.6 - */ - public function getTable($type = 'action', $prefix = 'Release_checkingTable', $config = array()) - { - // add table path for when model gets used from other component - $this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_release_checking/tables'); - // get instance of the table - return JTable::getInstance($type, $prefix, $config); - } - - /** - * Method to get a single record. - * - * @param integer $pk The id of the primary key. - * - * @return mixed Object on success, false on failure. - * - * @since 1.6 - */ - public function getItem($pk = null) - { - if ($item = parent::getItem($pk)) - { - if (!empty($item->params) && !is_array($item->params)) - { - // Convert the params field to an array. - $registry = new Registry; - $registry->loadString($item->params); - $item->params = $registry->toArray(); - } - - if (!empty($item->metadata)) - { - // Convert the metadata field to an array. - $registry = new Registry; - $registry->loadString($item->metadata); - $item->metadata = $registry->toArray(); - } - - if (!empty($item->id)) - { - $item->tags = new JHelperTags; - $item->tags->getTagIds($item->id, 'com_release_checking.action'); - } - } - - return $item; - } - - /** - * Method to get the record form. - * - * @param array $data Data for the form. - * @param boolean $loadData True if the form is to load its own data (default case), false if not. - * @param array $options Optional array of options for the form creation. - * - * @return mixed A JForm object on success, false on failure - * - * @since 1.6 - */ - public function getForm($data = array(), $loadData = true, $options = array('control' => 'jform')) - { - // set load data option + ); + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_RELEASE_CHECKING'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_release_checking.action'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JTable A database object + * + * @since 1.6 + */ + public function getTable($type = 'action', $prefix = 'Release_checkingTable', $config = array()) + { + // add table path for when model gets used from other component + $this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_release_checking/tables'); + // get instance of the table + return JTable::getInstance($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->id)) + { + $item->tags = new JHelperTags; + $item->tags->getTagIds($item->id, 'com_release_checking.action'); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return mixed A JForm object on success, false on failure + * + * @since 1.6 + */ + public function getForm($data = array(), $loadData = true, $options = array('control' => 'jform')) + { + // set load data option $options['load_data'] = $loadData; // check if xpath was set in options $xpath = false; @@ -217,29 +217,29 @@ class Release_checkingModelAction extends JModelAdmin $form->setValue($redirectedField, null, $redirectedValue); } } - return $form; - } - - /** - * Method to get the script that have to be included on the form - * - * @return string script files - */ - public function getScript() - { - return 'administrator/components/com_release_checking/models/forms/action.js'; - } - - /** - * Method to test whether a record can be deleted. - * - * @param object $record A record object. - * - * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. - * - * @since 1.6 - */ - protected function canDelete($record) + return $form; + } + + /** + * Method to get the script that have to be included on the form + * + * @return string script files + */ + public function getScript() + { + return 'administrator/components/com_release_checking/models/forms/action.js'; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canDelete($record) { if (!empty($record->id)) { @@ -252,19 +252,19 @@ class Release_checkingModelAction extends JModelAdmin // The record has been set. Check the record permissions. return $user->authorise('core.delete', 'com_release_checking.action.' . (int) $record->id); } - return false; - } - - /** - * Method to test whether a record can have its state edited. - * - * @param object $record A record object. - * - * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. - * - * @since 1.6 - */ - protected function canEditState($record) + return false; + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canEditState($record) { $user = JFactory::getUser(); $recordId = (!empty($record->id)) ? $record->id : 0; @@ -279,103 +279,103 @@ class Release_checkingModelAction extends JModelAdmin } } // In the absense of better information, revert to the component permissions. - return parent::canEditState($record); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * @since 2.5 - */ - protected function allowEdit($data = array(), $key = 'id') + return parent::canEditState($record); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = array(), $key = 'id') { // Check specific edit permission then general edit permission. - return JFactory::getUser()->authorise('core.edit', 'com_release_checking.action.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or parent::allowEdit($data, $key); - } - - /** - * Prepare and sanitise the table data prior to saving. - * - * @param JTable $table A JTable object. - * - * @return void - * - * @since 1.6 - */ - protected function prepareTable($table) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if (isset($table->name)) - { - $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); - } - - if (isset($table->alias) && empty($table->alias)) - { - $table->generateAlias(); - } - - if (empty($table->id)) - { - $table->created = $date->toSql(); - // set the user - if ($table->created_by == 0 || empty($table->created_by)) - { - $table->created_by = $user->id; - } - // Set ordering to the last item if not set - if (empty($table->ordering)) - { - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select('MAX(ordering)') - ->from($db->quoteName('#__release_checking_action')); - $db->setQuery($query); - $max = $db->loadResult(); - - $table->ordering = $max + 1; - } - } - else - { - $table->modified = $date->toSql(); - $table->modified_by = $user->id; - } - - if (!empty($table->id)) - { - // Increment the items version number. - $table->version++; - } - } - - /** - * Method to get the data that should be injected in the form. - * - * @return mixed The data for the form. - * - * @since 1.6 - */ - protected function loadFormData() - { - // Check the session for previously entered form data. - $data = JFactory::getApplication()->getUserState('com_release_checking.edit.action.data', array()); - - if (empty($data)) - { - $data = $this->getItem(); - // run the perprocess of the data - $this->preprocessData('com_release_checking.action', $data); - } - - return $data; + return JFactory::getUser()->authorise('core.edit', 'com_release_checking.action.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or parent::allowEdit($data, $key); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param JTable $table A JTable object. + * + * @return void + * + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + if (isset($table->name)) + { + $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__release_checking_action')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = JFactory::getApplication()->getUserState('com_release_checking.edit.action.data', array()); + + if (empty($data)) + { + $data = $this->getItem(); + // run the perprocess of the data + $this->preprocessData('com_release_checking.action', $data); + } + + return $data; } /** @@ -388,141 +388,141 @@ class Release_checkingModelAction extends JModelAdmin protected function getUniqueFields() { return false; - } - - /** - * Method to delete one or more records. - * - * @param array &$pks An array of record primary keys. - * - * @return boolean True if successful, false if an error occurs. - * - * @since 12.2 - */ - public function delete(&$pks) - { - if (!parent::delete($pks)) - { - return false; - } - - return true; - } - - /** - * Method to change the published state of one or more records. - * - * @param array &$pks A list of the primary keys to change. - * @param integer $value The value of the published state. - * - * @return boolean True on success. - * - * @since 12.2 - */ - public function publish(&$pks, $value = 1) - { - if (!parent::publish($pks, $value)) - { - return false; - } - - return true; - } - - /** - * Method to perform batch operations on an item or a set of items. - * - * @param array $commands An array of commands to perform. - * @param array $pks An array of item ids. - * @param array $contexts An array of item contexts. - * - * @return boolean Returns true on success, false on failure. - * - * @since 12.2 - */ - public function batch($commands, $pks, $contexts) - { - // Sanitize ids. - $pks = array_unique($pks); - ArrayHelper::toInteger($pks); - - // Remove any values of zero. - if (array_search(0, $pks, true)) - { - unset($pks[array_search(0, $pks, true)]); - } - - if (empty($pks)) - { - $this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED')); - return false; - } - - $done = false; - - // Set some needed variables. - $this->user = JFactory::getUser(); - $this->table = $this->getTable(); - $this->tableClassName = get_class($this->table); - $this->contentType = new JUcmType; - $this->type = $this->contentType->getTypeByTable($this->tableClassName); - $this->canDo = Release_checkingHelper::getActions('action'); - $this->batchSet = true; - - if (!$this->canDo->get('core.batch')) - { - $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); - return false; - } - - if ($this->type == false) - { - $type = new JUcmType; - $this->type = $type->getTypeByAlias($this->typeAlias); - } - - $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); - - if (!empty($commands['move_copy'])) - { - $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); - - if ($cmd == 'c') - { - $result = $this->batchCopy($commands, $pks, $contexts); - - if (is_array($result)) - { - foreach ($result as $old => $new) - { - $contexts[$new] = $contexts[$old]; - } - $pks = array_values($result); - } - else - { - return false; - } - } - elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) - { - return false; - } - - $done = true; - } - - if (!$done) - { - $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); - - return false; - } - - // Clear the cache - $this->cleanCache(); - - return true; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs. + * + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new JUcmType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = Release_checkingHelper::getActions('action'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new JUcmType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; } /** @@ -769,38 +769,38 @@ class Release_checkingModelAction extends JModelAdmin $this->cleanCache(); return true; - } - - /** - * Method to save the form data. - * - * @param array $data The form data. - * - * @return boolean True on success. - * - * @since 1.6 - */ - public function save($data) - { - $input = JFactory::getApplication()->input; - $filter = JFilterInput::getInstance(); - - // set the metadata to the Item Data - if (isset($data['metadata']) && isset($data['metadata']['author'])) - { - $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); - - $metadata = new JRegistry; - $metadata->loadArray($data['metadata']); - $data['metadata'] = (string) $metadata; - } - - // Set the Params Items to data - if (isset($data['params']) && is_array($data['params'])) - { - $params = new JRegistry; - $params->loadArray($data['params']); - $data['params'] = (string) $params; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * + * @since 1.6 + */ + public function save($data) + { + $input = JFactory::getApplication()->input; + $filter = JFilterInput::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new JRegistry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new JRegistry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; } // Alter the name for save as copy @@ -868,37 +868,37 @@ class Release_checkingModelAction extends JModelAdmin $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); } } - } - - if (parent::save($data)) - { - return true; - } - return false; - } - - /** - * Method to generate a unique value. - * - * @param string $field name. - * @param string $value data. - * - * @return string New value. - * - * @since 3.0 - */ - protected function generateUnique($field,$value) - { - - // set field value unique - $table = $this->getTable(); - - while ($table->load(array($field => $value))) - { - $value = StringHelper::increment($value); - } - - return $value; + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * + * @since 3.0 + */ + protected function generateUnique($field,$value) + { + + // set field value unique + $table = $this->getTable(); + + while ($table->load(array($field => $value))) + { + $value = StringHelper::increment($value); + } + + return $value; } /** @@ -946,5 +946,5 @@ class Release_checkingModelAction extends JModelAdmin } // We only had an alias return $alias; - } -} + } +} diff --git a/admin/models/actions.php b/admin/models/actions.php index c023e59..add0d49 100644 --- a/admin/models/actions.php +++ b/admin/models/actions.php @@ -5,23 +5,23 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\Utilities\ArrayHelper; - -/** - * Actions Model - */ -class Release_checkingModelActions extends JModelList -{ - public function __construct($config = array()) - { - if (empty($config['filter_fields'])) - { - $config['filter_fields'] = array( + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\Utilities\ArrayHelper; + +/** + * Actions Model + */ +class Release_checkingModelActions extends JModelList +{ + public function __construct($config = array()) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( 'a.id','id', 'a.published','published', 'a.access','access', @@ -29,32 +29,32 @@ class Release_checkingModelActions extends JModelList 'a.created_by','created_by', 'a.modified_by','modified_by', 'a.name','name', - 'g.name','context' - ); - } - - parent::__construct($config); - } - - /** - * Method to auto-populate the model state. - * - * Note. Calling getState in this method will result in recursion. - * - * @param string $ordering An optional ordering field. - * @param string $direction An optional direction (asc|desc). - * - * @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; + 'g.name','context' + ); + } + + parent::__construct($config); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @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; } // Check if the form was submitted @@ -94,36 +94,36 @@ class Release_checkingModelActions extends JModelList { $context = $app->input->post->get('context'); $this->setState('filter.context', $context); - } - - // 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() + } + + // 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 - $items = parent::getItems(); - - // return items - return $items; - } - - /** - * Method to build an SQL query to load the list data. - * - * @return string An SQL query - */ - protected function getListQuery() - { + + // load parent items + $items = parent::getItems(); + + // return items + return $items; + } + + /** + * 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. @@ -214,7 +214,7 @@ class Release_checkingModelActions extends JModelList $query->order($db->escape($orderCol . ' ' . $orderDirn)); } - return $query; + return $query; } /** @@ -339,16 +339,16 @@ class Release_checkingModelActions 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'); @@ -359,7 +359,7 @@ class Release_checkingModelActions extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || Release_checkingHelper::checkString($_access)) { @@ -369,9 +369,9 @@ class Release_checkingModelActions extends JModelList $id .= ':' . $this->getState('filter.created_by'); $id .= ':' . $this->getState('filter.modified_by'); $id .= ':' . $this->getState('filter.name'); - $id .= ':' . $this->getState('filter.context'); - - return parent::getStoreId($id); + $id .= ':' . $this->getState('filter.context'); + + return parent::getStoreId($id); } /** @@ -425,5 +425,5 @@ class Release_checkingModelActions extends JModelList } return false; - } -} + } +} diff --git a/admin/models/ajax.php b/admin/models/ajax.php index e1e7a99..4548fdd 100644 --- a/admin/models/ajax.php +++ b/admin/models/ajax.php @@ -5,26 +5,26 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\Utilities\ArrayHelper; - -/** - * Release_checking Ajax Model - */ -class Release_checkingModelAjax extends JModelList -{ - protected $app_params; - - public function __construct() - { - parent::__construct(); - // get params - $this->app_params = JComponentHelper::getParams('com_release_checking'); - + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\Utilities\ArrayHelper; + +/** + * Release_checking Ajax Model + */ +class Release_checkingModelAjax extends JModelList +{ + protected $app_params; + + public function __construct() + { + parent::__construct(); + // get params + $this->app_params = JComponentHelper::getParams('com_release_checking'); + } // Used in release_check @@ -92,5 +92,5 @@ class Release_checkingModelAjax extends JModelList } return false; } - -} + +} diff --git a/admin/models/context.php b/admin/models/context.php index 1ac35d9..c87257a 100644 --- a/admin/models/context.php +++ b/admin/models/context.php @@ -5,25 +5,25 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + use Joomla\Registry\Registry; use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Release_checking Context Model - */ -class Release_checkingModelContext extends JModelAdmin -{ - /** - * The tab layout fields array. - * - * @var array - */ +use Joomla\Utilities\ArrayHelper; + +/** + * Release_checking Context Model + */ +class Release_checkingModelContext extends JModelAdmin +{ + /** + * The tab layout fields array. + * + * @var array + */ protected $tabLayoutFields = array( 'details' => array( 'left' => array( @@ -33,94 +33,94 @@ class Release_checkingModelContext extends JModelAdmin 'alias' ) ) - ); - - /** - * @var string The prefix to use with controller messages. - * @since 1.6 - */ - protected $text_prefix = 'COM_RELEASE_CHECKING'; - - /** - * The type alias for this content type. - * - * @var string - * @since 3.2 - */ - public $typeAlias = 'com_release_checking.context'; - - /** - * Returns a Table object, always creating it - * - * @param type $type The table type to instantiate - * @param string $prefix A prefix for the table class name. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JTable A database object - * - * @since 1.6 - */ - public function getTable($type = 'context', $prefix = 'Release_checkingTable', $config = array()) - { - // add table path for when model gets used from other component - $this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_release_checking/tables'); - // get instance of the table - return JTable::getInstance($type, $prefix, $config); - } - - /** - * Method to get a single record. - * - * @param integer $pk The id of the primary key. - * - * @return mixed Object on success, false on failure. - * - * @since 1.6 - */ - public function getItem($pk = null) - { - if ($item = parent::getItem($pk)) - { - if (!empty($item->params) && !is_array($item->params)) - { - // Convert the params field to an array. - $registry = new Registry; - $registry->loadString($item->params); - $item->params = $registry->toArray(); - } - - if (!empty($item->metadata)) - { - // Convert the metadata field to an array. - $registry = new Registry; - $registry->loadString($item->metadata); - $item->metadata = $registry->toArray(); - } - - if (!empty($item->id)) - { - $item->tags = new JHelperTags; - $item->tags->getTagIds($item->id, 'com_release_checking.context'); - } - } - - return $item; - } - - /** - * Method to get the record form. - * - * @param array $data Data for the form. - * @param boolean $loadData True if the form is to load its own data (default case), false if not. - * @param array $options Optional array of options for the form creation. - * - * @return mixed A JForm object on success, false on failure - * - * @since 1.6 - */ - public function getForm($data = array(), $loadData = true, $options = array('control' => 'jform')) - { - // set load data option + ); + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_RELEASE_CHECKING'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_release_checking.context'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JTable A database object + * + * @since 1.6 + */ + public function getTable($type = 'context', $prefix = 'Release_checkingTable', $config = array()) + { + // add table path for when model gets used from other component + $this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_release_checking/tables'); + // get instance of the table + return JTable::getInstance($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->id)) + { + $item->tags = new JHelperTags; + $item->tags->getTagIds($item->id, 'com_release_checking.context'); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return mixed A JForm object on success, false on failure + * + * @since 1.6 + */ + public function getForm($data = array(), $loadData = true, $options = array('control' => 'jform')) + { + // set load data option $options['load_data'] = $loadData; // check if xpath was set in options $xpath = false; @@ -213,29 +213,29 @@ class Release_checkingModelContext extends JModelAdmin $form->setValue($redirectedField, null, $redirectedValue); } } - return $form; - } - - /** - * Method to get the script that have to be included on the form - * - * @return string script files - */ - public function getScript() - { - return 'administrator/components/com_release_checking/models/forms/context.js'; - } - - /** - * Method to test whether a record can be deleted. - * - * @param object $record A record object. - * - * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. - * - * @since 1.6 - */ - protected function canDelete($record) + return $form; + } + + /** + * Method to get the script that have to be included on the form + * + * @return string script files + */ + public function getScript() + { + return 'administrator/components/com_release_checking/models/forms/context.js'; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canDelete($record) { if (!empty($record->id)) { @@ -248,19 +248,19 @@ class Release_checkingModelContext extends JModelAdmin // The record has been set. Check the record permissions. return $user->authorise('core.delete', 'com_release_checking.context.' . (int) $record->id); } - return false; - } - - /** - * Method to test whether a record can have its state edited. - * - * @param object $record A record object. - * - * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. - * - * @since 1.6 - */ - protected function canEditState($record) + return false; + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canEditState($record) { $user = JFactory::getUser(); $recordId = (!empty($record->id)) ? $record->id : 0; @@ -275,103 +275,103 @@ class Release_checkingModelContext extends JModelAdmin } } // In the absense of better information, revert to the component permissions. - return parent::canEditState($record); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * @since 2.5 - */ - protected function allowEdit($data = array(), $key = 'id') + return parent::canEditState($record); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = array(), $key = 'id') { // Check specific edit permission then general edit permission. - return JFactory::getUser()->authorise('core.edit', 'com_release_checking.context.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or parent::allowEdit($data, $key); - } - - /** - * Prepare and sanitise the table data prior to saving. - * - * @param JTable $table A JTable object. - * - * @return void - * - * @since 1.6 - */ - protected function prepareTable($table) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if (isset($table->name)) - { - $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); - } - - if (isset($table->alias) && empty($table->alias)) - { - $table->generateAlias(); - } - - if (empty($table->id)) - { - $table->created = $date->toSql(); - // set the user - if ($table->created_by == 0 || empty($table->created_by)) - { - $table->created_by = $user->id; - } - // Set ordering to the last item if not set - if (empty($table->ordering)) - { - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select('MAX(ordering)') - ->from($db->quoteName('#__release_checking_context')); - $db->setQuery($query); - $max = $db->loadResult(); - - $table->ordering = $max + 1; - } - } - else - { - $table->modified = $date->toSql(); - $table->modified_by = $user->id; - } - - if (!empty($table->id)) - { - // Increment the items version number. - $table->version++; - } - } - - /** - * Method to get the data that should be injected in the form. - * - * @return mixed The data for the form. - * - * @since 1.6 - */ - protected function loadFormData() - { - // Check the session for previously entered form data. - $data = JFactory::getApplication()->getUserState('com_release_checking.edit.context.data', array()); - - if (empty($data)) - { - $data = $this->getItem(); - // run the perprocess of the data - $this->preprocessData('com_release_checking.context', $data); - } - - return $data; + return JFactory::getUser()->authorise('core.edit', 'com_release_checking.context.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or parent::allowEdit($data, $key); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param JTable $table A JTable object. + * + * @return void + * + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + if (isset($table->name)) + { + $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__release_checking_context')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = JFactory::getApplication()->getUserState('com_release_checking.edit.context.data', array()); + + if (empty($data)) + { + $data = $this->getItem(); + // run the perprocess of the data + $this->preprocessData('com_release_checking.context', $data); + } + + return $data; } /** @@ -384,141 +384,141 @@ class Release_checkingModelContext extends JModelAdmin protected function getUniqueFields() { return false; - } - - /** - * Method to delete one or more records. - * - * @param array &$pks An array of record primary keys. - * - * @return boolean True if successful, false if an error occurs. - * - * @since 12.2 - */ - public function delete(&$pks) - { - if (!parent::delete($pks)) - { - return false; - } - - return true; - } - - /** - * Method to change the published state of one or more records. - * - * @param array &$pks A list of the primary keys to change. - * @param integer $value The value of the published state. - * - * @return boolean True on success. - * - * @since 12.2 - */ - public function publish(&$pks, $value = 1) - { - if (!parent::publish($pks, $value)) - { - return false; - } - - return true; - } - - /** - * Method to perform batch operations on an item or a set of items. - * - * @param array $commands An array of commands to perform. - * @param array $pks An array of item ids. - * @param array $contexts An array of item contexts. - * - * @return boolean Returns true on success, false on failure. - * - * @since 12.2 - */ - public function batch($commands, $pks, $contexts) - { - // Sanitize ids. - $pks = array_unique($pks); - ArrayHelper::toInteger($pks); - - // Remove any values of zero. - if (array_search(0, $pks, true)) - { - unset($pks[array_search(0, $pks, true)]); - } - - if (empty($pks)) - { - $this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED')); - return false; - } - - $done = false; - - // Set some needed variables. - $this->user = JFactory::getUser(); - $this->table = $this->getTable(); - $this->tableClassName = get_class($this->table); - $this->contentType = new JUcmType; - $this->type = $this->contentType->getTypeByTable($this->tableClassName); - $this->canDo = Release_checkingHelper::getActions('context'); - $this->batchSet = true; - - if (!$this->canDo->get('core.batch')) - { - $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); - return false; - } - - if ($this->type == false) - { - $type = new JUcmType; - $this->type = $type->getTypeByAlias($this->typeAlias); - } - - $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); - - if (!empty($commands['move_copy'])) - { - $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); - - if ($cmd == 'c') - { - $result = $this->batchCopy($commands, $pks, $contexts); - - if (is_array($result)) - { - foreach ($result as $old => $new) - { - $contexts[$new] = $contexts[$old]; - } - $pks = array_values($result); - } - else - { - return false; - } - } - elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) - { - return false; - } - - $done = true; - } - - if (!$done) - { - $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); - - return false; - } - - // Clear the cache - $this->cleanCache(); - - return true; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs. + * + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new JUcmType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = Release_checkingHelper::getActions('context'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new JUcmType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; } /** @@ -765,38 +765,38 @@ class Release_checkingModelContext extends JModelAdmin $this->cleanCache(); return true; - } - - /** - * Method to save the form data. - * - * @param array $data The form data. - * - * @return boolean True on success. - * - * @since 1.6 - */ - public function save($data) - { - $input = JFactory::getApplication()->input; - $filter = JFilterInput::getInstance(); - - // set the metadata to the Item Data - if (isset($data['metadata']) && isset($data['metadata']['author'])) - { - $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); - - $metadata = new JRegistry; - $metadata->loadArray($data['metadata']); - $data['metadata'] = (string) $metadata; - } - - // Set the Params Items to data - if (isset($data['params']) && is_array($data['params'])) - { - $params = new JRegistry; - $params->loadArray($data['params']); - $data['params'] = (string) $params; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * + * @since 1.6 + */ + public function save($data) + { + $input = JFactory::getApplication()->input; + $filter = JFilterInput::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new JRegistry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new JRegistry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; } // Alter the name for save as copy @@ -864,37 +864,37 @@ class Release_checkingModelContext extends JModelAdmin $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); } } - } - - if (parent::save($data)) - { - return true; - } - return false; - } - - /** - * Method to generate a unique value. - * - * @param string $field name. - * @param string $value data. - * - * @return string New value. - * - * @since 3.0 - */ - protected function generateUnique($field,$value) - { - - // set field value unique - $table = $this->getTable(); - - while ($table->load(array($field => $value))) - { - $value = StringHelper::increment($value); - } - - return $value; + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * + * @since 3.0 + */ + protected function generateUnique($field,$value) + { + + // set field value unique + $table = $this->getTable(); + + while ($table->load(array($field => $value))) + { + $value = StringHelper::increment($value); + } + + return $value; } /** @@ -942,5 +942,5 @@ class Release_checkingModelContext extends JModelAdmin } // We only had an alias return $alias; - } -} + } +} diff --git a/admin/models/contexts.php b/admin/models/contexts.php index 948b713..cc8103d 100644 --- a/admin/models/contexts.php +++ b/admin/models/contexts.php @@ -5,55 +5,55 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\Utilities\ArrayHelper; - -/** - * Contexts Model - */ -class Release_checkingModelContexts extends JModelList -{ - public function __construct($config = array()) - { - if (empty($config['filter_fields'])) - { - $config['filter_fields'] = array( + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\Utilities\ArrayHelper; + +/** + * Contexts Model + */ +class Release_checkingModelContexts extends JModelList +{ + public function __construct($config = array()) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( 'a.id','id', 'a.published','published', 'a.access','access', 'a.ordering','ordering', 'a.created_by','created_by', 'a.modified_by','modified_by', - 'a.name','name' - ); - } - - parent::__construct($config); - } - - /** - * Method to auto-populate the model state. - * - * Note. Calling getState in this method will result in recursion. - * - * @param string $ordering An optional ordering field. - * @param string $direction An optional direction (asc|desc). - * - * @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.name','name' + ); + } + + parent::__construct($config); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @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; } // Check if the form was submitted @@ -86,36 +86,36 @@ class Release_checkingModelContexts extends JModelList { $name = $app->input->post->get('name'); $this->setState('filter.name', $name); - } - - // 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() + } + + // 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 - $items = parent::getItems(); - - // return items - return $items; - } - - /** - * Method to build an SQL query to load the list data. - * - * @return string An SQL query - */ - protected function getListQuery() - { + + // load parent items + $items = parent::getItems(); + + // return items + return $items; + } + + /** + * 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. @@ -202,7 +202,7 @@ class Release_checkingModelContexts extends JModelList $query->order($db->escape($orderCol . ' ' . $orderDirn)); } - return $query; + return $query; } /** @@ -319,16 +319,16 @@ class Release_checkingModelContexts 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'); @@ -339,7 +339,7 @@ class Release_checkingModelContexts extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || Release_checkingHelper::checkString($_access)) { @@ -348,9 +348,9 @@ class Release_checkingModelContexts extends JModelList $id .= ':' . $this->getState('filter.ordering'); $id .= ':' . $this->getState('filter.created_by'); $id .= ':' . $this->getState('filter.modified_by'); - $id .= ':' . $this->getState('filter.name'); - - return parent::getStoreId($id); + $id .= ':' . $this->getState('filter.name'); + + return parent::getStoreId($id); } /** @@ -404,5 +404,5 @@ class Release_checkingModelContexts extends JModelList } return false; - } -} + } +} diff --git a/admin/models/fields/actions.php b/admin/models/fields/actions.php index 805f598..eec1a91 100644 --- a/admin/models/fields/actions.php +++ b/admin/models/fields/actions.php @@ -5,25 +5,25 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); - -/** - * Actions Form Field class for the Release_checking component - */ -class JFormFieldActions extends JFormFieldList -{ - /** - * The actions field type. - * - * @var string - */ + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Actions Form Field class for the Release_checking component + */ +class JFormFieldActions extends JFormFieldList +{ + /** + * The actions field type. + * + * @var string + */ public $type = 'actions'; /** @@ -128,15 +128,15 @@ class JFormFieldActions extends JFormFieldList } } return $html; - } - - /** - * Method to get a list of options for a list input. - * - * @return array An array of JHtml options. - */ - protected function getOptions() - { + } + + /** + * 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. @@ -170,6 +170,6 @@ class JFormFieldActions extends JFormFieldList $options[] = JHtml::_('select.option', $item->id, $item->action_name); } } - return $options; - } -} + return $options; + } +} diff --git a/admin/models/fields/actionsfiltername.php b/admin/models/fields/actionsfiltername.php index 1041bbc..1b79764 100644 --- a/admin/models/fields/actionsfiltername.php +++ b/admin/models/fields/actionsfiltername.php @@ -5,34 +5,34 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); - -/** - * Actionsfiltername Form Field class for the Release_checking component - */ -class JFormFieldActionsfiltername extends JFormFieldList -{ - /** - * The actionsfiltername field type. - * - * @var string - */ - public $type = 'actionsfiltername'; - - /** - * Method to get a list of options for a list input. - * - * @return array An array of JHtml options. - */ - protected function getOptions() - { + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Actionsfiltername Form Field class for the Release_checking component + */ +class JFormFieldActionsfiltername extends JFormFieldList +{ + /** + * The actionsfiltername field type. + * + * @var string + */ + public $type = 'actionsfiltername'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { // Get a db connection. $db = JFactory::getDbo(); @@ -60,6 +60,6 @@ class JFormFieldActionsfiltername extends JFormFieldList $_filter[] = JHtml::_('select.option', $name, $name); } } - return $_filter; - } -} + return $_filter; + } +} diff --git a/admin/models/fields/contexts.php b/admin/models/fields/contexts.php index 7713b1b..3326dc9 100644 --- a/admin/models/fields/contexts.php +++ b/admin/models/fields/contexts.php @@ -5,25 +5,25 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); - -/** - * Contexts Form Field class for the Release_checking component - */ -class JFormFieldContexts extends JFormFieldList -{ - /** - * The contexts field type. - * - * @var string - */ + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Contexts Form Field class for the Release_checking component + */ +class JFormFieldContexts extends JFormFieldList +{ + /** + * The contexts field type. + * + * @var string + */ public $type = 'contexts'; /** @@ -128,15 +128,15 @@ class JFormFieldContexts extends JFormFieldList } } return $html; - } - - /** - * Method to get a list of options for a list input. - * - * @return array An array of JHtml options. - */ - protected function getOptions() - { + } + + /** + * 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. @@ -169,6 +169,6 @@ class JFormFieldContexts extends JFormFieldList $options[] = JHtml::_('select.option', $item->id, $item->context_name); } } - return $options; - } -} + return $options; + } +} diff --git a/admin/models/fields/contextsfiltername.php b/admin/models/fields/contextsfiltername.php index 555915e..620cb6b 100644 --- a/admin/models/fields/contextsfiltername.php +++ b/admin/models/fields/contextsfiltername.php @@ -5,34 +5,34 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); - -/** - * Contextsfiltername Form Field class for the Release_checking component - */ -class JFormFieldContextsfiltername extends JFormFieldList -{ - /** - * The contextsfiltername field type. - * - * @var string - */ - public $type = 'contextsfiltername'; - - /** - * Method to get a list of options for a list input. - * - * @return array An array of JHtml options. - */ - protected function getOptions() - { + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Contextsfiltername Form Field class for the Release_checking component + */ +class JFormFieldContextsfiltername extends JFormFieldList +{ + /** + * The contextsfiltername field type. + * + * @var string + */ + public $type = 'contextsfiltername'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { // Get a db connection. $db = JFactory::getDbo(); @@ -60,6 +60,6 @@ class JFormFieldContextsfiltername extends JFormFieldList $_filter[] = JHtml::_('select.option', $name, $name); } } - return $_filter; - } -} + return $_filter; + } +} diff --git a/admin/models/fields/joomlaversions.php b/admin/models/fields/joomlaversions.php index d203861..fc6d1e3 100644 --- a/admin/models/fields/joomlaversions.php +++ b/admin/models/fields/joomlaversions.php @@ -5,25 +5,25 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); - -/** - * Joomlaversions Form Field class for the Release_checking component - */ -class JFormFieldJoomlaversions extends JFormFieldList -{ - /** - * The joomlaversions field type. - * - * @var string - */ + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Joomlaversions Form Field class for the Release_checking component + */ +class JFormFieldJoomlaversions extends JFormFieldList +{ + /** + * The joomlaversions field type. + * + * @var string + */ public $type = 'joomlaversions'; /** @@ -128,15 +128,15 @@ class JFormFieldJoomlaversions extends JFormFieldList } } return $html; - } - - /** - * Method to get a list of options for a list input. - * - * @return array An array of JHtml options. - */ - protected function getOptions() - { + } + + /** + * 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. @@ -169,6 +169,6 @@ class JFormFieldJoomlaversions extends JFormFieldList $options[] = JHtml::_('select.option', $item->id, $item->joomla_version_name); } } - return $options; - } -} + return $options; + } +} diff --git a/admin/models/fields/releasechecksfiltercreatedby.php b/admin/models/fields/releasechecksfiltercreatedby.php index 2b06c97..4961283 100644 --- a/admin/models/fields/releasechecksfiltercreatedby.php +++ b/admin/models/fields/releasechecksfiltercreatedby.php @@ -5,34 +5,34 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); - -/** - * Releasechecksfiltercreatedby Form Field class for the Release_checking component - */ -class JFormFieldReleasechecksfiltercreatedby extends JFormFieldList -{ - /** - * The releasechecksfiltercreatedby field type. - * - * @var string - */ - public $type = 'releasechecksfiltercreatedby'; - - /** - * Method to get a list of options for a list input. - * - * @return array An array of JHtml options. - */ - protected function getOptions() - { + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Releasechecksfiltercreatedby Form Field class for the Release_checking component + */ +class JFormFieldReleasechecksfiltercreatedby extends JFormFieldList +{ + /** + * The releasechecksfiltercreatedby field type. + * + * @var string + */ + public $type = 'releasechecksfiltercreatedby'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { // Get a db connection. $db = JFactory::getDbo(); @@ -59,6 +59,6 @@ class JFormFieldReleasechecksfiltercreatedby extends JFormFieldList $_filter[] = JHtml::_('select.option', $created_by, JFactory::getUser($created_by)->name); } } - return $_filter; - } -} + return $_filter; + } +} diff --git a/admin/models/fields/releasechecksfilteroutcome.php b/admin/models/fields/releasechecksfilteroutcome.php index 393ca15..c4a9a9e 100644 --- a/admin/models/fields/releasechecksfilteroutcome.php +++ b/admin/models/fields/releasechecksfilteroutcome.php @@ -5,34 +5,34 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); - -/** - * Releasechecksfilteroutcome Form Field class for the Release_checking component - */ -class JFormFieldReleasechecksfilteroutcome extends JFormFieldList -{ - /** - * The releasechecksfilteroutcome field type. - * - * @var string - */ - public $type = 'releasechecksfilteroutcome'; - - /** - * Method to get a list of options for a list input. - * - * @return array An array of JHtml options. - */ - protected function getOptions() - { + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Releasechecksfilteroutcome Form Field class for the Release_checking component + */ +class JFormFieldReleasechecksfilteroutcome extends JFormFieldList +{ + /** + * The releasechecksfilteroutcome field type. + * + * @var string + */ + public $type = 'releasechecksfilteroutcome'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { // Get a db connection. $db = JFactory::getDbo(); @@ -63,6 +63,6 @@ class JFormFieldReleasechecksfilteroutcome extends JFormFieldList $_filter[] = JHtml::_('select.option', $outcome, JText::_($text)); } } - return $_filter; - } -} + return $_filter; + } +} diff --git a/admin/models/forms/action.js b/admin/models/forms/action.js index 369b6f9..3fed87b 100644 --- a/admin/models/forms/action.js +++ b/admin/models/forms/action.js @@ -4,6 +4,6 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - - + */ + + diff --git a/admin/models/forms/action.xml b/admin/models/forms/action.xml index 08694c2..c3e2f26 100644 --- a/admin/models/forms/action.xml +++ b/admin/models/forms/action.xml @@ -1,8 +1,8 @@ - -
+ +
@@ -84,6 +84,14 @@ readonly="true" filter="unset" /> + + + + -
- + +
@@ -155,5 +163,5 @@ component="com_release_checking" section="action" /> -
+
\ No newline at end of file diff --git a/admin/models/forms/context.js b/admin/models/forms/context.js index 369b6f9..3fed87b 100644 --- a/admin/models/forms/context.js +++ b/admin/models/forms/context.js @@ -4,6 +4,6 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - - + */ + + diff --git a/admin/models/forms/context.xml b/admin/models/forms/context.xml index 1ab1ac3..d64cc2e 100644 --- a/admin/models/forms/context.xml +++ b/admin/models/forms/context.xml @@ -1,8 +1,8 @@ - -
+ +
@@ -84,6 +84,14 @@ readonly="true" filter="unset" /> + + + + -
- + +
@@ -132,5 +140,5 @@ component="com_release_checking" section="context" /> -
+
\ No newline at end of file diff --git a/admin/models/forms/filter_actions.xml b/admin/models/forms/filter_actions.xml index 6d9fed5..82edfb6 100644 --- a/admin/models/forms/filter_actions.xml +++ b/admin/models/forms/filter_actions.xml @@ -1,8 +1,8 @@ - -
+ + - - + + - +
\ No newline at end of file diff --git a/admin/models/forms/filter_contexts.xml b/admin/models/forms/filter_contexts.xml index f571790..d37a32e 100644 --- a/admin/models/forms/filter_contexts.xml +++ b/admin/models/forms/filter_contexts.xml @@ -1,8 +1,8 @@ - -
+ + - - + + - +
\ No newline at end of file diff --git a/admin/models/forms/filter_joomla_versions.xml b/admin/models/forms/filter_joomla_versions.xml index c247b8c..d5898c7 100644 --- a/admin/models/forms/filter_joomla_versions.xml +++ b/admin/models/forms/filter_joomla_versions.xml @@ -1,8 +1,8 @@ - -
+ + - - + + - +
\ No newline at end of file diff --git a/admin/models/forms/filter_release_checks.xml b/admin/models/forms/filter_release_checks.xml index 0ddaae3..03a5ba6 100644 --- a/admin/models/forms/filter_release_checks.xml +++ b/admin/models/forms/filter_release_checks.xml @@ -1,8 +1,8 @@ - -
+ + - - + + - +
\ No newline at end of file diff --git a/admin/models/forms/joomla_version.js b/admin/models/forms/joomla_version.js index 369b6f9..3fed87b 100644 --- a/admin/models/forms/joomla_version.js +++ b/admin/models/forms/joomla_version.js @@ -4,6 +4,6 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - - + */ + + diff --git a/admin/models/forms/joomla_version.xml b/admin/models/forms/joomla_version.xml index f22a72c..1e01025 100644 --- a/admin/models/forms/joomla_version.xml +++ b/admin/models/forms/joomla_version.xml @@ -1,8 +1,8 @@ - -
+ +
@@ -84,6 +84,14 @@ readonly="true" filter="unset" /> + + + + -
- + +
@@ -132,5 +140,5 @@ component="com_release_checking" section="joomla_version" /> -
+
\ No newline at end of file diff --git a/admin/models/forms/release_check.js b/admin/models/forms/release_check.js index 60cd785..79721c0 100644 --- a/admin/models/forms/release_check.js +++ b/admin/models/forms/release_check.js @@ -4,8 +4,8 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - + */ + @@ -145,4 +145,4 @@ function setActionDescription(desc){ } else { console.log(desc); } -} +} diff --git a/admin/models/forms/release_check.xml b/admin/models/forms/release_check.xml index 0350c09..f7f0012 100644 --- a/admin/models/forms/release_check.xml +++ b/admin/models/forms/release_check.xml @@ -1,8 +1,8 @@ - -
+ +
@@ -77,6 +77,14 @@ readonly="true" filter="unset" /> + + + + -
- + +
@@ -160,5 +168,5 @@ component="com_release_checking" section="release_check" /> -
+
\ No newline at end of file diff --git a/admin/models/import.php b/admin/models/import.php index d8a062f..5785ba5 100644 --- a/admin/models/import.php +++ b/admin/models/import.php @@ -5,357 +5,359 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\Utilities\ArrayHelper; -use PhpOffice\PhpSpreadsheet\IOFactory; - -/** - * Release_checking Import Model - */ -class Release_checkingModelImport extends JModelLegacy -{ - // set uploading values - protected $use_streams = false; - protected $allow_unsafe = false; - protected $safeFileOptions = array(); - - /** - * @var object JTable object - */ - protected $_table = null; - - /** - * @var object JTable object - */ - protected $_url = null; - - /** - * Model context string. - * - * @var string - */ - protected $_context = 'com_release_checking.import'; - - /** - * Import Settings - */ - protected $getType = NULL; - protected $dataType = NULL; - - /** - * Method to auto-populate the model state. - * - * Note. Calling getState in this method will result in recursion. - * - * @return void - * - */ - protected function populateState() - { - $app = JFactory::getApplication('administrator'); - - $this->setState('message', $app->getUserState('com_release_checking.message')); - $app->setUserState('com_release_checking.message', ''); - - // Recall the 'Import from Directory' path. - $path = $app->getUserStateFromRequest($this->_context . '.import_directory', 'import_directory', $app->get('tmp_path')); - $this->setState('import.directory', $path); - parent::populateState(); - } - - /** - * Import an spreadsheet from either folder, url or upload. - * - * @return boolean result of import - * - */ - public function import() - { - $this->setState('action', 'import'); - $app = JFactory::getApplication(); - $session = JFactory::getSession(); - $package = null; - $continue = false; - // get import type - $this->getType = $app->input->getString('gettype', NULL); - // get import type - $this->dataType = $session->get('dataType_VDM_IMPORTINTO', NULL); - - if ($package === null) - { - switch ($this->getType) - { - case 'folder': - // Remember the 'Import from Directory' path. - $app->getUserStateFromRequest($this->_context . '.import_directory', 'import_directory'); - $package = $this->_getPackageFromFolder(); - break; - - case 'upload': - $package = $this->_getPackageFromUpload(); - break; - - case 'url': - $package = $this->_getPackageFromUrl(); - break; - - case 'continue': - $continue = true; - $package = $session->get('package', null); - $package = json_decode($package, true); - // clear session - $session->clear('package'); - $session->clear('dataType'); - $session->clear('hasPackage'); - break; - - default: - $app->setUserState('com_release_checking.message', JText::_('COM_RELEASE_CHECKING_IMPORT_NO_IMPORT_TYPE_FOUND')); - - return false; - break; - } - } - // Was the package valid? - if (!$package || !$package['type']) - { - if (in_array($this->getType, array('upload', 'url'))) - { - $this->remove($package['packagename']); - } - - $app->setUserState('com_release_checking.message', JText::_('COM_RELEASE_CHECKING_IMPORT_UNABLE_TO_FIND_IMPORT_PACKAGE')); - return false; - } - - // first link data to table headers - if(!$continue){ - $package = json_encode($package); - $session->set('package', $package); - $session->set('dataType', $this->dataType); - $session->set('hasPackage', true); - return true; - } - - // set the data - $headerList = json_decode($session->get($this->dataType.'_VDM_IMPORTHEADERS', false), true); - if (!$this->setData($package,$this->dataType,$headerList)) - { - // There was an error importing the package - $msg = JText::_('COM_RELEASE_CHECKING_IMPORT_ERROR'); - $back = $session->get('backto_VDM_IMPORT', NULL); - if ($back) - { - $app->setUserState('com_release_checking.redirect_url', 'index.php?option=com_release_checking&view='.$back); - $session->clear('backto_VDM_IMPORT'); - } - $result = false; - } - else - { - // Package imported sucessfully - $msg = JText::sprintf('COM_RELEASE_CHECKING_IMPORT_SUCCESS', $package['packagename']); - $back = $session->get('backto_VDM_IMPORT', NULL); - if ($back) - { - $app->setUserState('com_release_checking.redirect_url', 'index.php?option=com_release_checking&view='.$back); - $session->clear('backto_VDM_IMPORT'); - } - $result = true; - } - - // Set some model state values - $app->enqueueMessage($msg); - - // remove file after import - $this->remove($package['packagename']); - $session->clear($this->getType.'_VDM_IMPORTHEADERS'); - - return $result; - } - - /** - * Works out an importation spreadsheet from a HTTP upload - * - * @return spreadsheet definition or false on failure - */ - protected function _getPackageFromUpload() - { - // Get the uploaded file information - $app = JFactory::getApplication(); - $input = $app->input; - - // Do not change the filter type 'raw'. We need this to let files containing PHP code to upload. See JInputFiles::get. - $userfile = $input->files->get('import_package', null, 'raw'); - - // Make sure that file uploads are enabled in php - if (!(bool) ini_get('file_uploads')) - { - $app->enqueueMessage(JText::_('COM_RELEASE_CHECKING_IMPORT_MSG_WARNIMPORTFILE'), 'warning'); - return false; - } - - // If there is no uploaded file, we have a problem... - if (!is_array($userfile)) - { - $app->enqueueMessage(JText::_('COM_RELEASE_CHECKING_IMPORT_MSG_NO_FILE_SELECTED'), 'warning'); - return false; - } - - // Check if there was a problem uploading the file. - if ($userfile['error'] || $userfile['size'] < 1) - { - $app->enqueueMessage(JText::_('COM_RELEASE_CHECKING_IMPORT_MSG_WARNIMPORTUPLOADERROR'), 'warning'); - return false; - } - - // Build the appropriate paths - $config = JFactory::getConfig(); - $tmp_dest = $config->get('tmp_path') . '/' . $userfile['name']; - $tmp_src = $userfile['tmp_name']; - - // Move uploaded file - jimport('joomla.filesystem.file'); - $p_file = JFile::upload($tmp_src, $tmp_dest, $this->use_streams, $this->allow_unsafe, $this->safeFileOptions); - - // Was the package downloaded? - if (!$p_file) - { - $session = JFactory::getSession(); - $session->clear('package'); - $session->clear('dataType'); - $session->clear('hasPackage'); - // was not uploaded - return false; - } - - // check that this is a valid spreadsheet - $package = $this->check($userfile['name']); - - return $package; - } - - /** - * Import an spreadsheet from a directory - * - * @return array Spreadsheet details or false on failure - * - */ - protected function _getPackageFromFolder() - { - $app = JFactory::getApplication(); - $input = $app->input; - - // Get the path to the package to import - $p_dir = $input->getString('import_directory'); - $p_dir = JPath::clean($p_dir); - // Did you give us a valid path? - if (!file_exists($p_dir)) - { - $app->enqueueMessage(JText::_('COM_RELEASE_CHECKING_IMPORT_MSG_PLEASE_ENTER_A_PACKAGE_DIRECTORY'), 'warning'); - return false; - } - - // Detect the package type - $type = $this->getType; - - // Did you give us a valid package? - if (!$type) - { - $app->enqueueMessage(JText::_('COM_RELEASE_CHECKING_IMPORT_MSG_PATH_DOES_NOT_HAVE_A_VALID_PACKAGE'), 'warning'); - } - - // check the extention - if(!$this->checkExtension($p_dir)) - { - // set error message - $app->enqueueMessage(JText::_('COM_RELEASE_CHECKING_IMPORT_MSG_DOES_NOT_HAVE_A_VALID_FILE_TYPE'), 'warning'); - return false; - } - - $package['packagename'] = null; - $package['dir'] = $p_dir; - $package['type'] = $type; - - return $package; - } - - /** - * Import an spreadsheet from a URL - * - * @return Package details or false on failure - * - */ - protected function _getPackageFromUrl() - { - $app = JFactory::getApplication(); - $input = $app->input; - - // Get the URL of the package to import - $url = $input->getString('import_url'); - - // Did you give us a URL? - if (!$url) - { - $app->enqueueMessage(JText::_('COM_RELEASE_CHECKING_IMPORT_MSG_ENTER_A_URL'), 'warning'); - return false; - } - - // Download the package at the URL given - $p_file = JInstallerHelper::downloadPackage($url); - - // Was the package downloaded? - if (!$p_file) - { - $app->enqueueMessage(JText::_('COM_RELEASE_CHECKING_IMPORT_MSG_INVALID_URL'), 'warning'); - return false; - } - - // check that this is a valid spreadsheet - $package = $this->check($p_file); - - return $package; - } - - /** - * Check a file and verifies it as a spreadsheet file - * Supports .csv .xlsx .xls and .ods - * - * @param string $p_filename The uploaded package filename or import directory - * - * @return array of elements - * - */ - protected function check($archivename) - { - $app = JFactory::getApplication(); - // Clean the name - $archivename = JPath::clean($archivename); - - // check the extention - if(!$this->checkExtension($archivename)) - { - // Cleanup the import files - $this->remove($archivename); - $app->enqueueMessage(JText::_('COM_RELEASE_CHECKING_IMPORT_MSG_DOES_NOT_HAVE_A_VALID_FILE_TYPE'), 'warning'); - return false; - } - - $config = JFactory::getConfig(); - // set Package Name - $check['packagename'] = $archivename; - - // set directory - $check['dir'] = $config->get('tmp_path'). '/' .$archivename; - - // set type - $check['type'] = $this->getType; - - return $check; + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\Filesystem\File; +use Joomla\CMS\Filesystem\Folder; +use Joomla\Utilities\ArrayHelper; +use PhpOffice\PhpSpreadsheet\IOFactory; + +/** + * Release_checking Import Model + */ +class Release_checkingModelImport extends JModelLegacy +{ + // set uploading values + protected $use_streams = false; + protected $allow_unsafe = false; + protected $safeFileOptions = array(); + + /** + * @var object JTable object + */ + protected $_table = null; + + /** + * @var object JTable object + */ + protected $_url = null; + + /** + * Model context string. + * + * @var string + */ + protected $_context = 'com_release_checking.import'; + + /** + * Import Settings + */ + protected $getType = NULL; + protected $dataType = NULL; + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @return void + * + */ + protected function populateState() + { + $app = JFactory::getApplication('administrator'); + + $this->setState('message', $app->getUserState('com_release_checking.message')); + $app->setUserState('com_release_checking.message', ''); + + // Recall the 'Import from Directory' path. + $path = $app->getUserStateFromRequest($this->_context . '.import_directory', 'import_directory', $app->get('tmp_path')); + $this->setState('import.directory', $path); + parent::populateState(); + } + + /** + * Import an spreadsheet from either folder, url or upload. + * + * @return boolean result of import + * + */ + public function import() + { + $this->setState('action', 'import'); + $app = JFactory::getApplication(); + $session = JFactory::getSession(); + $package = null; + $continue = false; + // get import type + $this->getType = $app->input->getString('gettype', NULL); + // get import type + $this->dataType = $session->get('dataType_VDM_IMPORTINTO', NULL); + + if ($package === null) + { + switch ($this->getType) + { + case 'folder': + // Remember the 'Import from Directory' path. + $app->getUserStateFromRequest($this->_context . '.import_directory', 'import_directory'); + $package = $this->_getPackageFromFolder(); + break; + + case 'upload': + $package = $this->_getPackageFromUpload(); + break; + + case 'url': + $package = $this->_getPackageFromUrl(); + break; + + case 'continue': + $continue = true; + $package = $session->get('package', null); + $package = json_decode($package, true); + // clear session + $session->clear('package'); + $session->clear('dataType'); + $session->clear('hasPackage'); + break; + + default: + $app->setUserState('com_release_checking.message', JText::_('COM_RELEASE_CHECKING_IMPORT_NO_IMPORT_TYPE_FOUND')); + + return false; + break; + } + } + // Was the package valid? + if (!$package || !$package['type']) + { + if (in_array($this->getType, array('upload', 'url'))) + { + $this->remove($package['packagename']); + } + + $app->setUserState('com_release_checking.message', JText::_('COM_RELEASE_CHECKING_IMPORT_UNABLE_TO_FIND_IMPORT_PACKAGE')); + return false; + } + + // first link data to table headers + if(!$continue){ + $package = json_encode($package); + $session->set('package', $package); + $session->set('dataType', $this->dataType); + $session->set('hasPackage', true); + return true; + } + + // set the data + $headerList = json_decode($session->get($this->dataType.'_VDM_IMPORTHEADERS', false), true); + if (!$this->setData($package,$this->dataType,$headerList)) + { + // There was an error importing the package + $msg = JText::_('COM_RELEASE_CHECKING_IMPORT_ERROR'); + $back = $session->get('backto_VDM_IMPORT', NULL); + if ($back) + { + $app->setUserState('com_release_checking.redirect_url', 'index.php?option=com_release_checking&view='.$back); + $session->clear('backto_VDM_IMPORT'); + } + $result = false; + } + else + { + // Package imported sucessfully + $msg = JText::sprintf('COM_RELEASE_CHECKING_IMPORT_SUCCESS', $package['packagename']); + $back = $session->get('backto_VDM_IMPORT', NULL); + if ($back) + { + $app->setUserState('com_release_checking.redirect_url', 'index.php?option=com_release_checking&view='.$back); + $session->clear('backto_VDM_IMPORT'); + } + $result = true; + } + + // Set some model state values + $app->enqueueMessage($msg); + + // remove file after import + $this->remove($package['packagename']); + $session->clear($this->getType.'_VDM_IMPORTHEADERS'); + + return $result; + } + + /** + * Works out an importation spreadsheet from a HTTP upload + * + * @return spreadsheet definition or false on failure + */ + protected function _getPackageFromUpload() + { + // Get the uploaded file information + $app = JFactory::getApplication(); + $input = $app->input; + + // Do not change the filter type 'raw'. We need this to let files containing PHP code to upload. See JInputFiles::get. + $userfile = $input->files->get('import_package', null, 'raw'); + + // Make sure that file uploads are enabled in php + if (!(bool) ini_get('file_uploads')) + { + $app->enqueueMessage(JText::_('COM_RELEASE_CHECKING_IMPORT_MSG_WARNIMPORTFILE'), 'warning'); + return false; + } + + // If there is no uploaded file, we have a problem... + if (!is_array($userfile)) + { + $app->enqueueMessage(JText::_('COM_RELEASE_CHECKING_IMPORT_MSG_NO_FILE_SELECTED'), 'warning'); + return false; + } + + // Check if there was a problem uploading the file. + if ($userfile['error'] || $userfile['size'] < 1) + { + $app->enqueueMessage(JText::_('COM_RELEASE_CHECKING_IMPORT_MSG_WARNIMPORTUPLOADERROR'), 'warning'); + return false; + } + + // Build the appropriate paths + $config = JFactory::getConfig(); + $tmp_dest = $config->get('tmp_path') . '/' . $userfile['name']; + $tmp_src = $userfile['tmp_name']; + + // Move uploaded file + jimport('joomla.filesystem.file'); + $p_file = File::upload($tmp_src, $tmp_dest, $this->use_streams, $this->allow_unsafe, $this->safeFileOptions); + + // Was the package downloaded? + if (!$p_file) + { + $session = JFactory::getSession(); + $session->clear('package'); + $session->clear('dataType'); + $session->clear('hasPackage'); + // was not uploaded + return false; + } + + // check that this is a valid spreadsheet + $package = $this->check($userfile['name']); + + return $package; + } + + /** + * Import an spreadsheet from a directory + * + * @return array Spreadsheet details or false on failure + * + */ + protected function _getPackageFromFolder() + { + $app = JFactory::getApplication(); + $input = $app->input; + + // Get the path to the package to import + $p_dir = $input->getString('import_directory'); + $p_dir = JPath::clean($p_dir); + // Did you give us a valid path? + if (!file_exists($p_dir)) + { + $app->enqueueMessage(JText::_('COM_RELEASE_CHECKING_IMPORT_MSG_PLEASE_ENTER_A_PACKAGE_DIRECTORY'), 'warning'); + return false; + } + + // Detect the package type + $type = $this->getType; + + // Did you give us a valid package? + if (!$type) + { + $app->enqueueMessage(JText::_('COM_RELEASE_CHECKING_IMPORT_MSG_PATH_DOES_NOT_HAVE_A_VALID_PACKAGE'), 'warning'); + } + + // check the extention + if(!$this->checkExtension($p_dir)) + { + // set error message + $app->enqueueMessage(JText::_('COM_RELEASE_CHECKING_IMPORT_MSG_DOES_NOT_HAVE_A_VALID_FILE_TYPE'), 'warning'); + return false; + } + + $package['packagename'] = null; + $package['dir'] = $p_dir; + $package['type'] = $type; + + return $package; + } + + /** + * Import an spreadsheet from a URL + * + * @return Package details or false on failure + * + */ + protected function _getPackageFromUrl() + { + $app = JFactory::getApplication(); + $input = $app->input; + + // Get the URL of the package to import + $url = $input->getString('import_url'); + + // Did you give us a URL? + if (!$url) + { + $app->enqueueMessage(JText::_('COM_RELEASE_CHECKING_IMPORT_MSG_ENTER_A_URL'), 'warning'); + return false; + } + + // Download the package at the URL given + $p_file = JInstallerHelper::downloadPackage($url); + + // Was the package downloaded? + if (!$p_file) + { + $app->enqueueMessage(JText::_('COM_RELEASE_CHECKING_IMPORT_MSG_INVALID_URL'), 'warning'); + return false; + } + + // check that this is a valid spreadsheet + $package = $this->check($p_file); + + return $package; + } + + /** + * Check a file and verifies it as a spreadsheet file + * Supports .csv .xlsx .xls and .ods + * + * @param string $p_filename The uploaded package filename or import directory + * + * @return array of elements + * + */ + protected function check($archivename) + { + $app = JFactory::getApplication(); + // Clean the name + $archivename = JPath::clean($archivename); + + // check the extention + if(!$this->checkExtension($archivename)) + { + // Cleanup the import files + $this->remove($archivename); + $app->enqueueMessage(JText::_('COM_RELEASE_CHECKING_IMPORT_MSG_DOES_NOT_HAVE_A_VALID_FILE_TYPE'), 'warning'); + return false; + } + + $config = JFactory::getConfig(); + // set Package Name + $check['packagename'] = $archivename; + + // set directory + $check['dir'] = $config->get('tmp_path'). '/' .$archivename; + + // set type + $check['type'] = $this->getType; + + return $check; } /** @@ -378,33 +380,33 @@ class Release_checkingModelImport extends JModelLegacy break; } return false; - } - - /** - * Clean up temporary uploaded spreadsheet - * - * @param string $package Name of the uploaded spreadsheet file - * - * @return boolean True on success - * - */ - protected function remove($package) - { - jimport('joomla.filesystem.file'); - - $config = JFactory::getConfig(); - $package = $config->get('tmp_path'). '/' .$package; - - // Is the package file a valid file? - if (is_file($package)) - { - JFile::delete($package); - } - elseif (is_file(JPath::clean($package))) - { - // It might also be just a base filename - JFile::delete(JPath::clean($package)); - } + } + + /** + * Clean up temporary uploaded spreadsheet + * + * @param string $package Name of the uploaded spreadsheet file + * + * @return boolean True on success + * + */ + protected function remove($package) + { + jimport('joomla.filesystem.file'); + + $config = JFactory::getConfig(); + $package = $config->get('tmp_path'). '/' .$package; + + // Is the package file a valid file? + if (is_file($package)) + { + File::delete($package); + } + elseif (is_file(JPath::clean($package))) + { + // It might also be just a base filename + File::delete(JPath::clean($package)); + } } /** @@ -668,70 +670,70 @@ class Release_checkingModelImport extends JModelLegacy } } return false; - } - - protected function getAlias($name,$type = false) - { - // sanitize the name to an alias - if (JFactory::getConfig()->get('unicodeslugs') == 1) - { - $alias = JFilterOutput::stringURLUnicodeSlug($name); - } - else - { - $alias = JFilterOutput::stringURLSafe($name); - } - // must be a uniqe alias - if ($type) - { - return $this->getUniqe($alias,'alias',$type); - } - return $alias; - } - - /** - * Method to generate a uniqe value. - * - * @param string $field name. - * @param string $value data. - * @param string $type table. - * - * @return string New value. - */ - protected function getUniqe($value,$field,$type) - { - // insure the filed is always uniqe - while (isset($this->uniqeValueArray[$type][$field][$value])) - { - $value = JString::increment($value, 'dash'); - } - $this->uniqeValueArray[$type][$field][$value] = $value; - return $value; - } - - protected function getAliasesUsed($table) - { - // Get a db connection. - $db = JFactory::getDbo(); - // first we check if there is a alias column - $columns = $db->getTableColumns('#__release_checking_'.$table); - if(isset($columns['alias'])){ - // Create a new query object. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('alias'))); - $query->from($db->quoteName('#__release_checking_'.$table)); - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - $aliases = $db->loadColumn(); - foreach($aliases as $alias) - { - $this->uniqeValueArray[$table]['alias'][$alias] = $alias; - } - } - return true; - } - return false; - } -} + } + + protected function getAlias($name,$type = false) + { + // sanitize the name to an alias + if (JFactory::getConfig()->get('unicodeslugs') == 1) + { + $alias = JFilterOutput::stringURLUnicodeSlug($name); + } + else + { + $alias = JFilterOutput::stringURLSafe($name); + } + // must be a uniqe alias + if ($type) + { + return $this->getUniqe($alias,'alias',$type); + } + return $alias; + } + + /** + * Method to generate a uniqe value. + * + * @param string $field name. + * @param string $value data. + * @param string $type table. + * + * @return string New value. + */ + protected function getUniqe($value,$field,$type) + { + // insure the filed is always uniqe + while (isset($this->uniqeValueArray[$type][$field][$value])) + { + $value = JString::increment($value, 'dash'); + } + $this->uniqeValueArray[$type][$field][$value] = $value; + return $value; + } + + protected function getAliasesUsed($table) + { + // Get a db connection. + $db = JFactory::getDbo(); + // first we check if there is a alias column + $columns = $db->getTableColumns('#__release_checking_'.$table); + if(isset($columns['alias'])){ + // Create a new query object. + $query = $db->getQuery(true); + $query->select($db->quoteName(array('alias'))); + $query->from($db->quoteName('#__release_checking_'.$table)); + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $aliases = $db->loadColumn(); + foreach($aliases as $alias) + { + $this->uniqeValueArray[$table]['alias'][$alias] = $alias; + } + } + return true; + } + return false; + } +} diff --git a/admin/models/joomla_version.php b/admin/models/joomla_version.php index 101d0c9..ba86a5b 100644 --- a/admin/models/joomla_version.php +++ b/admin/models/joomla_version.php @@ -5,25 +5,25 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + use Joomla\Registry\Registry; use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Release_checking Joomla_version Model - */ -class Release_checkingModelJoomla_version extends JModelAdmin -{ - /** - * The tab layout fields array. - * - * @var array - */ +use Joomla\Utilities\ArrayHelper; + +/** + * Release_checking Joomla_version Model + */ +class Release_checkingModelJoomla_version extends JModelAdmin +{ + /** + * The tab layout fields array. + * + * @var array + */ protected $tabLayoutFields = array( 'details' => array( 'left' => array( @@ -33,94 +33,94 @@ class Release_checkingModelJoomla_version extends JModelAdmin 'alias' ) ) - ); - - /** - * @var string The prefix to use with controller messages. - * @since 1.6 - */ - protected $text_prefix = 'COM_RELEASE_CHECKING'; - - /** - * The type alias for this content type. - * - * @var string - * @since 3.2 - */ - public $typeAlias = 'com_release_checking.joomla_version'; - - /** - * Returns a Table object, always creating it - * - * @param type $type The table type to instantiate - * @param string $prefix A prefix for the table class name. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JTable A database object - * - * @since 1.6 - */ - public function getTable($type = 'joomla_version', $prefix = 'Release_checkingTable', $config = array()) - { - // add table path for when model gets used from other component - $this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_release_checking/tables'); - // get instance of the table - return JTable::getInstance($type, $prefix, $config); - } - - /** - * Method to get a single record. - * - * @param integer $pk The id of the primary key. - * - * @return mixed Object on success, false on failure. - * - * @since 1.6 - */ - public function getItem($pk = null) - { - if ($item = parent::getItem($pk)) - { - if (!empty($item->params) && !is_array($item->params)) - { - // Convert the params field to an array. - $registry = new Registry; - $registry->loadString($item->params); - $item->params = $registry->toArray(); - } - - if (!empty($item->metadata)) - { - // Convert the metadata field to an array. - $registry = new Registry; - $registry->loadString($item->metadata); - $item->metadata = $registry->toArray(); - } - - if (!empty($item->id)) - { - $item->tags = new JHelperTags; - $item->tags->getTagIds($item->id, 'com_release_checking.joomla_version'); - } - } - - return $item; - } - - /** - * Method to get the record form. - * - * @param array $data Data for the form. - * @param boolean $loadData True if the form is to load its own data (default case), false if not. - * @param array $options Optional array of options for the form creation. - * - * @return mixed A JForm object on success, false on failure - * - * @since 1.6 - */ - public function getForm($data = array(), $loadData = true, $options = array('control' => 'jform')) - { - // set load data option + ); + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_RELEASE_CHECKING'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_release_checking.joomla_version'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JTable A database object + * + * @since 1.6 + */ + public function getTable($type = 'joomla_version', $prefix = 'Release_checkingTable', $config = array()) + { + // add table path for when model gets used from other component + $this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_release_checking/tables'); + // get instance of the table + return JTable::getInstance($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->id)) + { + $item->tags = new JHelperTags; + $item->tags->getTagIds($item->id, 'com_release_checking.joomla_version'); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return mixed A JForm object on success, false on failure + * + * @since 1.6 + */ + public function getForm($data = array(), $loadData = true, $options = array('control' => 'jform')) + { + // set load data option $options['load_data'] = $loadData; // check if xpath was set in options $xpath = false; @@ -213,29 +213,29 @@ class Release_checkingModelJoomla_version extends JModelAdmin $form->setValue($redirectedField, null, $redirectedValue); } } - return $form; - } - - /** - * Method to get the script that have to be included on the form - * - * @return string script files - */ - public function getScript() - { - return 'administrator/components/com_release_checking/models/forms/joomla_version.js'; - } - - /** - * Method to test whether a record can be deleted. - * - * @param object $record A record object. - * - * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. - * - * @since 1.6 - */ - protected function canDelete($record) + return $form; + } + + /** + * Method to get the script that have to be included on the form + * + * @return string script files + */ + public function getScript() + { + return 'administrator/components/com_release_checking/models/forms/joomla_version.js'; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canDelete($record) { if (!empty($record->id)) { @@ -248,19 +248,19 @@ class Release_checkingModelJoomla_version extends JModelAdmin // The record has been set. Check the record permissions. return $user->authorise('core.delete', 'com_release_checking.joomla_version.' . (int) $record->id); } - return false; - } - - /** - * Method to test whether a record can have its state edited. - * - * @param object $record A record object. - * - * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. - * - * @since 1.6 - */ - protected function canEditState($record) + return false; + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canEditState($record) { $user = JFactory::getUser(); $recordId = (!empty($record->id)) ? $record->id : 0; @@ -275,103 +275,103 @@ class Release_checkingModelJoomla_version extends JModelAdmin } } // In the absense of better information, revert to the component permissions. - return parent::canEditState($record); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * @since 2.5 - */ - protected function allowEdit($data = array(), $key = 'id') + return parent::canEditState($record); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = array(), $key = 'id') { // Check specific edit permission then general edit permission. - return JFactory::getUser()->authorise('core.edit', 'com_release_checking.joomla_version.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or parent::allowEdit($data, $key); - } - - /** - * Prepare and sanitise the table data prior to saving. - * - * @param JTable $table A JTable object. - * - * @return void - * - * @since 1.6 - */ - protected function prepareTable($table) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if (isset($table->name)) - { - $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); - } - - if (isset($table->alias) && empty($table->alias)) - { - $table->generateAlias(); - } - - if (empty($table->id)) - { - $table->created = $date->toSql(); - // set the user - if ($table->created_by == 0 || empty($table->created_by)) - { - $table->created_by = $user->id; - } - // Set ordering to the last item if not set - if (empty($table->ordering)) - { - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select('MAX(ordering)') - ->from($db->quoteName('#__release_checking_joomla_version')); - $db->setQuery($query); - $max = $db->loadResult(); - - $table->ordering = $max + 1; - } - } - else - { - $table->modified = $date->toSql(); - $table->modified_by = $user->id; - } - - if (!empty($table->id)) - { - // Increment the items version number. - $table->version++; - } - } - - /** - * Method to get the data that should be injected in the form. - * - * @return mixed The data for the form. - * - * @since 1.6 - */ - protected function loadFormData() - { - // Check the session for previously entered form data. - $data = JFactory::getApplication()->getUserState('com_release_checking.edit.joomla_version.data', array()); - - if (empty($data)) - { - $data = $this->getItem(); - // run the perprocess of the data - $this->preprocessData('com_release_checking.joomla_version', $data); - } - - return $data; + return JFactory::getUser()->authorise('core.edit', 'com_release_checking.joomla_version.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or parent::allowEdit($data, $key); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param JTable $table A JTable object. + * + * @return void + * + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + if (isset($table->name)) + { + $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__release_checking_joomla_version')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = JFactory::getApplication()->getUserState('com_release_checking.edit.joomla_version.data', array()); + + if (empty($data)) + { + $data = $this->getItem(); + // run the perprocess of the data + $this->preprocessData('com_release_checking.joomla_version', $data); + } + + return $data; } /** @@ -384,141 +384,141 @@ class Release_checkingModelJoomla_version extends JModelAdmin protected function getUniqueFields() { return false; - } - - /** - * Method to delete one or more records. - * - * @param array &$pks An array of record primary keys. - * - * @return boolean True if successful, false if an error occurs. - * - * @since 12.2 - */ - public function delete(&$pks) - { - if (!parent::delete($pks)) - { - return false; - } - - return true; - } - - /** - * Method to change the published state of one or more records. - * - * @param array &$pks A list of the primary keys to change. - * @param integer $value The value of the published state. - * - * @return boolean True on success. - * - * @since 12.2 - */ - public function publish(&$pks, $value = 1) - { - if (!parent::publish($pks, $value)) - { - return false; - } - - return true; - } - - /** - * Method to perform batch operations on an item or a set of items. - * - * @param array $commands An array of commands to perform. - * @param array $pks An array of item ids. - * @param array $contexts An array of item contexts. - * - * @return boolean Returns true on success, false on failure. - * - * @since 12.2 - */ - public function batch($commands, $pks, $contexts) - { - // Sanitize ids. - $pks = array_unique($pks); - ArrayHelper::toInteger($pks); - - // Remove any values of zero. - if (array_search(0, $pks, true)) - { - unset($pks[array_search(0, $pks, true)]); - } - - if (empty($pks)) - { - $this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED')); - return false; - } - - $done = false; - - // Set some needed variables. - $this->user = JFactory::getUser(); - $this->table = $this->getTable(); - $this->tableClassName = get_class($this->table); - $this->contentType = new JUcmType; - $this->type = $this->contentType->getTypeByTable($this->tableClassName); - $this->canDo = Release_checkingHelper::getActions('joomla_version'); - $this->batchSet = true; - - if (!$this->canDo->get('core.batch')) - { - $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); - return false; - } - - if ($this->type == false) - { - $type = new JUcmType; - $this->type = $type->getTypeByAlias($this->typeAlias); - } - - $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); - - if (!empty($commands['move_copy'])) - { - $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); - - if ($cmd == 'c') - { - $result = $this->batchCopy($commands, $pks, $contexts); - - if (is_array($result)) - { - foreach ($result as $old => $new) - { - $contexts[$new] = $contexts[$old]; - } - $pks = array_values($result); - } - else - { - return false; - } - } - elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) - { - return false; - } - - $done = true; - } - - if (!$done) - { - $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); - - return false; - } - - // Clear the cache - $this->cleanCache(); - - return true; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs. + * + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new JUcmType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = Release_checkingHelper::getActions('joomla_version'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new JUcmType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; } /** @@ -765,38 +765,38 @@ class Release_checkingModelJoomla_version extends JModelAdmin $this->cleanCache(); return true; - } - - /** - * Method to save the form data. - * - * @param array $data The form data. - * - * @return boolean True on success. - * - * @since 1.6 - */ - public function save($data) - { - $input = JFactory::getApplication()->input; - $filter = JFilterInput::getInstance(); - - // set the metadata to the Item Data - if (isset($data['metadata']) && isset($data['metadata']['author'])) - { - $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); - - $metadata = new JRegistry; - $metadata->loadArray($data['metadata']); - $data['metadata'] = (string) $metadata; - } - - // Set the Params Items to data - if (isset($data['params']) && is_array($data['params'])) - { - $params = new JRegistry; - $params->loadArray($data['params']); - $data['params'] = (string) $params; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * + * @since 1.6 + */ + public function save($data) + { + $input = JFactory::getApplication()->input; + $filter = JFilterInput::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new JRegistry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new JRegistry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; } // Alter the name for save as copy @@ -864,37 +864,37 @@ class Release_checkingModelJoomla_version extends JModelAdmin $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); } } - } - - if (parent::save($data)) - { - return true; - } - return false; - } - - /** - * Method to generate a unique value. - * - * @param string $field name. - * @param string $value data. - * - * @return string New value. - * - * @since 3.0 - */ - protected function generateUnique($field,$value) - { - - // set field value unique - $table = $this->getTable(); - - while ($table->load(array($field => $value))) - { - $value = StringHelper::increment($value); - } - - return $value; + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * + * @since 3.0 + */ + protected function generateUnique($field,$value) + { + + // set field value unique + $table = $this->getTable(); + + while ($table->load(array($field => $value))) + { + $value = StringHelper::increment($value); + } + + return $value; } /** @@ -942,5 +942,5 @@ class Release_checkingModelJoomla_version extends JModelAdmin } // We only had an alias return $alias; - } -} + } +} diff --git a/admin/models/joomla_versions.php b/admin/models/joomla_versions.php index 043f28c..3e73eee 100644 --- a/admin/models/joomla_versions.php +++ b/admin/models/joomla_versions.php @@ -5,55 +5,55 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\Utilities\ArrayHelper; - -/** - * Joomla_versions Model - */ -class Release_checkingModelJoomla_versions extends JModelList -{ - public function __construct($config = array()) - { - if (empty($config['filter_fields'])) - { - $config['filter_fields'] = array( + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\Utilities\ArrayHelper; + +/** + * Joomla_versions Model + */ +class Release_checkingModelJoomla_versions extends JModelList +{ + public function __construct($config = array()) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( 'a.id','id', 'a.published','published', 'a.access','access', 'a.ordering','ordering', 'a.created_by','created_by', 'a.modified_by','modified_by', - 'a.name','name' - ); - } - - parent::__construct($config); - } - - /** - * Method to auto-populate the model state. - * - * Note. Calling getState in this method will result in recursion. - * - * @param string $ordering An optional ordering field. - * @param string $direction An optional direction (asc|desc). - * - * @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.name','name' + ); + } + + parent::__construct($config); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @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; } // Check if the form was submitted @@ -86,36 +86,36 @@ class Release_checkingModelJoomla_versions extends JModelList { $name = $app->input->post->get('name'); $this->setState('filter.name', $name); - } - - // 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() + } + + // 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 - $items = parent::getItems(); - - // return items - return $items; - } - - /** - * Method to build an SQL query to load the list data. - * - * @return string An SQL query - */ - protected function getListQuery() - { + + // load parent items + $items = parent::getItems(); + + // return items + return $items; + } + + /** + * 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. @@ -185,7 +185,7 @@ class Release_checkingModelJoomla_versions extends JModelList $query->order($db->escape($orderCol . ' ' . $orderDirn)); } - return $query; + return $query; } /** @@ -302,16 +302,16 @@ class Release_checkingModelJoomla_versions 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'); @@ -322,7 +322,7 @@ class Release_checkingModelJoomla_versions extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || Release_checkingHelper::checkString($_access)) { @@ -331,9 +331,9 @@ class Release_checkingModelJoomla_versions extends JModelList $id .= ':' . $this->getState('filter.ordering'); $id .= ':' . $this->getState('filter.created_by'); $id .= ':' . $this->getState('filter.modified_by'); - $id .= ':' . $this->getState('filter.name'); - - return parent::getStoreId($id); + $id .= ':' . $this->getState('filter.name'); + + return parent::getStoreId($id); } /** @@ -387,5 +387,5 @@ class Release_checkingModelJoomla_versions extends JModelList } return false; - } -} + } +} diff --git a/admin/models/release_check.php b/admin/models/release_check.php index 4b6e397..52fe7b5 100644 --- a/admin/models/release_check.php +++ b/admin/models/release_check.php @@ -5,25 +5,25 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + use Joomla\Registry\Registry; use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Release_checking Release_check Model - */ -class Release_checkingModelRelease_check extends JModelAdmin -{ - /** - * The tab layout fields array. - * - * @var array - */ +use Joomla\Utilities\ArrayHelper; + +/** + * Release_checking Release_check Model + */ +class Release_checkingModelRelease_check extends JModelAdmin +{ + /** + * The tab layout fields array. + * + * @var array + */ protected $tabLayoutFields = array( 'checking' => array( 'left' => array( @@ -37,39 +37,39 @@ class Release_checkingModelRelease_check extends JModelAdmin 'joomla_version' ) ) - ); - - /** - * @var string The prefix to use with controller messages. - * @since 1.6 - */ - protected $text_prefix = 'COM_RELEASE_CHECKING'; - - /** - * The type alias for this content type. - * - * @var string - * @since 3.2 - */ - public $typeAlias = 'com_release_checking.release_check'; - - /** - * Returns a Table object, always creating it - * - * @param type $type The table type to instantiate - * @param string $prefix A prefix for the table class name. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JTable A database object - * - * @since 1.6 - */ - public function getTable($type = 'release_check', $prefix = 'Release_checkingTable', $config = array()) - { - // add table path for when model gets used from other component - $this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_release_checking/tables'); - // get instance of the table - return JTable::getInstance($type, $prefix, $config); + ); + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_RELEASE_CHECKING'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_release_checking.release_check'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JTable A database object + * + * @since 1.6 + */ + public function getTable($type = 'release_check', $prefix = 'Release_checkingTable', $config = array()) + { + // add table path for when model gets used from other component + $this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_release_checking/tables'); + // get instance of the table + return JTable::getInstance($type, $prefix, $config); } protected function getLatestJoomlaVersion() @@ -91,61 +91,61 @@ class Release_checkingModelRelease_check extends JModelAdmin } return false; } - - - /** - * Method to get a single record. - * - * @param integer $pk The id of the primary key. - * - * @return mixed Object on success, false on failure. - * - * @since 1.6 - */ - public function getItem($pk = null) - { - if ($item = parent::getItem($pk)) - { - if (!empty($item->params) && !is_array($item->params)) - { - // Convert the params field to an array. - $registry = new Registry; - $registry->loadString($item->params); - $item->params = $registry->toArray(); - } - - if (!empty($item->metadata)) - { - // Convert the metadata field to an array. - $registry = new Registry; - $registry->loadString($item->metadata); - $item->metadata = $registry->toArray(); - } - - if (!empty($item->id)) - { - $item->tags = new JHelperTags; - $item->tags->getTagIds($item->id, 'com_release_checking.release_check'); - } - } - - return $item; - } - - /** - * Method to get the record form. - * - * @param array $data Data for the form. - * @param boolean $loadData True if the form is to load its own data (default case), false if not. - * @param array $options Optional array of options for the form creation. - * - * @return mixed A JForm object on success, false on failure - * - * @since 1.6 - */ - public function getForm($data = array(), $loadData = true, $options = array('control' => 'jform')) - { - // set load data option + + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->id)) + { + $item->tags = new JHelperTags; + $item->tags->getTagIds($item->id, 'com_release_checking.release_check'); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return mixed A JForm object on success, false on failure + * + * @since 1.6 + */ + public function getForm($data = array(), $loadData = true, $options = array('control' => 'jform')) + { + // set load data option $options['load_data'] = $loadData; // check if xpath was set in options $xpath = false; @@ -254,29 +254,29 @@ class Release_checkingModelRelease_check extends JModelAdmin { $form->setValue('joomla_version', null, $joomla_version); } - return $form; - } - - /** - * Method to get the script that have to be included on the form - * - * @return string script files - */ - public function getScript() - { - return 'administrator/components/com_release_checking/models/forms/release_check.js'; - } - - /** - * Method to test whether a record can be deleted. - * - * @param object $record A record object. - * - * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. - * - * @since 1.6 - */ - protected function canDelete($record) + return $form; + } + + /** + * Method to get the script that have to be included on the form + * + * @return string script files + */ + public function getScript() + { + return 'administrator/components/com_release_checking/models/forms/release_check.js'; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canDelete($record) { if (!empty($record->id)) { @@ -289,19 +289,19 @@ class Release_checkingModelRelease_check extends JModelAdmin // The record has been set. Check the record permissions. return $user->authorise('core.delete', 'com_release_checking.release_check.' . (int) $record->id); } - return false; - } - - /** - * Method to test whether a record can have its state edited. - * - * @param object $record A record object. - * - * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. - * - * @since 1.6 - */ - protected function canEditState($record) + return false; + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canEditState($record) { $user = JFactory::getUser(); $recordId = (!empty($record->id)) ? $record->id : 0; @@ -316,104 +316,104 @@ class Release_checkingModelRelease_check extends JModelAdmin } } // In the absense of better information, revert to the component permissions. - return parent::canEditState($record); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * @since 2.5 - */ - protected function allowEdit($data = array(), $key = 'id') + return parent::canEditState($record); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = array(), $key = 'id') { // Check specific edit permission then general edit permission. $user = JFactory::getUser(); - return $user->authorise('core.edit', 'com_release_checking.release_check.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('core.edit', 'com_release_checking'); - } - - /** - * Prepare and sanitise the table data prior to saving. - * - * @param JTable $table A JTable object. - * - * @return void - * - * @since 1.6 - */ - protected function prepareTable($table) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if (isset($table->name)) - { - $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); - } - - if (isset($table->alias) && empty($table->alias)) - { - $table->generateAlias(); - } - - if (empty($table->id)) - { - $table->created = $date->toSql(); - // set the user - if ($table->created_by == 0 || empty($table->created_by)) - { - $table->created_by = $user->id; - } - // Set ordering to the last item if not set - if (empty($table->ordering)) - { - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select('MAX(ordering)') - ->from($db->quoteName('#__release_checking_release_check')); - $db->setQuery($query); - $max = $db->loadResult(); - - $table->ordering = $max + 1; - } - } - else - { - $table->modified = $date->toSql(); - $table->modified_by = $user->id; - } - - if (!empty($table->id)) - { - // Increment the items version number. - $table->version++; - } - } - - /** - * Method to get the data that should be injected in the form. - * - * @return mixed The data for the form. - * - * @since 1.6 - */ - protected function loadFormData() - { - // Check the session for previously entered form data. - $data = JFactory::getApplication()->getUserState('com_release_checking.edit.release_check.data', array()); - - if (empty($data)) - { - $data = $this->getItem(); - // run the perprocess of the data - $this->preprocessData('com_release_checking.release_check', $data); - } - - return $data; + return $user->authorise('core.edit', 'com_release_checking.release_check.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('core.edit', 'com_release_checking'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param JTable $table A JTable object. + * + * @return void + * + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + if (isset($table->name)) + { + $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__release_checking_release_check')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = JFactory::getApplication()->getUserState('com_release_checking.edit.release_check.data', array()); + + if (empty($data)) + { + $data = $this->getItem(); + // run the perprocess of the data + $this->preprocessData('com_release_checking.release_check', $data); + } + + return $data; } /** @@ -426,141 +426,141 @@ class Release_checkingModelRelease_check extends JModelAdmin protected function getUniqueFields() { return false; - } - - /** - * Method to delete one or more records. - * - * @param array &$pks An array of record primary keys. - * - * @return boolean True if successful, false if an error occurs. - * - * @since 12.2 - */ - public function delete(&$pks) - { - if (!parent::delete($pks)) - { - return false; - } - - return true; - } - - /** - * Method to change the published state of one or more records. - * - * @param array &$pks A list of the primary keys to change. - * @param integer $value The value of the published state. - * - * @return boolean True on success. - * - * @since 12.2 - */ - public function publish(&$pks, $value = 1) - { - if (!parent::publish($pks, $value)) - { - return false; - } - - return true; - } - - /** - * Method to perform batch operations on an item or a set of items. - * - * @param array $commands An array of commands to perform. - * @param array $pks An array of item ids. - * @param array $contexts An array of item contexts. - * - * @return boolean Returns true on success, false on failure. - * - * @since 12.2 - */ - public function batch($commands, $pks, $contexts) - { - // Sanitize ids. - $pks = array_unique($pks); - ArrayHelper::toInteger($pks); - - // Remove any values of zero. - if (array_search(0, $pks, true)) - { - unset($pks[array_search(0, $pks, true)]); - } - - if (empty($pks)) - { - $this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED')); - return false; - } - - $done = false; - - // Set some needed variables. - $this->user = JFactory::getUser(); - $this->table = $this->getTable(); - $this->tableClassName = get_class($this->table); - $this->contentType = new JUcmType; - $this->type = $this->contentType->getTypeByTable($this->tableClassName); - $this->canDo = Release_checkingHelper::getActions('release_check'); - $this->batchSet = true; - - if (!$this->canDo->get('core.batch')) - { - $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); - return false; - } - - if ($this->type == false) - { - $type = new JUcmType; - $this->type = $type->getTypeByAlias($this->typeAlias); - } - - $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); - - if (!empty($commands['move_copy'])) - { - $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); - - if ($cmd == 'c') - { - $result = $this->batchCopy($commands, $pks, $contexts); - - if (is_array($result)) - { - foreach ($result as $old => $new) - { - $contexts[$new] = $contexts[$old]; - } - $pks = array_values($result); - } - else - { - return false; - } - } - elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) - { - return false; - } - - $done = true; - } - - if (!$done) - { - $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); - - return false; - } - - // Clear the cache - $this->cleanCache(); - - return true; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs. + * + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new JUcmType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = Release_checkingHelper::getActions('release_check'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new JUcmType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; } /** @@ -812,38 +812,38 @@ class Release_checkingModelRelease_check extends JModelAdmin $this->cleanCache(); return true; - } - - /** - * Method to save the form data. - * - * @param array $data The form data. - * - * @return boolean True on success. - * - * @since 1.6 - */ - public function save($data) - { - $input = JFactory::getApplication()->input; - $filter = JFilterInput::getInstance(); - - // set the metadata to the Item Data - if (isset($data['metadata']) && isset($data['metadata']['author'])) - { - $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); - - $metadata = new JRegistry; - $metadata->loadArray($data['metadata']); - $data['metadata'] = (string) $metadata; - } - - // Set the Params Items to data - if (isset($data['params']) && is_array($data['params'])) - { - $params = new JRegistry; - $params->loadArray($data['params']); - $data['params'] = (string) $params; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * + * @since 1.6 + */ + public function save($data) + { + $input = JFactory::getApplication()->input; + $filter = JFilterInput::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new JRegistry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new JRegistry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; } // Alter the unique field for save as copy @@ -858,37 +858,37 @@ class Release_checkingModelRelease_check extends JModelAdmin $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); } } - } - - if (parent::save($data)) - { - return true; - } - return false; - } - - /** - * Method to generate a unique value. - * - * @param string $field name. - * @param string $value data. - * - * @return string New value. - * - * @since 3.0 - */ - protected function generateUnique($field,$value) - { - - // set field value unique - $table = $this->getTable(); - - while ($table->load(array($field => $value))) - { - $value = StringHelper::increment($value); - } - - return $value; + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * + * @since 3.0 + */ + protected function generateUnique($field,$value) + { + + // set field value unique + $table = $this->getTable(); + + while ($table->load(array($field => $value))) + { + $value = StringHelper::increment($value); + } + + return $value; } /** @@ -911,5 +911,5 @@ class Release_checkingModelRelease_check extends JModelAdmin } return $title; - } -} + } +} diff --git a/admin/models/release_checks.php b/admin/models/release_checks.php index 032fd54..c040bb4 100644 --- a/admin/models/release_checks.php +++ b/admin/models/release_checks.php @@ -5,23 +5,23 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\Utilities\ArrayHelper; - -/** - * Release_checks Model - */ -class Release_checkingModelRelease_checks extends JModelList -{ - public function __construct($config = array()) - { - if (empty($config['filter_fields'])) - { - $config['filter_fields'] = array( + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\Utilities\ArrayHelper; + +/** + * Release_checks Model + */ +class Release_checkingModelRelease_checks extends JModelList +{ + public function __construct($config = array()) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( 'a.id','id', 'a.published','published', 'a.access','access', @@ -31,32 +31,32 @@ class Release_checkingModelRelease_checks extends JModelList 'g.name','context', 'h.name','action', 'a.outcome','outcome', - 'i.name','joomla_version' - ); - } - - parent::__construct($config); - } - - /** - * Method to auto-populate the model state. - * - * Note. Calling getState in this method will result in recursion. - * - * @param string $ordering An optional ordering field. - * @param string $direction An optional direction (asc|desc). - * - * @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; + 'i.name','joomla_version' + ); + } + + parent::__construct($config); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @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; } // Check if the form was submitted @@ -114,23 +114,23 @@ class Release_checkingModelRelease_checks extends JModelList { $created_by = $app->input->post->get('created_by'); $this->setState('filter.created_by', $created_by); - } - - // 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() + } + + // 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. @@ -159,10 +159,10 @@ class Release_checkingModelRelease_checks extends JModelList $item->outcome = $this->selectionTranslation($item->outcome, 'outcome'); } } - - - // return items - return $items; + + + // return items + return $items; } /** @@ -187,15 +187,15 @@ class Release_checkingModelRelease_checks 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. @@ -477,7 +477,7 @@ class Release_checkingModelRelease_checks extends JModelList $query->order($db->escape($orderCol . ' ' . $orderDirn)); } - return $query; + return $query; } /** @@ -629,16 +629,16 @@ class Release_checkingModelRelease_checks 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'); @@ -649,7 +649,7 @@ class Release_checkingModelRelease_checks extends JModelList { $id .= ':' . implode(':', $_access); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_access) || Release_checkingHelper::checkString($_access)) { @@ -663,7 +663,7 @@ class Release_checkingModelRelease_checks extends JModelList { $id .= ':' . implode(':', $_context); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_context) || Release_checkingHelper::checkString($_context)) { @@ -675,7 +675,7 @@ class Release_checkingModelRelease_checks extends JModelList { $id .= ':' . implode(':', $_action); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_action) || Release_checkingHelper::checkString($_action)) { @@ -687,7 +687,7 @@ class Release_checkingModelRelease_checks extends JModelList { $id .= ':' . implode(':', $_outcome); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_outcome) || Release_checkingHelper::checkString($_outcome)) { @@ -699,14 +699,14 @@ class Release_checkingModelRelease_checks extends JModelList { $id .= ':' . implode(':', $_joomla_version); } - // Check if this is only an int or string + // Check if this is only an number or string elseif (is_numeric($_joomla_version) || Release_checkingHelper::checkString($_joomla_version)) { $id .= ':' . $_joomla_version; - } - - return parent::getStoreId($id); + } + + return parent::getStoreId($id); } /** @@ -760,5 +760,5 @@ class Release_checkingModelRelease_checks extends JModelList } return false; - } -} + } +} diff --git a/admin/release_checking.php b/admin/release_checking.php index f9c2917..0def0ae 100644 --- a/admin/release_checking.php +++ b/admin/release_checking.php @@ -5,32 +5,33 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); -JHtml::_('behavior.tabstate'); - -// Access check. -if (!JFactory::getUser()->authorise('core.manage', 'com_release_checking')) -{ - throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); -}; - -// Add CSS file for all pages -$document = JFactory::getDocument(); -$document->addStyleSheet('components/com_release_checking/assets/css/admin.css'); -$document->addScript('components/com_release_checking/assets/js/admin.js'); - -// require helper files -JLoader::register('Release_checkingHelper', __DIR__ . '/helpers/release_checking.php'); -JLoader::register('JHtmlBatch_', __DIR__ . '/helpers/html/batch_.php'); - -// Get an instance of the controller prefixed by Release_checking -$controller = JControllerLegacy::getInstance('Release_checking'); - -// Perform the Request task -$controller->execute(JFactory::getApplication()->input->get('task')); - -// Redirect if set by the controller -$controller->redirect(); + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +JHtml::_('behavior.tabstate'); + +// Access check. +if (!JFactory::getUser()->authorise('core.manage', 'com_release_checking')) +{ + throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); +}; + +// Add CSS file for all pages +$document = JFactory::getDocument(); +$document->addStyleSheet('components/com_release_checking/assets/css/admin.css'); +$document->addScript('components/com_release_checking/assets/js/admin.js'); + +// require helper files +JLoader::register('Release_checkingHelper', __DIR__ . '/helpers/release_checking.php'); +JLoader::register('JHtmlBatch_', __DIR__ . '/helpers/html/batch_.php'); + +// Get an instance of the controller prefixed by Release_checking +$controller = JControllerLegacy::getInstance('Release_checking'); + +// Perform the Request task +$controller->execute(JFactory::getApplication()->input->get('task')); + +// Redirect if set by the controller +$controller->redirect(); diff --git a/admin/sql/install.mysql.utf8.sql b/admin/sql/install.mysql.utf8.sql index ca74baf..af186b7 100644 --- a/admin/sql/install.mysql.utf8.sql +++ b/admin/sql/install.mysql.utf8.sql @@ -112,174 +112,169 @@ CREATE TABLE IF NOT EXISTS `#__release_checking_action` ( KEY `idx_state` (`published`) ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; --- --- Dumping data for table `#__release_checking_joomla_version` --- - -INSERT INTO `#__release_checking_joomla_version` (`id`, `alias`, `name`, `published`) VALUES -(1, '3-9-5-rc', '3.9.5 RC ', 1), -(2, '3-9-5-stable-release', '3.9.5 Stable Release', 1), -(3, '3-9-6-rc', '3.9.6 RC', 1), -(4, '3-9-6-rc2', '3.9.6 RC2', 1), -(5, '3-9-7-stable', '3.9.7 Stable', 1), -(6, '3-9-18', '3.9.18', 1), -(7, '3-9-8-stable', '3.9.8 Stable', 1), -(8, '3-9-9-dev', '3.9.9-dev', 1), -(9, '3-9-11-rc', '3.9.11 RC', 1), -(10, '3-19-13', '3.19.13', 1), -(11, '3-9-14', '3.9.14', 1), -(12, '3-9-15', '3.9.15', 1), -(13, '3-9-16', '3.9.16', 1), -(14, '3-9-17', '3.9.17', 1), -(15, '3-9-19', '3.9.19', 1), -(16, '3-9-20', '3.9.20', 1), -(17, '3-9-21', '3.9.21', 1), +-- +-- Dumping data for table `#__release_checking_joomla_version` +-- + +INSERT INTO `#__release_checking_joomla_version` (`id`, `alias`, `name`, `published`) VALUES +(1, '3-9-5-rc', '3.9.5 RC ', 1), +(2, '3-9-5-stable-release', '3.9.5 Stable Release', 1), +(3, '3-9-6-rc', '3.9.6 RC', 1), +(4, '3-9-6-rc2', '3.9.6 RC2', 1), +(5, '3-9-7-stable', '3.9.7 Stable', 1), +(6, '3-9-18', '3.9.18', 1), +(7, '3-9-8-stable', '3.9.8 Stable', 1), +(8, '3-9-9-dev', '3.9.9-dev', 1), +(9, '3-9-11-rc', '3.9.11 RC', 1), +(10, '3-19-13', '3.19.13', 1), +(11, '3-9-14', '3.9.14', 1), +(12, '3-9-15', '3.9.15', 1), +(13, '3-9-16', '3.9.16', 1), +(14, '3-9-17', '3.9.17', 1), +(15, '3-9-19', '3.9.19', 1), +(16, '3-9-20', '3.9.20', 1), +(17, '3-9-21', '3.9.21', 1), (18, '3-9-22', '3.9.22', 1); --- --- Dumping data for table `#__release_checking_context` --- - -INSERT INTO `#__release_checking_context` (`id`, `alias`, `name`, `published`, `created`) VALUES -(1, 'com_installer', 'com_installer', 1, '2020-10-31 14:20:29'), -(2, 'com_users', 'com_users', 1, '2020-10-31 20:21:11'), -(3, 'com_menu', 'com_menu', 1, '2020-10-31 20:21:31'), -(4, 'com_categories-and-com_content', 'com_categories and com_content', 1, '2020-10-31 20:21:48'), -(5, 'com_fields', 'com_fields', 1, '2020-10-31 20:22:20'), -(6, 'com_tags', 'com_tags', 1, '2020-10-31 20:22:37'), -(7, 'com_media', 'com_media', 1, '2020-10-31 20:22:56'), -(9, 'com_plugins-com_installer', 'com_plugins (+ com_installer)', 1, '2020-10-31 20:25:17'), -(10, 'com_modules', 'com_modules', 1, '2020-10-31 20:25:32'), -(11, 'com_templates', 'com_templates', 1, '2020-10-31 20:25:50'), -(12, 'com_languages', 'com_languages', 1, '2020-10-31 20:26:10'), -(13, 'com_config', 'com_config', 1, '2020-10-31 20:26:43'), -(14, 'editors', 'Editors', 1, '2020-10-31 20:26:59'), -(15, 'com_admin-and-com_cache', 'com_admin and com_cache', 1, '2020-10-31 20:27:36'), -(16, 'com_search', 'com_search', 1, '2020-10-31 20:27:59'), -(17, 'com_finder', 'com_finder', 1, '2020-10-31 20:28:53'), -(18, 'com_redirect', 'com_redirect', 1, '2020-10-31 20:29:11'), -(19, 'com_weblinks', 'com_weblinks', 1, '2020-10-31 20:29:54'), -(20, 'com_privacy', 'com_privacy', 1, '2020-10-31 20:30:15'), -(21, 'com_actionlog', 'com_actionlog', 1, '2020-10-31 20:30:48'), -(22, 'com_login', 'com_login', 1, '2020-10-31 20:31:03'), -(23, 'com_contenthistory', 'com_contenthistory', 1, '2020-10-31 20:31:17'), -(24, 'com_contact', 'com_contact', 1, '2020-10-31 20:31:36'), -(25, 'com_checkin', 'com_checkin', 1, '2020-10-31 20:31:52'), -(26, 'com_banners', 'com_banners', 1, '2020-10-31 20:32:11'), -(27, 'com_mailto-only-frontend', 'com_mailto (only frontend)', 1, '2020-10-31 20:32:47'), -(28, 'category-filter-in-the-featured-view', 'category filter in the featured view', 1, '2020-10-31 20:33:08'), -(29, 'whitespace-characters-etc-new-users', 'whitespace characters etc new users', 1, '2020-10-31 20:33:31'), -(30, 'com_fields-sql-field', 'com_fields SQL field', 1, '2020-10-31 20:33:51'), -(31, 'beez3-and-protostar-forms,-button-groups', 'beez3 and protostar forms, button groups', 1, '2020-10-31 20:34:18'), -(32, 'template-crop-and-resize-image-functionality', 'template crop and resize image functionality', 1, '2020-10-31 20:34:37'), -(33, 'superusers-edit-templates-in-backend', 'superusers edit templates in backend', 1, '2020-10-31 20:35:04'), -(34, 'com_joomlaupdate', 'com_joomlaupdate', 1, '2020-10-31 20:35:28'), +-- +-- Dumping data for table `#__release_checking_context` +-- + +INSERT INTO `#__release_checking_context` (`id`, `alias`, `name`, `published`, `created`) VALUES +(1, 'com_installer', 'com_installer', 1, '2020-10-31 14:20:29'), +(2, 'com_users', 'com_users', 1, '2020-10-31 20:21:11'), +(3, 'com_menu', 'com_menu', 1, '2020-10-31 20:21:31'), +(4, 'com_categories-and-com_content', 'com_categories and com_content', 1, '2020-10-31 20:21:48'), +(5, 'com_fields', 'com_fields', 1, '2020-10-31 20:22:20'), +(6, 'com_tags', 'com_tags', 1, '2020-10-31 20:22:37'), +(7, 'com_media', 'com_media', 1, '2020-10-31 20:22:56'), +(9, 'com_plugins-com_installer', 'com_plugins (+ com_installer)', 1, '2020-10-31 20:25:17'), +(10, 'com_modules', 'com_modules', 1, '2020-10-31 20:25:32'), +(11, 'com_templates', 'com_templates', 1, '2020-10-31 20:25:50'), +(12, 'com_languages', 'com_languages', 1, '2020-10-31 20:26:10'), +(13, 'com_config', 'com_config', 1, '2020-10-31 20:26:43'), +(14, 'editors', 'Editors', 1, '2020-10-31 20:26:59'), +(15, 'com_admin-and-com_cache', 'com_admin and com_cache', 1, '2020-10-31 20:27:36'), +(16, 'com_search', 'com_search', 1, '2020-10-31 20:27:59'), +(17, 'com_finder', 'com_finder', 1, '2020-10-31 20:28:53'), +(18, 'com_redirect', 'com_redirect', 1, '2020-10-31 20:29:11'), +(19, 'com_weblinks', 'com_weblinks', 1, '2020-10-31 20:29:54'), +(20, 'com_privacy', 'com_privacy', 1, '2020-10-31 20:30:15'), +(21, 'com_actionlog', 'com_actionlog', 1, '2020-10-31 20:30:48'), +(22, 'com_login', 'com_login', 1, '2020-10-31 20:31:03'), +(23, 'com_contenthistory', 'com_contenthistory', 1, '2020-10-31 20:31:17'), +(24, 'com_contact', 'com_contact', 1, '2020-10-31 20:31:36'), +(25, 'com_checkin', 'com_checkin', 1, '2020-10-31 20:31:52'), +(26, 'com_banners', 'com_banners', 1, '2020-10-31 20:32:11'), +(27, 'com_mailto-only-frontend', 'com_mailto (only frontend)', 1, '2020-10-31 20:32:47'), +(28, 'category-filter-in-the-featured-view', 'category filter in the featured view', 1, '2020-10-31 20:33:08'), +(29, 'whitespace-characters-etc-new-users', 'whitespace characters etc new users', 1, '2020-10-31 20:33:31'), +(30, 'com_fields-sql-field', 'com_fields SQL field', 1, '2020-10-31 20:33:51'), +(31, 'beez3-and-protostar-forms,-button-groups', 'beez3 and protostar forms, button groups', 1, '2020-10-31 20:34:18'), +(32, 'template-crop-and-resize-image-functionality', 'template crop and resize image functionality', 1, '2020-10-31 20:34:37'), +(33, 'superusers-edit-templates-in-backend', 'superusers edit templates in backend', 1, '2020-10-31 20:35:04'), +(34, 'com_joomlaupdate', 'com_joomlaupdate', 1, '2020-10-31 20:35:28'), (35, 'recaptcha', 'Recaptcha', 1, '2020-10-31 20:35:46'); --- --- Dumping data for table `#__release_checking_action` --- - -INSERT INTO `#__release_checking_action` (`id`, `alias`, `context`, `description`, `name`, `published`) VALUES -(1, 'installing-joomla', 1, '', 'Installing Joomla', 1), -(2, 'adding-new-user-backend', 2, '', 'Adding new user (Backend)', 1), -(3, 'amending-user-details', 2, '', 'Amending user details', 1), -(4, 'amending-user-access-privileges', 2, '', 'Amending user access privileges', 1), -(5, 'deleting-user', 2, '', 'Deleting user', 1), -(6, 'creating-new-user-group', 2, '', 'Creating new User Group', 1), -(7, 'configuring-viewing-access-levels-for-new-user-group', 2, '', 'Configuring Viewing Access Levels for new User Group', 1), -(8, 'deleting-user-group', 2, '', 'Deleting User Group', 1), -(9, 'email-notifications', 2, '', 'Email notifications', 1), -(10, 'creating-new-menu', 3, '', 'Creating new Menu', 1), -(11, 'linking-module-to-new-menu', 3, '', 'Linking Module to new Menu', 1), -(12, 'create-new-menu-item', 3, '', 'Create new Menu Item', 1), -(13, 'deleting-menu-item', 3, '', 'Deleting Menu Item', 1), -(14, 'deleting-menu', 3, '', 'Deleting Menu', 1), -(15, 'empty-menu-trash', 3, '', 'Empty Menu Trash', 1), -(16, 'create-new-category', 4, '', 'Create new Category', 1), -(17, 'create-new-article', 4, '', 'Create new Article', 1), -(18, 'assign-category-to-article', 4, '', 'Assign category to article', 1), -(19, 'toggle-featured-status-on-article', 4, '', 'Toggle Featured status on article', 1), -(20, 'delete-category', 4, '', 'Delete category', 1), -(21, 'clear-category-trash', 4, '', 'Clear Category Trash', 1), -(22, 'delete-article', 4, '', 'Delete article', 1), -(23, 'clear-article-trash', 4, '', 'Clear Article Trash', 1), -(24, 'archive-article', 4, '', 'Archive Article', 1), -(25, 'un-archive-article', 4, '', 'Un-Archive Article', 1), -(26, 'check-versioning', 4, '', 'Check Versioning', 1), -(27, 'create-field-group', 5, '', 'Create Field Group', 1), -(28, 'create-field', 5, '', 'Create Field', 1), -(29, 'fill-in-field-in-an-article', 5, '', 'Fill-in field in an article', 1), -(30, 'delete-field', 5, '', 'Delete Field', 1), -(31, 'clear-field-trash', 5, '', 'Clear Field Trash', 1), -(32, 'delete-field-group', 5, '', 'Delete Field Group', 1), -(33, 'clear-field-group-trash', 5, '', 'Clear Field Group Trash', 1), -(34, 'create-new-tag', 6, '', 'Create new Tag', 1), -(35, 'assign-tag-to-article', 6, '', 'Assign tag to article', 1), -(36, 'remove-tag-from-article', 6, '', 'Remove tag from article', 1), -(37, 'delete-tag', 6, '', 'Delete Tag', 1), -(38, 'clear-tag-trash', 6, '', 'Clear Tag trash', 1), -(39, 'add-to-the-menu-system-and-check-tags-»-compact-list-of-tagged-i', 6, '', 'Add to the menu system and check Tags » Compact List of Tagged Items', 1), -(40, 'add-to-the-menu-system-and-check-tags-»-list-all-tags', 6, '', 'Add to the menu system and check Tags » List All Tags', 1), -(41, 'add-to-the-menu-system-and-check-tags-»-tagged-items', 6, '', 'Add to the menu system and check Tags » Tagged Items', 1), -(42, 'media-manager-back-end-changing-legal-extensions,-legal-image-ex', 7, '', 'Media Manager Back-end - Changing Legal Extensions, Legal Image Extensions, and Legal MIME Types', 1), -(43, 'media-manager-back-end-uploading-image', 7, '', 'Media Manager Back-end - Uploading image', 1), -(44, 'media-manager-back-end-deleting-image', 7, '', 'Media Manager Back-end - Deleting image', 1), -(45, 'media-manager-back-end-uploading-video', 7, '', 'Media Manager Back-end - Uploading video', 1), -(46, 'media-manager-back-end-deleting-video', 7, '', 'Media Manager Back-end - Deleting video', 1), -(47, 'media-manager-back-end-create-folder', 7, '', 'Media Manager Back-end - Create Folder', 1), -(48, 'media-manager-back-end-delete-folder', 7, '', 'Media Manager Back-end - Delete Folder', 1), -(49, 'drag-n-drop-adding-new-image-in-tiny-mce-specify-folder-in-plugi', 7, '', 'Drag\'n\'Drop adding new image in Tiny MCE (specify folder in plugin)', 1), -(50, 'install-a-component-via-browse-for-file', 1, '', 'Install a component via \"Browse for File\"', 1), -(51, 'install-a-component-via-drag-n-drop', 1, '', 'Install a component via Drag\'n\'Drop', 1), -(52, 'update-component', 1, '', 'Update component', 1), -(53, 'uninstall-a-component', 1, '', 'Uninstall a component', 1), -(54, 'install-a-plugin', 9, '', 'Install a plugin', 1), -(55, 'turn-on-plugin', 9, '', 'Turn on plugin', 1), -(56, 'update-plugin', 9, '', 'Update plugin', 1), -(57, 'turn-off-plugin', 9, '', 'Turn off plugin', 1), -(58, 'uninstall-a-plugin', 9, '', 'Uninstall a plugin', 1), -(59, 'install-module', 10, '', 'Install module', 1), -(60, 'assign-module-to-module-position', 10, '', 'Assign module to module position', 1), -(61, 'create-new-module-position', 10, '', 'Create new module position', 1), -(62, 'remove-module-from-module-position', 10, '', 'Remove module from module position', 1), -(63, 'delete-module', 10, '', 'Delete Module', 1), -(64, 'clear-module-trash', 10, '', 'Clear Module trash', 1), -(65, 'install-a-template', 11, '', 'Install a template', 1), -(66, 'turn-on-template', 11, '', 'Turn on template', 1), -(67, 'remove-template', 11, '', 'Remove template', 1), -(68, 'install-language-package', 12, '', 'Install Language Package', 1), -(69, 'uninstall-language-package', 12, '', 'Uninstall Language Package', 1), -(70, 'language-associations', 12, '', 'Language associations', 1), -(71, 'global-configuration-change-site-name', 13, '', 'Global Configuration: Change Site Name', 1), -(72, 'global-configuration-set-site-to-offline', 13, '', 'Global Configuration: Set site to Offline', 1), -(73, 'global-configuration-set-site-online', 13, '', 'Global Configuration: Set site Online', 1), -(74, 'global-configuration-configure-mail-settings,-and-send-test-mail', 13, '', 'Global Configuration: Configure Mail Settings, and send test mail', 1), -(75, 'install-new-editor-program', 14, '', 'Install new Editor program', 1), -(76, 'global-configuration-change-default-editor', 14, '', 'Global Configuration: Change Default Editor', 1), -(77, 'clear-cache', 15, '', 'Clear Cache', 1), -(78, 'clear-expire-cache', 15, '', 'Clear Expire Cache', 1), -(79, 'switch-on-statistics-gathering', 16, '', 'Switch on statistics gathering', 1), -(80, 'add-to-menu', 16, '', 'Add to menu', 1), -(81, 'switch-off-statistics-gathering', 16, '', 'Switch off statistics gathering', 1), -(82, 'switch-on-content-smart-search-plugin', 17, '', 'Switch on Content Smart search plugin', 1), -(83, 'index-content', 17, '', 'Index content', 1), -(84, 'check-search-is-working-on-the-front', 17, '', 'Check search is working on the front', 1), -(85, 'switch-off-content-smart-search-plugin', 17, '', 'Switch off Content Smart search plugin', 1), -(86, 'switch-on-redirect-plugin', 18, '', 'Switch on Redirect Plugin', 1), -(87, 'create-a-url-to-redirect', 18, '', 'create a url to redirect', 1), -(88, 'add-a-redirect-rule,-test-it-redir', 18, '', ' Add a redirect rule, test it redir', 1), -(89, 'test-the-redirect', 18, '', 'Test the redirect', 1), -(90, 'turn-redirect-off', 18, '', 'Turn redirect off', 1), -(91, 'test-it-no-longer-works', 18, '', 'Test it no longer works', 1), -(92, 'check-if-user-activities-are-logged', 21, '', 'Check if user activities are logged', 1), -(93, 'live-update-with-custom-url-for-rc', 34, '', 'Live Update (with custom URL for RC)', 1), -(94, 'upload-update-with-zip-package', 34, '', 'Upload & Update (with ZIP package)', 1), +-- +-- Dumping data for table `#__release_checking_action` +-- + +INSERT INTO `#__release_checking_action` (`id`, `alias`, `context`, `description`, `name`, `published`) VALUES +(1, 'installing-joomla', 1, '', 'Installing Joomla', 1), +(2, 'adding-new-user-backend', 2, '', 'Adding new user (Backend)', 1), +(3, 'amending-user-details', 2, '', 'Amending user details', 1), +(4, 'amending-user-access-privileges', 2, '', 'Amending user access privileges', 1), +(5, 'deleting-user', 2, '', 'Deleting user', 1), +(6, 'creating-new-user-group', 2, '', 'Creating new User Group', 1), +(7, 'configuring-viewing-access-levels-for-new-user-group', 2, '', 'Configuring Viewing Access Levels for new User Group', 1), +(8, 'deleting-user-group', 2, '', 'Deleting User Group', 1), +(9, 'email-notifications', 2, '', 'Email notifications', 1), +(10, 'creating-new-menu', 3, '', 'Creating new Menu', 1), +(11, 'linking-module-to-new-menu', 3, '', 'Linking Module to new Menu', 1), +(12, 'create-new-menu-item', 3, '', 'Create new Menu Item', 1), +(13, 'deleting-menu-item', 3, '', 'Deleting Menu Item', 1), +(14, 'deleting-menu', 3, '', 'Deleting Menu', 1), +(15, 'empty-menu-trash', 3, '', 'Empty Menu Trash', 1), +(16, 'create-new-category', 4, '', 'Create new Category', 1), +(17, 'create-new-article', 4, '', 'Create new Article', 1), +(18, 'assign-category-to-article', 4, '', 'Assign category to article', 1), +(19, 'toggle-featured-status-on-article', 4, '', 'Toggle Featured status on article', 1), +(20, 'delete-category', 4, '', 'Delete category', 1), +(21, 'clear-category-trash', 4, '', 'Clear Category Trash', 1), +(22, 'delete-article', 4, '', 'Delete article', 1), +(23, 'clear-article-trash', 4, '', 'Clear Article Trash', 1), +(24, 'archive-article', 4, '', 'Archive Article', 1), +(25, 'un-archive-article', 4, '', 'Un-Archive Article', 1), +(26, 'check-versioning', 4, '', 'Check Versioning', 1), +(27, 'create-field-group', 5, '', 'Create Field Group', 1), +(28, 'create-field', 5, '', 'Create Field', 1), +(29, 'fill-in-field-in-an-article', 5, '', 'Fill-in field in an article', 1), +(30, 'delete-field', 5, '', 'Delete Field', 1), +(31, 'clear-field-trash', 5, '', 'Clear Field Trash', 1), +(32, 'delete-field-group', 5, '', 'Delete Field Group', 1), +(33, 'clear-field-group-trash', 5, '', 'Clear Field Group Trash', 1), +(34, 'create-new-tag', 6, '', 'Create new Tag', 1), +(35, 'assign-tag-to-article', 6, '', 'Assign tag to article', 1), +(36, 'remove-tag-from-article', 6, '', 'Remove tag from article', 1), +(37, 'delete-tag', 6, '', 'Delete Tag', 1), +(38, 'clear-tag-trash', 6, '', 'Clear Tag trash', 1), +(39, 'add-to-the-menu-system-and-check-tags-»-compact-list-of-tagged-i', 6, '', 'Add to the menu system and check Tags » Compact List of Tagged Items', 1), +(40, 'add-to-the-menu-system-and-check-tags-»-list-all-tags', 6, '', 'Add to the menu system and check Tags » List All Tags', 1), +(41, 'add-to-the-menu-system-and-check-tags-»-tagged-items', 6, '', 'Add to the menu system and check Tags » Tagged Items', 1), +(42, 'media-manager-back-end-changing-legal-extensions,-legal-image-ex', 7, '', 'Media Manager Back-end - Changing Legal Extensions, Legal Image Extensions, and Legal MIME Types', 1), +(43, 'media-manager-back-end-uploading-image', 7, '', 'Media Manager Back-end - Uploading image', 1), +(44, 'media-manager-back-end-deleting-image', 7, '', 'Media Manager Back-end - Deleting image', 1), +(45, 'media-manager-back-end-uploading-video', 7, '', 'Media Manager Back-end - Uploading video', 1), +(46, 'media-manager-back-end-deleting-video', 7, '', 'Media Manager Back-end - Deleting video', 1), +(47, 'media-manager-back-end-create-folder', 7, '', 'Media Manager Back-end - Create Folder', 1), +(48, 'media-manager-back-end-delete-folder', 7, '', 'Media Manager Back-end - Delete Folder', 1), +(49, 'drag-n-drop-adding-new-image-in-tiny-mce-specify-folder-in-plugi', 7, '', 'Drag\'n\'Drop adding new image in Tiny MCE (specify folder in plugin)', 1), +(50, 'install-a-component-via-browse-for-file', 1, '', 'Install a component via \"Browse for File\"', 1), +(51, 'install-a-component-via-drag-n-drop', 1, '', 'Install a component via Drag\'n\'Drop', 1), +(52, 'update-component', 1, '', 'Update component', 1), +(53, 'uninstall-a-component', 1, '', 'Uninstall a component', 1), +(54, 'install-a-plugin', 9, '', 'Install a plugin', 1), +(55, 'turn-on-plugin', 9, '', 'Turn on plugin', 1), +(56, 'update-plugin', 9, '', 'Update plugin', 1), +(57, 'turn-off-plugin', 9, '', 'Turn off plugin', 1), +(58, 'uninstall-a-plugin', 9, '', 'Uninstall a plugin', 1), +(59, 'install-module', 10, '', 'Install module', 1), +(60, 'assign-module-to-module-position', 10, '', 'Assign module to module position', 1), +(61, 'create-new-module-position', 10, '', 'Create new module position', 1), +(62, 'remove-module-from-module-position', 10, '', 'Remove module from module position', 1), +(63, 'delete-module', 10, '', 'Delete Module', 1), +(64, 'clear-module-trash', 10, '', 'Clear Module trash', 1), +(65, 'install-a-template', 11, '', 'Install a template', 1), +(66, 'turn-on-template', 11, '', 'Turn on template', 1), +(67, 'remove-template', 11, '', 'Remove template', 1), +(68, 'install-language-package', 12, '', 'Install Language Package', 1), +(69, 'uninstall-language-package', 12, '', 'Uninstall Language Package', 1), +(70, 'language-associations', 12, '', 'Language associations', 1), +(71, 'global-configuration-change-site-name', 13, '', 'Global Configuration: Change Site Name', 1), +(72, 'global-configuration-set-site-to-offline', 13, '', 'Global Configuration: Set site to Offline', 1), +(73, 'global-configuration-set-site-online', 13, '', 'Global Configuration: Set site Online', 1), +(74, 'global-configuration-configure-mail-settings,-and-send-test-mail', 13, '', 'Global Configuration: Configure Mail Settings, and send test mail', 1), +(75, 'install-new-editor-program', 14, '', 'Install new Editor program', 1), +(76, 'global-configuration-change-default-editor', 14, '', 'Global Configuration: Change Default Editor', 1), +(77, 'clear-cache', 15, '', 'Clear Cache', 1), +(78, 'clear-expire-cache', 15, '', 'Clear Expire Cache', 1), +(79, 'switch-on-statistics-gathering', 16, '', 'Switch on statistics gathering', 1), +(80, 'add-to-menu', 16, '', 'Add to menu', 1), +(81, 'switch-off-statistics-gathering', 16, '', 'Switch off statistics gathering', 1), +(82, 'switch-on-content-smart-search-plugin', 17, '', 'Switch on Content Smart search plugin', 1), +(83, 'index-content', 17, '', 'Index content', 1), +(84, 'check-search-is-working-on-the-front', 17, '', 'Check search is working on the front', 1), +(85, 'switch-off-content-smart-search-plugin', 17, '', 'Switch off Content Smart search plugin', 1), +(86, 'switch-on-redirect-plugin', 18, '', 'Switch on Redirect Plugin', 1), +(87, 'create-a-url-to-redirect', 18, '', 'create a url to redirect', 1), +(88, 'add-a-redirect-rule,-test-it-redir', 18, '', ' Add a redirect rule, test it redir', 1), +(89, 'test-the-redirect', 18, '', 'Test the redirect', 1), +(90, 'turn-redirect-off', 18, '', 'Turn redirect off', 1), +(91, 'test-it-no-longer-works', 18, '', 'Test it no longer works', 1), +(92, 'check-if-user-activities-are-logged', 21, '', 'Check if user activities are logged', 1), +(93, 'live-update-with-custom-url-for-rc', 34, '', 'Live Update (with custom URL for RC)', 1), +(94, 'upload-update-with-zip-package', 34, '', 'Upload & Update (with ZIP package)', 1), (95, 'make-sure-google-recaptcha-still-works', 35, '', 'Make sure Google recaptcha still works', 1); - --- --- Always insure this column rules is large enough for all the access control values. --- -ALTER TABLE `#__assets` CHANGE `rules` `rules` TEXT NOT NULL COMMENT 'JSON encoded access control.'; diff --git a/admin/sql/uninstall.mysql.utf8.sql b/admin/sql/uninstall.mysql.utf8.sql index c582b85..b56a1ab 100644 --- a/admin/sql/uninstall.mysql.utf8.sql +++ b/admin/sql/uninstall.mysql.utf8.sql @@ -3,8 +3,3 @@ DROP TABLE IF EXISTS `#__release_checking_joomla_version`; DROP TABLE IF EXISTS `#__release_checking_context`; DROP TABLE IF EXISTS `#__release_checking_action`; - --- --- Always insure this column rules is reversed to Joomla defaults on uninstall. (as on 1st Dec 2020) --- -ALTER TABLE `#__assets` CHANGE `rules` `rules` varchar(5120) NOT NULL COMMENT 'JSON encoded access control.'; diff --git a/admin/sql/updates/mysql/1.0.0.sql b/admin/sql/updates/mysql/1.0.0.sql index d3f5a12..8b13789 100644 --- a/admin/sql/updates/mysql/1.0.0.sql +++ b/admin/sql/updates/mysql/1.0.0.sql @@ -1 +1 @@ - + diff --git a/admin/tables/action.php b/admin/tables/action.php index b34f2ef..26349d4 100644 --- a/admin/tables/action.php +++ b/admin/tables/action.php @@ -5,307 +5,307 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Actions Table class - */ -class Release_checkingTableAction extends JTable -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; + +/** + * Actions Table class + */ +class Release_checkingTableAction extends JTable +{ + /** + * Ensure the params and metadata in json encoded in the bind method + * + * @var array + * @since 3.3 + */ + protected $_jsonEncode = array('params', 'metadata'); + + /** + * Constructor + * + * @param object Database connector object + */ + function __construct(&$db) + { parent::__construct('#__release_checking_action', 'id', $db); // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_release_checking.action')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Action table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New action. A action created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('action', 'Release_checkingTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_RELEASE_CHECKING_ACTION_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('action', 'release_checkingTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_release_checking.action.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_release_checking.action.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_release_checking'); - - return $asset->id; + JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_release_checking.action')); + } + + public function bind($array, $ignore = '') + { + + if (isset($array['params']) && is_array($array['params'])) + { + $registry = new JRegistry; + $registry->loadArray($array['params']); + $array['params'] = (string) $registry; + } + + if (isset($array['metadata']) && is_array($array['metadata'])) + { + $registry = new JRegistry; + $registry->loadArray($array['metadata']); + $array['metadata'] = (string) $registry; + } + + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new JAccessRules($array['rules']); + $this->setRules($rules); + } + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Action table. + * + * @param boolean Toggle whether null values should be updated. + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + if ($this->id) + { + // Existing item + $this->modified = $date->toSql(); + $this->modified_by = $user->get('id'); + } + else + { + // New action. A action created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date->toSql(); + } + if (empty($this->created_by)) + { + $this->created_by = $user->get('id'); + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = JTable::getInstance('action', 'Release_checkingTable'); + + if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(JText::_('COM_RELEASE_CHECKING_ACTION_ERROR_UNIQUE_ALIAS')); + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = JStringPunycode::urlToPunycode($this->url); + } + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = JStringPunycode::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + */ + public function check() + { + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = JTable::getInstance('action', 'release_checkingTable'); + + while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = array(); + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty JAccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_release_checking.action.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return JAccessRules The JAccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof JAccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = array(); + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the JAccessRules object for the asset rules. + $rules = new JAccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return JAccess::getAssetRules(0); + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form 'table_name.id' + * where id is the value of the primary key of the table. + * + * @return string + * @since 2.5 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + return 'com_release_checking.action.'.(int) $this->$k; + } + + /** + * Method to return the title to use for the asset table. + * + * @return string + * @since 2.5 + */ + protected function _getAssetTitle() + { + if (isset($this->title)) + { + return $this->title; + } + return ''; + } + + /** + * Get the parent asset id for the record + * + * @return int + * @since 2.5 + */ + protected function _getAssetParentId(JTable $table = NULL, $id = NULL) + { + $asset = JTable::getInstance('Asset'); + $asset->loadByName('com_release_checking'); + + return $asset->id; } /** @@ -329,6 +329,6 @@ class Release_checkingTableAction extends JTable } return $this->alias; - } - -} + } + +} diff --git a/admin/tables/context.php b/admin/tables/context.php index 9b93120..999d557 100644 --- a/admin/tables/context.php +++ b/admin/tables/context.php @@ -5,307 +5,307 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Contexts Table class - */ -class Release_checkingTableContext extends JTable -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; + +/** + * Contexts Table class + */ +class Release_checkingTableContext extends JTable +{ + /** + * Ensure the params and metadata in json encoded in the bind method + * + * @var array + * @since 3.3 + */ + protected $_jsonEncode = array('params', 'metadata'); + + /** + * Constructor + * + * @param object Database connector object + */ + function __construct(&$db) + { parent::__construct('#__release_checking_context', 'id', $db); // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_release_checking.context')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Context table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New context. A context created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('context', 'Release_checkingTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_RELEASE_CHECKING_CONTEXT_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('context', 'release_checkingTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_release_checking.context.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_release_checking.context.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_release_checking'); - - return $asset->id; + JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_release_checking.context')); + } + + public function bind($array, $ignore = '') + { + + if (isset($array['params']) && is_array($array['params'])) + { + $registry = new JRegistry; + $registry->loadArray($array['params']); + $array['params'] = (string) $registry; + } + + if (isset($array['metadata']) && is_array($array['metadata'])) + { + $registry = new JRegistry; + $registry->loadArray($array['metadata']); + $array['metadata'] = (string) $registry; + } + + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new JAccessRules($array['rules']); + $this->setRules($rules); + } + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Context table. + * + * @param boolean Toggle whether null values should be updated. + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + if ($this->id) + { + // Existing item + $this->modified = $date->toSql(); + $this->modified_by = $user->get('id'); + } + else + { + // New context. A context created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date->toSql(); + } + if (empty($this->created_by)) + { + $this->created_by = $user->get('id'); + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = JTable::getInstance('context', 'Release_checkingTable'); + + if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(JText::_('COM_RELEASE_CHECKING_CONTEXT_ERROR_UNIQUE_ALIAS')); + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = JStringPunycode::urlToPunycode($this->url); + } + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = JStringPunycode::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + */ + public function check() + { + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = JTable::getInstance('context', 'release_checkingTable'); + + while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = array(); + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty JAccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_release_checking.context.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return JAccessRules The JAccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof JAccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = array(); + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the JAccessRules object for the asset rules. + $rules = new JAccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return JAccess::getAssetRules(0); + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form 'table_name.id' + * where id is the value of the primary key of the table. + * + * @return string + * @since 2.5 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + return 'com_release_checking.context.'.(int) $this->$k; + } + + /** + * Method to return the title to use for the asset table. + * + * @return string + * @since 2.5 + */ + protected function _getAssetTitle() + { + if (isset($this->title)) + { + return $this->title; + } + return ''; + } + + /** + * Get the parent asset id for the record + * + * @return int + * @since 2.5 + */ + protected function _getAssetParentId(JTable $table = NULL, $id = NULL) + { + $asset = JTable::getInstance('Asset'); + $asset->loadByName('com_release_checking'); + + return $asset->id; } /** @@ -329,6 +329,6 @@ class Release_checkingTableContext extends JTable } return $this->alias; - } - -} + } + +} diff --git a/admin/tables/joomla_version.php b/admin/tables/joomla_version.php index 3068b5b..a4c088c 100644 --- a/admin/tables/joomla_version.php +++ b/admin/tables/joomla_version.php @@ -5,307 +5,307 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Joomla_versions Table class - */ -class Release_checkingTableJoomla_version extends JTable -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; + +/** + * Joomla_versions Table class + */ +class Release_checkingTableJoomla_version extends JTable +{ + /** + * Ensure the params and metadata in json encoded in the bind method + * + * @var array + * @since 3.3 + */ + protected $_jsonEncode = array('params', 'metadata'); + + /** + * Constructor + * + * @param object Database connector object + */ + function __construct(&$db) + { parent::__construct('#__release_checking_joomla_version', 'id', $db); // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_release_checking.joomla_version')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Joomla_version table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New joomla_version. A joomla_version created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('joomla_version', 'Release_checkingTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_RELEASE_CHECKING_JOOMLA_VERSION_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('joomla_version', 'release_checkingTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_release_checking.joomla_version.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_release_checking.joomla_version.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_release_checking'); - - return $asset->id; + JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_release_checking.joomla_version')); + } + + public function bind($array, $ignore = '') + { + + if (isset($array['params']) && is_array($array['params'])) + { + $registry = new JRegistry; + $registry->loadArray($array['params']); + $array['params'] = (string) $registry; + } + + if (isset($array['metadata']) && is_array($array['metadata'])) + { + $registry = new JRegistry; + $registry->loadArray($array['metadata']); + $array['metadata'] = (string) $registry; + } + + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new JAccessRules($array['rules']); + $this->setRules($rules); + } + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Joomla_version table. + * + * @param boolean Toggle whether null values should be updated. + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + if ($this->id) + { + // Existing item + $this->modified = $date->toSql(); + $this->modified_by = $user->get('id'); + } + else + { + // New joomla_version. A joomla_version created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date->toSql(); + } + if (empty($this->created_by)) + { + $this->created_by = $user->get('id'); + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = JTable::getInstance('joomla_version', 'Release_checkingTable'); + + if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(JText::_('COM_RELEASE_CHECKING_JOOMLA_VERSION_ERROR_UNIQUE_ALIAS')); + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = JStringPunycode::urlToPunycode($this->url); + } + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = JStringPunycode::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + */ + public function check() + { + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = JTable::getInstance('joomla_version', 'release_checkingTable'); + + while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = array(); + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty JAccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_release_checking.joomla_version.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return JAccessRules The JAccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof JAccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = array(); + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the JAccessRules object for the asset rules. + $rules = new JAccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return JAccess::getAssetRules(0); + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form 'table_name.id' + * where id is the value of the primary key of the table. + * + * @return string + * @since 2.5 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + return 'com_release_checking.joomla_version.'.(int) $this->$k; + } + + /** + * Method to return the title to use for the asset table. + * + * @return string + * @since 2.5 + */ + protected function _getAssetTitle() + { + if (isset($this->title)) + { + return $this->title; + } + return ''; + } + + /** + * Get the parent asset id for the record + * + * @return int + * @since 2.5 + */ + protected function _getAssetParentId(JTable $table = NULL, $id = NULL) + { + $asset = JTable::getInstance('Asset'); + $asset->loadByName('com_release_checking'); + + return $asset->id; } /** @@ -329,6 +329,6 @@ class Release_checkingTableJoomla_version extends JTable } return $this->alias; - } - -} + } + +} diff --git a/admin/tables/release_check.php b/admin/tables/release_check.php index bb3e0a1..99a6bb7 100644 --- a/admin/tables/release_check.php +++ b/admin/tables/release_check.php @@ -5,307 +5,307 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Release_checks Table class - */ -class Release_checkingTableRelease_check extends JTable -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; + +/** + * Release_checks Table class + */ +class Release_checkingTableRelease_check extends JTable +{ + /** + * Ensure the params and metadata in json encoded in the bind method + * + * @var array + * @since 3.3 + */ + protected $_jsonEncode = array('params', 'metadata'); + + /** + * Constructor + * + * @param object Database connector object + */ + function __construct(&$db) + { parent::__construct('#__release_checking_release_check', 'id', $db); // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_release_checking.release_check')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Release_check table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New release_check. A release_check created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('release_check', 'Release_checkingTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_RELEASE_CHECKING_RELEASE_CHECK_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('release_check', 'release_checkingTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_release_checking.release_check.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_release_checking.release_check.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_release_checking'); - - return $asset->id; + JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_release_checking.release_check')); + } + + public function bind($array, $ignore = '') + { + + if (isset($array['params']) && is_array($array['params'])) + { + $registry = new JRegistry; + $registry->loadArray($array['params']); + $array['params'] = (string) $registry; + } + + if (isset($array['metadata']) && is_array($array['metadata'])) + { + $registry = new JRegistry; + $registry->loadArray($array['metadata']); + $array['metadata'] = (string) $registry; + } + + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new JAccessRules($array['rules']); + $this->setRules($rules); + } + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Release_check table. + * + * @param boolean Toggle whether null values should be updated. + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + if ($this->id) + { + // Existing item + $this->modified = $date->toSql(); + $this->modified_by = $user->get('id'); + } + else + { + // New release_check. A release_check created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date->toSql(); + } + if (empty($this->created_by)) + { + $this->created_by = $user->get('id'); + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = JTable::getInstance('release_check', 'Release_checkingTable'); + + if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(JText::_('COM_RELEASE_CHECKING_RELEASE_CHECK_ERROR_UNIQUE_ALIAS')); + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = JStringPunycode::urlToPunycode($this->url); + } + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = JStringPunycode::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + */ + public function check() + { + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = JTable::getInstance('release_check', 'release_checkingTable'); + + while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = array(); + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty JAccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_release_checking.release_check.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return JAccessRules The JAccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof JAccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = array(); + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the JAccessRules object for the asset rules. + $rules = new JAccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return JAccess::getAssetRules(0); + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form 'table_name.id' + * where id is the value of the primary key of the table. + * + * @return string + * @since 2.5 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + return 'com_release_checking.release_check.'.(int) $this->$k; + } + + /** + * Method to return the title to use for the asset table. + * + * @return string + * @since 2.5 + */ + protected function _getAssetTitle() + { + if (isset($this->title)) + { + return $this->title; + } + return ''; + } + + /** + * Get the parent asset id for the record + * + * @return int + * @since 2.5 + */ + protected function _getAssetParentId(JTable $table = NULL, $id = NULL) + { + $asset = JTable::getInstance('Asset'); + $asset->loadByName('com_release_checking'); + + return $asset->id; } /** @@ -316,6 +316,6 @@ class Release_checkingTableRelease_check extends JTable public function generateAlias() { return false; - } - -} + } + +} diff --git a/admin/views/action/submitbutton.js b/admin/views/action/submitbutton.js index 7a09178..3333252 100644 --- a/admin/views/action/submitbutton.js +++ b/admin/views/action/submitbutton.js @@ -4,20 +4,20 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('action, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } + */ + +Joomla.submitbutton = function(task) +{ + if (task == ''){ + return false; + } else { + var action = task.split('.'); + if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ + Joomla.submitform(task, document.getElementById("adminForm")); + return true; + } else { + alert(Joomla.JText._('action, some values are not acceptable.','Some values are unacceptable')); + return false; + } + } } \ No newline at end of file diff --git a/admin/views/action/tmpl/edit.php b/admin/views/action/tmpl/edit.php index 96adad7..54da30a 100644 --- a/admin/views/action/tmpl/edit.php +++ b/admin/views/action/tmpl/edit.php @@ -5,18 +5,18 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); JHtml::_('behavior.tooltip'); JHtml::_('behavior.formvalidation'); JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> +JHtml::_('behavior.keepalive'); +$componentParams = $this->params; // will be removed just use $this->params instead +?> - + + + diff --git a/admin/views/action/view.html.php b/admin/views/action/view.html.php index 91b740a..f5b97e2 100644 --- a/admin/views/action/view.html.php +++ b/admin/views/action/view.html.php @@ -5,77 +5,77 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -/** - * Action View class - */ -class Release_checkingViewAction extends JViewLegacy -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_release_checking'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = Release_checkingHelper::getActions('action', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +/** + * Action View class + */ +class Release_checkingViewAction extends JViewLegacy +{ + /** + * display method of View + * @return void + */ + public function display($tpl = null) + { + // set params + $this->params = JComponentHelper::getParams('com_release_checking'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->script = $this->get('Script'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = Release_checkingHelper::getActions('action', $this->item); + // get input + $jinput = JFactory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string)$this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string)$return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + + /** + * Setting the toolbar + */ + protected function addToolBar() + { JFactory::getApplication()->input->set('hidemainmenu', true); $user = JFactory::getUser(); $userId = $user->id; @@ -151,43 +151,43 @@ class Release_checkingViewAction extends JViewLegacy if (Release_checkingHelper::checkString($help_url)) { JToolbarHelper::help('COM_RELEASE_CHECKING_HELP_MANAGER', false, $help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return Release_checkingHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return Release_checkingHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_RELEASE_CHECKING_ACTION_NEW' : 'COM_RELEASE_CHECKING_ACTION_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_release_checking/assets/css/action.css", (Release_checkingHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addScript(JURI::root() . $this->script, (Release_checkingHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_release_checking/views/action/submitbutton.js", (Release_checkingHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - JText::script('view not acceptable. Error'); - } -} + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 30) + { + // use the helper htmlEscape method instead and shorten the string + return Release_checkingHelper::htmlEscape($var, $this->_charset, true, 30); + } + // use the helper htmlEscape method instead. + return Release_checkingHelper::htmlEscape($var, $this->_charset); + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + $isNew = ($this->item->id < 1); + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_($isNew ? 'COM_RELEASE_CHECKING_ACTION_NEW' : 'COM_RELEASE_CHECKING_ACTION_EDIT')); + $this->document->addStyleSheet(JURI::root() . "administrator/components/com_release_checking/assets/css/action.css", (Release_checkingHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + $this->document->addScript(JURI::root() . $this->script, (Release_checkingHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + $this->document->addScript(JURI::root() . "administrator/components/com_release_checking/views/action/submitbutton.js", (Release_checkingHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + JText::script('view not acceptable. Error'); + } +} diff --git a/admin/views/actions/tmpl/default.php b/admin/views/actions/tmpl/default.php index 0f0fc91..2fa9468 100644 --- a/admin/views/actions/tmpl/default.php +++ b/admin/views/actions/tmpl/default.php @@ -5,22 +5,22 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + JHtml::_('behavior.tooltip'); JHtml::_('behavior.multiselect'); JHtml::_('dropdown.init'); JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_RELEASE_CHECKING_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_release_checking&task=actions.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'actionList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> +JHtml::_('formbehavior.chosen', 'select'); +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_release_checking&task=actions.saveOrderAjax&tmpl=component'; + JHtml::_('sortablelist.sortable', 'actionList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?>
sidebar)): ?>
@@ -61,4 +61,4 @@ if ($this->saveOrder) - + diff --git a/admin/views/actions/tmpl/default_batch_body.php b/admin/views/actions/tmpl/default_batch_body.php index d845b97..3a37889 100644 --- a/admin/views/actions/tmpl/default_batch_body.php +++ b/admin/views/actions/tmpl/default_batch_body.php @@ -5,12 +5,12 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

+ */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + +

batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/actions/tmpl/default_batch_footer.php b/admin/views/actions/tmpl/default_batch_footer.php index 47e2519..0407513 100644 --- a/admin/views/actions/tmpl/default_batch_footer.php +++ b/admin/views/actions/tmpl/default_batch_footer.php @@ -5,17 +5,17 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - + + \ No newline at end of file diff --git a/admin/views/actions/tmpl/default_body.php b/admin/views/actions/tmpl/default_body.php index fe021de..ec59794 100644 --- a/admin/views/actions/tmpl/default_body.php +++ b/admin/views/actions/tmpl/default_body.php @@ -5,14 +5,14 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_release_checking&view=actions&task=action.edit"; - -?> + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +$edit = "index.php?option=com_release_checking&view=actions&task=action.edit"; + +?> items as $i => $item): ?> user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; diff --git a/admin/views/actions/tmpl/default_foot.php b/admin/views/actions/tmpl/default_foot.php index 5f618ae..ed2b0aa 100644 --- a/admin/views/actions/tmpl/default_foot.php +++ b/admin/views/actions/tmpl/default_foot.php @@ -5,12 +5,12 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + pagination->getListFooter(); ?> \ No newline at end of file diff --git a/admin/views/actions/tmpl/default_head.php b/admin/views/actions/tmpl/default_head.php index 07dd4cb..5aa0316 100644 --- a/admin/views/actions/tmpl/default_head.php +++ b/admin/views/actions/tmpl/default_head.php @@ -5,12 +5,12 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> canEdit&& $this->canState): ?> diff --git a/admin/views/actions/tmpl/default_toolbar.php b/admin/views/actions/tmpl/default_toolbar.php index 5a0cc12..fd1244f 100644 --- a/admin/views/actions/tmpl/default_toolbar.php +++ b/admin/views/actions/tmpl/default_toolbar.php @@ -5,39 +5,39 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
- -
- - -
-
- - pagination->getLimitBox(); ?> -
-
- - -
-
- - -
-
+ */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
+ +
+ + +
+
+ + pagination->getLimitBox(); ?> +
+
+ + +
+
+ + +
+
\ No newline at end of file diff --git a/admin/views/actions/view.html.php b/admin/views/actions/view.html.php index a183ad2..2fcb0a3 100644 --- a/admin/views/actions/view.html.php +++ b/admin/views/actions/view.html.php @@ -5,32 +5,32 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -/** - * Release_checking View class for the Actions - */ -class Release_checkingViewActions extends JViewLegacy -{ - /** - * Actions view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - Release_checkingHelper::addSubmenu('actions'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +/** + * Release_checking View class for the Actions + */ +class Release_checkingViewActions extends JViewLegacy +{ + /** + * Actions view display method + * @return void + */ + function display($tpl = null) + { + if ($this->getLayout() !== 'modal') + { + // Include helper submenu + Release_checkingHelper::addSubmenu('actions'); + } + + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); $this->user = JFactory::getUser(); // Load the filter form from xml. $this->filterForm = $this->get('FilterForm'); @@ -38,122 +38,122 @@ class Release_checkingViewActions extends JViewLegacy $this->activeFilters = $this->get('ActiveFilters'); // Add the list ordering clause. $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions + $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); + // get global action permissions $this->canDo = Release_checkingHelper::getActions('action'); $this->canEdit = $this->canDo->get('core.edit'); $this->canState = $this->canDo->get('core.edit.state'); $this->canCreate = $this->canDo->get('core.create'); $this->canDelete = $this->canDo->get('core.delete'); - $this->canBatch = $this->canDo->get('core.batch'); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_RELEASE_CHECKING_ACTIONS'), 'joomla'); - JHtmlSidebar::setAction('index.php?option=com_release_checking&view=actions'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('action.add'); - } - - // Only load if there are items - if (Release_checkingHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('action.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('actions.publish'); - JToolBarHelper::unpublishList('actions.unpublish'); - JToolBarHelper::archiveList('actions.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('actions.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'actions.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('actions.trash'); + $this->canBatch = $this->canDo->get('core.batch'); + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + $this->sidebar = JHtmlSidebar::render(); + // load the batch html + if ($this->canCreate && $this->canEdit && $this->canState) + { + $this->batchDisplay = JHtmlBatch_::render(); + } + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + JToolBarHelper::title(JText::_('COM_RELEASE_CHECKING_ACTIONS'), 'joomla'); + JHtmlSidebar::setAction('index.php?option=com_release_checking&view=actions'); + JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); + + if ($this->canCreate) + { + JToolBarHelper::addNew('action.add'); + } + + // Only load if there are items + if (Release_checkingHelper::checkArray($this->items)) + { + if ($this->canEdit) + { + JToolBarHelper::editList('action.edit'); + } + + if ($this->canState) + { + JToolBarHelper::publishList('actions.publish'); + JToolBarHelper::unpublishList('actions.unpublish'); + JToolBarHelper::archiveList('actions.archive'); + + if ($this->canDo->get('core.admin')) + { + JToolBarHelper::checkin('actions.checkin'); + } + } + + // Add a batch button + if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) + { + // Get the toolbar object instance + $bar = JToolBar::getInstance('toolbar'); + // set the batch button name + $title = JText::_('JTOOLBAR_BATCH'); + // Instantiate a new JLayoutFile instance and render the batch button + $layout = new JLayoutFile('joomla.toolbar.batch'); + // add the button to the page + $dhtml = $layout->render(array('title' => $title)); + $bar->appendButton('Custom', $dhtml, 'batch'); + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + JToolbarHelper::deleteList('', 'actions.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + JToolbarHelper::trash('actions.trash'); } if ($this->canDo->get('core.export') && $this->canDo->get('action.export')) { JToolBarHelper::custom('actions.exportData', 'download', '', 'COM_RELEASE_CHECKING_EXPORT_DATA', true); - } + } } if ($this->canDo->get('core.import') && $this->canDo->get('action.import')) { JToolBarHelper::custom('actions.importData', 'upload', '', 'COM_RELEASE_CHECKING_IMPORT_DATA', false); - } - - // set help url for this view if found - $help_url = Release_checkingHelper::getHelpUrl('actions'); - if (Release_checkingHelper::checkString($help_url)) - { - JToolbarHelper::help('COM_RELEASE_CHECKING_HELP_MANAGER', false, $help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_release_checking'); + } + + // set help url for this view if found + $help_url = Release_checkingHelper::getHelpUrl('actions'); + if (Release_checkingHelper::checkString($help_url)) + { + JToolbarHelper::help('COM_RELEASE_CHECKING_HELP_MANAGER', false, $help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + JToolBarHelper::preferences('com_release_checking'); } // Only load published batch if state and batch is allowed @@ -194,55 +194,55 @@ class Release_checkingViewActions extends JViewLegacy 'batch[name]', JHtml::_('select.options', $this->nameOptions, 'value', 'text') ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_RELEASE_CHECKING_ACTIONS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_release_checking/assets/css/actions.css", (Release_checkingHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return Release_checkingHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return Release_checkingHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { + } + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_('COM_RELEASE_CHECKING_ACTIONS')); + $this->document->addStyleSheet(JURI::root() . "administrator/components/com_release_checking/assets/css/actions.css", (Release_checkingHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 50) + { + // use the helper htmlEscape method instead and shorten the string + return Release_checkingHelper::htmlEscape($var, $this->_charset, true); + } + // use the helper htmlEscape method instead. + return Release_checkingHelper::htmlEscape($var, $this->_charset); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array Array containing the field name to sort by as the key and display text as value + */ + protected function getSortFields() + { return array( 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), 'a.published' => JText::_('JSTATUS'), 'a.name' => JText::_('COM_RELEASE_CHECKING_ACTION_NAME_LABEL'), 'g.name' => JText::_('COM_RELEASE_CHECKING_ACTION_CONTEXT_LABEL'), 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} + ); + } +} diff --git a/admin/views/context/submitbutton.js b/admin/views/context/submitbutton.js index 5c44ef8..47f9f6f 100644 --- a/admin/views/context/submitbutton.js +++ b/admin/views/context/submitbutton.js @@ -4,20 +4,20 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('context, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } + */ + +Joomla.submitbutton = function(task) +{ + if (task == ''){ + return false; + } else { + var action = task.split('.'); + if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ + Joomla.submitform(task, document.getElementById("adminForm")); + return true; + } else { + alert(Joomla.JText._('context, some values are not acceptable.','Some values are unacceptable')); + return false; + } + } } \ No newline at end of file diff --git a/admin/views/context/tmpl/edit.php b/admin/views/context/tmpl/edit.php index 5ac045d..ff61b75 100644 --- a/admin/views/context/tmpl/edit.php +++ b/admin/views/context/tmpl/edit.php @@ -5,18 +5,18 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); JHtml::_('behavior.tooltip'); JHtml::_('behavior.formvalidation'); JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> +JHtml::_('behavior.keepalive'); +$componentParams = $this->params; // will be removed just use $this->params instead +?> - +
+ + diff --git a/admin/views/context/view.html.php b/admin/views/context/view.html.php index 29b768e..8a09053 100644 --- a/admin/views/context/view.html.php +++ b/admin/views/context/view.html.php @@ -5,77 +5,77 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -/** - * Context View class - */ -class Release_checkingViewContext extends JViewLegacy -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_release_checking'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = Release_checkingHelper::getActions('context', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +/** + * Context View class + */ +class Release_checkingViewContext extends JViewLegacy +{ + /** + * display method of View + * @return void + */ + public function display($tpl = null) + { + // set params + $this->params = JComponentHelper::getParams('com_release_checking'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->script = $this->get('Script'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = Release_checkingHelper::getActions('context', $this->item); + // get input + $jinput = JFactory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string)$this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string)$return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + + /** + * Setting the toolbar + */ + protected function addToolBar() + { JFactory::getApplication()->input->set('hidemainmenu', true); $user = JFactory::getUser(); $userId = $user->id; @@ -151,43 +151,43 @@ class Release_checkingViewContext extends JViewLegacy if (Release_checkingHelper::checkString($help_url)) { JToolbarHelper::help('COM_RELEASE_CHECKING_HELP_MANAGER', false, $help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return Release_checkingHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return Release_checkingHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_RELEASE_CHECKING_CONTEXT_NEW' : 'COM_RELEASE_CHECKING_CONTEXT_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_release_checking/assets/css/context.css", (Release_checkingHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addScript(JURI::root() . $this->script, (Release_checkingHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_release_checking/views/context/submitbutton.js", (Release_checkingHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - JText::script('view not acceptable. Error'); - } -} + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 30) + { + // use the helper htmlEscape method instead and shorten the string + return Release_checkingHelper::htmlEscape($var, $this->_charset, true, 30); + } + // use the helper htmlEscape method instead. + return Release_checkingHelper::htmlEscape($var, $this->_charset); + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + $isNew = ($this->item->id < 1); + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_($isNew ? 'COM_RELEASE_CHECKING_CONTEXT_NEW' : 'COM_RELEASE_CHECKING_CONTEXT_EDIT')); + $this->document->addStyleSheet(JURI::root() . "administrator/components/com_release_checking/assets/css/context.css", (Release_checkingHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + $this->document->addScript(JURI::root() . $this->script, (Release_checkingHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + $this->document->addScript(JURI::root() . "administrator/components/com_release_checking/views/context/submitbutton.js", (Release_checkingHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + JText::script('view not acceptable. Error'); + } +} diff --git a/admin/views/contexts/tmpl/default.php b/admin/views/contexts/tmpl/default.php index 5e0af44..5cae2a4 100644 --- a/admin/views/contexts/tmpl/default.php +++ b/admin/views/contexts/tmpl/default.php @@ -5,22 +5,22 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + JHtml::_('behavior.tooltip'); JHtml::_('behavior.multiselect'); JHtml::_('dropdown.init'); JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_RELEASE_CHECKING_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_release_checking&task=contexts.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'contextList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> +JHtml::_('formbehavior.chosen', 'select'); +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_release_checking&task=contexts.saveOrderAjax&tmpl=component'; + JHtml::_('sortablelist.sortable', 'contextList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?>
sidebar)): ?>
@@ -61,4 +61,4 @@ if ($this->saveOrder) - + diff --git a/admin/views/contexts/tmpl/default_batch_body.php b/admin/views/contexts/tmpl/default_batch_body.php index e7c3054..10d73c1 100644 --- a/admin/views/contexts/tmpl/default_batch_body.php +++ b/admin/views/contexts/tmpl/default_batch_body.php @@ -5,12 +5,12 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

+ */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + +

batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/contexts/tmpl/default_batch_footer.php b/admin/views/contexts/tmpl/default_batch_footer.php index 776f4c9..3f08c23 100644 --- a/admin/views/contexts/tmpl/default_batch_footer.php +++ b/admin/views/contexts/tmpl/default_batch_footer.php @@ -5,17 +5,17 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - + + \ No newline at end of file diff --git a/admin/views/contexts/tmpl/default_body.php b/admin/views/contexts/tmpl/default_body.php index 422331d..09f0239 100644 --- a/admin/views/contexts/tmpl/default_body.php +++ b/admin/views/contexts/tmpl/default_body.php @@ -5,14 +5,14 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_release_checking&view=contexts&task=context.edit"; - -?> + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +$edit = "index.php?option=com_release_checking&view=contexts&task=context.edit"; + +?> items as $i => $item): ?> user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; diff --git a/admin/views/contexts/tmpl/default_foot.php b/admin/views/contexts/tmpl/default_foot.php index 9feff4a..9e31250 100644 --- a/admin/views/contexts/tmpl/default_foot.php +++ b/admin/views/contexts/tmpl/default_foot.php @@ -5,12 +5,12 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + pagination->getListFooter(); ?> \ No newline at end of file diff --git a/admin/views/contexts/tmpl/default_head.php b/admin/views/contexts/tmpl/default_head.php index 6ffef1f..3cde801 100644 --- a/admin/views/contexts/tmpl/default_head.php +++ b/admin/views/contexts/tmpl/default_head.php @@ -5,12 +5,12 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> canEdit&& $this->canState): ?> diff --git a/admin/views/contexts/tmpl/default_toolbar.php b/admin/views/contexts/tmpl/default_toolbar.php index 6560ada..1d1110f 100644 --- a/admin/views/contexts/tmpl/default_toolbar.php +++ b/admin/views/contexts/tmpl/default_toolbar.php @@ -5,39 +5,39 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
- -
- - -
-
- - pagination->getLimitBox(); ?> -
-
- - -
-
- - -
-
+ */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
+ +
+ + +
+
+ + pagination->getLimitBox(); ?> +
+
+ + +
+
+ + +
+
\ No newline at end of file diff --git a/admin/views/contexts/view.html.php b/admin/views/contexts/view.html.php index 3d3324e..e5b48d5 100644 --- a/admin/views/contexts/view.html.php +++ b/admin/views/contexts/view.html.php @@ -5,32 +5,32 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -/** - * Release_checking View class for the Contexts - */ -class Release_checkingViewContexts extends JViewLegacy -{ - /** - * Contexts view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - Release_checkingHelper::addSubmenu('contexts'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +/** + * Release_checking View class for the Contexts + */ +class Release_checkingViewContexts extends JViewLegacy +{ + /** + * Contexts view display method + * @return void + */ + function display($tpl = null) + { + if ($this->getLayout() !== 'modal') + { + // Include helper submenu + Release_checkingHelper::addSubmenu('contexts'); + } + + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); $this->user = JFactory::getUser(); // Load the filter form from xml. $this->filterForm = $this->get('FilterForm'); @@ -38,122 +38,122 @@ class Release_checkingViewContexts extends JViewLegacy $this->activeFilters = $this->get('ActiveFilters'); // Add the list ordering clause. $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions + $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); + // get global action permissions $this->canDo = Release_checkingHelper::getActions('context'); $this->canEdit = $this->canDo->get('core.edit'); $this->canState = $this->canDo->get('core.edit.state'); $this->canCreate = $this->canDo->get('core.create'); $this->canDelete = $this->canDo->get('core.delete'); - $this->canBatch = $this->canDo->get('core.batch'); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_RELEASE_CHECKING_CONTEXTS'), 'joomla'); - JHtmlSidebar::setAction('index.php?option=com_release_checking&view=contexts'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('context.add'); - } - - // Only load if there are items - if (Release_checkingHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('context.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('contexts.publish'); - JToolBarHelper::unpublishList('contexts.unpublish'); - JToolBarHelper::archiveList('contexts.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('contexts.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'contexts.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('contexts.trash'); + $this->canBatch = $this->canDo->get('core.batch'); + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + $this->sidebar = JHtmlSidebar::render(); + // load the batch html + if ($this->canCreate && $this->canEdit && $this->canState) + { + $this->batchDisplay = JHtmlBatch_::render(); + } + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + JToolBarHelper::title(JText::_('COM_RELEASE_CHECKING_CONTEXTS'), 'joomla'); + JHtmlSidebar::setAction('index.php?option=com_release_checking&view=contexts'); + JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); + + if ($this->canCreate) + { + JToolBarHelper::addNew('context.add'); + } + + // Only load if there are items + if (Release_checkingHelper::checkArray($this->items)) + { + if ($this->canEdit) + { + JToolBarHelper::editList('context.edit'); + } + + if ($this->canState) + { + JToolBarHelper::publishList('contexts.publish'); + JToolBarHelper::unpublishList('contexts.unpublish'); + JToolBarHelper::archiveList('contexts.archive'); + + if ($this->canDo->get('core.admin')) + { + JToolBarHelper::checkin('contexts.checkin'); + } + } + + // Add a batch button + if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) + { + // Get the toolbar object instance + $bar = JToolBar::getInstance('toolbar'); + // set the batch button name + $title = JText::_('JTOOLBAR_BATCH'); + // Instantiate a new JLayoutFile instance and render the batch button + $layout = new JLayoutFile('joomla.toolbar.batch'); + // add the button to the page + $dhtml = $layout->render(array('title' => $title)); + $bar->appendButton('Custom', $dhtml, 'batch'); + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + JToolbarHelper::deleteList('', 'contexts.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + JToolbarHelper::trash('contexts.trash'); } if ($this->canDo->get('core.export') && $this->canDo->get('context.export')) { JToolBarHelper::custom('contexts.exportData', 'download', '', 'COM_RELEASE_CHECKING_EXPORT_DATA', true); - } + } } if ($this->canDo->get('core.import') && $this->canDo->get('context.import')) { JToolBarHelper::custom('contexts.importData', 'upload', '', 'COM_RELEASE_CHECKING_IMPORT_DATA', false); - } - - // set help url for this view if found - $help_url = Release_checkingHelper::getHelpUrl('contexts'); - if (Release_checkingHelper::checkString($help_url)) - { - JToolbarHelper::help('COM_RELEASE_CHECKING_HELP_MANAGER', false, $help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_release_checking'); + } + + // set help url for this view if found + $help_url = Release_checkingHelper::getHelpUrl('contexts'); + if (Release_checkingHelper::checkString($help_url)) + { + JToolbarHelper::help('COM_RELEASE_CHECKING_HELP_MANAGER', false, $help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + JToolBarHelper::preferences('com_release_checking'); } // Only load published batch if state and batch is allowed @@ -194,54 +194,54 @@ class Release_checkingViewContexts extends JViewLegacy 'batch[name]', JHtml::_('select.options', $this->nameOptions, 'value', 'text') ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_RELEASE_CHECKING_CONTEXTS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_release_checking/assets/css/contexts.css", (Release_checkingHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return Release_checkingHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return Release_checkingHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { + } + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_('COM_RELEASE_CHECKING_CONTEXTS')); + $this->document->addStyleSheet(JURI::root() . "administrator/components/com_release_checking/assets/css/contexts.css", (Release_checkingHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 50) + { + // use the helper htmlEscape method instead and shorten the string + return Release_checkingHelper::htmlEscape($var, $this->_charset, true); + } + // use the helper htmlEscape method instead. + return Release_checkingHelper::htmlEscape($var, $this->_charset); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array Array containing the field name to sort by as the key and display text as value + */ + protected function getSortFields() + { return array( 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), 'a.published' => JText::_('JSTATUS'), 'a.name' => JText::_('COM_RELEASE_CHECKING_CONTEXT_NAME_LABEL'), 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} + ); + } +} diff --git a/admin/views/import/tmpl/default.php b/admin/views/import/tmpl/default.php index d6974c2..a946154 100644 --- a/admin/views/import/tmpl/default.php +++ b/admin/views/import/tmpl/default.php @@ -5,211 +5,211 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('jquery.framework'); -JHtml::_('bootstrap.tooltip'); -JHtml::_('script', 'system/core.js', false, true); -JHtml::_('behavior.keepalive'); -?> - - -
-
- - sidebar)) : ?> -
- sidebar; ?> -
-
- -
- - - hasPackage && Release_checkingHelper::checkArray($this->headerList) && Release_checkingHelper::checkArray($this->headers)) : ?> -
- -
- -
- -
-
- headerList as $name => $title): ?> -
- -
- -
-
- -
- -
-
- - - 'upload')); ?> - - -
- -
- -
- -
-
-
-     (.csv .xls .ods) -
-
- - - -
- -
- -
- -
-
-
-     (.csv .xls .ods) -
-
- - - -
- -
- -
- -
-
-
-     (.csv .xls .ods) -
-
- - - - - - - + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +JHtml::_('jquery.framework'); +JHtml::_('bootstrap.tooltip'); +JHtml::_('script', 'system/core.js', false, true); +JHtml::_('behavior.keepalive'); +?> + + +
+
+ + sidebar)) : ?> +
+ sidebar; ?> +
+
+ +
+ + + hasPackage && Release_checkingHelper::checkArray($this->headerList) && Release_checkingHelper::checkArray($this->headers)) : ?> +
+ +
+ +
+ +
+
+ headerList as $name => $title): ?> +
+ +
+ +
+
+ +
+ +
+
+ + + 'upload')); ?> + + +
+ +
+ +
+ +
+
+
+     (.csv .xls .ods) +
+
+ + + +
+ +
+ +
+ +
+
+
+     (.csv .xls .ods) +
+
+ + + +
+ +
+ +
+ +
+
+
+     (.csv .xls .ods) +
+
+ + + + + + +
\ No newline at end of file diff --git a/admin/views/import/view.html.php b/admin/views/import/view.html.php index 5436a53..7213ce3 100644 --- a/admin/views/import/view.html.php +++ b/admin/views/import/view.html.php @@ -5,87 +5,87 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -/** - * Release_checking Import View - */ -class Release_checkingViewImport extends JViewLegacy -{ - protected $headerList; - protected $hasPackage = false; - protected $headers; - protected $hasHeader = 0; - protected $dataType; - - public function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - Release_checkingHelper::addSubmenu('import'); - } - - $paths = new stdClass; - $paths->first = ''; - $state = $this->get('state'); - - $this->paths = &$paths; - $this->state = &$state; - // get global action permissions - $this->canDo = Release_checkingHelper::getActions('import'); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - } - - // get the session object - $session = JFactory::getSession(); - // check if it has package - $this->hasPackage = $session->get('hasPackage', false); - $this->dataType = $session->get('dataType', false); - if($this->hasPackage && $this->dataType) - { - $this->headerList = json_decode($session->get($this->dataType.'_VDM_IMPORTHEADERS', false),true); - $this->headers = Release_checkingHelper::getFileHeaders($this->dataType); - // clear the data type - $session->clear('dataType'); - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_RELEASE_CHECKING_IMPORT_TITLE'), 'upload'); - JHtmlSidebar::setAction('index.php?option=com_release_checking&view=import'); - - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_release_checking'); - } - - // set help url for this view if found - $help_url = Release_checkingHelper::getHelpUrl('import'); - if (Release_checkingHelper::checkString($help_url)) - { - JToolbarHelper::help('COM_RELEASE_CHECKING_HELP_MANAGER', false, $help_url); - } - } -} + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +/** + * Release_checking Import View + */ +class Release_checkingViewImport extends JViewLegacy +{ + protected $headerList; + protected $hasPackage = false; + protected $headers; + protected $hasHeader = 0; + protected $dataType; + + public function display($tpl = null) + { + if ($this->getLayout() !== 'modal') + { + // Include helper submenu + Release_checkingHelper::addSubmenu('import'); + } + + $paths = new stdClass; + $paths->first = ''; + $state = $this->get('state'); + + $this->paths = &$paths; + $this->state = &$state; + // get global action permissions + $this->canDo = Release_checkingHelper::getActions('import'); + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + $this->sidebar = JHtmlSidebar::render(); + } + + // get the session object + $session = JFactory::getSession(); + // check if it has package + $this->hasPackage = $session->get('hasPackage', false); + $this->dataType = $session->get('dataType', false); + if($this->hasPackage && $this->dataType) + { + $this->headerList = json_decode($session->get($this->dataType.'_VDM_IMPORTHEADERS', false),true); + $this->headers = Release_checkingHelper::getFileHeaders($this->dataType); + // clear the data type + $session->clear('dataType'); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + } + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + JToolBarHelper::title(JText::_('COM_RELEASE_CHECKING_IMPORT_TITLE'), 'upload'); + JHtmlSidebar::setAction('index.php?option=com_release_checking&view=import'); + + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + JToolBarHelper::preferences('com_release_checking'); + } + + // set help url for this view if found + $help_url = Release_checkingHelper::getHelpUrl('import'); + if (Release_checkingHelper::checkString($help_url)) + { + JToolbarHelper::help('COM_RELEASE_CHECKING_HELP_MANAGER', false, $help_url); + } + } +} diff --git a/admin/views/joomla_version/submitbutton.js b/admin/views/joomla_version/submitbutton.js index 072090c..6116415 100644 --- a/admin/views/joomla_version/submitbutton.js +++ b/admin/views/joomla_version/submitbutton.js @@ -4,20 +4,20 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('joomla_version, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } + */ + +Joomla.submitbutton = function(task) +{ + if (task == ''){ + return false; + } else { + var action = task.split('.'); + if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ + Joomla.submitform(task, document.getElementById("adminForm")); + return true; + } else { + alert(Joomla.JText._('joomla_version, some values are not acceptable.','Some values are unacceptable')); + return false; + } + } } \ No newline at end of file diff --git a/admin/views/joomla_version/tmpl/edit.php b/admin/views/joomla_version/tmpl/edit.php index 6d9aace..f34ea6e 100644 --- a/admin/views/joomla_version/tmpl/edit.php +++ b/admin/views/joomla_version/tmpl/edit.php @@ -5,18 +5,18 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); JHtml::_('behavior.tooltip'); JHtml::_('behavior.formvalidation'); JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> +JHtml::_('behavior.keepalive'); +$componentParams = $this->params; // will be removed just use $this->params instead +?> - +
+ +
diff --git a/admin/views/joomla_version/view.html.php b/admin/views/joomla_version/view.html.php index ffffa5f..53bef2b 100644 --- a/admin/views/joomla_version/view.html.php +++ b/admin/views/joomla_version/view.html.php @@ -5,77 +5,77 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -/** - * Joomla_version View class - */ -class Release_checkingViewJoomla_version extends JViewLegacy -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_release_checking'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = Release_checkingHelper::getActions('joomla_version', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +/** + * Joomla_version View class + */ +class Release_checkingViewJoomla_version extends JViewLegacy +{ + /** + * display method of View + * @return void + */ + public function display($tpl = null) + { + // set params + $this->params = JComponentHelper::getParams('com_release_checking'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->script = $this->get('Script'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = Release_checkingHelper::getActions('joomla_version', $this->item); + // get input + $jinput = JFactory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string)$this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string)$return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + + /** + * Setting the toolbar + */ + protected function addToolBar() + { JFactory::getApplication()->input->set('hidemainmenu', true); $user = JFactory::getUser(); $userId = $user->id; @@ -151,43 +151,43 @@ class Release_checkingViewJoomla_version extends JViewLegacy if (Release_checkingHelper::checkString($help_url)) { JToolbarHelper::help('COM_RELEASE_CHECKING_HELP_MANAGER', false, $help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return Release_checkingHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return Release_checkingHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_RELEASE_CHECKING_JOOMLA_VERSION_NEW' : 'COM_RELEASE_CHECKING_JOOMLA_VERSION_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_release_checking/assets/css/joomla_version.css", (Release_checkingHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addScript(JURI::root() . $this->script, (Release_checkingHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_release_checking/views/joomla_version/submitbutton.js", (Release_checkingHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - JText::script('view not acceptable. Error'); - } -} + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 30) + { + // use the helper htmlEscape method instead and shorten the string + return Release_checkingHelper::htmlEscape($var, $this->_charset, true, 30); + } + // use the helper htmlEscape method instead. + return Release_checkingHelper::htmlEscape($var, $this->_charset); + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + $isNew = ($this->item->id < 1); + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_($isNew ? 'COM_RELEASE_CHECKING_JOOMLA_VERSION_NEW' : 'COM_RELEASE_CHECKING_JOOMLA_VERSION_EDIT')); + $this->document->addStyleSheet(JURI::root() . "administrator/components/com_release_checking/assets/css/joomla_version.css", (Release_checkingHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + $this->document->addScript(JURI::root() . $this->script, (Release_checkingHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + $this->document->addScript(JURI::root() . "administrator/components/com_release_checking/views/joomla_version/submitbutton.js", (Release_checkingHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + JText::script('view not acceptable. Error'); + } +} diff --git a/admin/views/joomla_versions/tmpl/default.php b/admin/views/joomla_versions/tmpl/default.php index 8d3fadd..96cd220 100644 --- a/admin/views/joomla_versions/tmpl/default.php +++ b/admin/views/joomla_versions/tmpl/default.php @@ -5,22 +5,22 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + JHtml::_('behavior.tooltip'); JHtml::_('behavior.multiselect'); JHtml::_('dropdown.init'); JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_RELEASE_CHECKING_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_release_checking&task=joomla_versions.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'joomla_versionList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> +JHtml::_('formbehavior.chosen', 'select'); +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_release_checking&task=joomla_versions.saveOrderAjax&tmpl=component'; + JHtml::_('sortablelist.sortable', 'joomla_versionList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?>
sidebar)): ?>
@@ -61,4 +61,4 @@ if ($this->saveOrder) - + diff --git a/admin/views/joomla_versions/tmpl/default_batch_body.php b/admin/views/joomla_versions/tmpl/default_batch_body.php index a3cdabe..1ed7300 100644 --- a/admin/views/joomla_versions/tmpl/default_batch_body.php +++ b/admin/views/joomla_versions/tmpl/default_batch_body.php @@ -5,12 +5,12 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

+ */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + +

batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/joomla_versions/tmpl/default_batch_footer.php b/admin/views/joomla_versions/tmpl/default_batch_footer.php index 2103eac..abfd8f3 100644 --- a/admin/views/joomla_versions/tmpl/default_batch_footer.php +++ b/admin/views/joomla_versions/tmpl/default_batch_footer.php @@ -5,17 +5,17 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - + + \ No newline at end of file diff --git a/admin/views/joomla_versions/tmpl/default_body.php b/admin/views/joomla_versions/tmpl/default_body.php index ed92b0d..90b2db4 100644 --- a/admin/views/joomla_versions/tmpl/default_body.php +++ b/admin/views/joomla_versions/tmpl/default_body.php @@ -5,14 +5,14 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_release_checking&view=joomla_versions&task=joomla_version.edit"; - -?> + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +$edit = "index.php?option=com_release_checking&view=joomla_versions&task=joomla_version.edit"; + +?> items as $i => $item): ?> user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; diff --git a/admin/views/joomla_versions/tmpl/default_foot.php b/admin/views/joomla_versions/tmpl/default_foot.php index 9feff4a..9e31250 100644 --- a/admin/views/joomla_versions/tmpl/default_foot.php +++ b/admin/views/joomla_versions/tmpl/default_foot.php @@ -5,12 +5,12 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + pagination->getListFooter(); ?> \ No newline at end of file diff --git a/admin/views/joomla_versions/tmpl/default_head.php b/admin/views/joomla_versions/tmpl/default_head.php index db7f1fe..c9c0af7 100644 --- a/admin/views/joomla_versions/tmpl/default_head.php +++ b/admin/views/joomla_versions/tmpl/default_head.php @@ -5,12 +5,12 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> canEdit&& $this->canState): ?> diff --git a/admin/views/joomla_versions/tmpl/default_toolbar.php b/admin/views/joomla_versions/tmpl/default_toolbar.php index b5ef320..9a61a2d 100644 --- a/admin/views/joomla_versions/tmpl/default_toolbar.php +++ b/admin/views/joomla_versions/tmpl/default_toolbar.php @@ -5,39 +5,39 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
- -
- - -
-
- - pagination->getLimitBox(); ?> -
-
- - -
-
- - -
-
+ */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
+ +
+ + +
+
+ + pagination->getLimitBox(); ?> +
+
+ + +
+
+ + +
+
\ No newline at end of file diff --git a/admin/views/joomla_versions/view.html.php b/admin/views/joomla_versions/view.html.php index b2c5bfd..6d66272 100644 --- a/admin/views/joomla_versions/view.html.php +++ b/admin/views/joomla_versions/view.html.php @@ -5,32 +5,32 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -/** - * Release_checking View class for the Joomla_versions - */ -class Release_checkingViewJoomla_versions extends JViewLegacy -{ - /** - * Joomla_versions view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - Release_checkingHelper::addSubmenu('joomla_versions'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +/** + * Release_checking View class for the Joomla_versions + */ +class Release_checkingViewJoomla_versions extends JViewLegacy +{ + /** + * Joomla_versions view display method + * @return void + */ + function display($tpl = null) + { + if ($this->getLayout() !== 'modal') + { + // Include helper submenu + Release_checkingHelper::addSubmenu('joomla_versions'); + } + + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); $this->user = JFactory::getUser(); // Load the filter form from xml. $this->filterForm = $this->get('FilterForm'); @@ -38,122 +38,122 @@ class Release_checkingViewJoomla_versions extends JViewLegacy $this->activeFilters = $this->get('ActiveFilters'); // Add the list ordering clause. $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions + $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); + // get global action permissions $this->canDo = Release_checkingHelper::getActions('joomla_version'); $this->canEdit = $this->canDo->get('core.edit'); $this->canState = $this->canDo->get('core.edit.state'); $this->canCreate = $this->canDo->get('core.create'); $this->canDelete = $this->canDo->get('core.delete'); - $this->canBatch = $this->canDo->get('core.batch'); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_RELEASE_CHECKING_JOOMLA_VERSIONS'), 'joomla'); - JHtmlSidebar::setAction('index.php?option=com_release_checking&view=joomla_versions'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('joomla_version.add'); - } - - // Only load if there are items - if (Release_checkingHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('joomla_version.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('joomla_versions.publish'); - JToolBarHelper::unpublishList('joomla_versions.unpublish'); - JToolBarHelper::archiveList('joomla_versions.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('joomla_versions.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'joomla_versions.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('joomla_versions.trash'); + $this->canBatch = $this->canDo->get('core.batch'); + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + $this->sidebar = JHtmlSidebar::render(); + // load the batch html + if ($this->canCreate && $this->canEdit && $this->canState) + { + $this->batchDisplay = JHtmlBatch_::render(); + } + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + JToolBarHelper::title(JText::_('COM_RELEASE_CHECKING_JOOMLA_VERSIONS'), 'joomla'); + JHtmlSidebar::setAction('index.php?option=com_release_checking&view=joomla_versions'); + JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); + + if ($this->canCreate) + { + JToolBarHelper::addNew('joomla_version.add'); + } + + // Only load if there are items + if (Release_checkingHelper::checkArray($this->items)) + { + if ($this->canEdit) + { + JToolBarHelper::editList('joomla_version.edit'); + } + + if ($this->canState) + { + JToolBarHelper::publishList('joomla_versions.publish'); + JToolBarHelper::unpublishList('joomla_versions.unpublish'); + JToolBarHelper::archiveList('joomla_versions.archive'); + + if ($this->canDo->get('core.admin')) + { + JToolBarHelper::checkin('joomla_versions.checkin'); + } + } + + // Add a batch button + if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) + { + // Get the toolbar object instance + $bar = JToolBar::getInstance('toolbar'); + // set the batch button name + $title = JText::_('JTOOLBAR_BATCH'); + // Instantiate a new JLayoutFile instance and render the batch button + $layout = new JLayoutFile('joomla.toolbar.batch'); + // add the button to the page + $dhtml = $layout->render(array('title' => $title)); + $bar->appendButton('Custom', $dhtml, 'batch'); + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + JToolbarHelper::deleteList('', 'joomla_versions.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + JToolbarHelper::trash('joomla_versions.trash'); } if ($this->canDo->get('core.export') && $this->canDo->get('joomla_version.export')) { JToolBarHelper::custom('joomla_versions.exportData', 'download', '', 'COM_RELEASE_CHECKING_EXPORT_DATA', true); - } + } } if ($this->canDo->get('core.import') && $this->canDo->get('joomla_version.import')) { JToolBarHelper::custom('joomla_versions.importData', 'upload', '', 'COM_RELEASE_CHECKING_IMPORT_DATA', false); - } - - // set help url for this view if found - $help_url = Release_checkingHelper::getHelpUrl('joomla_versions'); - if (Release_checkingHelper::checkString($help_url)) - { - JToolbarHelper::help('COM_RELEASE_CHECKING_HELP_MANAGER', false, $help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_release_checking'); + } + + // set help url for this view if found + $help_url = Release_checkingHelper::getHelpUrl('joomla_versions'); + if (Release_checkingHelper::checkString($help_url)) + { + JToolbarHelper::help('COM_RELEASE_CHECKING_HELP_MANAGER', false, $help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + JToolBarHelper::preferences('com_release_checking'); } // Only load published batch if state and batch is allowed @@ -174,54 +174,54 @@ class Release_checkingViewJoomla_versions extends JViewLegacy 'batch[access]', JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_RELEASE_CHECKING_JOOMLA_VERSIONS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_release_checking/assets/css/joomla_versions.css", (Release_checkingHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return Release_checkingHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return Release_checkingHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { + } + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_('COM_RELEASE_CHECKING_JOOMLA_VERSIONS')); + $this->document->addStyleSheet(JURI::root() . "administrator/components/com_release_checking/assets/css/joomla_versions.css", (Release_checkingHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 50) + { + // use the helper htmlEscape method instead and shorten the string + return Release_checkingHelper::htmlEscape($var, $this->_charset, true); + } + // use the helper htmlEscape method instead. + return Release_checkingHelper::htmlEscape($var, $this->_charset); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array Array containing the field name to sort by as the key and display text as value + */ + protected function getSortFields() + { return array( 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), 'a.published' => JText::_('JSTATUS'), 'a.name' => JText::_('COM_RELEASE_CHECKING_JOOMLA_VERSION_NAME_LABEL'), 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} + ); + } +} diff --git a/admin/views/release_check/submitbutton.js b/admin/views/release_check/submitbutton.js index 46e15db..3fd95de 100644 --- a/admin/views/release_check/submitbutton.js +++ b/admin/views/release_check/submitbutton.js @@ -4,20 +4,20 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('release_check, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } + */ + +Joomla.submitbutton = function(task) +{ + if (task == ''){ + return false; + } else { + var action = task.split('.'); + if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ + Joomla.submitform(task, document.getElementById("adminForm")); + return true; + } else { + alert(Joomla.JText._('release_check, some values are not acceptable.','Some values are unacceptable')); + return false; + } + } } \ No newline at end of file diff --git a/admin/views/release_check/tmpl/edit.php b/admin/views/release_check/tmpl/edit.php index 1405b9f..fbdd17b 100644 --- a/admin/views/release_check/tmpl/edit.php +++ b/admin/views/release_check/tmpl/edit.php @@ -5,18 +5,18 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); JHtml::_('behavior.tooltip'); JHtml::_('behavior.formvalidation'); JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> +JHtml::_('behavior.keepalive'); +$componentParams = $this->params; // will be removed just use $this->params instead +?> - +
+ diff --git a/admin/views/release_check/view.html.php b/admin/views/release_check/view.html.php index e9af258..94bd518 100644 --- a/admin/views/release_check/view.html.php +++ b/admin/views/release_check/view.html.php @@ -5,77 +5,77 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -/** - * Release_check View class - */ -class Release_checkingViewRelease_check extends JViewLegacy -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_release_checking'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = Release_checkingHelper::getActions('release_check', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +/** + * Release_check View class + */ +class Release_checkingViewRelease_check extends JViewLegacy +{ + /** + * display method of View + * @return void + */ + public function display($tpl = null) + { + // set params + $this->params = JComponentHelper::getParams('com_release_checking'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->script = $this->get('Script'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = Release_checkingHelper::getActions('release_check', $this->item); + // get input + $jinput = JFactory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string)$this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string)$return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + + /** + * Setting the toolbar + */ + protected function addToolBar() + { JFactory::getApplication()->input->set('hidemainmenu', true); $user = JFactory::getUser(); $userId = $user->id; @@ -151,50 +151,50 @@ class Release_checkingViewRelease_check extends JViewLegacy if (Release_checkingHelper::checkString($help_url)) { JToolbarHelper::help('COM_RELEASE_CHECKING_HELP_MANAGER', false, $help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return Release_checkingHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return Release_checkingHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_RELEASE_CHECKING_RELEASE_CHECK_NEW' : 'COM_RELEASE_CHECKING_RELEASE_CHECK_EDIT')); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 30) + { + // use the helper htmlEscape method instead and shorten the string + return Release_checkingHelper::htmlEscape($var, $this->_charset, true, 30); + } + // use the helper htmlEscape method instead. + return Release_checkingHelper::htmlEscape($var, $this->_charset); + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + $isNew = ($this->item->id < 1); + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_($isNew ? 'COM_RELEASE_CHECKING_RELEASE_CHECK_NEW' : 'COM_RELEASE_CHECKING_RELEASE_CHECK_EDIT')); $this->document->addStyleSheet(JURI::root() . "administrator/components/com_release_checking/assets/css/release_check.css", (Release_checkingHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); // Add Ajax Token - $this->document->addScriptDeclaration("var token = '".JSession::getFormToken()."';"); - $this->document->addScript(JURI::root() . $this->script, (Release_checkingHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + $this->document->addScriptDeclaration("var token = '".JSession::getFormToken()."';"); + $this->document->addScript(JURI::root() . $this->script, (Release_checkingHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); $this->document->addScript(JURI::root() . "administrator/components/com_release_checking/views/release_check/submitbutton.js", (Release_checkingHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); // set some language strings JText::script('COM_RELEASE_CHECKING_SELECT'); JText::script('COM_RELEASE_CHECKING_CREATE'); JText::script('COM_RELEASE_CHECKING_ALL_DONE_HERE_SELECT_THE_NEXT_CONTEXT'); - JText::script('COM_RELEASE_CHECKING_YOU_MUST_FIRST_SELECT_THE_JOOMLA_VERSION_BEING_TESTED'); - JText::script('view not acceptable. Error'); - } -} + JText::script('COM_RELEASE_CHECKING_YOU_MUST_FIRST_SELECT_THE_JOOMLA_VERSION_BEING_TESTED'); + JText::script('view not acceptable. Error'); + } +} diff --git a/admin/views/release_checks/tmpl/default.php b/admin/views/release_checks/tmpl/default.php index 9a6962c..4cf2311 100644 --- a/admin/views/release_checks/tmpl/default.php +++ b/admin/views/release_checks/tmpl/default.php @@ -5,11 +5,11 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + JHtml::_('behavior.tooltip'); JHtml::_('behavior.multiselect'); JHtml::_('dropdown.init'); @@ -19,13 +19,13 @@ JHtml::_('formbehavior.chosen', '.multipleReleasechecksfilteroutcome', null, arr JHtml::_('formbehavior.chosen', '.multipleJoomlaversions', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_RELEASE_CHECKING_FILTER_SELECT_JOOMLA_VERSION') . ' -')); JHtml::_('formbehavior.chosen', '.multipleReleasechecksfiltercreatedby', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_RELEASE_CHECKING_FILTER_SELECT_CREATED_BY') . ' -')); JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_RELEASE_CHECKING_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_release_checking&task=release_checks.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'release_checkList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> +JHtml::_('formbehavior.chosen', 'select'); +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_release_checking&task=release_checks.saveOrderAjax&tmpl=component'; + JHtml::_('sortablelist.sortable', 'release_checkList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?>
sidebar)): ?>
@@ -66,4 +66,4 @@ if ($this->saveOrder) - + diff --git a/admin/views/release_checks/tmpl/default_batch_body.php b/admin/views/release_checks/tmpl/default_batch_body.php index b25b362..9ccdb8a 100644 --- a/admin/views/release_checks/tmpl/default_batch_body.php +++ b/admin/views/release_checks/tmpl/default_batch_body.php @@ -5,12 +5,12 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

+ */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + +

batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/release_checks/tmpl/default_batch_footer.php b/admin/views/release_checks/tmpl/default_batch_footer.php index 97cd00c..355e317 100644 --- a/admin/views/release_checks/tmpl/default_batch_footer.php +++ b/admin/views/release_checks/tmpl/default_batch_footer.php @@ -5,17 +5,17 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - + + \ No newline at end of file diff --git a/admin/views/release_checks/tmpl/default_body.php b/admin/views/release_checks/tmpl/default_body.php index 9605cc4..a7254b8 100644 --- a/admin/views/release_checks/tmpl/default_body.php +++ b/admin/views/release_checks/tmpl/default_body.php @@ -5,14 +5,14 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_release_checking&view=release_checks&task=release_check.edit"; - -?> + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +$edit = "index.php?option=com_release_checking&view=release_checks&task=release_check.edit"; + +?> items as $i => $item): ?> user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; diff --git a/admin/views/release_checks/tmpl/default_foot.php b/admin/views/release_checks/tmpl/default_foot.php index 2a24274..e7405ac 100644 --- a/admin/views/release_checks/tmpl/default_foot.php +++ b/admin/views/release_checks/tmpl/default_foot.php @@ -5,12 +5,12 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + pagination->getListFooter(); ?> \ No newline at end of file diff --git a/admin/views/release_checks/tmpl/default_head.php b/admin/views/release_checks/tmpl/default_head.php index cd17f21..9cc069b 100644 --- a/admin/views/release_checks/tmpl/default_head.php +++ b/admin/views/release_checks/tmpl/default_head.php @@ -5,12 +5,12 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> canEdit&& $this->canState): ?> diff --git a/admin/views/release_checks/tmpl/default_toolbar.php b/admin/views/release_checks/tmpl/default_toolbar.php index dd256a3..acf9de6 100644 --- a/admin/views/release_checks/tmpl/default_toolbar.php +++ b/admin/views/release_checks/tmpl/default_toolbar.php @@ -5,39 +5,39 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
- -
- - -
-
- - pagination->getLimitBox(); ?> -
-
- - -
-
- - -
-
+ */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
+ +
+ + +
+
+ + pagination->getLimitBox(); ?> +
+
+ + +
+
+ + +
+
\ No newline at end of file diff --git a/admin/views/release_checks/view.html.php b/admin/views/release_checks/view.html.php index e803a35..9542455 100644 --- a/admin/views/release_checks/view.html.php +++ b/admin/views/release_checks/view.html.php @@ -5,32 +5,32 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -/** - * Release_checking View class for the Release_checks - */ -class Release_checkingViewRelease_checks extends JViewLegacy -{ - /** - * Release_checks view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - Release_checkingHelper::addSubmenu('release_checks'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +/** + * Release_checking View class for the Release_checks + */ +class Release_checkingViewRelease_checks extends JViewLegacy +{ + /** + * Release_checks view display method + * @return void + */ + function display($tpl = null) + { + if ($this->getLayout() !== 'modal') + { + // Include helper submenu + Release_checkingHelper::addSubmenu('release_checks'); + } + + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); $this->user = JFactory::getUser(); // Load the filter form from xml. $this->filterForm = $this->get('FilterForm'); @@ -38,122 +38,122 @@ class Release_checkingViewRelease_checks extends JViewLegacy $this->activeFilters = $this->get('ActiveFilters'); // Add the list ordering clause. $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions + $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); + // get global action permissions $this->canDo = Release_checkingHelper::getActions('release_check'); $this->canEdit = $this->canDo->get('core.edit'); $this->canState = $this->canDo->get('core.edit.state'); $this->canCreate = $this->canDo->get('core.create'); $this->canDelete = $this->canDo->get('core.delete'); - $this->canBatch = $this->canDo->get('core.batch'); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_RELEASE_CHECKING_RELEASE_CHECKS'), 'pencil-2'); - JHtmlSidebar::setAction('index.php?option=com_release_checking&view=release_checks'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('release_check.add'); - } - - // Only load if there are items - if (Release_checkingHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('release_check.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('release_checks.publish'); - JToolBarHelper::unpublishList('release_checks.unpublish'); - JToolBarHelper::archiveList('release_checks.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('release_checks.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'release_checks.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('release_checks.trash'); + $this->canBatch = $this->canDo->get('core.batch'); + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + $this->sidebar = JHtmlSidebar::render(); + // load the batch html + if ($this->canCreate && $this->canEdit && $this->canState) + { + $this->batchDisplay = JHtmlBatch_::render(); + } + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + JToolBarHelper::title(JText::_('COM_RELEASE_CHECKING_RELEASE_CHECKS'), 'pencil-2'); + JHtmlSidebar::setAction('index.php?option=com_release_checking&view=release_checks'); + JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); + + if ($this->canCreate) + { + JToolBarHelper::addNew('release_check.add'); + } + + // Only load if there are items + if (Release_checkingHelper::checkArray($this->items)) + { + if ($this->canEdit) + { + JToolBarHelper::editList('release_check.edit'); + } + + if ($this->canState) + { + JToolBarHelper::publishList('release_checks.publish'); + JToolBarHelper::unpublishList('release_checks.unpublish'); + JToolBarHelper::archiveList('release_checks.archive'); + + if ($this->canDo->get('core.admin')) + { + JToolBarHelper::checkin('release_checks.checkin'); + } + } + + // Add a batch button + if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) + { + // Get the toolbar object instance + $bar = JToolBar::getInstance('toolbar'); + // set the batch button name + $title = JText::_('JTOOLBAR_BATCH'); + // Instantiate a new JLayoutFile instance and render the batch button + $layout = new JLayoutFile('joomla.toolbar.batch'); + // add the button to the page + $dhtml = $layout->render(array('title' => $title)); + $bar->appendButton('Custom', $dhtml, 'batch'); + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + JToolbarHelper::deleteList('', 'release_checks.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + JToolbarHelper::trash('release_checks.trash'); } if ($this->canDo->get('core.export') && $this->canDo->get('release_check.export')) { JToolBarHelper::custom('release_checks.exportData', 'download', '', 'COM_RELEASE_CHECKING_EXPORT_DATA', true); - } + } } if ($this->canDo->get('core.import') && $this->canDo->get('release_check.import')) { JToolBarHelper::custom('release_checks.importData', 'upload', '', 'COM_RELEASE_CHECKING_IMPORT_DATA', false); - } - - // set help url for this view if found - $help_url = Release_checkingHelper::getHelpUrl('release_checks'); - if (Release_checkingHelper::checkString($help_url)) - { - JToolbarHelper::help('COM_RELEASE_CHECKING_HELP_MANAGER', false, $help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_release_checking'); + } + + // set help url for this view if found + $help_url = Release_checkingHelper::getHelpUrl('release_checks'); + if (Release_checkingHelper::checkString($help_url)) + { + JToolbarHelper::help('COM_RELEASE_CHECKING_HELP_MANAGER', false, $help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + JToolBarHelper::preferences('com_release_checking'); } // Only load published batch if state and batch is allowed @@ -274,49 +274,49 @@ class Release_checkingViewRelease_checks extends JViewLegacy 'batch[created_by]', JHtml::_('select.options', $this->created_byOptions, 'value', 'text') ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_RELEASE_CHECKING_RELEASE_CHECKS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_release_checking/assets/css/release_checks.css", (Release_checkingHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return Release_checkingHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return Release_checkingHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { + } + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_('COM_RELEASE_CHECKING_RELEASE_CHECKS')); + $this->document->addStyleSheet(JURI::root() . "administrator/components/com_release_checking/assets/css/release_checks.css", (Release_checkingHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 50) + { + // use the helper htmlEscape method instead and shorten the string + return Release_checkingHelper::htmlEscape($var, $this->_charset, true); + } + // use the helper htmlEscape method instead. + return Release_checkingHelper::htmlEscape($var, $this->_charset); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array Array containing the field name to sort by as the key and display text as value + */ + protected function getSortFields() + { return array( 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), 'a.published' => JText::_('JSTATUS'), @@ -326,6 +326,6 @@ class Release_checkingViewRelease_checks extends JViewLegacy 'i.name' => JText::_('COM_RELEASE_CHECKING_RELEASE_CHECK_JOOMLA_VERSION_LABEL'), 'a.created_by' => JText::_('COM_RELEASE_CHECKING_RELEASE_CHECK_CREATED_BY_LABEL'), 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} + ); + } +} diff --git a/release_checking.xml b/release_checking.xml index 51e4c6a..c649367 100644 --- a/release_checking.xml +++ b/release_checking.xml @@ -1,84 +1,84 @@ - - - COM_RELEASE_CHECKING - 10th December, 2020 - Joomla! Project - admin@joomla.org - http://www.joomla.org - (C) 2020 Open Source Matters, Inc. - GNU General Public License version 2 or later; see LICENSE.txt - 1.0.5 - Track Release Checking (v.1.0.5) -
-

A component to keep track of release checking.

-

Created by Joomla! Project
Development started 29th July, 2020

- ]]>
- - - - - sql/install.mysql.utf8.sql - - - - - - - sql/uninstall.mysql.utf8.sql - - - - - script.php - - - index.html - js - css - images - - - - - - sql/updates/mysql/ - - - - - - - - - COM_RELEASE_CHECKING_MENU - - - - - access.xml - config.xml - controller.php - index.html + + + COM_RELEASE_CHECKING + 8th March, 2021 + Joomla! Project + admin@joomla.org + http://www.joomla.org + (C) 2020 Open Source Matters, Inc. + GNU General Public License version 2 or later; see LICENSE.txt + 1.0.5 + Track Release Checking (v.1.0.5) +
+

A component to keep track of release checking.

+

Created by Joomla! Project
Development started 29th July, 2020

+ ]]>
+ + + + + sql/install.mysql.utf8.sql + + + + + + + sql/uninstall.mysql.utf8.sql + + + + + script.php + + + index.html + js + css + images + + + + + + sql/updates/mysql/ + + + + + + + + + COM_RELEASE_CHECKING_MENU + + + + + access.xml + config.xml + controller.php + index.html release_checking.php - README.txt - assets - controllers - helpers - models - sql - tables - views - layouts - - - + README.txt + assets + controllers + helpers + models + sql + tables + views + layouts +
+ + language/en-GB/en-GB.com_release_checking.ini - language/en-GB/en-GB.com_release_checking.sys.ini - - + language/en-GB/en-GB.com_release_checking.sys.ini + +
https://raw.githubusercontent.com/joomla-projects/com_release_checking/master/update_server.xml - +
\ No newline at end of file diff --git a/script.php b/script.php index 56d15e0..446fd5f 100644 --- a/script.php +++ b/script.php @@ -5,40 +5,42 @@ * * @copyright (C) 2020 Open Source Matters, Inc. * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHTML::_('behavior.modal'); - -/** - * Script File of Release_checking Component - */ -class com_release_checkingInstallerScript -{ - /** - * Constructor - * - * @param JAdapterInstance $parent The object responsible for running this script - */ - public function __construct(JAdapterInstance $parent) {} - - /** - * Called on installation - * - * @param JAdapterInstance $parent The object responsible for running this script - * - * @return boolean True on success - */ - public function install(JAdapterInstance $parent) {} - - /** - * Called on uninstallation - * - * @param JAdapterInstance $parent The object responsible for running this script - */ - public function uninstall(JAdapterInstance $parent) + */ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\Filesystem\File; +use Joomla\CMS\Filesystem\Folder; +JHTML::_('behavior.modal'); + +/** + * Script File of Release_checking Component + */ +class com_release_checkingInstallerScript +{ + /** + * Constructor + * + * @param JAdapterInstance $parent The object responsible for running this script + */ + public function __construct(JAdapterInstance $parent) {} + + /** + * Called on installation + * + * @param JAdapterInstance $parent The object responsible for running this script + * + * @return boolean True on success + */ + public function install(JAdapterInstance $parent) {} + + /** + * Called on uninstallation + * + * @param JAdapterInstance $parent The object responsible for running this script + */ + public function uninstall(JAdapterInstance $parent) { // Get Application object $app = JFactory::getApplication(); @@ -409,6 +411,27 @@ class com_release_checkingInstallerScript $app->enqueueMessage(JText::_('All related items was removed from the #__assets table')); } + // Get the biggest rule column in the assets table at this point. + $get_rule_length = "SELECT CHAR_LENGTH(`rules`) as rule_size FROM #__assets ORDER BY rule_size DESC LIMIT 1"; + $db->setQuery($get_rule_length); + if ($db->execute()) + { + $rule_length = $db->loadResult(); + // Check the size of the rules column + if ($rule_length < 5120) + { + // Revert the assets table rules column back to the default + $revert_rule = "ALTER TABLE `#__assets` CHANGE `rules` `rules` varchar(5120) NOT NULL COMMENT 'JSON encoded access control.';"; + $db->setQuery($revert_rule); + $db->execute(); + $app->enqueueMessage(JText::_('Reverted the #__assets table rules column back to its default size of varchar(5120)')); + } + else + { + + $app->enqueueMessage(JText::_('Could not revert the #__assets table rules column back to its default size of varchar(5120), since there is still one or more components that still requires the column to be larger.')); + } + } // Set db if not set already. if (!isset($db)) @@ -533,83 +556,83 @@ class com_release_checkingInstallerScript { // If successfully removed Release_checking Action add queued success message. $app->enqueueMessage(JText::_('The com_release_checking.action type alias was removed from the #__action_log_config table')); - } - // little notice as after service, in case of bad experience with component. - echo '

Did something go wrong? Are you disappointed?

-

Please let me know at admin@joomla.org. -
We at Open Source Matters are committed to building extensions that performs proficiently! You can help us, really! -
Send me your thoughts on improvements that is needed, trust me, I will be very grateful! -
Visit us at http://www.joomla.org today!

'; - } - - /** - * Called on update - * - * @param JAdapterInstance $parent The object responsible for running this script - * - * @return boolean True on success - */ - public function update(JAdapterInstance $parent){} - - /** - * Called before any type of action - * - * @param string $type Which action is happening (install|uninstall|discover_install|update) - * @param JAdapterInstance $parent The object responsible for running this script - * - * @return boolean True on success - */ - public function preflight($type, JAdapterInstance $parent) - { - // get application - $app = JFactory::getApplication(); - // is redundant or so it seems ...hmmm let me know if it works again - if ($type === 'uninstall') - { - return true; - } - // the default for both install and update - $jversion = new JVersion(); - if (!$jversion->isCompatible('3.8.0')) - { - $app->enqueueMessage('Please upgrade to at least Joomla! 3.8.0 before continuing!', 'error'); - return false; - } - // do any updates needed - if ($type === 'update') - { - } - // do any install needed - if ($type === 'install') - { - } - // check if the PHPExcel stuff is still around - if (JFile::exists(JPATH_ADMINISTRATOR . '/components/com_release_checking/helpers/PHPExcel.php')) - { - // We need to remove this old PHPExcel folder - $this->removeFolder(JPATH_ADMINISTRATOR . '/components/com_release_checking/helpers/PHPExcel'); - // We need to remove this old PHPExcel file - JFile::delete(JPATH_ADMINISTRATOR . '/components/com_release_checking/helpers/PHPExcel.php'); - } - return true; - } - - /** - * Called after any type of action - * - * @param string $type Which action is happening (install|uninstall|discover_install|update) - * @param JAdapterInstance $parent The object responsible for running this script - * - * @return boolean True on success - */ - public function postflight($type, JAdapterInstance $parent) - { - // get application + } + // little notice as after service, in case of bad experience with component. + echo '

Did something go wrong? Are you disappointed?

+

Please let me know at admin@joomla.org. +
We at Open Source Matters are committed to building extensions that performs proficiently! You can help us, really! +
Send me your thoughts on improvements that is needed, trust me, I will be very grateful! +
Visit us at http://www.joomla.org today!

'; + } + + /** + * Called on update + * + * @param JAdapterInstance $parent The object responsible for running this script + * + * @return boolean True on success + */ + public function update(JAdapterInstance $parent){} + + /** + * Called before any type of action + * + * @param string $type Which action is happening (install|uninstall|discover_install|update) + * @param JAdapterInstance $parent The object responsible for running this script + * + * @return boolean True on success + */ + public function preflight($type, JAdapterInstance $parent) + { + // get application + $app = JFactory::getApplication(); + // is redundant or so it seems ...hmmm let me know if it works again + if ($type === 'uninstall') + { + return true; + } + // the default for both install and update + $jversion = new JVersion(); + if (!$jversion->isCompatible('3.8.0')) + { + $app->enqueueMessage('Please upgrade to at least Joomla! 3.8.0 before continuing!', 'error'); + return false; + } + // do any updates needed + if ($type === 'update') + { + } + // do any install needed + if ($type === 'install') + { + } + // check if the PHPExcel stuff is still around + if (File::exists(JPATH_ADMINISTRATOR . '/components/com_release_checking/helpers/PHPExcel.php')) + { + // We need to remove this old PHPExcel folder + $this->removeFolder(JPATH_ADMINISTRATOR . '/components/com_release_checking/helpers/PHPExcel'); + // We need to remove this old PHPExcel file + File::delete(JPATH_ADMINISTRATOR . '/components/com_release_checking/helpers/PHPExcel.php'); + } + return true; + } + + /** + * Called after any type of action + * + * @param string $type Which action is happening (install|uninstall|discover_install|update) + * @param JAdapterInstance $parent The object responsible for running this script + * + * @return boolean True on success + */ + public function postflight($type, JAdapterInstance $parent) + { + // get application $app = JFactory::getApplication(); // We check if we have dynamic folders to copy - $this->setDynamicF0ld3rs($app, $parent); - // set the default component settings - if ($type === 'install') + $this->setDynamicF0ld3rs($app, $parent); + // set the default component settings + if ($type === 'install') { // Get The Database object @@ -678,6 +701,22 @@ class com_release_checkingInstallerScript $db->setQuery($query); $allDone = $db->execute(); + // Get the biggest rule column in the assets table at this point. + $get_rule_length = "SELECT CHAR_LENGTH(`rules`) as rule_size FROM #__assets ORDER BY rule_size DESC LIMIT 1"; + $db->setQuery($get_rule_length); + if ($db->execute()) + { + $rule_length = $db->loadResult(); + // Check the size of the rules column + if ($rule_length <= 6080) + { + // Fix the assets table rules column size + $fix_rules_size = "ALTER TABLE `#__assets` CHANGE `rules` `rules` TEXT NOT NULL COMMENT 'JSON encoded access control. Enlarged to TEXT by JCB';"; + $db->setQuery($fix_rules_size); + $db->execute(); + $app->enqueueMessage(JText::_('The #__assets table rules column was resized to the TEXT datatype for the components possible large permission rules.')); + } + } echo ' '; @@ -760,10 +799,10 @@ class com_release_checkingInstallerScript $action_action_log_config->text_prefix = 'COM_RELEASE_CHECKING'; // Set the object into the action log config table. - $action_Inserted = $db->insertObject('#__action_log_config', $action_action_log_config); - } - // do any updates needed - if ($type === 'update') + $action_Inserted = $db->insertObject('#__action_log_config', $action_action_log_config); + } + // do any updates needed + if ($type === 'update') { // Get The Database object @@ -1048,110 +1087,110 @@ class com_release_checkingInstallerScript else { $action_action_log_config_Inserted = $db->insertObject('#__action_log_config', $action_action_log_config); - } - } - return true; - } - - /** - * Remove folders with files - * - * @param string $dir The path to folder to remove - * @param boolean $ignore The folders and files to ignore and not remove - * - * @return boolean True in all is removed - * - */ - protected function removeFolder($dir, $ignore = false) - { - if (JFolder::exists($dir)) - { - $it = new RecursiveDirectoryIterator($dir); - $it = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST); - // remove ending / - $dir = rtrim($dir, '/'); - // now loop the files & folders - foreach ($it as $file) - { - if ('.' === $file->getBasename() || '..' === $file->getBasename()) continue; - // set file dir - $file_dir = $file->getPathname(); - // check if this is a dir or a file - if ($file->isDir()) - { - $keeper = false; - if ($this->checkArray($ignore)) - { - foreach ($ignore as $keep) - { - if (strpos($file_dir, $dir.'/'.$keep) !== false) - { - $keeper = true; - } - } - } - if ($keeper) - { - continue; - } - JFolder::delete($file_dir); - } - else - { - $keeper = false; - if ($this->checkArray($ignore)) - { - foreach ($ignore as $keep) - { - if (strpos($file_dir, $dir.'/'.$keep) !== false) - { - $keeper = true; - } - } - } - if ($keeper) - { - continue; - } - JFile::delete($file_dir); - } - } - // delete the root folder if not ignore found - if (!$this->checkArray($ignore)) - { - return JFolder::delete($dir); - } - return true; - } - return false; - } - - /** - * Check if have an array with a length - * - * @input array The array to check - * - * @returns bool/int number of items in array on success - */ - protected function checkArray($array, $removeEmptyString = false) - { - if (isset($array) && is_array($array) && ($nr = count((array)$array)) > 0) - { - // also make sure the empty strings are removed - if ($removeEmptyString) - { - foreach ($array as $key => $string) - { - if (empty($string)) - { - unset($array[$key]); - } - } - return $this->checkArray($array, false); - } - return $nr; - } - return false; + } + } + return true; + } + + /** + * Remove folders with files + * + * @param string $dir The path to folder to remove + * @param boolean $ignore The folders and files to ignore and not remove + * + * @return boolean True in all is removed + * + */ + protected function removeFolder($dir, $ignore = false) + { + if (Folder::exists($dir)) + { + $it = new RecursiveDirectoryIterator($dir); + $it = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST); + // remove ending / + $dir = rtrim($dir, '/'); + // now loop the files & folders + foreach ($it as $file) + { + if ('.' === $file->getBasename() || '..' === $file->getBasename()) continue; + // set file dir + $file_dir = $file->getPathname(); + // check if this is a dir or a file + if ($file->isDir()) + { + $keeper = false; + if ($this->checkArray($ignore)) + { + foreach ($ignore as $keep) + { + if (strpos($file_dir, $dir.'/'.$keep) !== false) + { + $keeper = true; + } + } + } + if ($keeper) + { + continue; + } + Folder::delete($file_dir); + } + else + { + $keeper = false; + if ($this->checkArray($ignore)) + { + foreach ($ignore as $keep) + { + if (strpos($file_dir, $dir.'/'.$keep) !== false) + { + $keeper = true; + } + } + } + if ($keeper) + { + continue; + } + File::delete($file_dir); + } + } + // delete the root folder if not ignore found + if (!$this->checkArray($ignore)) + { + return Folder::delete($dir); + } + return true; + } + return false; + } + + /** + * Check if have an array with a length + * + * @input array The array to check + * + * @returns bool/int number of items in array on success + */ + protected function checkArray($array, $removeEmptyString = false) + { + if (isset($array) && is_array($array) && ($nr = count((array)$array)) > 0) + { + // also make sure the empty strings are removed + if ($removeEmptyString) + { + foreach ($array as $key => $string) + { + if (empty($string)) + { + unset($array[$key]); + } + } + return $this->checkArray($array, false); + } + return $nr; + } + return false; } /** @@ -1165,7 +1204,7 @@ class com_release_checkingInstallerScript $installer = $parent->getParent(); $installPath = $installer->getPath('source'); // get all the folders - $folders = JFolder::folders($installPath); + $folders = Folder::folders($installPath); // check if we have folders we may want to copy $doNotCopy = array('media','admin','site'); // Joomla already deals with these if (count((array) $folders) > 1) @@ -1180,12 +1219,12 @@ class com_release_checkingInstallerScript // set the destination path $dest = JPATH_ROOT.'/'.$folder; // now try to copy the folder - if (!JFolder::copy($src, $dest, '', true)) + if (!Folder::copy($src, $dest, '', true)) { $app->enqueueMessage('Could not copy '.$folder.' folder into place, please make sure destination is writable!', 'error'); } } } } - } -} + } +}