-
Notifications
You must be signed in to change notification settings - Fork 0
/
redirectbackend.php
executable file
·45 lines (42 loc) · 1.43 KB
/
redirectbackend.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
/**
* @copyright Copyright (C) 2017 - 2020 pageup.gr, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
use Joomla\CMS\Factory;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\Router\Route;
class plgSystemRedirectbackend extends CMSPlugin
{
/**
* Event triggered after a user logs in.
*
* @return void
*/
public function onUserAfterLogin()
{
$app = Factory::getApplication();
if ($app->isClient('administrator'))
{
$user = Factory::getUser();
$groups = array_values($user->get('groups', []));
// Get the plugin parameters
$plugin = $this->params;
$groupsToRedirect = $plugin->get('usergroup_dashboard');
if (!empty($groupsToRedirect)) {
foreach ($groupsToRedirect as $item) {
$usergroup = $item->params->usergroup;
$dashboard = $item->params->dashboard;
if (in_array($usergroup,$groups))
{
$url = Route::_('index.php?' . $dashboard);
$app->redirect(html_entity_decode($url));
break; // Redirect once for the first matching group
}
}
}
}
}
}