From eefbe1abf2ee77c961f769c412186d41569a86ec Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Fri, 12 Apr 2024 09:34:27 +0200 Subject: [PATCH 1/2] Removing deprecated access to User object attributes --- .../components/com_banners/tmpl/banners/default.php | 2 +- .../components/com_banners/tmpl/clients/default.php | 4 ++-- .../com_categories/tmpl/categories/default.php | 2 +- .../com_config/src/Model/ApplicationModel.php | 2 +- .../components/com_contact/src/Service/HTML/Icon.php | 2 +- .../components/com_contact/tmpl/contacts/default.php | 2 +- .../components/com_content/src/Service/HTML/Icon.php | 2 +- .../components/com_content/tmpl/articles/default.php | 2 +- .../components/com_content/tmpl/featured/default.php | 2 +- .../components/com_fields/src/Table/FieldTable.php | 4 ++-- .../components/com_fields/src/Table/GroupTable.php | 4 ++-- .../components/com_fields/src/View/Field/HtmlView.php | 2 +- .../components/com_fields/src/View/Group/HtmlView.php | 2 +- .../components/com_fields/tmpl/fields/default.php | 2 +- .../components/com_fields/tmpl/groups/default.php | 2 +- .../components/com_finder/src/Model/IndexModel.php | 2 +- .../components/com_finder/src/Model/MapsModel.php | 2 +- .../components/com_finder/tmpl/filters/default.php | 2 +- .../components/com_guidedtours/tmpl/steps/default.php | 2 +- .../components/com_guidedtours/tmpl/tours/default.php | 2 +- .../com_installer/tmpl/updatesites/default.php | 2 +- .../components/com_menus/src/View/Item/HtmlView.php | 4 ++-- .../components/com_menus/tmpl/items/default.php | 4 ++-- .../components/com_messages/src/Model/ConfigModel.php | 2 +- .../components/com_messages/src/Model/MessageModel.php | 6 +++--- .../com_messages/src/Model/MessagesModel.php | 2 +- .../com_modules/src/View/Module/HtmlView.php | 2 +- .../components/com_modules/tmpl/modules/default.php | 2 +- .../com_newsfeeds/src/Model/NewsfeedModel.php | 2 +- .../com_newsfeeds/src/Table/NewsfeedTable.php | 4 ++-- .../com_newsfeeds/src/View/Newsfeed/HtmlView.php | 2 +- .../com_newsfeeds/tmpl/newsfeeds/default.php | 2 +- .../components/com_plugins/tmpl/plugins/default.php | 2 +- .../components/com_scheduler/tmpl/tasks/default.php | 2 +- .../components/com_tags/src/Table/TagTable.php | 4 ++-- .../components/com_tags/src/View/Tag/HtmlView.php | 2 +- .../components/com_tags/tmpl/tags/default.php | 4 ++-- .../components/com_users/src/Model/GroupModel.php | 4 ++-- .../components/com_users/src/Model/UserModel.php | 4 ++-- .../components/com_users/src/Table/NoteTable.php | 2 +- .../components/com_users/src/View/Note/HtmlView.php | 2 +- .../components/com_users/tmpl/notes/default.php | 2 +- .../modules/mod_latest/src/Helper/LatestHelper.php | 2 +- .../modules/mod_popular/src/Helper/PopularHelper.php | 2 +- components/com_config/src/Model/FormModel.php | 6 +++--- .../com_contact/src/Controller/ContactController.php | 2 +- .../com_content/src/Controller/ArticleController.php | 2 +- .../com_content/src/Controller/DisplayController.php | 2 +- components/com_content/src/Model/ArticleModel.php | 4 ++-- components/com_content/src/Model/ArticlesModel.php | 4 ++-- components/com_content/src/Model/FormModel.php | 2 +- components/com_content/src/View/Article/HtmlView.php | 2 +- components/com_content/tmpl/article/default.php | 2 +- components/com_finder/src/Model/SearchModel.php | 2 +- components/com_finder/src/Model/SuggestionsModel.php | 2 +- .../com_tags/src/Controller/DisplayController.php | 2 +- .../com_users/src/Controller/DisplayController.php | 6 +++--- .../com_users/src/Controller/ProfileController.php | 4 ++-- .../src/Controller/RegistrationController.php | 2 +- components/com_users/src/Model/ProfileModel.php | 4 ++-- components/com_users/src/View/Login/HtmlView.php | 2 +- components/com_users/tmpl/login/default.php | 2 +- libraries/src/Application/AdministratorApplication.php | 4 ++-- libraries/src/Application/CMSApplication.php | 10 +++++----- libraries/src/Application/SiteApplication.php | 2 +- libraries/src/Component/ComponentHelper.php | 2 +- libraries/src/HTML/Helpers/Grid.php | 2 +- libraries/src/Helper/ModuleHelper.php | 2 +- libraries/src/MVC/Model/AdminModel.php | 2 +- libraries/src/MVC/Model/FormModel.php | 6 +++--- libraries/src/Session/Session.php | 2 +- libraries/src/Table/Category.php | 4 ++-- libraries/src/Table/Content.php | 4 ++-- libraries/src/Table/CoreContent.php | 4 ++-- .../src/Helper/ArticlesLatestHelper.php | 4 ++-- modules/mod_login/src/Helper/LoginHelper.php | 2 +- modules/mod_login/tmpl/default_logout.php | 4 ++-- plugins/content/joomla/src/Extension/Joomla.php | 2 +- .../editors/tinymce/src/PluginTraits/GlobalFilters.php | 2 +- 79 files changed, 111 insertions(+), 111 deletions(-) diff --git a/administrator/components/com_banners/tmpl/banners/default.php b/administrator/components/com_banners/tmpl/banners/default.php index 0f17f68c11818..7b24a58ff792c 100644 --- a/administrator/components/com_banners/tmpl/banners/default.php +++ b/administrator/components/com_banners/tmpl/banners/default.php @@ -25,7 +25,7 @@ ->useScript('multiselect'); $user = $this->getCurrentUser(); -$userId = $user->get('id'); +$userId = $user->id; $listOrder = $this->escape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); $saveOrder = $listOrder == 'a.ordering'; diff --git a/administrator/components/com_banners/tmpl/clients/default.php b/administrator/components/com_banners/tmpl/clients/default.php index 7d47f26e5afe4..36e8899c727ad 100644 --- a/administrator/components/com_banners/tmpl/clients/default.php +++ b/administrator/components/com_banners/tmpl/clients/default.php @@ -32,7 +32,7 @@ ]; $user = $this->getCurrentUser(); -$userId = $user->get('id'); +$userId = $user->id; $listOrder = $this->escape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); $params = $this->state->get('params') ?? new Registry(); @@ -107,7 +107,7 @@ items as $i => $item) : $canCreate = $user->authorise('core.create', 'com_banners'); $canEdit = $user->authorise('core.edit', 'com_banners'); - $canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $user->get('id') || is_null($item->checked_out); + $canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $user->id || is_null($item->checked_out); $canChange = $user->authorise('core.edit.state', 'com_banners') && $canCheckin; ?> diff --git a/administrator/components/com_categories/tmpl/categories/default.php b/administrator/components/com_categories/tmpl/categories/default.php index 4099dc9f610f0..0c8d3e62bad27 100644 --- a/administrator/components/com_categories/tmpl/categories/default.php +++ b/administrator/components/com_categories/tmpl/categories/default.php @@ -26,7 +26,7 @@ ->useScript('multiselect'); $user = $this->getCurrentUser(); -$userId = $user->get('id'); +$userId = $user->id; $extension = $this->escape($this->state->get('filter.extension')); $listOrder = $this->escape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); diff --git a/administrator/components/com_config/src/Model/ApplicationModel.php b/administrator/components/com_config/src/Model/ApplicationModel.php index bd62fdd71b1ff..7f382e0349f9e 100644 --- a/administrator/components/com_config/src/Model/ApplicationModel.php +++ b/administrator/components/com_config/src/Model/ApplicationModel.php @@ -374,7 +374,7 @@ public function save($data) // Check that we aren't removing our Super User permission // Need to get groups from database, since they might have changed - $myGroups = Access::getGroupsByUser($this->getCurrentUser()->get('id')); + $myGroups = Access::getGroupsByUser($this->getCurrentUser()->id); $myRules = $rules->getData(); $hasSuperAdmin = $myRules['core.admin']->allow($myGroups); diff --git a/administrator/components/com_contact/src/Service/HTML/Icon.php b/administrator/components/com_contact/src/Service/HTML/Icon.php index 7955ec57bf3cb..9073e21a66395 100644 --- a/administrator/components/com_contact/src/Service/HTML/Icon.php +++ b/administrator/components/com_contact/src/Service/HTML/Icon.php @@ -118,7 +118,7 @@ public function edit($contact, $params, $attribs = [], $legacy = false) property_exists($contact, 'checked_out') && property_exists($contact, 'checked_out_time') && !\is_null($contact->checked_out) - && $contact->checked_out !== $user->get('id') + && $contact->checked_out !== $user->id ) { $checkoutUser = $this->getUserFactory()->loadUserById($contact->checked_out); $date = HTMLHelper::_('date', $contact->checked_out_time); diff --git a/administrator/components/com_contact/tmpl/contacts/default.php b/administrator/components/com_contact/tmpl/contacts/default.php index e1f0039b806d2..83049cc92f6be 100644 --- a/administrator/components/com_contact/tmpl/contacts/default.php +++ b/administrator/components/com_contact/tmpl/contacts/default.php @@ -26,7 +26,7 @@ ->useScript('multiselect'); $user = $this->getCurrentUser(); -$userId = $user->get('id'); +$userId = $user->id; $listOrder = $this->escape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); $saveOrder = $listOrder == 'a.ordering'; diff --git a/administrator/components/com_content/src/Service/HTML/Icon.php b/administrator/components/com_content/src/Service/HTML/Icon.php index be1bfc6a4dedd..fe1782260de47 100644 --- a/administrator/components/com_content/src/Service/HTML/Icon.php +++ b/administrator/components/com_content/src/Service/HTML/Icon.php @@ -104,7 +104,7 @@ public function edit($article, $params, $attribs = [], $legacy = false) property_exists($article, 'checked_out') && property_exists($article, 'checked_out_time') && !\is_null($article->checked_out) - && $article->checked_out != $user->get('id') + && $article->checked_out != $user->id ) { $checkoutUser = Factory::getUser($article->checked_out); $date = HTMLHelper::_('date', $article->checked_out_time); diff --git a/administrator/components/com_content/tmpl/articles/default.php b/administrator/components/com_content/tmpl/articles/default.php index 7235fe934540f..72cb283302965 100644 --- a/administrator/components/com_content/tmpl/articles/default.php +++ b/administrator/components/com_content/tmpl/articles/default.php @@ -34,7 +34,7 @@ $app = Factory::getApplication(); $user = $this->getCurrentUser(); -$userId = $user->get('id'); +$userId = $user->id; $listOrder = $this->escape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); $saveOrder = $listOrder == 'a.ordering'; diff --git a/administrator/components/com_content/tmpl/featured/default.php b/administrator/components/com_content/tmpl/featured/default.php index 2465c9d1e21e5..048b8640421c0 100644 --- a/administrator/components/com_content/tmpl/featured/default.php +++ b/administrator/components/com_content/tmpl/featured/default.php @@ -34,7 +34,7 @@ $app = Factory::getApplication(); $user = $this->getCurrentUser(); -$userId = $user->get('id'); +$userId = $user->id; $listOrder = $this->escape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); $saveOrder = $listOrder == 'fp.ordering'; diff --git a/administrator/components/com_fields/src/Table/FieldTable.php b/administrator/components/com_fields/src/Table/FieldTable.php index b40fd9524c8cd..bdc72b9e212d7 100644 --- a/administrator/components/com_fields/src/Table/FieldTable.php +++ b/administrator/components/com_fields/src/Table/FieldTable.php @@ -181,14 +181,14 @@ public function check() if ($this->id) { // Existing item $this->modified_time = $date; - $this->modified_by = $user->get('id'); + $this->modified_by = $user->id; } else { if (!(int) $this->modified_time) { $this->modified_time = $this->created_time; } if (empty($this->created_user_id)) { - $this->created_user_id = $user->get('id'); + $this->created_user_id = $user->id; } if (empty($this->modified_by)) { diff --git a/administrator/components/com_fields/src/Table/GroupTable.php b/administrator/components/com_fields/src/Table/GroupTable.php index e153f289ed0c0..abc0dd9879eee 100644 --- a/administrator/components/com_fields/src/Table/GroupTable.php +++ b/administrator/components/com_fields/src/Table/GroupTable.php @@ -116,14 +116,14 @@ public function check() if ($this->id) { $this->modified = $date; - $this->modified_by = $user->get('id'); + $this->modified_by = $user->id; } else { if (!(int) $this->modified) { $this->modified = $this->created; } if (empty($this->created_by)) { - $this->created_by = $user->get('id'); + $this->created_by = $user->id; } if (empty($this->modified_by)) { diff --git a/administrator/components/com_fields/src/View/Field/HtmlView.php b/administrator/components/com_fields/src/View/Field/HtmlView.php index 25d8167e20a2c..0191220f4f140 100644 --- a/administrator/components/com_fields/src/View/Field/HtmlView.php +++ b/administrator/components/com_fields/src/View/Field/HtmlView.php @@ -93,7 +93,7 @@ protected function addToolbar() { $component = $this->state->get('field.component'); $section = $this->state->get('field.section'); - $userId = $this->getCurrentUser()->get('id'); + $userId = $this->getCurrentUser()->id; $canDo = $this->canDo; $toolbar = Toolbar::getInstance(); diff --git a/administrator/components/com_fields/src/View/Group/HtmlView.php b/administrator/components/com_fields/src/View/Group/HtmlView.php index e540aaa32c0f3..5a3f9a2cc71c6 100644 --- a/administrator/components/com_fields/src/View/Group/HtmlView.php +++ b/administrator/components/com_fields/src/View/Group/HtmlView.php @@ -114,7 +114,7 @@ protected function addToolbar() $component = $parts[0]; } - $userId = $this->getCurrentUser()->get('id'); + $userId = $this->getCurrentUser()->id; $canDo = $this->canDo; $isNew = ($this->item->id == 0); diff --git a/administrator/components/com_fields/tmpl/fields/default.php b/administrator/components/com_fields/tmpl/fields/default.php index 4dd23d088fc42..77b27cce1aa81 100644 --- a/administrator/components/com_fields/tmpl/fields/default.php +++ b/administrator/components/com_fields/tmpl/fields/default.php @@ -29,7 +29,7 @@ $app = Factory::getApplication(); $user = $this->getCurrentUser(); -$userId = $user->get('id'); +$userId = $user->id; $context = $this->escape($this->state->get('filter.context')); $component = $this->state->get('filter.component'); $section = $this->state->get('filter.section'); diff --git a/administrator/components/com_fields/tmpl/groups/default.php b/administrator/components/com_fields/tmpl/groups/default.php index fef9087f777a7..d72ad1d5cb4c9 100644 --- a/administrator/components/com_fields/tmpl/groups/default.php +++ b/administrator/components/com_fields/tmpl/groups/default.php @@ -28,7 +28,7 @@ $app = Factory::getApplication(); $user = $this->getCurrentUser(); -$userId = $user->get('id'); +$userId = $user->id; $component = ''; $parts = FieldsHelper::extract($this->state->get('filter.context')); diff --git a/administrator/components/com_finder/src/Model/IndexModel.php b/administrator/components/com_finder/src/Model/IndexModel.php index 75ea94cbcffa7..941c9976b8f41 100644 --- a/administrator/components/com_finder/src/Model/IndexModel.php +++ b/administrator/components/com_finder/src/Model/IndexModel.php @@ -441,7 +441,7 @@ public function publish(&$pks, $value = 1) } // Attempt to change the state of the records. - if (!$table->publish($pks, $value, $user->get('id'))) { + if (!$table->publish($pks, $value, $user->id)) { $this->setError($table->getError()); return false; diff --git a/administrator/components/com_finder/src/Model/MapsModel.php b/administrator/components/com_finder/src/Model/MapsModel.php index b256927f00087..312ed7699eba3 100644 --- a/administrator/components/com_finder/src/Model/MapsModel.php +++ b/administrator/components/com_finder/src/Model/MapsModel.php @@ -335,7 +335,7 @@ public function publish(&$pks, $value = 1) } // Attempt to change the state of the records. - if (!$table->publish($pks, $value, $user->get('id'))) { + if (!$table->publish($pks, $value, $user->id)) { $this->setError($table->getError()); return false; diff --git a/administrator/components/com_finder/tmpl/filters/default.php b/administrator/components/com_finder/tmpl/filters/default.php index 0e8c7d0da6e6b..a75c842ed8ec5 100644 --- a/administrator/components/com_finder/tmpl/filters/default.php +++ b/administrator/components/com_finder/tmpl/filters/default.php @@ -18,7 +18,7 @@ /** @var \Joomla\Component\Finder\Administrator\View\Filters\HtmlView $this */ $user = $this->getCurrentUser(); -$userId = $user->get('id'); +$userId = $user->id; $listOrder = $this->escape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); diff --git a/administrator/components/com_guidedtours/tmpl/steps/default.php b/administrator/components/com_guidedtours/tmpl/steps/default.php index 459007fdc8089..97a0217a49c86 100644 --- a/administrator/components/com_guidedtours/tmpl/steps/default.php +++ b/administrator/components/com_guidedtours/tmpl/steps/default.php @@ -27,7 +27,7 @@ ->useScript('multiselect'); $user = $this->getCurrentUser(); -$userId = $user->get('id'); +$userId = $user->id; $listOrder = $this->escape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); $saveOrder = $listOrder == 'a.ordering'; diff --git a/administrator/components/com_guidedtours/tmpl/tours/default.php b/administrator/components/com_guidedtours/tmpl/tours/default.php index aa456fa3fb493..6b1f349b562f2 100644 --- a/administrator/components/com_guidedtours/tmpl/tours/default.php +++ b/administrator/components/com_guidedtours/tmpl/tours/default.php @@ -34,7 +34,7 @@ } $user = $app->getIdentity(); -$userId = $user->get('id'); +$userId = $user->id; $listOrder = $this->escape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); $saveOrder = $listOrder == 'a.ordering'; diff --git a/administrator/components/com_installer/tmpl/updatesites/default.php b/administrator/components/com_installer/tmpl/updatesites/default.php index b1736234e47e8..be5c1e9f25249 100644 --- a/administrator/components/com_installer/tmpl/updatesites/default.php +++ b/administrator/components/com_installer/tmpl/updatesites/default.php @@ -23,7 +23,7 @@ ->useScript('multiselect'); $user = $this->getCurrentUser(); -$userId = $user->get('id'); +$userId = $user->id; $listOrder = $this->escape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); ?> diff --git a/administrator/components/com_menus/src/View/Item/HtmlView.php b/administrator/components/com_menus/src/View/Item/HtmlView.php index 028f73b052b1f..21208cab7ab81 100644 --- a/administrator/components/com_menus/src/View/Item/HtmlView.php +++ b/administrator/components/com_menus/src/View/Item/HtmlView.php @@ -141,7 +141,7 @@ protected function addToolbar() $user = $this->getCurrentUser(); $isNew = ($this->item->id == 0); - $checkedOut = !(\is_null($this->item->checked_out) || $this->item->checked_out == $user->get('id')); + $checkedOut = !(\is_null($this->item->checked_out) || $this->item->checked_out == $user->id); $canDo = $this->canDo; $clientId = $this->state->get('item.client_id', 0); $toolbar = Toolbar::getInstance(); @@ -229,7 +229,7 @@ protected function addModalToolbar() { $user = $this->getCurrentUser(); $isNew = ($this->item->id == 0); - $checkedOut = !(\is_null($this->item->checked_out) || $this->item->checked_out == $user->get('id')); + $checkedOut = !(\is_null($this->item->checked_out) || $this->item->checked_out == $user->id); $canDo = $this->canDo; $toolbar = Toolbar::getInstance(); diff --git a/administrator/components/com_menus/tmpl/items/default.php b/administrator/components/com_menus/tmpl/items/default.php index 0d13a218052d7..f2b5971bd021c 100644 --- a/administrator/components/com_menus/tmpl/items/default.php +++ b/administrator/components/com_menus/tmpl/items/default.php @@ -28,7 +28,7 @@ $user = $this->getCurrentUser(); $app = Factory::getApplication(); -$userId = $user->get('id'); +$userId = $user->id; $listOrder = $this->escape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); $ordering = ($listOrder == 'a.lft'); @@ -109,7 +109,7 @@ $orderkey = array_search($item->id, $this->ordering[$item->parent_id]); $canCreate = $user->authorise('core.create', 'com_menus.menu.' . $item->menutype_id); $canEdit = $user->authorise('core.edit', 'com_menus.menu.' . $item->menutype_id); - $canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $user->get('id') || is_null($item->checked_out); + $canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $user->id || is_null($item->checked_out); $canChange = $user->authorise('core.edit.state', 'com_menus.menu.' . $item->menutype_id) && $canCheckin; // Get the parents of item for sorting diff --git a/administrator/components/com_messages/src/Model/ConfigModel.php b/administrator/components/com_messages/src/Model/ConfigModel.php index 4b0d3ae9ebc66..692299e83bceb 100644 --- a/administrator/components/com_messages/src/Model/ConfigModel.php +++ b/administrator/components/com_messages/src/Model/ConfigModel.php @@ -43,7 +43,7 @@ protected function populateState() { $user = $this->getCurrentUser(); - $this->setState('user.id', $user->get('id')); + $this->setState('user.id', $user->id); // Load the parameters. $params = ComponentHelper::getParams('com_messages'); diff --git a/administrator/components/com_messages/src/Model/MessageModel.php b/administrator/components/com_messages/src/Model/MessageModel.php index 534a353cf4c8a..b4547ca06250e 100644 --- a/administrator/components/com_messages/src/Model/MessageModel.php +++ b/administrator/components/com_messages/src/Model/MessageModel.php @@ -69,7 +69,7 @@ protected function populateState() $input = Factory::getApplication()->getInput(); $user = $this->getCurrentUser(); - $this->setState('user.id', $user->get('id')); + $this->setState('user.id', $user->id); $messageId = (int) $input->getInt('message_id'); $this->setState('message.id', $messageId); @@ -300,7 +300,7 @@ public function save($data) // Assign empty values. if (empty($table->user_id_from)) { - $table->user_id_from = $this->getCurrentUser()->get('id'); + $table->user_id_from = $this->getCurrentUser()->id; } if ((int) $table->date_time == 0) { @@ -366,7 +366,7 @@ public function save($data) $app = Factory::getApplication(); $linkMode = $app->get('force_ssl', 0) >= 1 ? Route::TLS_FORCE : Route::TLS_IGNORE; $sitename = $app->get('sitename'); - $fromName = $fromUser->get('name'); + $fromName = $fromUser->name; $siteURL = Route::link( 'administrator', 'index.php?option=com_messages&view=message&message_id=' . $table->message_id, diff --git a/administrator/components/com_messages/src/Model/MessagesModel.php b/administrator/components/com_messages/src/Model/MessagesModel.php index 0d2494ce3ead9..08a68ea249846 100644 --- a/administrator/components/com_messages/src/Model/MessagesModel.php +++ b/administrator/components/com_messages/src/Model/MessagesModel.php @@ -109,7 +109,7 @@ protected function getListQuery() $db = $this->getDatabase(); $query = $db->getQuery(true); $user = $this->getCurrentUser(); - $id = (int) $user->get('id'); + $id = (int) $user->id; // Select the required fields from the table. $query->select( diff --git a/administrator/components/com_modules/src/View/Module/HtmlView.php b/administrator/components/com_modules/src/View/Module/HtmlView.php index 52c22cbe56b08..3b1c84d9924de 100644 --- a/administrator/components/com_modules/src/View/Module/HtmlView.php +++ b/administrator/components/com_modules/src/View/Module/HtmlView.php @@ -114,7 +114,7 @@ protected function addToolbar() $user = $this->getCurrentUser(); $isNew = ($this->item->id == 0); - $checkedOut = !(\is_null($this->item->checked_out) || $this->item->checked_out == $user->get('id')); + $checkedOut = !(\is_null($this->item->checked_out) || $this->item->checked_out == $user->id); $canDo = $this->canDo; $toolbar = Toolbar::getInstance(); diff --git a/administrator/components/com_modules/tmpl/modules/default.php b/administrator/components/com_modules/tmpl/modules/default.php index c7822b3c86f04..5928d7c24d6e3 100644 --- a/administrator/components/com_modules/tmpl/modules/default.php +++ b/administrator/components/com_modules/tmpl/modules/default.php @@ -95,7 +95,7 @@ $ordering = ($listOrder == 'a.ordering'); $canCreate = $user->authorise('core.create', 'com_modules'); $canEdit = $user->authorise('core.edit', 'com_modules.module.' . $item->id); - $canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $user->get('id') || is_null($item->checked_out); + $canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $user->id || is_null($item->checked_out); $canChange = $user->authorise('core.edit.state', 'com_modules.module.' . $item->id) && $canCheckin; ?> diff --git a/administrator/components/com_newsfeeds/src/Model/NewsfeedModel.php b/administrator/components/com_newsfeeds/src/Model/NewsfeedModel.php index 5fccfccf5154c..b165d3134b4b2 100644 --- a/administrator/components/com_newsfeeds/src/Model/NewsfeedModel.php +++ b/administrator/components/com_newsfeeds/src/Model/NewsfeedModel.php @@ -320,7 +320,7 @@ protected function prepareTable($table) } else { // Set the values $table->modified = $date->toSql(); - $table->modified_by = $user->get('id'); + $table->modified_by = $user->id; } // Increment the content version number. diff --git a/administrator/components/com_newsfeeds/src/Table/NewsfeedTable.php b/administrator/components/com_newsfeeds/src/Table/NewsfeedTable.php index 327afc27bbd08..6207b270a5efa 100644 --- a/administrator/components/com_newsfeeds/src/Table/NewsfeedTable.php +++ b/administrator/components/com_newsfeeds/src/Table/NewsfeedTable.php @@ -150,12 +150,12 @@ public function store($updateNulls = true) if ($this->id) { // Existing item - $this->modified_by = $user->get('id'); + $this->modified_by = $user->id; $this->modified = $date->toSql(); } else { // Field created_by can be set by the user, so we don't touch it if it's set. if (empty($this->created_by)) { - $this->created_by = $user->get('id'); + $this->created_by = $user->id; } if (!(int) $this->modified) { diff --git a/administrator/components/com_newsfeeds/src/View/Newsfeed/HtmlView.php b/administrator/components/com_newsfeeds/src/View/Newsfeed/HtmlView.php index 8f35fe1752b2b..f1d19c7e52389 100644 --- a/administrator/components/com_newsfeeds/src/View/Newsfeed/HtmlView.php +++ b/administrator/components/com_newsfeeds/src/View/Newsfeed/HtmlView.php @@ -119,7 +119,7 @@ protected function addToolbar() $user = $this->getCurrentUser(); $isNew = ($this->item->id == 0); - $checkedOut = !(\is_null($this->item->checked_out) || $this->item->checked_out == $user->get('id')); + $checkedOut = !(\is_null($this->item->checked_out) || $this->item->checked_out == $user->id); $toolbar = Toolbar::getInstance(); // Since we don't track these assets at the item level, use the category id. diff --git a/administrator/components/com_newsfeeds/tmpl/newsfeeds/default.php b/administrator/components/com_newsfeeds/tmpl/newsfeeds/default.php index 62e076e7a0fe1..5b1cf424eb896 100644 --- a/administrator/components/com_newsfeeds/tmpl/newsfeeds/default.php +++ b/administrator/components/com_newsfeeds/tmpl/newsfeeds/default.php @@ -98,7 +98,7 @@ $ordering = ($listOrder == 'a.ordering'); $canCreate = $user->authorise('core.create', 'com_newsfeeds.category.' . $item->catid); $canEdit = $user->authorise('core.edit', 'com_newsfeeds.category.' . $item->catid); - $canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $user->get('id') || is_null($item->checked_out); + $canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $user->id || is_null($item->checked_out); $canEditOwn = $user->authorise('core.edit.own', 'com_newsfeeds.category.' . $item->catid) && $item->created_by == $user->id; $canChange = $user->authorise('core.edit.state', 'com_newsfeeds.category.' . $item->catid) && $canCheckin; ?> diff --git a/administrator/components/com_plugins/tmpl/plugins/default.php b/administrator/components/com_plugins/tmpl/plugins/default.php index 41ffb97566232..f56129c5dacd5 100644 --- a/administrator/components/com_plugins/tmpl/plugins/default.php +++ b/administrator/components/com_plugins/tmpl/plugins/default.php @@ -82,7 +82,7 @@ items as $i => $item) : $ordering = ($listOrder == 'ordering'); $canEdit = $user->authorise('core.edit', 'com_plugins'); - $canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $user->get('id') || is_null($item->checked_out); + $canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $user->id || is_null($item->checked_out); $canChange = $user->authorise('core.edit.state', 'com_plugins') && $canCheckin; ?> diff --git a/administrator/components/com_scheduler/tmpl/tasks/default.php b/administrator/components/com_scheduler/tmpl/tasks/default.php index e2ecc581c7736..93d538ff17dfc 100644 --- a/administrator/components/com_scheduler/tmpl/tasks/default.php +++ b/administrator/components/com_scheduler/tmpl/tasks/default.php @@ -52,7 +52,7 @@ } $user = $app->getIdentity(); -$userId = $user->get('id'); +$userId = $user->id; $listOrder = $this->escape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); $saveOrder = $listOrder == 'a.ordering'; diff --git a/administrator/components/com_tags/src/Table/TagTable.php b/administrator/components/com_tags/src/Table/TagTable.php index 76eaad2d792f9..8c45f4a957a51 100644 --- a/administrator/components/com_tags/src/Table/TagTable.php +++ b/administrator/components/com_tags/src/Table/TagTable.php @@ -174,7 +174,7 @@ public function store($updateNulls = true) if ($this->id) { // Existing item - $this->modified_user_id = $user->get('id'); + $this->modified_user_id = $user->id; $this->modified_time = $date->toSql(); } else { // New tag. A tag created and created_by field can be set by the user, @@ -184,7 +184,7 @@ public function store($updateNulls = true) } if (empty($this->created_user_id)) { - $this->created_user_id = $user->get('id'); + $this->created_user_id = $user->id; } if (!(int) $this->modified_time) { diff --git a/administrator/components/com_tags/src/View/Tag/HtmlView.php b/administrator/components/com_tags/src/View/Tag/HtmlView.php index 0db1c2d0ed746..40eedb510832c 100644 --- a/administrator/components/com_tags/src/View/Tag/HtmlView.php +++ b/administrator/components/com_tags/src/View/Tag/HtmlView.php @@ -102,7 +102,7 @@ protected function addToolbar() Factory::getApplication()->getInput()->set('hidemainmenu', true); $user = $this->getCurrentUser(); - $userId = $user->get('id'); + $userId = $user->id; $isNew = ($this->item->id == 0); $checkedOut = !(\is_null($this->item->checked_out) || $this->item->checked_out == $userId); $toolbar = Toolbar::getInstance(); diff --git a/administrator/components/com_tags/tmpl/tags/default.php b/administrator/components/com_tags/tmpl/tags/default.php index 3de7be6294eaf..a3b20bea037f1 100644 --- a/administrator/components/com_tags/tmpl/tags/default.php +++ b/administrator/components/com_tags/tmpl/tags/default.php @@ -28,7 +28,7 @@ $app = Factory::getApplication(); $user = $this->getCurrentUser(); -$userId = $user->get('id'); +$userId = $user->id; $listOrder = $this->escape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); $saveOrder = ($listOrder == 'a.lft' && strtolower($listDirn) == 'asc'); @@ -136,7 +136,7 @@ $orderkey = array_search($item->id, $this->ordering[$item->parent_id]); $canCreate = $user->authorise('core.create', 'com_tags'); $canEdit = $user->authorise('core.edit', 'com_tags'); - $canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $user->get('id') || is_null($item->checked_out); + $canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $user->id || is_null($item->checked_out); $canChange = $user->authorise('core.edit.state', 'com_tags') && $canCheckin; // Get the parents of item for sorting diff --git a/administrator/components/com_users/src/Model/GroupModel.php b/administrator/components/com_users/src/Model/GroupModel.php index 6c90f55193572..57d0cfa73538c 100644 --- a/administrator/components/com_users/src/Model/GroupModel.php +++ b/administrator/components/com_users/src/Model/GroupModel.php @@ -197,7 +197,7 @@ public function save($data) */ if ($iAmSuperAdmin) { // Next, are we a member of the current group? - $myGroups = Access::getGroupsByUser($this->getCurrentUser()->get('id'), false); + $myGroups = Access::getGroupsByUser($this->getCurrentUser()->id, false); if (\in_array($data['id'], $myGroups)) { // Now, would we have super admin permissions without the current group? @@ -243,7 +243,7 @@ public function delete(&$pks) // Typecast variable. $pks = (array) $pks; $user = $this->getCurrentUser(); - $groups = Access::getGroupsByUser($user->get('id')); + $groups = Access::getGroupsByUser($user->id); $context = $this->option . '.' . $this->name; $dispatcher = $this->getDispatcher(); diff --git a/administrator/components/com_users/src/Model/UserModel.php b/administrator/components/com_users/src/Model/UserModel.php index cdbbd8ed9baef..324e3220335f8 100644 --- a/administrator/components/com_users/src/Model/UserModel.php +++ b/administrator/components/com_users/src/Model/UserModel.php @@ -252,7 +252,7 @@ public function save($data) } // Make sure that we are not removing ourself from Super Admin group - if ($iAmSuperAdmin && $my->get('id') == $pk) { + if ($iAmSuperAdmin && $my->id == $pk) { // Check that at least one of our new groups is Super Admin $stillSuperAdmin = false; $myNewGroups = $data['groups']; @@ -388,7 +388,7 @@ public function block(&$pks, $value = 1) // Access checks. foreach ($pks as $i => $pk) { - if ($value == 1 && $pk == $user->get('id')) { + if ($value == 1 && $pk == $user->id) { // Cannot block yourself. unset($pks[$i]); Factory::getApplication()->enqueueMessage(Text::_('COM_USERS_USERS_ERROR_CANNOT_BLOCK_SELF'), 'error'); diff --git a/administrator/components/com_users/src/Table/NoteTable.php b/administrator/components/com_users/src/Table/NoteTable.php index 8a6c393a99a42..acd6bddb652da 100644 --- a/administrator/components/com_users/src/Table/NoteTable.php +++ b/administrator/components/com_users/src/Table/NoteTable.php @@ -67,7 +67,7 @@ public function __construct(DatabaseDriver $db, DispatcherInterface $dispatcher public function store($updateNulls = true) { $date = Factory::getDate()->toSql(); - $userId = $this->getCurrentUser()->get('id'); + $userId = $this->getCurrentUser()->id; if (!((int) $this->review_time)) { $this->review_time = null; diff --git a/administrator/components/com_users/src/View/Note/HtmlView.php b/administrator/components/com_users/src/View/Note/HtmlView.php index be207e6fdee66..526557ca36926 100644 --- a/administrator/components/com_users/src/View/Note/HtmlView.php +++ b/administrator/components/com_users/src/View/Note/HtmlView.php @@ -96,7 +96,7 @@ protected function addToolbar() $user = $this->getCurrentUser(); $isNew = ($this->item->id == 0); - $checkedOut = !(\is_null($this->item->checked_out) || $this->item->checked_out == $user->get('id')); + $checkedOut = !(\is_null($this->item->checked_out) || $this->item->checked_out == $user->id); $toolbar = Toolbar::getInstance(); // Since we don't track these assets at the item level, use the category id. diff --git a/administrator/components/com_users/tmpl/notes/default.php b/administrator/components/com_users/tmpl/notes/default.php index 0def9e35d2696..fa64f4e57220f 100644 --- a/administrator/components/com_users/tmpl/notes/default.php +++ b/administrator/components/com_users/tmpl/notes/default.php @@ -70,7 +70,7 @@ items as $i => $item) : $canEdit = $user->authorise('core.edit', 'com_users.category.' . $item->catid); - $canCheckin = $user->authorise('core.admin', 'com_checkin') || $item->checked_out == $user->get('id') || is_null($item->checked_out); + $canCheckin = $user->authorise('core.admin', 'com_checkin') || $item->checked_out == $user->id || is_null($item->checked_out); $canChange = $user->authorise('core.edit.state', 'com_users.category.' . $item->catid) && $canCheckin; $subject = $item->subject ?: Text::_('COM_USERS_EMPTY_SUBJECT'); ?> diff --git a/administrator/modules/mod_latest/src/Helper/LatestHelper.php b/administrator/modules/mod_latest/src/Helper/LatestHelper.php index f0db28fd79eaa..617d70fd8dd50 100644 --- a/administrator/modules/mod_latest/src/Helper/LatestHelper.php +++ b/administrator/modules/mod_latest/src/Helper/LatestHelper.php @@ -66,7 +66,7 @@ public static function getList(Registry $params, ArticlesModel $model) } // Set User Filter. - $userId = $user->get('id'); + $userId = $user->id; switch ($params->get('user_id', '0')) { case 'by_me': diff --git a/administrator/modules/mod_popular/src/Helper/PopularHelper.php b/administrator/modules/mod_popular/src/Helper/PopularHelper.php index ec089cdb54ae9..926196117773e 100644 --- a/administrator/modules/mod_popular/src/Helper/PopularHelper.php +++ b/administrator/modules/mod_popular/src/Helper/PopularHelper.php @@ -58,7 +58,7 @@ public static function getList(Registry $params, ArticlesModel $model) } // Set User Filter. - $userId = $user->get('id'); + $userId = $user->id; switch ($params->get('user_id', '0')) { case 'by_me': diff --git a/components/com_config/src/Model/FormModel.php b/components/com_config/src/Model/FormModel.php index fa0ec9fd8de62..cf96ceeb35614 100644 --- a/components/com_config/src/Model/FormModel.php +++ b/components/com_config/src/Model/FormModel.php @@ -63,7 +63,7 @@ public function checkin($pk = null) } // Check if this is the user has previously checked out the row. - if (!\is_null($table->checked_out) && $table->checked_out != $user->get('id') && !$user->authorise('core.admin', 'com_checkin')) { + if (!\is_null($table->checked_out) && $table->checked_out != $user->id && !$user->authorise('core.admin', 'com_checkin')) { throw new \RuntimeException($table->getError()); } @@ -99,12 +99,12 @@ public function checkout($pk = null) } // Check if this is the user having previously checked out the row. - if (!\is_null($table->checked_out) && $table->checked_out != $user->get('id')) { + if (!\is_null($table->checked_out) && $table->checked_out != $user->id) { throw new \RuntimeException(Text::_('JLIB_APPLICATION_ERROR_CHECKOUT_USER_MISMATCH')); } // Attempt to check the row out. - if (!$table->checkOut($user->get('id'), $pk)) { + if (!$table->checkOut($user->id, $pk)) { throw new \RuntimeException($table->getError()); } } diff --git a/components/com_contact/src/Controller/ContactController.php b/components/com_contact/src/Controller/ContactController.php index 9c2bb4cdcaa22..bbf476d0ada65 100644 --- a/components/com_contact/src/Controller/ContactController.php +++ b/components/com_contact/src/Controller/ContactController.php @@ -247,7 +247,7 @@ private function _sendEmail($data, $contact, $emailCopyToSender) if ($contact->email_to == '' && $contact->user_id != 0) { $contact_user = $this->getUserFactory()->loadUserById($contact->user_id); - $contact->email_to = $contact_user->get('email'); + $contact->email_to = $contact_user->email; } $templateData = [ diff --git a/components/com_content/src/Controller/ArticleController.php b/components/com_content/src/Controller/ArticleController.php index 2b7bc43a9d61e..3a3e3d985f230 100644 --- a/components/com_content/src/Controller/ArticleController.php +++ b/components/com_content/src/Controller/ArticleController.php @@ -147,7 +147,7 @@ protected function allowEdit($data = [], $key = 'id') } // Grant if current user is owner of the record - return $user->get('id') == $record->created_by; + return $user->id == $record->created_by; } return false; diff --git a/components/com_content/src/Controller/DisplayController.php b/components/com_content/src/Controller/DisplayController.php index 20ede3f6f5510..6f5eba7707eec 100644 --- a/components/com_content/src/Controller/DisplayController.php +++ b/components/com_content/src/Controller/DisplayController.php @@ -79,7 +79,7 @@ public function display($cachable = false, $urlparams = false) $user = $this->app->getIdentity(); if ( - $user->get('id') + $user->id || ($this->input->getMethod() === 'POST' && (($vName === 'category' && $this->input->get('layout') !== 'blog') || $vName === 'archive')) ) { diff --git a/components/com_content/src/Model/ArticleModel.php b/components/com_content/src/Model/ArticleModel.php index 5a2114607363e..dd64c43756e0b 100644 --- a/components/com_content/src/Model/ArticleModel.php +++ b/components/com_content/src/Model/ArticleModel.php @@ -232,8 +232,8 @@ public function getItem($pk = null) $data->metadata = new Registry($data->metadata); // Technically guest could edit an article, but lets not check that to improve performance a little. - if (!$user->get('guest')) { - $userId = $user->get('id'); + if (!$user->guest) { + $userId = $user->id; $asset = 'com_content.article.' . $data->id; // Check general edit permission first. diff --git a/components/com_content/src/Model/ArticlesModel.php b/components/com_content/src/Model/ArticlesModel.php index acda4d0217aa3..5a910eacf97d9 100644 --- a/components/com_content/src/Model/ArticlesModel.php +++ b/components/com_content/src/Model/ArticlesModel.php @@ -651,8 +651,8 @@ public function getItems() $items = parent::getItems(); $user = $this->getCurrentUser(); - $userId = $user->get('id'); - $guest = $user->get('guest'); + $userId = $user->id; + $guest = $user->guest; $groups = $user->getAuthorisedViewLevels(); $input = Factory::getApplication()->getInput(); diff --git a/components/com_content/src/Model/FormModel.php b/components/com_content/src/Model/FormModel.php index ee86d95c6e011..4119f8d610e39 100644 --- a/components/com_content/src/Model/FormModel.php +++ b/components/com_content/src/Model/FormModel.php @@ -107,7 +107,7 @@ public function getItem($itemId = null) // Compute selected asset permissions. $user = $this->getCurrentUser(); - $userId = $user->get('id'); + $userId = $user->id; $asset = 'com_content.article.' . $value->id; // Check general edit permission first. diff --git a/components/com_content/src/View/Article/HtmlView.php b/components/com_content/src/View/Article/HtmlView.php index b67bbf701ce7b..4987934a81c1d 100644 --- a/components/com_content/src/View/Article/HtmlView.php +++ b/components/com_content/src/View/Article/HtmlView.php @@ -190,7 +190,7 @@ public function display($tpl = null) * NOTE: we do not recheck for no access-view + show_noauth disabled ... since it was checked above */ if ($item->params->get('access-view') == false && !\strlen($item->fulltext)) { - if ($this->user->get('guest')) { + if ($this->user->guest) { $return = base64_encode(Uri::getInstance()); $login_url_with_return = Route::_('index.php?option=com_users&view=login&return=' . $return); $app->enqueueMessage(Text::_('JERROR_ALERTNOAUTHOR'), 'notice'); diff --git a/components/com_content/tmpl/article/default.php b/components/com_content/tmpl/article/default.php index e1be9259138d8..98782149a9d97 100644 --- a/components/com_content/tmpl/article/default.php +++ b/components/com_content/tmpl/article/default.php @@ -122,7 +122,7 @@ loadTemplate('links'); ?> - get('show_noauth') == true && $user->get('guest')) : ?> + get('show_noauth') == true && $user->guest) : ?> item); ?> item->introtext); ?> diff --git a/components/com_finder/src/Model/SearchModel.php b/components/com_finder/src/Model/SearchModel.php index acfbae9802bf5..a79fe746cf040 100644 --- a/components/com_finder/src/Model/SearchModel.php +++ b/components/com_finder/src/Model/SearchModel.php @@ -578,7 +578,7 @@ protected function populateState($ordering = null, $direction = null) $this->setState('params', $params); // Load the user state. - $this->setState('user.id', (int) $user->get('id')); + $this->setState('user.id', (int) $user->id); $this->setState('user.groups', $user->getAuthorisedViewLevels()); } } diff --git a/components/com_finder/src/Model/SuggestionsModel.php b/components/com_finder/src/Model/SuggestionsModel.php index 7ae65bbf1920b..1aac034b46730 100644 --- a/components/com_finder/src/Model/SuggestionsModel.php +++ b/components/com_finder/src/Model/SuggestionsModel.php @@ -176,6 +176,6 @@ protected function populateState($ordering = null, $direction = null) $this->setState('params', $params); // Load the user state. - $this->setState('user.id', (int) $user->get('id')); + $this->setState('user.id', (int) $user->id); } } diff --git a/components/com_tags/src/Controller/DisplayController.php b/components/com_tags/src/Controller/DisplayController.php index d50b974a9b3e6..7af87d11cdad9 100644 --- a/components/com_tags/src/Controller/DisplayController.php +++ b/components/com_tags/src/Controller/DisplayController.php @@ -43,7 +43,7 @@ public function display($cachable = false, $urlparams = false) $vName = $this->input->get('view', 'tags'); $this->input->set('view', $vName); - if ($user->get('id') || ($this->input->getMethod() === 'POST' && $vName === 'tags')) { + if ($user->id || ($this->input->getMethod() === 'POST' && $vName === 'tags')) { $cachable = false; } diff --git a/components/com_users/src/Controller/DisplayController.php b/components/com_users/src/Controller/DisplayController.php index 6cf720999980c..34571888ab1c6 100644 --- a/components/com_users/src/Controller/DisplayController.php +++ b/components/com_users/src/Controller/DisplayController.php @@ -54,7 +54,7 @@ public function display($cachable = false, $urlparams = false) // If the user is already logged in, redirect to the profile page. $user = $this->app->getIdentity(); - if ($user->get('guest') != 1) { + if ($user->guest != 1) { // Redirect to profile page. $this->setRedirect(Route::_('index.php?option=com_users&view=profile', false)); @@ -78,7 +78,7 @@ public function display($cachable = false, $urlparams = false) // If the user is a guest, redirect to the login page. $user = $this->app->getIdentity(); - if ($user->get('guest') == 1) { + if ($user->guest == 1) { // Redirect to login page. $this->setRedirect(Route::_('index.php?option=com_users&view=login', false)); @@ -98,7 +98,7 @@ public function display($cachable = false, $urlparams = false) // If the user is already logged in, redirect to the profile page. $user = $this->app->getIdentity(); - if ($user->get('guest') != 1) { + if ($user->guest != 1) { // Redirect to profile page. $this->setRedirect(Route::_('index.php?option=com_users&view=profile', false)); diff --git a/components/com_users/src/Controller/ProfileController.php b/components/com_users/src/Controller/ProfileController.php index 645a55ecdc58b..a874411eddd5b 100644 --- a/components/com_users/src/Controller/ProfileController.php +++ b/components/com_users/src/Controller/ProfileController.php @@ -39,7 +39,7 @@ public function edit() { $app = $this->app; $user = $this->app->getIdentity(); - $loginUserId = (int) $user->get('id'); + $loginUserId = (int) $user->id; // Get the current user id. $userId = $this->input->getInt('user_id'); @@ -90,7 +90,7 @@ public function save() /** @var \Joomla\Component\Users\Site\Model\ProfileModel $model */ $model = $this->getModel('Profile', 'Site'); $user = $this->app->getIdentity(); - $userId = (int) $user->get('id'); + $userId = (int) $user->id; // Get the user data. $requestData = $app->getInput()->post->get('jform', [], 'array'); diff --git a/components/com_users/src/Controller/RegistrationController.php b/components/com_users/src/Controller/RegistrationController.php index 7803077b2176a..93ec4f2169698 100644 --- a/components/com_users/src/Controller/RegistrationController.php +++ b/components/com_users/src/Controller/RegistrationController.php @@ -46,7 +46,7 @@ public function activate() $uParams = ComponentHelper::getParams('com_users'); // Check for admin activation. Don't allow non-super-admin to delete a super admin - if ($uParams->get('useractivation') != 2 && $user->get('id')) { + if ($uParams->get('useractivation') != 2 && $user->id) { $this->setRedirect('index.php'); return true; diff --git a/components/com_users/src/Model/ProfileModel.php b/components/com_users/src/Model/ProfileModel.php index 2746417a7a858..b3e09c60487bd 100644 --- a/components/com_users/src/Model/ProfileModel.php +++ b/components/com_users/src/Model/ProfileModel.php @@ -84,7 +84,7 @@ public function getData() $this->data = new User($userId); // Set the base user data. - $this->data->email1 = $this->data->get('email'); + $this->data->email1 = $this->data->email; // Override the base user data with any data in the session. $temp = (array) Factory::getApplication()->getUserState('com_users.edit.profile.data', []); @@ -220,7 +220,7 @@ protected function populateState() // Get the user id. $userId = Factory::getApplication()->getUserState('com_users.edit.profile.id'); - $userId = !empty($userId) ? $userId : (int) $this->getCurrentUser()->get('id'); + $userId = !empty($userId) ? $userId : (int) $this->getCurrentUser()->id; // Set the user id. $this->setState('user.id', $userId); diff --git a/components/com_users/src/View/Login/HtmlView.php b/components/com_users/src/View/Login/HtmlView.php index 25dbab1724748..116aa464e9bcd 100644 --- a/components/com_users/src/View/Login/HtmlView.php +++ b/components/com_users/src/View/Login/HtmlView.php @@ -133,7 +133,7 @@ public function display($tpl = null) */ protected function prepareDocument() { - $login = (bool) $this->getCurrentUser()->get('guest'); + $login = (bool) $this->getCurrentUser()->guest; // Because the application sets a default page title, // we need to get it from the menu item itself diff --git a/components/com_users/tmpl/login/default.php b/components/com_users/tmpl/login/default.php index 0fbcc008e8855..2e6aa5c037c10 100644 --- a/components/com_users/tmpl/login/default.php +++ b/components/com_users/tmpl/login/default.php @@ -14,7 +14,7 @@ $cookieLogin = $this->user->get('cookieLogin'); -if (!empty($cookieLogin) || $this->user->get('guest')) { +if (!empty($cookieLogin) || $this->user->guest) { // The user is not logged in or needs to provide a password. echo $this->loadTemplate('login'); } else { diff --git a/libraries/src/Application/AdministratorApplication.php b/libraries/src/Application/AdministratorApplication.php index 672a206e4416c..bdd210f4ec397 100644 --- a/libraries/src/Application/AdministratorApplication.php +++ b/libraries/src/Application/AdministratorApplication.php @@ -410,7 +410,7 @@ protected function render() $rootUser = $this->get('root_user'); if (property_exists('\JConfig', 'root_user')) { - if (Factory::getUser()->get('username') === $rootUser || Factory::getUser()->id === (string) $rootUser) { + if (Factory::getUser()->username === $rootUser || Factory::getUser()->id === (string) $rootUser) { $this->enqueueMessage( Text::sprintf( 'JWARNING_REMOVE_ROOT_USER', @@ -487,7 +487,7 @@ public function findOption(): string * request to go through. Otherwise we force com_login to be loaded, letting the user (re)try authenticating * with a user account that has the Backend Login privilege. */ - if ($user->get('guest') || !$user->authorise('core.login.admin')) { + if ($user->guest || !$user->authorise('core.login.admin')) { $option = \in_array($option, $this->allowedUnprivilegedOptions) ? $option : 'com_login'; } diff --git a/libraries/src/Application/CMSApplication.php b/libraries/src/Application/CMSApplication.php index 2ea7735bbee92..027cb265accc4 100644 --- a/libraries/src/Application/CMSApplication.php +++ b/libraries/src/Application/CMSApplication.php @@ -368,7 +368,7 @@ public function execute() */ protected function checkUserRequireReset($option, $view, $layout, $tasks) { - if (Factory::getUser()->get('requireReset', 0)) { + if (Factory::getUser()->requireReset) { $redirect = false; /* @@ -966,8 +966,8 @@ public function logout($userid = null, $options = []) // Build the credentials array. $parameters = [ - 'username' => $user->get('username'), - 'id' => $user->get('id'), + 'username' => $user->username, + 'id' => $user->id, ]; // Set clientid in the options array if it hasn't been set already and shared sessions are not enabled. @@ -985,7 +985,7 @@ public function logout($userid = null, $options = []) // Check if any of the plugins failed. If none did, success. if (!\in_array(false, $results, true)) { - $options['username'] = $user->get('username'); + $options['username'] = $user->username; $dispatcher->dispatch('onUserAfterLogout', new AfterLogoutEvent('onUserAfterLogout', [ 'options' => $options, 'subject' => $parameters, @@ -1065,7 +1065,7 @@ protected function render() $caching = false; - if ($this->isClient('site') && $this->get('caching') && $this->get('caching', 2) == 2 && !Factory::getUser()->get('id')) { + if ($this->isClient('site') && $this->get('caching') && $this->get('caching', 2) == 2 && !Factory::getUser()->id) { $caching = true; } diff --git a/libraries/src/Application/SiteApplication.php b/libraries/src/Application/SiteApplication.php index 5450677e9209a..6b89a7602f0c9 100644 --- a/libraries/src/Application/SiteApplication.php +++ b/libraries/src/Application/SiteApplication.php @@ -113,7 +113,7 @@ protected function authorise($itemid) $user = Factory::getUser(); if (!$menus->authorise($itemid)) { - if ($user->get('id') == 0) { + if ($user->id == 0) { // Set the data $this->setUserState('users.login.form.data', ['return' => Uri::getInstance()->toString()]); diff --git a/libraries/src/Component/ComponentHelper.php b/libraries/src/Component/ComponentHelper.php index b7f0ca0294b82..0c127d3087d60 100644 --- a/libraries/src/Component/ComponentHelper.php +++ b/libraries/src/Component/ComponentHelper.php @@ -131,7 +131,7 @@ public static function filterText($text) // Filter settings $config = static::getParams('com_config'); $user = Factory::getUser(); - $userGroups = Access::getGroupsByUser($user->get('id')); + $userGroups = Access::getGroupsByUser($user->id); $filters = $config->get('filters'); diff --git a/libraries/src/HTML/Helpers/Grid.php b/libraries/src/HTML/Helpers/Grid.php index 1c77f9bfe01c2..8dd523b468ece 100644 --- a/libraries/src/HTML/Helpers/Grid.php +++ b/libraries/src/HTML/Helpers/Grid.php @@ -138,7 +138,7 @@ public static function id($rowNum, $recId, $checkedOut = false, $name = 'cid', $ public static function checkedOut(&$row, $i, $identifier = 'id') { $user = Factory::getUser(); - $userid = $user->get('id'); + $userid = $user->id; if ($row instanceof Table) { $result = $row->isCheckedOut($userid); diff --git a/libraries/src/Helper/ModuleHelper.php b/libraries/src/Helper/ModuleHelper.php index 6ceb9e95e5dbe..7ded94f7d26b5 100644 --- a/libraries/src/Helper/ModuleHelper.php +++ b/libraries/src/Helper/ModuleHelper.php @@ -590,7 +590,7 @@ public static function moduleCache($module, $moduleparams, $cacheparams) $ownCacheDisabled = $moduleparams->get('owncache') === 0 || $moduleparams->get('owncache') === '0'; $cacheDisabled = $moduleparams->get('cache') === 0 || $moduleparams->get('cache') === '0'; - if ($ownCacheDisabled || $cacheDisabled || $app->get('caching') == 0 || $user->get('id')) { + if ($ownCacheDisabled || $cacheDisabled || $app->get('caching') == 0 || $user->id) { $cache->setCaching(false); } diff --git a/libraries/src/MVC/Model/AdminModel.php b/libraries/src/MVC/Model/AdminModel.php index a2c92bab8b75c..d4bdd20547a27 100644 --- a/libraries/src/MVC/Model/AdminModel.php +++ b/libraries/src/MVC/Model/AdminModel.php @@ -1142,7 +1142,7 @@ public function publish(&$pks, $value = 1) } // Attempt to change the state of the records. - if (!$table->publish($pks, $value, $user->get('id'))) { + if (!$table->publish($pks, $value, $user->id)) { $this->setError($table->getError()); return false; diff --git a/libraries/src/MVC/Model/FormModel.php b/libraries/src/MVC/Model/FormModel.php index 196b8b94e1a9a..301ba37787e6b 100644 --- a/libraries/src/MVC/Model/FormModel.php +++ b/libraries/src/MVC/Model/FormModel.php @@ -101,7 +101,7 @@ public function checkin($pk = null) $checkedOutField = $table->getColumnAlias('checked_out'); // Check if this is the user having previously checked out the row. - if ($table->$checkedOutField > 0 && $table->$checkedOutField != $user->get('id') && !$user->authorise('core.manage', 'com_checkin')) { + if ($table->$checkedOutField > 0 && $table->$checkedOutField != $user->id && !$user->authorise('core.manage', 'com_checkin')) { $this->setError(Text::_('JLIB_APPLICATION_ERROR_CHECKIN_USER_MISMATCH')); return false; @@ -160,14 +160,14 @@ public function checkout($pk = null) $checkedOutField = $table->getColumnAlias('checked_out'); // Check if this is the user having previously checked out the row. - if ($table->$checkedOutField > 0 && $table->$checkedOutField != $user->get('id')) { + if ($table->$checkedOutField > 0 && $table->$checkedOutField != $user->id) { $this->setError(Text::_('JLIB_APPLICATION_ERROR_CHECKOUT_USER_MISMATCH')); return false; } // Attempt to check the row out. - if (!$table->checkOut($user->get('id'), $pk)) { + if (!$table->checkOut($user->id, $pk)) { $this->setError($table->getError()); return false; diff --git a/libraries/src/Session/Session.php b/libraries/src/Session/Session.php index afd6ee44ff2f3..fc524839ffb08 100644 --- a/libraries/src/Session/Session.php +++ b/libraries/src/Session/Session.php @@ -100,7 +100,7 @@ public static function getFormToken($forceNew = false) { $user = Factory::getUser(); - return ApplicationHelper::getHash($user->get('id', 0) . Factory::getApplication()->getSession()->getToken($forceNew)); + return ApplicationHelper::getHash($user->id . Factory::getApplication()->getSession()->getToken($forceNew)); } /** diff --git a/libraries/src/Table/Category.php b/libraries/src/Table/Category.php index c3fd1887c6fc0..0e14d4f6a0dff 100644 --- a/libraries/src/Table/Category.php +++ b/libraries/src/Table/Category.php @@ -241,7 +241,7 @@ public function store($updateNulls = true) if ($this->id) { // Existing category - $this->modified_user_id = $user->get('id'); + $this->modified_user_id = $user->id; $this->modified_time = $date; } else { if (!(int) ($this->modified_time)) { @@ -250,7 +250,7 @@ public function store($updateNulls = true) // Field created_user_id can be set by the user, so we don't touch it if it's set. if (empty($this->created_user_id)) { - $this->created_user_id = $user->get('id'); + $this->created_user_id = $user->id; } if (empty($this->modified_user_id)) { diff --git a/libraries/src/Table/Content.php b/libraries/src/Table/Content.php index 109cff6d2ec4b..8bf6d85248b50 100644 --- a/libraries/src/Table/Content.php +++ b/libraries/src/Table/Content.php @@ -328,12 +328,12 @@ public function store($updateNulls = true) if ($this->id) { // Existing item - $this->modified_by = $user->get('id'); + $this->modified_by = $user->id; $this->modified = $date; } else { // Field created_by can be set by the user, so we don't touch it if it's set. if (empty($this->created_by)) { - $this->created_by = $user->get('id'); + $this->created_by = $user->id; } // Set modified to created date if not set diff --git a/libraries/src/Table/CoreContent.php b/libraries/src/Table/CoreContent.php index f2e8b87510b78..d394579b966bc 100644 --- a/libraries/src/Table/CoreContent.php +++ b/libraries/src/Table/CoreContent.php @@ -233,7 +233,7 @@ public function store($updateNulls = true) if ($this->core_content_id) { // Existing item $this->core_modified_time = $date->toSql(); - $this->core_modified_user_id = $user->get('id'); + $this->core_modified_user_id = $user->id; $isNew = false; } else { // New content item. A content item core_created_time and core_created_user_id field can be set by the user, @@ -243,7 +243,7 @@ public function store($updateNulls = true) } if (empty($this->core_created_user_id)) { - $this->core_created_user_id = $user->get('id'); + $this->core_created_user_id = $user->id; } if (!(int) $this->core_modified_time) { diff --git a/modules/mod_articles_latest/src/Helper/ArticlesLatestHelper.php b/modules/mod_articles_latest/src/Helper/ArticlesLatestHelper.php index 926073bf0d60c..011e15d706e7b 100644 --- a/modules/mod_articles_latest/src/Helper/ArticlesLatestHelper.php +++ b/modules/mod_articles_latest/src/Helper/ArticlesLatestHelper.php @@ -68,7 +68,7 @@ public function getArticles(Registry $params, SiteApplication $app) // Access filter $access = !ComponentHelper::getParams('com_content')->get('show_noauth'); - $authorised = Access::getAuthorisedViewLevels($user->get('id')); + $authorised = Access::getAuthorisedViewLevels($user->id); $model->setState('filter.access', $access); // Category filter @@ -78,7 +78,7 @@ public function getArticles(Registry $params, SiteApplication $app) $model->setState('filter.condition', 1); // User filter - $userId = $user->get('id'); + $userId = $user->id; switch ($params->get('user_id')) { case 'by_me': diff --git a/modules/mod_login/src/Helper/LoginHelper.php b/modules/mod_login/src/Helper/LoginHelper.php index 3803fdb5685e7..990729c9cb8f1 100644 --- a/modules/mod_login/src/Helper/LoginHelper.php +++ b/modules/mod_login/src/Helper/LoginHelper.php @@ -62,7 +62,7 @@ public static function getType() { $user = Factory::getUser(); - return (!$user->get('guest')) ? 'logout' : 'login'; + return (!$user->guest) ? 'logout' : 'login'; } /** diff --git a/modules/mod_login/tmpl/default_logout.php b/modules/mod_login/tmpl/default_logout.php index 1feee67430151..d4d3a983a7337 100644 --- a/modules/mod_login/tmpl/default_logout.php +++ b/modules/mod_login/tmpl/default_logout.php @@ -23,9 +23,9 @@ get('greeting', 1)) : ?>
get('name', 0)) : ?> - get('name'), ENT_COMPAT, 'UTF-8')); ?> + name, ENT_COMPAT, 'UTF-8')); ?> - get('username'), ENT_COMPAT, 'UTF-8')); ?> + username, ENT_COMPAT, 'UTF-8')); ?>
diff --git a/plugins/content/joomla/src/Extension/Joomla.php b/plugins/content/joomla/src/Extension/Joomla.php index 95f8523ada7c2..58d3d197b7a78 100644 --- a/plugins/content/joomla/src/Extension/Joomla.php +++ b/plugins/content/joomla/src/Extension/Joomla.php @@ -144,7 +144,7 @@ public function onContentAfterSave($context, $article, $isNew): void $message = [ 'user_id_to' => $user_id, 'subject' => $lang->_('COM_CONTENT_NEW_ARTICLE'), - 'message' => sprintf($lang->_('COM_CONTENT_ON_NEW_CONTENT'), $user->get('name'), $article->title), + 'message' => sprintf($lang->_('COM_CONTENT_ON_NEW_CONTENT'), $user->name, $article->title), ]; $model_message = $this->getApplication()->bootComponent('com_messages')->getMVCFactory() ->createModel('Message', 'Administrator'); diff --git a/plugins/editors/tinymce/src/PluginTraits/GlobalFilters.php b/plugins/editors/tinymce/src/PluginTraits/GlobalFilters.php index 009ec84e12567..e1ac4e4d4a5e1 100644 --- a/plugins/editors/tinymce/src/PluginTraits/GlobalFilters.php +++ b/plugins/editors/tinymce/src/PluginTraits/GlobalFilters.php @@ -38,7 +38,7 @@ protected static function getGlobalFilters($user) { // Filter settings $config = ComponentHelper::getParams('com_config'); - $userGroups = Access::getGroupsByUser($user->get('id')); + $userGroups = Access::getGroupsByUser($user->id); $filters = $config->get('filters'); $forbiddenListTags = []; From 7d4e3bd89947857f44a258d406aa958f0bebfe23 Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Wed, 24 Apr 2024 22:20:04 +0200 Subject: [PATCH 2/2] Replace Factory::getUser() with $this->getIdentity() --- libraries/src/Application/AdministratorApplication.php | 4 ++-- libraries/src/Application/CMSApplication.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/src/Application/AdministratorApplication.php b/libraries/src/Application/AdministratorApplication.php index bdd210f4ec397..ce33bc1528c4c 100644 --- a/libraries/src/Application/AdministratorApplication.php +++ b/libraries/src/Application/AdministratorApplication.php @@ -410,7 +410,7 @@ protected function render() $rootUser = $this->get('root_user'); if (property_exists('\JConfig', 'root_user')) { - if (Factory::getUser()->username === $rootUser || Factory::getUser()->id === (string) $rootUser) { + if ($this->getIdentity()->username === $rootUser || $this->getIdentity()->id === (string) $rootUser) { $this->enqueueMessage( Text::sprintf( 'JWARNING_REMOVE_ROOT_USER', @@ -418,7 +418,7 @@ protected function render() ), 'warning' ); - } elseif (Factory::getUser()->authorise('core.admin')) { + } elseif ($this->getIdentity()->authorise('core.admin')) { // Show this message to superusers too $this->enqueueMessage( Text::sprintf( diff --git a/libraries/src/Application/CMSApplication.php b/libraries/src/Application/CMSApplication.php index 027cb265accc4..0cc8877ebe4c8 100644 --- a/libraries/src/Application/CMSApplication.php +++ b/libraries/src/Application/CMSApplication.php @@ -368,7 +368,7 @@ public function execute() */ protected function checkUserRequireReset($option, $view, $layout, $tasks) { - if (Factory::getUser()->requireReset) { + if ($this->getIdentity()->requireReset) { $redirect = false; /* @@ -1065,7 +1065,7 @@ protected function render() $caching = false; - if ($this->isClient('site') && $this->get('caching') && $this->get('caching', 2) == 2 && !Factory::getUser()->id) { + if ($this->isClient('site') && $this->get('caching') && $this->get('caching', 2) == 2 && !$this->getIdentity()->id) { $caching = true; }