diff --git a/administrator/components/com_banners/banners.php b/administrator/components/com_banners/banners.php index d673982001aff..2db000db4c36f 100644 --- a/administrator/components/com_banners/banners.php +++ b/administrator/components/com_banners/banners.php @@ -12,7 +12,7 @@ if (!JFactory::getUser()->authorise('core.manage', 'com_banners')) { - throw new JControllerExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); + throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); } // Execute the task. diff --git a/administrator/components/com_cache/cache.php b/administrator/components/com_cache/cache.php index 694adac16ccab..f42244702f049 100644 --- a/administrator/components/com_cache/cache.php +++ b/administrator/components/com_cache/cache.php @@ -11,7 +11,7 @@ if (!JFactory::getUser()->authorise('core.manage', 'com_cache')) { - return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); + throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); } $controller = JControllerLegacy::getInstance('Cache'); diff --git a/administrator/components/com_categories/categories.php b/administrator/components/com_categories/categories.php index 91219048d14de..b06ab6761a19b 100644 --- a/administrator/components/com_categories/categories.php +++ b/administrator/components/com_categories/categories.php @@ -18,7 +18,7 @@ if (!JFactory::getUser()->authorise('core.manage', $component)) { - return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); + throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); } JLoader::register('JHtmlCategoriesAdministrator', JPATH_ADMINISTRATOR . '/components/com_categories/helpers/html/categoriesadministrator.php'); diff --git a/administrator/components/com_checkin/checkin.php b/administrator/components/com_checkin/checkin.php index 911bb2603dc5d..9f7d1f7417495 100644 --- a/administrator/components/com_checkin/checkin.php +++ b/administrator/components/com_checkin/checkin.php @@ -11,7 +11,7 @@ if (!JFactory::getUser()->authorise('core.manage', 'com_checkin')) { - return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); + throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); } $controller = JControllerLegacy::getInstance('Checkin'); diff --git a/administrator/components/com_contact/contact.php b/administrator/components/com_contact/contact.php index 7489fc3e734bc..0085da569d117 100644 --- a/administrator/components/com_contact/contact.php +++ b/administrator/components/com_contact/contact.php @@ -12,7 +12,7 @@ if (!JFactory::getUser()->authorise('core.manage', 'com_contact')) { - return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); + throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); } $controller = JControllerLegacy::getInstance('contact'); diff --git a/administrator/components/com_content/content.php b/administrator/components/com_content/content.php index 516564ec579fe..78bb8fee16650 100644 --- a/administrator/components/com_content/content.php +++ b/administrator/components/com_content/content.php @@ -12,7 +12,7 @@ if (!JFactory::getUser()->authorise('core.manage', 'com_content')) { - return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); + throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); } JLoader::register('ContentHelper', __DIR__ . '/helpers/content.php'); diff --git a/administrator/components/com_contenthistory/contenthistory.php b/administrator/components/com_contenthistory/contenthistory.php index 5e76938a84ef3..58de68d98de01 100644 --- a/administrator/components/com_contenthistory/contenthistory.php +++ b/administrator/components/com_contenthistory/contenthistory.php @@ -12,7 +12,7 @@ // Disallow unauthenticated users if (JFactory::getUser()->guest) { - return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); + throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); } $controller = JControllerLegacy::getInstance('Contenthistory', array('base_path' => JPATH_COMPONENT_ADMINISTRATOR)); diff --git a/administrator/components/com_finder/finder.php b/administrator/components/com_finder/finder.php index ad1107f561c0a..49f37bc9b2cac 100644 --- a/administrator/components/com_finder/finder.php +++ b/administrator/components/com_finder/finder.php @@ -11,7 +11,7 @@ if (!JFactory::getUser()->authorise('core.manage', 'com_finder')) { - return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); + throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); } $controller = JControllerLegacy::getInstance('Finder'); diff --git a/administrator/components/com_installer/installer.php b/administrator/components/com_installer/installer.php index 5d00e11e4a9a7..a8726ed99b2ee 100644 --- a/administrator/components/com_installer/installer.php +++ b/administrator/components/com_installer/installer.php @@ -12,7 +12,7 @@ if (!JFactory::getUser()->authorise('core.manage', 'com_installer')) { - return JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR')); + throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); } $controller = JControllerLegacy::getInstance('Installer'); diff --git a/administrator/components/com_joomlaupdate/joomlaupdate.php b/administrator/components/com_joomlaupdate/joomlaupdate.php index 939760c3830b0..55cd7f8bb65d8 100644 --- a/administrator/components/com_joomlaupdate/joomlaupdate.php +++ b/administrator/components/com_joomlaupdate/joomlaupdate.php @@ -11,7 +11,7 @@ if (!JFactory::getUser()->authorise('core.manage', 'com_joomlaupdate')) { - return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); + throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); } $controller = JControllerLegacy::getInstance('Joomlaupdate'); diff --git a/administrator/components/com_languages/languages.php b/administrator/components/com_languages/languages.php index 30d3765461327..913469ca5c57a 100644 --- a/administrator/components/com_languages/languages.php +++ b/administrator/components/com_languages/languages.php @@ -12,7 +12,7 @@ if (!JFactory::getUser()->authorise('core.manage', 'com_languages')) { - return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); + throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); } $controller = JControllerLegacy::getInstance('Languages'); diff --git a/administrator/components/com_media/media.php b/administrator/components/com_media/media.php index 2071beeb163ee..5d50f908ecdae 100644 --- a/administrator/components/com_media/media.php +++ b/administrator/components/com_media/media.php @@ -20,7 +20,7 @@ && count($user->getAuthorisedCategories($asset, 'core.create')) == 0) && !($user->id == $author && $user->authorise('core.edit.own', $asset)))) { - return JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR')); + throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); } $params = JComponentHelper::getParams('com_media'); diff --git a/administrator/components/com_menus/menus.php b/administrator/components/com_menus/menus.php index d65440794e602..e4453e9202066 100644 --- a/administrator/components/com_menus/menus.php +++ b/administrator/components/com_menus/menus.php @@ -11,7 +11,7 @@ if (!JFactory::getUser()->authorise('core.manage', 'com_menus')) { - return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); + throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); } $controller = JControllerLegacy::getInstance('Menus'); diff --git a/administrator/components/com_messages/messages.php b/administrator/components/com_messages/messages.php index fb1f846665b88..d58ad6d569ccc 100644 --- a/administrator/components/com_messages/messages.php +++ b/administrator/components/com_messages/messages.php @@ -11,7 +11,7 @@ if (!JFactory::getUser()->authorise('core.manage', 'com_messages')) { - return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); + throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); } $task = JFactory::getApplication()->input->get('task'); diff --git a/administrator/components/com_modules/modules.php b/administrator/components/com_modules/modules.php index 759313fc8ebd2..b30029920f7ed 100644 --- a/administrator/components/com_modules/modules.php +++ b/administrator/components/com_modules/modules.php @@ -12,7 +12,7 @@ if (!JFactory::getUser()->authorise('core.manage', 'com_modules')) { - return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); + throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); } $controller = JControllerLegacy::getInstance('Modules'); diff --git a/administrator/components/com_newsfeeds/newsfeeds.php b/administrator/components/com_newsfeeds/newsfeeds.php index d7b025bff0fe7..d98f6e2a740eb 100644 --- a/administrator/components/com_newsfeeds/newsfeeds.php +++ b/administrator/components/com_newsfeeds/newsfeeds.php @@ -12,7 +12,7 @@ if (!JFactory::getUser()->authorise('core.manage', 'com_newsfeeds')) { - return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); + throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); } $controller = JControllerLegacy::getInstance('Newsfeeds'); diff --git a/administrator/components/com_plugins/plugins.php b/administrator/components/com_plugins/plugins.php index b7e18b061abe7..5c77e033cdc04 100644 --- a/administrator/components/com_plugins/plugins.php +++ b/administrator/components/com_plugins/plugins.php @@ -12,7 +12,7 @@ if (!JFactory::getUser()->authorise('core.manage', 'com_plugins')) { - throw new JControllerExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); + throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); } $controller = JControllerLegacy::getInstance('Plugins'); diff --git a/administrator/components/com_redirect/redirect.php b/administrator/components/com_redirect/redirect.php index e2088de15b80e..ebe62f846009c 100644 --- a/administrator/components/com_redirect/redirect.php +++ b/administrator/components/com_redirect/redirect.php @@ -11,7 +11,7 @@ if (!JFactory::getUser()->authorise('core.manage', 'com_redirect')) { - return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); + throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); } $controller = JControllerLegacy::getInstance('Redirect'); diff --git a/administrator/components/com_search/search.php b/administrator/components/com_search/search.php index feaecdde7b1bb..98b57a9c128c4 100644 --- a/administrator/components/com_search/search.php +++ b/administrator/components/com_search/search.php @@ -11,7 +11,7 @@ if (!JFactory::getUser()->authorise('core.manage', 'com_search')) { - return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); + throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); } $controller = JControllerLegacy::getInstance('Search'); diff --git a/administrator/components/com_tags/tags.php b/administrator/components/com_tags/tags.php index 59cd7365ef457..e2867634b723e 100644 --- a/administrator/components/com_tags/tags.php +++ b/administrator/components/com_tags/tags.php @@ -12,7 +12,7 @@ if (!JFactory::getUser()->authorise('core.manage', 'com_tags')) { - return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); + throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); } $controller = JControllerLegacy::getInstance('Tags'); diff --git a/administrator/components/com_templates/templates.php b/administrator/components/com_templates/templates.php index cac1b8ff0a5b4..24fcef4e62a45 100644 --- a/administrator/components/com_templates/templates.php +++ b/administrator/components/com_templates/templates.php @@ -10,14 +10,9 @@ defined('_JEXEC') or die; JHtml::_('behavior.tabstate'); -$app = JFactory::getApplication(); -$user = JFactory::getUser(); - -if (!$user->authorise('core.manage', 'com_templates')) +if (!JFactory::getUser()->authorise('core.manage', 'com_templates')) { - $app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'), 'error'); - - return false; + throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); } JLoader::register('TemplatesHelper', __DIR__ . '/helpers/templates.php'); diff --git a/administrator/components/com_users/users.php b/administrator/components/com_users/users.php index 6aa00c34e5deb..4c3ca532f0425 100644 --- a/administrator/components/com_users/users.php +++ b/administrator/components/com_users/users.php @@ -12,7 +12,7 @@ if (!JFactory::getUser()->authorise('core.manage', 'com_users')) { - return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); + throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); } JLoader::register('UsersHelper', __DIR__ . '/helpers/users.php'); diff --git a/libraries/joomla/controller/exception/notallowed.php b/libraries/joomla/access/exception/notallowed.php similarity index 66% rename from libraries/joomla/controller/exception/notallowed.php rename to libraries/joomla/access/exception/notallowed.php index d2ed2d57a6028..a62e3386a9a70 100644 --- a/libraries/joomla/controller/exception/notallowed.php +++ b/libraries/joomla/access/exception/notallowed.php @@ -1,7 +1,7 @@