-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix LimitToGroups not working and hide app toolbar icon for excluded …
…users - #517
- Loading branch information
1 parent
d8e825a
commit d8e38b7
Showing
6 changed files
with
76 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
namespace OCA\Appointments\Backend; | ||
|
||
use OCA\Appointments\AppInfo\Application; | ||
use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent; | ||
use OCP\AppFramework\Http\TemplateResponse; | ||
use OCP\EventDispatcher\Event; | ||
use OCP\EventDispatcher\IEventListener; | ||
use OCP\IConfig; | ||
use OCP\IGroupManager; | ||
use OCP\IUserSession; | ||
use Psr\Log\LoggerInterface; | ||
|
||
class BeforeTemplateRenderedListener implements IEventListener | ||
{ | ||
public function handle(Event $event): void | ||
{ | ||
if (!($event instanceof BeforeTemplateRenderedEvent)) { | ||
return; | ||
} | ||
if ($event->isLoggedIn() && $event->getResponse()->getRenderAs() === TemplateResponse::RENDER_AS_USER) { | ||
|
||
try { | ||
$config = \OC::$server->get(IConfig::class); | ||
$allowedGroups = $config->getAppValue(Application::APP_ID, | ||
BackendUtils::KEY_LIMIT_TO_GROUPS); | ||
|
||
if (!empty($allowedGroups)) { | ||
$aga = json_decode($allowedGroups, true); | ||
if ($aga !== null) { | ||
$user = \OC::$server->get(IUserSession::class)->getUser(); | ||
if (!empty($user)) { | ||
$userGroups = \OC::$server->get(IGroupManager::class)->getUserGroups($user); | ||
$disable = true; | ||
foreach ($aga as $ag) { | ||
if (array_key_exists($ag, $userGroups)) { | ||
$disable = false; | ||
break; | ||
} | ||
} | ||
if ($disable) { | ||
\OC_Util::addStyle(Application::APP_ID, 'hide-app'); | ||
} | ||
} | ||
} | ||
} | ||
} catch (\Throwable $e) { | ||
\OC::$server->get(LoggerInterface::class)->error('error: cannot hide appointments app icon', [ | ||
'app' => Application::APP_ID, | ||
'exception' => $e, | ||
]); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.app-menu-main .app-menu-entry[data-app-id="appointments"], | ||
.app-menu-main .app-menu-entry__active[data-app-id="appointments"], | ||
.action.app-menu-popover-entry .action-link[href="/index.php/apps/appointments/"], | ||
.action.app-menu-popover-entry .action-link[href="/apps/appointments/"] { | ||
display: none !important; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters