-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphpgen_admin.php
More file actions
100 lines (85 loc) · 3.26 KB
/
Copy pathphpgen_admin.php
File metadata and controls
100 lines (85 loc) · 3.26 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* ATTENTION!
* If you see this message in your browser (Internet Explorer, Mozilla Firefox, Google Chrome, etc.)
* this means that PHP is not properly installed on your web server. Please refer to the PHP manual
* for more details: http://php.net/manual/install.php
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/
include_once dirname(__FILE__) . '/components/startup.php';
include_once dirname(__FILE__) . '/authorization.php';
include_once dirname(__FILE__) . '/components/error_utils.php';
include_once dirname(__FILE__) . '/components/utils/system_utils.php';
include_once dirname(__FILE__) . '/components/utils/string_utils.php';
include_once dirname(__FILE__) . '/components/security/grant_manager/table_based_user_grant_manager.php';
SetUpUserAuthorization();
class AdminPage extends CommonPage
{
public function __construct()
{
parent::__construct('Admin panel', 'UTF-8');
}
public function GetAllUsersAsJson()
{
$userManager = CreateTableBasedUserManager();
return $userManager->getUsersAsJson(GetApplication()->GetUserAuthentication()->getGuestAccessEnabled());
}
public function GetAuthenticationViewData() {
return array(
'Enabled' => true,
'LoggedIn' => GetApplication()->IsCurrentUserLoggedIn(),
'CurrentUser' => array(
'Name' => GetApplication()->GetCurrentUser(),
'Id' => GetApplication()->GetCurrentUserId(),
),
'isAdminPanelVisible' => GetApplication()->HasAdminPanelForCurrentUser(),
'canManageUsers' => GetApplication()->HasAdminGrantForCurrentUser(),
'EmailBasedFeaturesEnabled' => GetApplication()->GetUserAuthentication()->getSelfRegistrationEnabled() || GetApplication()->GetUserAuthentication()->getRecoveringPasswordEnabled(),
);
}
public function Accept(Renderer $renderer)
{
$renderer->RenderAdminPage($this);
}
private function GetCurrentPageMode() {
switch (GetApplication()->GetOperation()) {
case OPERATION_VIEWALL:
return PageMode::ViewAll;
}
return null;
}
public function GetCustomTemplate($part, $mode, $defaultValue, &$params = null)
{
return parent::GetCustomTemplate(
$part,
$mode ? $mode : $this->GetCurrentPageMode(),
$defaultValue,
$params
);
}
public function GetShowPageList() {
return true;
}
public function GetTitle()
{
return $this->GetLocalizerCaptions()->GetMessageString('AdminPage');
}
public function GetPageFileName() {
return basename(__FILE__);
}
public function getType()
{
return PageType::Admin;
}
public function checkAccessPermitted()
{
if (!GetApplication()->HasAdminPanelForCurrentUser()) {
RaiseSecurityError($this, $this->GetLocalizerCaptions()->GetMessageString('OperationNotPermitted'));
}
}
}
$page = new AdminPage();
$page->checkAccessPermitted();
$renderer = new ViewRenderer($page->GetLocalizerCaptions());
echo $renderer->Render($page);