Skip to content

Commit 2ac3fc0

Browse files
fix: Allow admin to see all camapigns
Allow all admin users, not just those who are Aspen Admin, to see all campaigns
1 parent e4cbe8f commit 2ac3fc0

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

code/web/sys/Account/User.php

+12
Original file line numberDiff line numberDiff line change
@@ -5603,6 +5603,18 @@ public function isAspenAdminUser(): bool {
56035603
return $this->source == 'admin' && $this->username == 'aspen_admin';
56045604
}
56055605

5606+
public function isUserAdmin(): bool {
5607+
require_once ROOT_DIR . '/sys/Administration/UserRoles.php';
5608+
$userRole = new UserRoles();
5609+
$userRole->find();
5610+
5611+
$adminList = [];
5612+
while ($userRole->fetch()) {
5613+
$adminList[] = $userRole->userId;
5614+
}
5615+
return in_array($this->id, $adminList);
5616+
}
5617+
56065618
public function showRenewalLink(AccountSummary $ilsAccountSummary): bool {
56075619
$showRenewalLink = false;
56085620
if ($ilsAccountSummary->isExpirationClose()) {

code/web/sys/Community/Campaign.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,8 @@ public static function getCampaignById($id) {
361361
* @return bool True if a record is found, false otherwise.
362362
*/
363363
public function find($fetchFirst = false, $requireOneMatchToReturn = true): bool {
364-
if (!UserAccount::isLoggedIn() || UserAccount::getActiveUserObj()->isAspenAdminUser())
365-
return parent::find($fetchFirst, $requireOneMatchToReturn);
366-
364+
if (!UserAccount::isLoggedIn() || UserAccount::getActiveUserObj()->isAspenAdminUser() || UserAccount::getActiveUserObj()->isUserAdmin())
365+
return parent::find($fetchFirst, $requireOneMatchToReturn);
367366
$this->joinAdd(new CampaignPatronTypeAccess(), 'LEFT', 'ce_campaign_patron_type_access', 'id', 'campaignId');
368367
$this->whereAdd("ce_campaign_patron_type_access.patronTypeId = '" . UserAccount::getActiveUserObj()->getPTypeObj()->id . "' OR ce_campaign_patron_type_access.patronTypeId IS NULL");
369368
$this->joinAdd(new CampaignLibraryAccess(), 'LEFT', 'ce_campaign_library_access', 'id', 'campaignId');

0 commit comments

Comments
 (0)