-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset_admin.php
More file actions
50 lines (39 loc) · 2.02 KB
/
set_admin.php
File metadata and controls
50 lines (39 loc) · 2.02 KB
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
46
47
48
49
50
<?php
/******************************************************************************
* Plugin Admin access
*
* Copyright : (c) 2004-2021 The Admidio Team
* Homepage : http://www.admidio.org
* Author : Markus Faßbender
* License : GNU Public License 2 http://www.gnu.org/licenses/gpl-2.0.html
* Version : 0.9.0
* Required : Admidio Version 3.3
*
*****************************************************************************/
$rootPath = dirname(dirname(__DIR__));
$pluginFolder = basename(__DIR__);
require_once($rootPath . '/adm_program/system/common.php');
require_once($rootPath . '/adm_program/system/login_valid.php');
$assignedRoles = array();
// read all admin roles
$sql = 'SELECT rol_id, rol_name, org_longname
FROM '.TBL_ROLES.'
INNER JOIN ' . TBL_CATEGORIES . ' ON cat_id = rol_cat_id
INNER JOIN ' . TBL_ORGANIZATIONS . ' ON org_id = cat_org_id
WHERE rol_administrator = true ';
$adminStatement = $gDb->queryPrepared($sql);
// assign the current user to the admin roles
while ($row = $adminStatement->fetch()) {
$membership = new TableMembers($gDb);
$membership->startMembership((int) $row['rol_id'], $gCurrentUser->getValue('usr_id'));
$assignedRoles[] = $row;
}
$gNavigation->clear();
// generate html output
$page = new HtmlPage('admidio-plugin-admin-access', 'Admin access');
$page->addHtml('<div class="alert alert-primary" role="alert">The current user ' . $gCurrentUser->getValue('FIRST_NAME') . ' '. $gCurrentUser->getValue('LAST_NAME') . ' was assigned to the following roles:<br /><br />');
foreach($assignedRoles as $role) {
$page->addHtml('<p><b>' . $role['rol_name'] . '</b> of the organization ' . $role['org_longname'] . '</p>');
}
$page->addHtml('</div><br /><br /><div class="alert alert-danger" role="alert"><h4>!!! Important notice !!!</h4><p>Please delete this script and the complete folder <b>' . $pluginFolder . '</b>.</p>With this script other users could get admin access to your Admidio installation.</div><br />');
$page->show();