Skip to content

Commit

Permalink
fix: #145 admin list users urls problem
Browse files Browse the repository at this point in the history
  • Loading branch information
mshannaq committed Feb 29, 2024
1 parent 6e27a6c commit 9a9c697
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 6 additions & 1 deletion app/Controllers/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ public function listuserurls($urlOwnerUserId = null)

$data['filterrule'] = 'user';
$data['filtervalue'] = $urlOwnerUserId;
$data['filtertext'] = lang('Url.urlsUserLinks') . ' ' . smarty_get_user_username($user_id);

if ($urlOwnerUserId !== null) {
$data['filtertext'] = lang('Url.urlsUserLinks') . ' ' . smarty_get_user_username($urlOwnerUserId);
} else {
$data['filtertext'] = lang('Url.urlsAllLink') . ' ' . smarty_get_user_username($user_id);
}

if (! auth()->user()->can('admin.manageotherurls', 'super.admin') && (int) $urlOwnerUserId !== $user_id) {
return smarty_permission_error(lang('Common.permissionsNoenoughpermissions'), false);
Expand Down
9 changes: 8 additions & 1 deletion app/Models/UrlModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,14 @@ public function getUrlsForUser(int|array|null $userIds = null, int|null $start =
$builder = $this->builder();

// Check if shared URLs should be included
$sharedUrlFeatureEnabled = setting('Smartyurl.url_can_be_shared_between_users');
if ((is_array($userIds) && in_array(user_id(), $userIds, true)) || ((user_id() === $userIds))) {
// that mean user is try to get his urls, so i will check if the shared urls feature is enabled
$sharedUrlFeatureEnabled = setting('Smartyurl.url_can_be_shared_between_users');
} else {
// that mean other user try to get the user urls , mostly admin
// so i will not show shared urls
$sharedUrlFeatureEnabled = false;
}

// Check if $userIds is an array or a single value
if (isset($userIds)) {
Expand Down

0 comments on commit 9a9c697

Please sign in to comment.