From e401f68529e8af9f5c17396647c0516809430fd6 Mon Sep 17 00:00:00 2001 From: Sachintechjoomla Date: Tue, 4 Jun 2024 10:00:56 +0530 Subject: [PATCH] Issue #220502 Fix: We cannot access 'Notification Templates' in backend -> An error has occurred. 0 Class "JError" not found --- .../admin/views/logs/view.html.php | 3 ++- .../admin/views/notification/view.html.php | 4 ++-- .../admin/views/notifications/view.html.php | 4 ++-- src/com_tjnotifications/install.tjnotifications.php | 12 +++++++----- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/com_tjnotifications/admin/views/logs/view.html.php b/src/com_tjnotifications/admin/views/logs/view.html.php index 6b127247..292ea27e 100644 --- a/src/com_tjnotifications/admin/views/logs/view.html.php +++ b/src/com_tjnotifications/admin/views/logs/view.html.php @@ -50,7 +50,8 @@ public function display($tpl = null) // Check for errors. if (count($errors = $this->get('Errors'))) { - JError::raiseError(500, implode('
', $errors)); + $app = Factory::getApplication(); + $app->enqueueMessage(implode('
', $errors), 'error'); return false; } diff --git a/src/com_tjnotifications/admin/views/notification/view.html.php b/src/com_tjnotifications/admin/views/notification/view.html.php index 301c0fcf..c964a2fe 100644 --- a/src/com_tjnotifications/admin/views/notification/view.html.php +++ b/src/com_tjnotifications/admin/views/notification/view.html.php @@ -56,7 +56,7 @@ public function display($tpl = null) if (empty($this->user->authorise('core.create', 'com_tjnotifications')) || empty($this->user->authorise('core.edit', 'com_tjnotifications'))) { $msg = Text::_('JERROR_ALERTNOAUTHOR'); - JError::raiseError(403, $msg); + $this->app->enqueueMessage($msg, 'error'); $this->app->redirect(Route::_('index.php?Itemid=0', false)); } @@ -74,7 +74,7 @@ public function display($tpl = null) // Check for errors. if (count($errors = $this->get('Errors'))) { - JError::raiseError(500, implode('
', $errors)); + $this->app->enqueueMessage(implode('
', $errors), 'error'); return false; } diff --git a/src/com_tjnotifications/admin/views/notifications/view.html.php b/src/com_tjnotifications/admin/views/notifications/view.html.php index e668c2df..cf218afc 100644 --- a/src/com_tjnotifications/admin/views/notifications/view.html.php +++ b/src/com_tjnotifications/admin/views/notifications/view.html.php @@ -62,7 +62,7 @@ public function display($tpl = null) if (empty($this->user->authorise('core.viewlist', 'com_tjnotifications'))) { $msg = Text::_('JERROR_ALERTNOAUTHOR'); - JError::raiseError(403, $msg); + $this->app->enqueueMessage($msg, 'error'); $this->app->redirect(Route::_('index.php?Itemid=0', false)); } @@ -78,7 +78,7 @@ public function display($tpl = null) // Check for errors. if (count($errors = $this->get('Errors'))) { - JError::raiseError(500, implode('
', $errors)); + $this->app->enqueueMessage(implode('
', $errors), 'error'); return false; } diff --git a/src/com_tjnotifications/install.tjnotifications.php b/src/com_tjnotifications/install.tjnotifications.php index 15eef954..b544125e 100644 --- a/src/com_tjnotifications/install.tjnotifications.php +++ b/src/com_tjnotifications/install.tjnotifications.php @@ -265,7 +265,8 @@ public function installSqlFiles($parent) if (!$db->execute()) { - JError::raiseWarning(1, Text::sprintf('JLIB_INSTALLER_ERROR_SQL_ERROR', $db->stderr(true))); + $app = Factory::getApplication(); + $app->enqueueMessage(Text::sprintf('JLIB_INSTALLER_ERROR_SQL_ERROR', $db->stderr(true)), 'error'); return false; } @@ -294,6 +295,7 @@ public function installSqlFiles($parent) */ public function fixTemplateTable($db, $dbprefix, $config) { + $app = Factory::getApplication(); $query = "SHOW COLUMNS FROM #__tj_notification_templates WHERE `Field` = 'title'"; $db->setQuery($query); $check = $db->loadResult(); @@ -305,7 +307,7 @@ public function fixTemplateTable($db, $dbprefix, $config) if (!$db->execute()) { - JError::raiseError(500, $db->stderr()); + $app->enqueueMessage($db->stderr(), 'error'); } } @@ -320,7 +322,7 @@ public function fixTemplateTable($db, $dbprefix, $config) if (!$db->execute()) { - JError::raiseError(500, $db->stderr()); + $app->enqueueMessage($db->stderr(), 'error'); } } @@ -335,7 +337,7 @@ public function fixTemplateTable($db, $dbprefix, $config) if (!$db->execute()) { - JError::raiseError(500, $db->stderr()); + $app->enqueueMessage($db->stderr(), 'error'); } } @@ -350,7 +352,7 @@ public function fixTemplateTable($db, $dbprefix, $config) if (!$db->execute()) { - JError::raiseError(500, $db->stderr()); + $app->enqueueMessage($db->stderr(), 'error'); } } }