Skip to content

Commit 305305b

Browse files
author
Kristan Kenney
committed
Merge branch 'feature/read-only-mode' into feature/user-roles
2 parents 2a97198 + 2d3f91b commit 305305b

File tree

11 files changed

+62
-45
lines changed

11 files changed

+62
-45
lines changed

web/inc/main.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ function render_page($user, $TAB, $page) {
128128
// I think those variables should be passed via arguments
129129
extract($GLOBALS, EXTR_SKIP);
130130

131+
// Policies controller
132+
@include_once(dirname(__DIR__) . '/inc/policies.php');
133+
131134
// Body
132135
include($__template_dir . "pages/$page.html");
133136

web/inc/policies.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
if (($_SESSION['userContext'] === 'user') && ($panel[$user]['SUSPENDED'] === 'yes') && ($_SESSION['POLICY_USER_VIEW_SUSPENDED'] === 'yes')) {
4+
$read_only='true';
5+
}
6+
7+
if (($_SESSION['userContext'] === 'admin') && ($_SESSION['look'] === 'admin') && ($_SESSION['POLICY_SYSTEM_PROTECTED_ADMIN'] === 'yes')) {
8+
$read_only='true';
9+
}
10+
11+
if ($read_only === 'true') {
12+
$display_mode='disabled';
13+
}
14+
15+
?>

web/templates/includes/panel.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@
6060
<!-- Hide 'edit user' entry point from other administrators for default 'admin' account-->
6161
<div class="l-menu__item"><a href="/list/log/" title="<?_('Logs')?>" class="l-profile__username"><i class="fas fa-history"></i></a></div>
6262
<? } else { ?>
63-
<div class="l-menu__item"><a href="/edit/user/?user=<?php echo $user; ?>&token=<?=$_SESSION['token']?>" title="<?=htmlspecialchars($user)?> (<?=htmlspecialchars($panel[$user]['NAME'])?>)" class="l-profile__username"><i class="fas fa-user-circle"></i></a></div>
63+
<? if ($panel[$user]['SUSPENDED'] === 'no') {?>
64+
<div class="l-menu__item"><a href="/edit/user/?user=<?php echo $user; ?>&token=<?=$_SESSION['token']?>" title="<?=htmlspecialchars($user)?> (<?=htmlspecialchars($panel[$user]['NAME'])?>)" class="l-profile__username"><i class="fas fa-user-circle"></i></a></div>
65+
<? } ?>
6466
<? } ?>
6567
<div class="l-menu__item"><a href="https://docs.hestiacp.com/" rel="noopener" title="<?=_('Help')?>" class="l-profile__help" target="_blank"><i class="fas fa-question-circle"></i></a></div>
6668
<? if(isset($_SESSION['look']) && (!empty($_SESSION['look']))){ ?>

web/templates/pages/list_backup.html

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div class="l-center">
22
<div class="l-sort clearfix noselect">
33
<div class="l-unit-toolbar__buttonstrip">
4-
<? if (($_SESSION['userContext'] === 'admin') && ($_SESSION['look'] === 'admin') && ($_SESSION['POLICY_SYSTEM_PROTECTED_ADMIN'] === 'yes')) {?>
4+
<? if ($read_only === 'true') {?>
55
<!-- Hide item creation button when impersonating 'admin' account -->
66
<? } else { ?>
77
<a href="/schedule/backup/?token=<?=$_SESSION['token']?>" class="ui-button cancel" dir="ltr"><i class="fas fa-plus-circle status-icon green"></i><?=_('Create Backup')?></a>
@@ -18,7 +18,7 @@
1818
<button type="submit" class="l-sort-toolbar__filter-apply" onclick="return doSearch('/search/')" value="" title="<?=_('Search')?>"><i class="fas fa-search"></i></button>
1919
</form>
2020
</td>
21-
<? if (($_SESSION['userContext'] === 'admin') && ($_SESSION['look'] === 'admin') && ($_SESSION['POLICY_SYSTEM_PROTECTED_ADMIN'] === 'yes')) {?>
21+
<? if ($read_only === 'true') {?>
2222
<!-- Hide bulk actions for domain items when impersonating 'admin' account-->
2323
<? } else { ?>
2424
<td>
@@ -46,7 +46,6 @@
4646
<div class="l-unit__col l-unit__col--right">
4747
<div>
4848
<div class="clearfix l-unit__stat-col--left super-compact">
49-
<? if (($_SESSION['userContext'] === 'admin') && ($_SESSION['look'] === 'admin') && ($_SESSION['POLICY_SYSTEM_PROTECTED_ADMIN'] === 'yes')) { $display_mode = 'disabled'; } ?>
5049
<input id="toggle-all" type="checkbox" name="toggle-all" value="toggle-all" title="<?=_('Select all')?>" onChange="checkedAll('objects');" <?=$display_mode;?>>
5150
</div>
5251
<div class="clearfix l-unit__stat-col--left wide-4"><b><?php print _('File Name');?></b></div>
@@ -84,7 +83,7 @@
8483
<input id="check<?php echo $i ?>" class="ch-toggle" type="checkbox" title="<?=_('Select')?>" name="backup[]" value="<?php echo $key ?>" <?=$display_mode;?>>
8584
</div>
8685
<div class="clearfix l-unit__stat-col--left wide-4 truncate">
87-
<? if (($_SESSION['userContext'] === 'admin') && ($_SESSION['look'] === 'admin') && ($_SESSION['POLICY_SYSTEM_PROTECTED_ADMIN'] === 'yes')) {?>
86+
<? if ($read_only === 'true') {?>
8887
<b><?=$key?></b>
8988
<? } else { ?>
9089
<b><a href="/list/backup/?backup=<?=$key?>&token=<?=$_SESSION['token']?>" title="<?=_('restore')?>"><?=$key?></a></b>
@@ -94,11 +93,12 @@
9493
<div class="clearfix l-unit__stat-col--left compact-4 text-right">
9594
<div class="l-unit-toolbar__col l-unit-toolbar__col--right noselect">
9695
<div class="actions-panel clearfix">
97-
<? if (($_SESSION['userContext'] === 'admin') && ($_SESSION['look'] === 'admin') && ($_SESSION['POLICY_SYSTEM_PROTECTED_ADMIN'] === 'yes')) {?>
96+
<? if (($_SESSION['userContext'] === 'admin') && ($_SESSION['look'] === 'admin') && ($read_only === 'true')) {?>
9897
<!-- Restrict ability to restore or delete backups when impersonating 'admin' account -->
9998
&nbsp;
10099
<? } else { ?>
101100
<div class="actions-panel__col actions-panel__download shortcut-d" key-action="href"><a href="/download/backup/?backup=<?=$key?>&token=<?=$_SESSION['token']?>" title="<?=_('download')?>"><i class="fas fa-file-download status-icon lightblue status-icon dim"></i></a></div>
101+
<? if ($read_only === 'false') {?>
102102
<div class="actions-panel__col actions-panel__list shortcut-enter" key-action="href"><a href="/list/backup/?backup=<?=$key?>&token=<?=$_SESSION['token']?>" title="<?=_('restore')?>"><i class="fas fa-undo status-icon green status-icon dim"></i></a></div>
103103
<div class="actions-panel__col actions-panel__delete shortcut-delete" key-action="js">
104104
<a id="delete_link_<?=$i?>" class="data-controls do_delete" title="<?=_('delete')?>">
@@ -109,6 +109,7 @@
109109
</div>
110110
</a>
111111
</div>
112+
<? } ?>
112113
<? } ?>
113114
</div>
114115
</div>

web/templates/pages/list_cron.html

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<div class="l-center">
1+
<div class="l-center">
22
<div class="l-sort clearfix noselect">
33
<div class="l-unit-toolbar__buttonstrip">
4-
<? if (($_SESSION['userContext'] === 'admin') && ($_SESSION['look'] === 'admin') && ($_SESSION['POLICY_SYSTEM_PROTECTED_ADMIN'] === 'yes')) {?>
4+
<? if ($read_only === 'true') {?>
55
<!-- Hide item creation button when impersonating 'admin' account -->
66
<? } else { ?>
77
<a href="/add/cron/" id="btn-create" class="ui-button cancel" dir="ltr"><i class="fas fa-plus-circle status-icon green"></i><?=_('Add Cron Job')?></a>
@@ -34,7 +34,7 @@
3434
<button type="submit" class="l-sort-toolbar__filter-apply" onclick="return doSearch('/search/')" value="" title="<?=_('Search')?>"><i class="fas fa-search"></i></button>
3535
</form>
3636
</td>
37-
<? if (($_SESSION['userContext'] === 'admin') && ($_SESSION['look'] === 'admin') && ($_SESSION['POLICY_SYSTEM_PROTECTED_ADMIN'] === 'yes')) {?>
37+
<? if ($read_only === 'true') {?>
3838
<!-- Hide bulk actions for domain items when impersonating 'admin' account-->
3939
<? } else { ?>
4040
<td class="">
@@ -65,7 +65,6 @@
6565
<div class="header table-header">
6666
<div class="l-unit__col l-unit__col--right">
6767
<div class="clearfix l-unit__stat-col--left super-compact">
68-
<? if (($_SESSION['userContext'] === 'admin') && ($_SESSION['look'] === 'admin') && ($_SESSION['POLICY_SYSTEM_PROTECTED_ADMIN'] === 'yes')) { $display_mode = 'disabled'; } ?>
6968
<input id="toggle-all" type="checkbox" name="toggle-all" value="toggle-all" title="<?=_('Select all')?>" onChange="checkedAll('objects');" <?=$display_mode;?>>
7069
</div>
7170
<div class="clearfix l-unit__stat-col--left wide-5"><b><?php print _('Command');?></b></div>
@@ -101,7 +100,7 @@
101100
<input id="check<?php echo $i ?>" class="ch-toggle" type="checkbox" title="<?=_('Select')?>" name="job[]" value="<?php echo $key ?>" <?=$display_mode;?>>
102101
</div>
103102
<div class="clearfix l-unit__stat-col--left wide-5 truncate">
104-
<? if (($_SESSION['userContext'] === 'admin') && (isset($_SESSION['look'])) && ($_SESSION['look'] === 'admin') && ($_SESSION['POLICY_SYSTEM_PROTECTED_ADMIN'] === 'yes') || ($data[$key]['SUSPENDED'] == 'yes')) {?>
103+
<? if (($read_only === 'true') || ($data[$key]['SUSPENDED'] == 'yes')) {?>
105104
<b><?=htmlspecialchars($data[$key]['CMD'], ENT_NOQUOTES)?></b>
106105
<? } else { ?>
107106
<b><a href="/edit/cron/?job=<?=$data[$key]['JOB']?>&token=<?=$_SESSION['token']?>" title="<?=_('Editing Cron Job')?>: <?=htmlspecialchars($data[$key]['CMD'], ENT_NOQUOTES)?>"><?=htmlspecialchars($data[$key]['CMD'], ENT_NOQUOTES)?></a></b>
@@ -111,7 +110,7 @@
111110
<div class="clearfix l-unit__stat-col--left compact-2 text-right">
112111
<div class="l-unit-toolbar__col l-unit-toolbar__col--right noselect">
113112
<div class="actions-panel clearfix">
114-
<? if (($_SESSION['userContext'] === 'admin') && (isset($_SESSION['look'])) && ($_SESSION['look'] === 'admin') && ($_SESSION['POLICY_SYSTEM_PROTECTED_ADMIN'] === 'yes')) {?>
113+
<? if ($read_only === 'true') {?>
115114
<!-- Restrict other administrators from editing, deleting, or suspending 'admin' user cron jobs -->
116115
&nbsp;
117116
<? } else { ?>

web/templates/pages/list_db.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
$db_pgadmin_link = "//".$http_host."/".$_SESSION['DB_PGA_ALIAS']."/";
1212
}
1313
?>
14+
1415
<div class="l-center">
1516
<div class="l-sort clearfix noselect">
1617
<div class="l-unit-toolbar__buttonstrip">
17-
<? if (($_SESSION['userContext'] === 'admin') && ($_SESSION['look'] === 'admin') && ($_SESSION['POLICY_SYSTEM_PROTECTED_ADMIN'] === 'yes')) {?>
18+
<? if ($read_only === 'true') {?>
1819
<!-- Hide item creation button when impersonating 'admin' account -->
1920
<? } else {?>
2021
<a href="/add/db/" id="btn-create" class="ui-button cancel" dir="ltr"><i class="fas fa-plus-circle status-icon green"></i><?=_('Add Database')?></a>
@@ -52,7 +53,7 @@
5253
<button type="submit" class="l-sort-toolbar__filter-apply" onclick="return doSearch('/search/')" value="" title="<?=_('Search')?>"><i class="fas fa-search"></i></button>
5354
</form>
5455
</td>
55-
<? if (($_SESSION['userContext'] === 'admin') && ($_SESSION['look'] === 'admin') && ($_SESSION['POLICY_SYSTEM_PROTECTED_ADMIN'] === 'yes')) {?>
56+
<? if ($read_only === 'true') {?>
5657
<!-- Hide bulk actions for domain items when impersonating 'admin' account-->
5758
<? } else { ?>
5859
<td>
@@ -84,7 +85,6 @@
8485
<div class="header table-header">
8586
<div class="l-unit__col l-unit__col--right">
8687
<div class="clearfix l-unit__stat-col--left super-compact">
87-
<? if (($_SESSION['userContext'] === 'admin') && ($_SESSION['look'] === 'admin') && ($_SESSION['POLICY_SYSTEM_PROTECTED_ADMIN'] === 'yes')) { $display_mode = 'disabled'; } ?>
8888
<input id="toggle-all" type="checkbox" name="toggle-all" value="toggle-all" title="<?=_('Select all')?>" onChange="checkedAll('objects');" <?=$display_mode;?>>
8989
</div>
9090
<div class="clearfix l-unit__stat-col--left wide-3"><b><?php print _('Name');?></b></div>
@@ -131,7 +131,7 @@
131131
<input id="check<?php echo $i ?>" class="ch-toggle" type="checkbox" title="<?=_('Select')?>" name="database[]" value="<?php echo $key ?>" <?=$display_mode;?>>
132132
</div>
133133
<div class="clearfix l-unit__stat-col--left wide-3 truncate">
134-
<? if (($_SESSION['userContext'] === 'admin') && ($_SESSION['look'] === 'admin') && ($_SESSION['POLICY_SYSTEM_PROTECTED_ADMIN'] === 'yes') || ($data[$key]['SUSPENDED'] == 'yes')) {?>
134+
<? if (($read_only === 'true') || ($data[$key]['SUSPENDED'] == 'yes')) {?>
135135
<b><?=$key?></b>
136136
<? } else { ?>
137137
<b><a href="/edit/db/?database=<?=$key?>&token=<?=$_SESSION['token']?>" title="<?=_('Editing Database')?>: <?=$key?>"><?=$key?></a></b>
@@ -141,7 +141,7 @@
141141
<div class="clearfix l-unit__stat-col--left text-right compact-3">
142142
<div class="l-unit-toolbar__col l-unit-toolbar__col--right noselect">
143143
<div class="actions-panel clearfix">
144-
<? if (($_SESSION['userContext'] === 'admin') && ($_SESSION['look'] === 'admin') && ($_SESSION['POLICY_SYSTEM_PROTECTED_ADMIN'] === 'yes')) {?>
144+
<? if ($read_only === 'true') {?>
145145
<!-- Restrict the ability to edit, delete, or suspend domain items when impersonating 'admin' user -->
146146
&nbsp;
147147
<? } else { ?>

web/templates/pages/list_dns.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<div class="l-center">
1+
<div class="l-center">
22
<div class="l-sort clearfix noselect">
33
<div class="l-unit-toolbar__buttonstrip">
4-
<? if (($_SESSION['userContext'] === 'admin') && ($_SESSION['look'] === 'admin') && ($_SESSION['POLICY_SYSTEM_PROTECTED_ADMIN'] === 'yes')) {?>
4+
<? if ($read_only === 'true') {?>
55
<!-- Hide item creation button when impersonating 'admin' account -->
66
<? } else {?>
77
<a href="/add/dns/" id="btn-create" class="ui-button cancel" dir="ltr"><i class="fas fa-plus-circle status-icon green"></i><?=_('Add DNS Domain')?></a>
@@ -32,7 +32,7 @@
3232
<button type="submit" class="l-sort-toolbar__filter-apply" onclick="return doSearch('/search/')" value="" title="<?=_('Search')?>"><i class="fas fa-search"></i></button>
3333
</form>
3434
</td>
35-
<? if (($_SESSION['userContext'] === 'admin') && ($_SESSION['look'] === 'admin') && ($_SESSION['POLICY_SYSTEM_PROTECTED_ADMIN'] === 'yes')) {?>
35+
<? if ($read_only === 'true') {?>
3636
<!-- Hide bulk actions for domain items when impersonating 'admin' account-->
3737
<? } else { ?>
3838
<td>
@@ -64,7 +64,6 @@
6464
<div class="header table-header">
6565
<div class="l-unit__col l-unit__col--right">
6666
<div class="clearfix l-unit__stat-col--left super-compact">
67-
<? if (($_SESSION['userContext'] === 'admin') && ($_SESSION['look'] === 'admin') && ($_SESSION['POLICY_SYSTEM_PROTECTED_ADMIN'] === 'yes')) { $display_mode = 'disabled'; } ?>
6867
<input id="toggle-all" type="checkbox" name="toggle-all" value="toggle-all" title="<?=_('Select all')?>" onChange="checkedAll('objects');" <?=$display_mode;?>>
6968
</div>
7069
<div class="clearfix l-unit__stat-col--left wide-3"><b><?php print _('Name');?></b></div>
@@ -108,7 +107,7 @@
108107
<div class="clearfix l-unit__stat-col--left text-right">
109108
<div class="l-unit-toolbar__col l-unit-toolbar__col--right noselect">
110109
<div class="actions-panel clearfix">
111-
<? if (($_SESSION['userContext'] === 'admin') && ($_SESSION['look'] === 'admin') && ($_SESSION['POLICY_SYSTEM_PROTECTED_ADMIN'] === 'yes')) {?>
110+
<? if ($read_only === 'true') {?>
112111
<!-- Restrict administrators from editing domain items when impersonating the 'admin' user -->
113112
&nbsp;
114113
<? } else { ?>

web/templates/pages/list_dns_rec.html

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
<div class="l-center">
1+
<div class="l-center">
22
<div class="l-sort clearfix noselect">
33
<div class="l-unit-toolbar__buttonstrip">
44
<a class="ui-button cancel" dir="ltr" id="btn-back" href="/list/dns/"><i class="fas fa-arrow-left status-icon blue"></i><?=_('Back')?></a>
5-
<? if (($_SESSION['userContext'] === 'admin') && ($_SESSION['look'] === 'admin') && ($_SESSION['POLICY_SYSTEM_PROTECTED_ADMIN'] === 'yes')) {?>
5+
<? if ($read_only === 'true') {?>
66
<!-- Hide item creation button when impersonating 'admin' account -->
77
<? } else { ?>
88
<a href="/add/dns/?domain=<?=htmlentities($_GET['domain'])?>" id="btn-create" class="ui-button cancel" dir="ltr"><i class="fas fa-plus-circle status-icon green"></i> <?=_('Add Record')?></a>
@@ -34,7 +34,7 @@
3434
<button type="submit" class="l-sort-toolbar__filter-apply" onclick="return doSearch('/search/')" value="" title="<?=_('Search')?>"><i class="fas fa-search"></i></button>
3535
</form>
3636
</td>
37-
<? if (($_SESSION['userContext'] === 'admin') && ($_SESSION['look'] === 'admin') && ($_SESSION['POLICY_SYSTEM_PROTECTED_ADMIN'] === 'yes')) {?>
37+
<? if ($read_only === 'true') {?>
3838
<!-- Hide bulk actions for domain items when impersonating 'admin' account-->
3939
<? } else { ?>
4040
<td>
@@ -64,7 +64,6 @@
6464
<div class="header table-header">
6565
<div class="l-unit__col l-unit__col--right">
6666
<div class="clearfix l-unit__stat-col--left super-compact">
67-
<? if (($_SESSION['userContext'] === 'admin') && ($_SESSION['look'] === 'admin') && ($_SESSION['POLICY_SYSTEM_PROTECTED_ADMIN'] === 'yes')) { $display_mode = 'disabled'; } ?>
6867
<input id="toggle-all" type="checkbox" name="toggle-all" value="toggle-all" title="<?=_('Select all')?>" onChange="checkedAll('objects');" <?=$display_mode;?>>
6968
</div>
7069
<div class="clearfix l-unit__stat-col--left small"><b><?php print _('Record');?></b></div>
@@ -89,7 +88,7 @@
8988
<input id="check<?=$data[$key]['ID']?>" class="ch-toggle" type="checkbox" title="<?=_('Select')?>" name="record[]" value="<?=$data[$key]['ID']?>" <?=$display_mode;?>>
9089
</div>
9190
<div class="clearfix l-unit__stat-col--left small truncate">
92-
<? if (($_SESSION['userContext'] === 'admin') && ($_SESSION['look'] === 'admin') && ($_SESSION['POLICY_SYSTEM_PROTECTED_ADMIN'] === 'yes') || ($data[$key]['SUSPENDED'] == 'yes')) {?>
91+
<? if (($read_only === 'true') || ($data[$key]['SUSPENDED'] == 'yes')) {?>
9392
<b><? echo substr($data[$key]['RECORD'], 0, 12); if(strlen($data[$key]['RECORD']) > 12 ) echo '...'; ?></b></div>
9493
<? } else { ?>
9594
<b><a href="/edit/dns/?domain=<?=htmlspecialchars($_GET['domain'])?>&record_id=<?=$data[$key]['ID']?>&token=<?=$_SESSION['token']?>" title="<?=_('Editing DNS Record').': '.htmlspecialchars($data[$key]['RECORD'])?>"><? echo substr($data[$key]['RECORD'], 0, 12); if(strlen($data[$key]['RECORD']) > 12 ) echo '...'; ?></a></b></div>
@@ -98,7 +97,7 @@
9897
<div class="clearfix l-unit__stat-col--left super-compact text-right">
9998
<div class="l-unit-toolbar__col l-unit-toolbar__col--right noselect">
10099
<div class="actions-panel clearfix">
101-
<? if (($_SESSION['userContext'] === 'admin') && ($_SESSION['look'] === 'admin') && ($_SESSION['POLICY_SYSTEM_PROTECTED_ADMIN'] === 'yes')) {?>
100+
<? if ($read_only === 'true') {?>
102101
<!-- Restrict editing of DNS records when impersonating 'admin' account -->
103102
&nbsp;
104103
<? } else { ?>

0 commit comments

Comments
 (0)