From ef7df2520a1fd779a7712dd4de5de97b4bf2b9d5 Mon Sep 17 00:00:00 2001 From: Tuan Pham Ngoc Date: Thu, 21 Dec 2017 07:08:35 +0700 Subject: [PATCH 01/19] Update route.php (#19109) --- components/com_users/helpers/route.php | 42 +++++++++----------------- 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/components/com_users/helpers/route.php b/components/com_users/helpers/route.php index 646370a3c1..89d4699891 100644 --- a/components/com_users/helpers/route.php +++ b/components/com_users/helpers/route.php @@ -32,10 +32,8 @@ public static function &getItems() // Get the menu items for this component. if (!isset($items)) { - $app = JFactory::getApplication(); - $menu = $app->getMenu(); - $com = JComponentHelper::getComponent('com_users'); - $items = $menu->getItems('component_id', $com->id); + $component = JComponentHelper::getComponent('com_users'); + $items = JFactory::getApplication()->getMenu()->getItems('component_id', $component->id); // If no items found, set to empty array. if (!$items) @@ -59,19 +57,17 @@ public static function getLoginRoute() { // Get the items. $items = self::getItems(); - $itemid = null; // Search for a suitable menu id. foreach ($items as $item) { if (isset($item->query['view']) && $item->query['view'] === 'login') { - $itemid = $item->id; - break; + return $item->id; } } - return $itemid; + return null; } /** @@ -86,7 +82,6 @@ public static function getProfileRoute() { // Get the items. $items = self::getItems(); - $itemid = null; // Search for a suitable menu id. // Menu link can only go to users own profile. @@ -95,12 +90,11 @@ public static function getProfileRoute() { if (isset($item->query['view']) && $item->query['view'] === 'profile') { - $itemid = $item->id; - break; + return $item->id; } } - return $itemid; + return null; } /** @@ -115,19 +109,17 @@ public static function getRegistrationRoute() { // Get the items. $items = self::getItems(); - $itemid = null; // Search for a suitable menu id. foreach ($items as $item) { if (isset($item->query['view']) && $item->query['view'] === 'registration') { - $itemid = $item->id; - break; + return $item->id; } } - return $itemid; + return null; } /** @@ -142,19 +134,17 @@ public static function getRemindRoute() { // Get the items. $items = self::getItems(); - $itemid = null; // Search for a suitable menu id. foreach ($items as $item) { if (isset($item->query['view']) && $item->query['view'] === 'remind') { - $itemid = $item->id; - break; + return $item->id; } } - return $itemid; + return null; } /** @@ -169,19 +159,17 @@ public static function getResendRoute() { // Get the items. $items = self::getItems(); - $itemid = null; // Search for a suitable menu id. foreach ($items as $item) { if (isset($item->query['view']) && $item->query['view'] === 'resend') { - $itemid = $item->id; - break; + return $item->id; } } - return $itemid; + return null; } /** @@ -196,18 +184,16 @@ public static function getResetRoute() { // Get the items. $items = self::getItems(); - $itemid = null; // Search for a suitable menu id. foreach ($items as $item) { if (isset($item->query['view']) && $item->query['view'] === 'reset') { - $itemid = $item->id; - break; + return $item->id; } } - return $itemid; + return null; } } From d88bc6b7f988b93450547787f704e69578f95d12 Mon Sep 17 00:00:00 2001 From: Michael Babker Date: Thu, 21 Dec 2017 01:09:25 +0100 Subject: [PATCH 02/19] Don't hardcode class/method names into Exception messages (#19049) --- libraries/cms/html/select.php | 5 +++- libraries/cms/html/sortablelist.php | 2 +- libraries/joomla/filesystem/path.php | 25 +++++++++++++++++--- libraries/src/Feed/Feed.php | 26 +++++++++++++++++---- libraries/src/Feed/FeedEntry.php | 26 +++++++++++++++++---- libraries/src/Form/Form.php | 6 ++--- libraries/src/Helper/RouteHelper.php | 2 +- libraries/src/Log/Logger/CallbackLogger.php | 2 +- libraries/src/Table/ContentType.php | 6 ++--- 9 files changed, 79 insertions(+), 21 deletions(-) diff --git a/libraries/cms/html/select.php b/libraries/cms/html/select.php index 835d1dff14..3cccd385b7 100644 --- a/libraries/cms/html/select.php +++ b/libraries/cms/html/select.php @@ -159,7 +159,10 @@ public static function suggestionlist($data, $optKey = 'value', $optText = 'text { // Log deprecated message JLog::add( - 'JHtmlSelect::suggestionlist() is deprecated. Create the tag directly instead.', + sprintf( + '%s() is deprecated. Create the tag directly instead.', + __METHOD__ + ), JLog::WARNING, 'deprecated' ); diff --git a/libraries/cms/html/sortablelist.php b/libraries/cms/html/sortablelist.php index 51646b0fa4..48171a811a 100644 --- a/libraries/cms/html/sortablelist.php +++ b/libraries/cms/html/sortablelist.php @@ -49,7 +49,7 @@ public static function sortable($tableId, $formId, $sortDir = 'asc', $saveOrderi // Note: $i is required but has to be an optional argument in the function call due to argument order if ($saveOrderingUrl === null) { - throw new InvalidArgumentException('$saveOrderingUrl is a required argument in JHtmlSortablelist::sortable'); + throw new InvalidArgumentException(sprintf('$saveOrderingUrl is a required argument in %s()', __METHOD__)); } $displayData = array( diff --git a/libraries/joomla/filesystem/path.php b/libraries/joomla/filesystem/path.php index 3827382f1d..d39368ce06 100644 --- a/libraries/joomla/filesystem/path.php +++ b/libraries/joomla/filesystem/path.php @@ -167,14 +167,27 @@ public static function check($path) if (strpos($path, '..') !== false) { // Don't translate - throw new Exception('JPath::check Use of relative paths not permitted', 20); + throw new Exception( + sprintf( + '%s() - Use of relative paths not permitted', + __METHOD__ + ), + 20 + ); } $path = self::clean($path); if ((JPATH_ROOT != '') && strpos($path, self::clean(JPATH_ROOT)) !== 0) { - throw new Exception('JPath::check Snooping out of bounds @ ' . $path, 20); + throw new Exception( + sprintf( + '%1$s() - Snooping out of bounds @ %2$s', + __METHOD__, + $path + ), + 20 + ); } return $path; @@ -195,7 +208,13 @@ public static function clean($path, $ds = DIRECTORY_SEPARATOR) { if (!is_string($path) && !empty($path)) { - throw new UnexpectedValueException('JPath::clean: $path is not a string.'); + throw new UnexpectedValueException( + sprintf( + '%s() - $path is not a string', + __METHOD__ + ), + 20 + ); } $path = trim($path); diff --git a/libraries/src/Feed/Feed.php b/libraries/src/Feed/Feed.php index 21147b693f..b6964067e2 100644 --- a/libraries/src/Feed/Feed.php +++ b/libraries/src/Feed/Feed.php @@ -85,13 +85,25 @@ public function __set($name, $value) // Validate that any authors that are set are instances of JFeedPerson or null. if (($name == 'author') && (!($value instanceof FeedPerson) || ($value === null))) { - throw new \InvalidArgumentException('Feed "author" must be of type FeedPerson. ' . gettype($value) . 'given.'); + throw new \InvalidArgumentException( + sprintf( + '%1$s "author" must be an instance of Joomla\\CMS\\Feed\\FeedPerson. %2$s given.', + get_class($this), + gettype($value) === 'object' ? get_class($value) : gettype($value) + ) + ); } // Disallow setting categories or contributors directly. - if (($name == 'categories') || ($name == 'contributors')) + if (in_array($name, array('categories', 'contributors'))) { - throw new \InvalidArgumentException('Cannot directly set Feed property "' . $name . '".'); + throw new \InvalidArgumentException( + sprintf( + 'Cannot directly set %1$s property "%2$s".', + get_class($this), + $name + ) + ); } $this->properties[$name] = $value; @@ -231,7 +243,13 @@ public function offsetSet($offset, $value) { if (!($value instanceof FeedEntry)) { - throw new \InvalidArgumentException('Cannot set value of type "' . gettype($value) . '".'); + throw new \InvalidArgumentException( + sprintf( + '%1$s entries must be an instance of Joomla\\CMS\\Feed\\FeedPerson. %2$s given.', + get_class($this), + gettype($value) === 'object' ? get_class($value) : gettype($value) + ) + ); } $this->entries[$offset] = $value; diff --git a/libraries/src/Feed/FeedEntry.php b/libraries/src/Feed/FeedEntry.php index 66867df79d..f19261d450 100644 --- a/libraries/src/Feed/FeedEntry.php +++ b/libraries/src/Feed/FeedEntry.php @@ -80,19 +80,37 @@ public function __set($name, $value) // Validate that any authors that are set are instances of JFeedPerson or null. if (($name == 'author') && (!($value instanceof FeedPerson) || ($value === null))) { - throw new \InvalidArgumentException('FeedEntry "author" must be of type FeedPerson. ' . gettype($value) . 'given.'); + throw new \InvalidArgumentException( + sprintf( + '%1$s "author" must be an instance of Joomla\\CMS\\Feed\\FeedPerson. %2$s given.', + get_class($this), + gettype($value) === 'object' ? get_class($value) : gettype($value) + ) + ); } // Validate that any sources that are set are instances of JFeed or null. if (($name == 'source') && (!($value instanceof Feed) || ($value === null))) { - throw new \InvalidArgumentException('FeedEntry "source" must be of type Feed. ' . gettype($value) . 'given.'); + throw new \InvalidArgumentException( + sprintf( + '%1$s "source" must be an instance of Joomla\\CMS\\Feed\\Feed. %2$s given.', + get_class($this), + gettype($value) === 'object' ? get_class($value) : gettype($value) + ) + ); } // Disallow setting categories, contributors, or links directly. - if (($name == 'categories') || ($name == 'contributors') || ($name == 'links')) + if (in_array($name, array('categories', 'contributors', 'links'))) { - throw new \InvalidArgumentException('Cannot directly set FeedEntry property "' . $name . '".'); + throw new \InvalidArgumentException( + sprintf( + 'Cannot directly set %1$s property "%2$s".', + get_class($this), + $name + ) + ); } $this->properties[$name] = $value; diff --git a/libraries/src/Form/Form.php b/libraries/src/Form/Form.php index 6faa1c1081..700cf67387 100644 --- a/libraries/src/Form/Form.php +++ b/libraries/src/Form/Form.php @@ -2205,7 +2205,7 @@ public static function getInstance($name, $data = null, $options = array(), $rep if (empty($data)) { - throw new \InvalidArgumentException(sprintf('Form::getInstance(%s, *%s*)', $name, gettype($data))); + throw new \InvalidArgumentException(sprintf('%1$s(%2$s, *%3$s*)', __METHOD__, $name, gettype($data))); } // Instantiate the form. @@ -2216,14 +2216,14 @@ public static function getInstance($name, $data = null, $options = array(), $rep { if ($forms[$name]->load($data, $replace, $xpath) == false) { - throw new \RuntimeException('JForm::getInstance could not load form'); + throw new \RuntimeException(sprintf('%s() could not load form', __METHOD__)); } } else { if ($forms[$name]->loadFile($data, $replace, $xpath) == false) { - throw new \RuntimeException('JForm::getInstance could not load file'); + throw new \RuntimeException(sprintf('%s() could not load file', __METHOD__)); } } } diff --git a/libraries/src/Helper/RouteHelper.php b/libraries/src/Helper/RouteHelper.php index d72cdb4552..6410bf9b38 100644 --- a/libraries/src/Helper/RouteHelper.php +++ b/libraries/src/Helper/RouteHelper.php @@ -241,7 +241,7 @@ public static function getCategoryRoute($catid, $language = 0, $extension = '') // Note: $extension is required but has to be an optional argument in the function call due to argument order if (empty($extension)) { - throw new \InvalidArgumentException('$extension is a required argument in RouteHelper::getCategoryRoute'); + throw new \InvalidArgumentException(sprintf('$extension is a required argument in %s()', __METHOD__)); } if ($catid instanceof \JCategoryNode) diff --git a/libraries/src/Log/Logger/CallbackLogger.php b/libraries/src/Log/Logger/CallbackLogger.php index b48682beb6..6d876bed5c 100644 --- a/libraries/src/Log/Logger/CallbackLogger.php +++ b/libraries/src/Log/Logger/CallbackLogger.php @@ -47,7 +47,7 @@ public function __construct(array &$options) // Throw an exception if there is not a valid callback if (!isset($this->options['callback']) || !is_callable($this->options['callback'])) { - throw new \RuntimeException('JLogLoggerCallback created without valid callback function.'); + throw new \RuntimeException(sprintf('%s created without valid callback function.', get_class($this))); } $this->callback = $this->options['callback']; diff --git a/libraries/src/Table/ContentType.php b/libraries/src/Table/ContentType.php index 7e73d2a141..0b5dfb6c9d 100644 --- a/libraries/src/Table/ContentType.php +++ b/libraries/src/Table/ContentType.php @@ -132,12 +132,12 @@ public function getContentTable() { if (is_object($tableInfo->special) && isset($tableInfo->special->type) && isset($tableInfo->special->prefix)) { - $class = isset($tableInfo->special->class) ? $tableInfo->special->class : 'Joomla\\Cms\\Table\\Table'; + $class = isset($tableInfo->special->class) ? $tableInfo->special->class : 'Joomla\\CMS\\Table\\Table'; - if (!class_implements($class, 'Joomla\\Cms\\Table\\TableInterface')) + if (!class_implements($class, 'Joomla\\CMS\\Table\\TableInterface')) { // This isn't an instance of TableInterface. Abort. - throw new \RuntimeException('Class must be an instance of TableInterface'); + throw new \RuntimeException('Class must be an instance of Joomla\\CMS\\Table\\TableInterface'); } $result = $class::getInstance($tableInfo->special->type, $tableInfo->special->prefix); From 5339ba9448b400d0077bc65c906ddd960588105a Mon Sep 17 00:00:00 2001 From: Michael Richey Date: Wed, 20 Dec 2017 18:10:24 -0600 Subject: [PATCH 03/19] [com_fields] Encode complex values to JSON (#19025) * Minor adjustment to field value This adjustment allows complex field types (types with more than one input) to store and retrieve data. * coding style compliance * coding style compliance * more rigorous test single dimension arrays are already handled, so this alteration changes the behavior to limit the effect to multi-dimensional arrays. * Update fields.php --- plugins/system/fields/fields.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/system/fields/fields.php b/plugins/system/fields/fields.php index 297baa493d..c20f770700 100644 --- a/plugins/system/fields/fields.php +++ b/plugins/system/fields/fields.php @@ -90,6 +90,12 @@ public function onContentAfterSave($context, $item, $isNew, $data = array()) // Determine the value if it is available from the data $value = key_exists($field->name, $fieldsData) ? $fieldsData[$field->name] : null; + // JSON encode value for complex fields + if (is_array($value) && count($value, COUNT_NORMAL) !== count($value, COUNT_RECURSIVE)) + { + $value = json_encode($value); + } + // Setting the value for the field and the item $model->setFieldValue($field->id, $item->id, $value); } From 164a259fad089e3a019ae179194e12c6b9545781 Mon Sep 17 00:00:00 2001 From: Elijah Madden Date: Thu, 21 Dec 2017 09:11:06 +0900 Subject: [PATCH 04/19] In-menu-item modal modual editor fix (#18982) Instead of one modal per module -> one generalized modal for ALL modules Instead of specific js functions for each modal -> generalized js for ALL modals --- .../views/item/tmpl/edit_modules.php | 100 +++++++++++------- 1 file changed, 60 insertions(+), 40 deletions(-) diff --git a/administrator/components/com_menus/views/item/tmpl/edit_modules.php b/administrator/components/com_menus/views/item/tmpl/edit_modules.php index 726b4b8c2a..f0192db7aa 100644 --- a/administrator/components/com_menus/views/item/tmpl/edit_modules.php +++ b/administrator/components/com_menus/views/item/tmpl/edit_modules.php @@ -17,29 +17,69 @@ JFactory::getDocument()->addScriptDeclaration(' var viewLevels = ' . json_encode($allLevels) . ', - menuId = parseInt(' . $this->item->id . '); + menuId = parseInt(' . (int) $this->item->id . '); - jQuery(document).ready(function() { - jQuery(document).on("click", "input:radio[id^=\'jform_toggle_modules_assigned1\']", function (event) { - jQuery(".table tr.no").hide(); - }); - jQuery(document).on("click", "input:radio[id^=\'jform_toggle_modules_assigned0\']", function (event) { - jQuery(".table tr.no").show(); - }); - jQuery(document).on("click", "input:radio[id^=\'jform_toggle_modules_published1\']", function (event) { - jQuery(".table tr.unpublished").hide(); - }); - jQuery(document).on("click", "input:radio[id^=\'jform_toggle_modules_published0\']", function (event) { - jQuery(".table tr.unpublished").show(); - }); + jQuery(function($) { + var baseLink = "index.php?option=com_modules&client_id=0&task=module.edit&tmpl=component&view=module&layout=modal&id=", + iFrameAttr = "class=\"iframe jviewport-height70\""; + + $(document) + .on("click", "input:radio[id^=\'jform_toggle_modules_assigned1\']", function (event) { + $(".table tr.no").hide(); + }) + .on("click", "input:radio[id^=\'jform_toggle_modules_assigned0\']", function (event) { + $(".table tr.no").show(); + }) + .on("click", "input:radio[id^=\'jform_toggle_modules_published1\']", function (event) { + $(".table tr.unpublished").hide(); + }) + .on("click", "input:radio[id^=\'jform_toggle_modules_published0\']", function (event) { + $(".table tr.unpublished").show(); + }) + .on("click", ".module-edit-link", function () { + var link = baseLink + $(this).data("moduleId"), + iFrame = $(""); + + $("#moduleEditModal").modal() + .find(".modal-body").empty().prepend(iFrame); + }) + .on("click", "#moduleEditModal .modal-footer .btn", function () { + var target = $(this).data("target"); + + if (target) { + $("#moduleEditModal iframe").contents().find(target).click(); + } + }); }); '); + JFactory::getDocument()->addStyleDeclaration(' ul.horizontal-buttons li { display: inline-block; padding-right: 10%; } '); + +// Set up the bootstrap modal that will be used for all module editors +echo JHtml::_( + 'bootstrap.renderModal', + 'moduleEditModal', + array( + 'title' => JText::_('COM_MENUS_EDIT_MODULE_SETTINGS'), + 'backdrop' => 'static', + 'keyboard' => false, + 'closeButton' => false, + 'bodyHeight' => '70', + 'modalWidth' => '80', + 'footer' => '' + . '' + . '', + ) +); + ?> - id . '&tmpl=component&view=module&layout=modal'; ?> - + escape($module->title); ?> @@ -131,30 +175,6 @@ - id . 'Modal', - array( - 'title' => JText::_('COM_MENUS_EDIT_MODULE_SETTINGS'), - 'backdrop' => 'static', - 'keyboard' => false, - 'closeButton' => false, - 'url' => $link, - 'height' => '400px', - 'width' => '800px', - 'bodyHeight' => '70', - 'modalWidth' => '80', - 'footer' => '' - . '' - . '', - ) - ); ?> From 37ec66368b04d8fd91f82805fd2b177b6e51665c Mon Sep 17 00:00:00 2001 From: Brian Teeman Date: Thu, 21 Dec 2017 00:11:57 +0000 Subject: [PATCH 05/19] [com_fields] Color plugin - invalid markup (#18239) * [com_fields]Color plugin - invalid markup Create a color field for content and set it to be required Open an article to edit and view the source You will see `` Note the data-control="hue"1 the 1 should not be there This PR resolves that PR for #18067 * revert readonly --- layouts/joomla/form/field/color/advanced.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/joomla/form/field/color/advanced.php b/layouts/joomla/form/field/color/advanced.php index b446b36541..ec3164d40e 100644 --- a/layouts/joomla/form/field/color/advanced.php +++ b/layouts/joomla/form/field/color/advanced.php @@ -77,4 +77,4 @@ JHtml::_('script', 'system/color-field-adv-init.min.js', array('version' => 'auto', 'relative' => true)); ?> /> +echo $hint . $class . $position . $control . $readonly . $disabled . $onchange . $autocomplete . $autofocus . $format . $keywords . $direction . $validate; ?>/> From 0531d2f302bd3549e4a5aa0f868235aaf287b43a Mon Sep 17 00:00:00 2001 From: joomlart Date: Thu, 21 Dec 2017 07:13:22 +0700 Subject: [PATCH 06/19] Passing a null value for the first argument of Text::script() is deprecated (#18101) Use Text::getScriptStrings() instead. --- libraries/src/Document/HtmlDocument.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/src/Document/HtmlDocument.php b/libraries/src/Document/HtmlDocument.php index 83191c4f72..098efa196b 100644 --- a/libraries/src/Document/HtmlDocument.php +++ b/libraries/src/Document/HtmlDocument.php @@ -145,7 +145,7 @@ public function getHeadData() $data['scripts'] = $this->_scripts; $data['script'] = $this->_script; $data['custom'] = $this->_custom; - $data['scriptText'] = \JText::script(); + $data['scriptText'] = \JText::getScriptStrings(); return $data; } From f925beb086d5a75d33065bab72d3e31faa5c82df Mon Sep 17 00:00:00 2001 From: zero-24 Date: Sat, 31 Mar 2018 20:41:05 +0200 Subject: [PATCH 07/19] drop gmail on new installs (#18322) --- .../en-GB/en-GB.plg_authentication_gmail.ini | 18 -- .../en-GB.plg_authentication_gmail.sys.ini | 7 - installation/sql/mysql/joomla.sql | 1 - installation/sql/postgresql/joomla.sql | 1 - plugins/authentication/gmail/gmail.php | 242 ------------------ plugins/authentication/gmail/gmail.xml | 74 ------ 6 files changed, 343 deletions(-) delete mode 100644 administrator/language/en-GB/en-GB.plg_authentication_gmail.ini delete mode 100644 administrator/language/en-GB/en-GB.plg_authentication_gmail.sys.ini delete mode 100644 plugins/authentication/gmail/gmail.php delete mode 100644 plugins/authentication/gmail/gmail.xml diff --git a/administrator/language/en-GB/en-GB.plg_authentication_gmail.ini b/administrator/language/en-GB/en-GB.plg_authentication_gmail.ini deleted file mode 100644 index 2bfaf314a8..0000000000 --- a/administrator/language/en-GB/en-GB.plg_authentication_gmail.ini +++ /dev/null @@ -1,18 +0,0 @@ -; Joomla! Project -; Copyright (C) 2005 - 2017 Open Source Matters. All rights reserved. -; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php -; Note : All ini files need to be saved as UTF-8 - -PLG_AUTHENTICATION_GMAIL="Authentication - Gmail" -PLG_GMAIL_ERROR_LOCAL_USERNAME_CONFLICT="A local username conflicts with your Gmail username." -PLG_GMAIL_FIELD_APPLYSUFFIX_LABEL="Apply Username Suffix" -PLG_GMAIL_FIELD_BACKEND_LOGIN_LABEL="Backend Login" -PLG_GMAIL_FIELD_SUFFIX_DESC="A suffix to use for the username, typically gmail.com (or googlemail.com) is the suffix but you may wish to use a Google Apps for Your Domain suffix, this doesn't include the @ symbol." -PLG_GMAIL_FIELD_SUFFIX_LABEL="Username Suffix" -PLG_GMAIL_FIELD_USER_BLACKLIST_DESC="The usernames should be separated by a comma." -PLG_GMAIL_FIELD_USER_BLACKLIST_LABEL="Username Blacklist" -PLG_GMAIL_FIELD_VALUE_APPLYSUFFIXALWAYS="Always use suffix" -PLG_GMAIL_FIELD_VALUE_APPLYSUFFIXMISSING="Apply suffix if missing" -PLG_GMAIL_FIELD_VALUE_NOAPPLYSUFFIX="Don't Apply Suffix" -PLG_GMAIL_FIELD_VERIFYPEER_LABEL="Verify Peer" -PLG_GMAIL_XML_DESCRIPTION="Handles User Authentication with a Gmail or Googlemail account (Requires cURL).
Users may need to enable Access for less secure apps at https://www.google.com/settings/security/lesssecureapps to be able to log in using this method.
Warning! You must have at least one authentication plugin enabled or you will lose all access to your site." diff --git a/administrator/language/en-GB/en-GB.plg_authentication_gmail.sys.ini b/administrator/language/en-GB/en-GB.plg_authentication_gmail.sys.ini deleted file mode 100644 index b9c9e63266..0000000000 --- a/administrator/language/en-GB/en-GB.plg_authentication_gmail.sys.ini +++ /dev/null @@ -1,7 +0,0 @@ -; Joomla! Project -; Copyright (C) 2005 - 2017 Open Source Matters. All rights reserved. -; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php -; Note : All ini files need to be saved as UTF-8 - -PLG_AUTHENTICATION_GMAIL="Authentication - Gmail" -PLG_GMAIL_XML_DESCRIPTION="Handles User Authentication with a Gmail or Googlemail account (Requires cURL).
Users may need to enable Access for less secure apps at https://www.google.com/settings/security/lesssecureapps to be able to log in using this method.
Warning! You must have at least one authentication plugin enabled or you will lose all access to your site." diff --git a/installation/sql/mysql/joomla.sql b/installation/sql/mysql/joomla.sql index 9b7452b823..5ea362f83a 100644 --- a/installation/sql/mysql/joomla.sql +++ b/installation/sql/mysql/joomla.sql @@ -559,7 +559,6 @@ INSERT INTO `#__extensions` (`extension_id`, `package_id`, `name`, `type`, `elem (316, 0, 'mod_tags_popular', 'module', 'mod_tags_popular', '', 0, 1, 1, 0, '', '{"maximum":"5","timeframe":"alltime","owncache":"1"}', 0, '0000-00-00 00:00:00', 0, 0, ''), (317, 0, 'mod_tags_similar', 'module', 'mod_tags_similar', '', 0, 1, 1, 0, '', '{"maximum":"5","matchtype":"any","owncache":"1"}', 0, '0000-00-00 00:00:00', 0, 0, ''), (318, 0, 'mod_sampledata', 'module', 'mod_sampledata', '', 1, 1, 1, 0, '', '{}', 0, '0000-00-00 00:00:00', 0, 0, ''), -(400, 0, 'plg_authentication_gmail', 'plugin', 'gmail', 'authentication', 0, 0, 1, 0, '', '{"applysuffix":"0","suffix":"","verifypeer":"1","user_blacklist":""}', 0, '0000-00-00 00:00:00', 1, 0, ''), (401, 0, 'plg_authentication_joomla', 'plugin', 'joomla', 'authentication', 0, 1, 1, 1, '', '', 0, '0000-00-00 00:00:00', 0, 0, ''), (402, 0, 'plg_authentication_ldap', 'plugin', 'ldap', 'authentication', 0, 0, 1, 0, '', '{"host":"","port":"389","use_ldapV3":"0","negotiate_tls":"0","no_referrals":"0","auth_method":"bind","base_dn":"","search_string":"","users_dn":"","username":"admin","password":"bobby7","ldap_fullname":"fullName","ldap_email":"mail","ldap_uid":"uid"}', 0, '0000-00-00 00:00:00', 3, 0, ''), (403, 0, 'plg_content_contact', 'plugin', 'contact', 'content', 0, 1, 1, 0, '', '', 0, '0000-00-00 00:00:00', 1, 0, ''), diff --git a/installation/sql/postgresql/joomla.sql b/installation/sql/postgresql/joomla.sql index 6a5ac93c48..150c2027ee 100644 --- a/installation/sql/postgresql/joomla.sql +++ b/installation/sql/postgresql/joomla.sql @@ -570,7 +570,6 @@ INSERT INTO "#__extensions" ("extension_id", "package_id", "name", "type", "elem (315, 0, 'mod_stats_admin', 'module', 'mod_stats_admin', '', 1, 1, 1, 0, '', '{"serverinfo":"0","siteinfo":"0","counter":"0","increase":"0","cache":"1","cache_time":"900","cachemode":"static"}', 0, '1970-01-01 00:00:00', 0, 0, ''), (316, 0, 'mod_tags_popular', 'module', 'mod_tags_popular', '', 0, 1, 1, 0, '', '{"maximum":"5","timeframe":"alltime","owncache":"1"}', 0, '1970-01-01 00:00:00', 0, 0, ''), (317, 0, 'mod_tags_similar', 'module', 'mod_tags_similar', '', 0, 1, 1, 0, '', '{"maximum":"5","matchtype":"any","owncache":"1"}', 0, '1970-01-01 00:00:00', 0, 0, ''), -(400, 0, 'plg_authentication_gmail', 'plugin', 'gmail', 'authentication', 0, 0, 1, 0, '', '{"applysuffix":"0","suffix":"","verifypeer":"1","user_blacklist":""}', 0, '1970-01-01 00:00:00', 1, 0, ''), (401, 0, 'plg_authentication_joomla', 'plugin', 'joomla', 'authentication', 0, 1, 1, 1, '', '', 0, '1970-01-01 00:00:00', 0, 0, ''), (402, 0, 'plg_authentication_ldap', 'plugin', 'ldap', 'authentication', 0, 0, 1, 0, '', '{"host":"","port":"389","use_ldapV3":"0","negotiate_tls":"0","no_referrals":"0","auth_method":"bind","base_dn":"","search_string":"","users_dn":"","username":"admin","password":"bobby7","ldap_fullname":"fullName","ldap_email":"mail","ldap_uid":"uid"}', 0, '1970-01-01 00:00:00', 3, 0, ''), (403, 0, 'plg_content_contact', 'plugin', 'contact', 'content', 0, 1, 1, 0, '', '', 0, '1970-01-01 00:00:00', 1, 0, ''), diff --git a/plugins/authentication/gmail/gmail.php b/plugins/authentication/gmail/gmail.php deleted file mode 100644 index 84acf797a4..0000000000 --- a/plugins/authentication/gmail/gmail.php +++ /dev/null @@ -1,242 +0,0 @@ -loadLanguage(); - - // No backend authentication - if (Factory::getApplication()->isClient('administrator') && !$this->params->get('backendLogin', 0)) - { - return; - } - - $success = false; - - $curlParams = array( - 'follow_location' => true, - 'transport.curl' => array( - CURLOPT_SSL_VERIFYPEER => $this->params->get('verifypeer', 1) - ), - ); - - $transportParams = new Registry($curlParams); - - try - { - $http = HttpFactory::getHttp($transportParams, 'curl'); - } - catch (RuntimeException $e) - { - $response->status = Authentication::STATUS_FAILURE; - $response->type = 'GMail'; - $response->error_message = Text::sprintf('JGLOBAL_AUTH_FAILED', Text::_('JGLOBAL_AUTH_CURL_NOT_INSTALLED')); - - return; - } - - // Check if we have a username and password - if ($credentials['username'] === '' || $credentials['password'] === '') - { - $response->type = 'GMail'; - $response->status = Authentication::STATUS_FAILURE; - $response->error_message = Text::sprintf('JGLOBAL_AUTH_FAILED', Text::_('JGLOBAL_AUTH_USER_BLACKLISTED')); - - return; - } - - $blacklist = explode(',', $this->params->get('user_blacklist', '')); - - // Check if the username isn't blacklisted - if (in_array($credentials['username'], $blacklist)) - { - $response->type = 'GMail'; - $response->status = Authentication::STATUS_FAILURE; - $response->error_message = Text::sprintf('JGLOBAL_AUTH_FAILED', Text::_('JGLOBAL_AUTH_USER_BLACKLISTED')); - - return; - } - - $suffix = $this->params->get('suffix', ''); - $applysuffix = $this->params->get('applysuffix', 0); - $offset = strpos($credentials['username'], '@'); - - // Check if we want to do suffix stuff, typically for Google Apps for Your Domain - if ($suffix && $applysuffix) - { - if ($applysuffix == 1 && $offset === false) - { - // Apply suffix if missing - $credentials['username'] .= '@' . $suffix; - } - elseif ($applysuffix == 2) - { - // Always use suffix - if ($offset) - { - // If we already have an @, get rid of it and replace it - $credentials['username'] = substr($credentials['username'], 0, $offset); - } - - $credentials['username'] .= '@' . $suffix; - } - } - - $headers = array( - 'Authorization' => 'Basic ' . base64_encode($credentials['username'] . ':' . $credentials['password']) - ); - - try - { - $result = $http->get('https://mail.google.com/mail/feed/atom', $headers); - } - catch (Exception $e) - { - // If there was an error in the request then create a 'false' dummy response. - $result = new Response; - $result = $result->withStatus(500); - } - - $code = $result->code; - - switch ($code) - { - case 200 : - $message = Text::_('JGLOBAL_AUTH_ACCESS_GRANTED'); - $success = true; - break; - - case 401 : - $message = Text::_('JGLOBAL_AUTH_ACCESS_DENIED'); - break; - - default : - $message = Text::_('JGLOBAL_AUTH_UNKNOWN_ACCESS_DENIED'); - break; - } - - $response->type = 'GMail'; - - if (!$success) - { - $response->status = Authentication::STATUS_FAILURE; - $response->error_message = Text::sprintf('JGLOBAL_AUTH_FAILED', $message); - - return; - } - - if (strpos($credentials['username'], '@') === false) - { - if ($suffix) - { - // If there is a suffix then we want to apply it - $email = $credentials['username'] . '@' . $suffix; - } - else - { - // If there isn't a suffix just use the default gmail one - $email = $credentials['username'] . '@gmail.com'; - } - } - else - { - // The username looks like an email address (probably is) so use that - $email = $credentials['username']; - } - - // Extra security checks with existing local accounts - $db = Factory::getDbo(); - $localUsernameChecks = array(strstr($email, '@', true), $email); - - $query = $db->getQuery(true) - ->select('id, activation, username, email, block') - ->from('#__users') - ->where('username IN(' . implode(',', array_map(array($db, 'quote'), $localUsernameChecks)) . ')' - . ' OR email = ' . $db->quote($email) - ); - - $db->setQuery($query); - - if ($localUsers = $db->loadObjectList()) - { - foreach ($localUsers as $localUser) - { - // Local user exists with same username but different email address - if ($email !== $localUser->email) - { - $response->status = Authentication::STATUS_FAILURE; - $response->error_message = Text::sprintf('JGLOBAL_AUTH_FAILED', Text::_('PLG_GMAIL_ERROR_LOCAL_USERNAME_CONFLICT')); - - return; - } - else - { - // Existing user disabled locally - if ($localUser->block || !empty($localUser->activation)) - { - $response->status = Authentication::STATUS_FAILURE; - $response->error_message = Text::_('JGLOBAL_AUTH_ACCESS_DENIED'); - - return; - } - - // We will always keep the local username for existing accounts - $credentials['username'] = $localUser->username; - - break; - } - } - } - elseif (Factory::getApplication()->isClient('administrator')) - { - // We wont' allow backend access without local account - $response->status = Authentication::STATUS_FAILURE; - $response->error_message = Text::_('JERROR_LOGIN_DENIED'); - - return; - } - - $response->status = Authentication::STATUS_SUCCESS; - $response->error_message = ''; - $response->email = $email; - - // Reset the username to what we ended up using - $response->username = $credentials['username']; - $response->fullname = $credentials['username']; - } -} diff --git a/plugins/authentication/gmail/gmail.xml b/plugins/authentication/gmail/gmail.xml deleted file mode 100644 index 60562234f9..0000000000 --- a/plugins/authentication/gmail/gmail.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - plg_authentication_gmail - Joomla! Project - February 2006 - Copyright (C) 2005 - 2017 Open Source Matters. All rights reserved. - GNU General Public License version 2 or later; see LICENSE.txt - admin@joomla.org - www.joomla.org - 3.0.0 - PLG_GMAIL_XML_DESCRIPTION - - gmail.php - - - en-GB.plg_authentication_gmail.ini - en-GB.plg_authentication_gmail.sys.ini - - - -
- - - - - - - - - - - - - - - - - - - -
-
-
-
From 11daf532343471b68d72b43952dd5cec7220f9dd Mon Sep 17 00:00:00 2001 From: David Jardin Date: Sat, 31 Mar 2018 21:19:36 +0200 Subject: [PATCH 08/19] 4.0 Removed hardcoded error reporting levels from CLI scripts (#20027) * Removed hardcoded maximum error reporting statement * Also removed statement from finder indexer --- cli/finder_indexer.php | 4 ---- cli/joomla.php | 4 ---- 2 files changed, 8 deletions(-) diff --git a/cli/finder_indexer.php b/cli/finder_indexer.php index 010f7ffcec..51b4ba412c 100644 --- a/cli/finder_indexer.php +++ b/cli/finder_indexer.php @@ -38,10 +38,6 @@ // Get the framework. require_once JPATH_BASE . '/includes/framework.php'; -// Configure error reporting to maximum for CLI output. -error_reporting(E_ALL); -ini_set('display_errors', 1); - // Load Library language $lang = JFactory::getLanguage(); diff --git a/cli/joomla.php b/cli/joomla.php index 862611975c..b50de254fe 100644 --- a/cli/joomla.php +++ b/cli/joomla.php @@ -24,10 +24,6 @@ // Get the framework. require_once JPATH_BASE . '/includes/framework.php'; -// Configure error reporting to maximum for CLI output. -error_reporting(E_ALL); -ini_set('display_errors', 1); - $app = \Joomla\CMS\Factory::getContainer()->get(\Joomla\Console\Application::class); \Joomla\CMS\Factory::$application = $app; $app->execute(); From 5005838fa36b017fe898482075c64b32926d773d Mon Sep 17 00:00:00 2001 From: infograf768 Date: Sun, 1 Apr 2018 01:48:34 +0200 Subject: [PATCH 09/19] [4.0] Multilanguage. Set the multilangstatus module as published or not in the modules manager depending on the status of the languagefilter plugin (#19463) * [4.0] Multilanguage. Set the multilangstatus module as published or not in the modules manager depending on the status of the languagefilter plugin * Adding various checks --- .../Helper/MultilangstatusAdminHelper.php | 140 ++++++++++++++++++ .../modules/mod_status/tmpl/default.php | 22 ++- 2 files changed, 158 insertions(+), 4 deletions(-) create mode 100644 administrator/modules/mod_multilangstatus/Helper/MultilangstatusAdminHelper.php diff --git a/administrator/modules/mod_multilangstatus/Helper/MultilangstatusAdminHelper.php b/administrator/modules/mod_multilangstatus/Helper/MultilangstatusAdminHelper.php new file mode 100644 index 0000000000..c7d19c21f4 --- /dev/null +++ b/administrator/modules/mod_multilangstatus/Helper/MultilangstatusAdminHelper.php @@ -0,0 +1,140 @@ +getQuery(true) + ->select($db->quoteName('enabled')) + ->from($db->quoteName('#__extensions')) + ->where($db->quoteName('type') . ' = ' . $db->quote('module')) + ->where($db->quoteName('element') . ' = ' . $db->quote('mod_multilangstatus')); + $db->setQuery($query); + + try + { + $result = (int) $db->loadResult(); + } + catch (\RuntimeException $e) + { + $app->enqueueMessage($e->getMessage(), 'error'); + } + + return $result; + } + + /** + * Method to check the state of the module + * + * @return void + * + * @since __DEPLOY_VERSION__ + */ + public static function getState() + { + $app = Factory::getApplication(); + $db = Factory::getDbo(); + + $query = $db->getQuery(true) + ->select($db->quoteName('published')) + ->from($db->quoteName('#__modules')) + ->where($db->quoteName('module') . ' = ' . $db->quote('mod_multilangstatus')); + $db->setQuery($query); + + try + { + $result = (int) $db->loadResult(); + } + catch (\RuntimeException $e) + { + $app->enqueueMessage($e->getMessage(), 'error'); + } + + return $result; + } + + /** + * Method to publish/unpublish the module depending on the languagefilter state + * + * @return void + * + * @since __DEPLOY_VERSION__ + */ + public static function publish() + { + $app = Factory::getApplication(); + $db = Factory::getDbo(); + + // If the module is trashed do not change its status + if (self::getState() != -2) + { + // Publish the module when the languagefilter is enabled + if (Multilanguage::isEnabled()) + { + $query = $db->getQuery(true) + ->update($db->quoteName('#__modules')) + ->set($db->quoteName('published') . ' = ' . (int) 1) + ->where($db->quoteName('module') . ' = ' . $db->quote('mod_multilangstatus')); + + try + { + $db->setQuery($query)->execute(); + } + catch (\RuntimeException $e) + { + $app->enqueueMessage($e->getMessage(), 'error'); + + return; + } + } + else + { + // Unpublish the module when the languagefilter is disabled + $query = $db->getQuery(true) + ->update($db->quoteName('#__modules')) + ->set($db->quoteName('published') . ' = ' . (int) 0) + ->where($db->quoteName('module') . ' = ' . $db->quote('mod_multilangstatus')); + + try + { + $db->setQuery($query)->execute(); + } + catch (Exception $e) + { + $app->enqueueMessage($e->getMessage(), 'error'); + + return; + } + } + } + } +} diff --git a/administrator/modules/mod_status/tmpl/default.php b/administrator/modules/mod_status/tmpl/default.php index 57c7e5c5ef..d8f0c7f4a8 100644 --- a/administrator/modules/mod_status/tmpl/default.php +++ b/administrator/modules/mod_status/tmpl/default.php @@ -17,16 +17,30 @@ use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; use Joomla\CMS\Helper\ModuleHelper; +use Joomla\Module\Multilangstatus\Administrator\Helper\MultilangstatusAdminHelper; $hideLinks = $app->input->getBool('hidemainmenu'); +// Check if the multilangstatus module is present in the site +if (class_exists(MultilangstatusAdminHelper::class)) +{ + // Check if the module is present and enabled in the extensions table + if (MultilangstatusAdminHelper::isEnabled()) + { + // Publish/Unpublish the module if it exists in the modules table + // depending on the status of the languagefilter + MultilangstatusAdminHelper::publish(); + } +} ?>