Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.2] Removing deprecated access to User object attributes #43268

Merged
merged 4 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 2 additions & 2 deletions administrator/components/com_banners/tmpl/clients/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -107,7 +107,7 @@
<?php foreach ($this->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;
?>
<tr class="row<?php echo $i % 2; ?>">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 2 additions & 2 deletions administrator/components/com_fields/src/Table/FieldTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
4 changes: 2 additions & 2 deletions administrator/components/com_fields/src/Table/GroupTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
?>
Expand Down
4 changes: 2 additions & 2 deletions administrator/components/com_menus/src/View/Item/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions administrator/components/com_menus/tmpl/items/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
?>
<tr class="row<?php echo $i % 2; ?>" data-draggable-group="<?php echo $item->position ?: 'none'; ?>">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
<?php foreach ($this->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;
?>
<tr class="row<?php echo $i % 2; ?>" data-draggable-group="<?php echo $item->folder; ?>">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 2 additions & 2 deletions administrator/components/com_tags/src/Table/TagTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading