Skip to content

Commit 97ccdd2

Browse files
committed
HOO should not be able to set a date if they are the last HoO
1 parent 450a7ba commit 97ccdd2

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

include/cms_users_edit.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@
8181
// Prevent HoO user from downgrading their usergroup if they're the only HoO
8282
if (!$is_admin
8383
&& $_POST['id'] == $_SESSION['user']['id']
84-
&& 100 == $_SESSION['usergroup']['userlevel']
85-
&& $posteduser['userlevel'] < $_SESSION['usergroup']['userlevel']) {
84+
&& 100 == $_SESSION['usergroup']['userlevel']) {
8685
// Count how many HoO users exist in this organization
8786
$hoo_count = db_value(
8887
'
@@ -100,8 +99,13 @@
10099

101100
// If this is the last HoO, prevent the change
102101
if ($hoo_count <= 1) {
103-
trigger_error('You cannot downgrade yourself. Your organisation must have at least one Head of Operations user.', E_USER_NOTICE);
104-
redirect('?action=cms_users_edit&id='.$_POST['id'].'&origin='.$_POST['_origin'].'&warning=1&message=You cannot downgrade yourself. Your organisation must have at least one Head of Operations user.');
102+
if ($posteduser['userlevel'] < $_SESSION['usergroup']['userlevel']) {
103+
redirect('?action=cms_users_edit&id='.$_POST['id'].'&origin='.$_POST['_origin'].'&warning=1&message=You cannot downgrade yourself. Your organisation must have at least one Head of Operations user.');
104+
trigger_error('You cannot downgrade yourself. Your organisation must have at least one Head of Operations user.', E_USER_NOTICE);
105+
} elseif (('' !== $_POST['valid_firstday']) || ('' !== $_POST['valid_lastday'])) {
106+
redirect('?action=cms_users_edit&id='.$_POST['id'].'&origin='.$_POST['_origin'].'&warning=1&message=You cannot edit yourself. Your organisation must have at least one Head of Operations user.');
107+
trigger_error('You cannot edit yourself. Your organisation must have at least one Head of Operations user.', E_USER_NOTICE);
108+
}
105109
}
106110
}
107111

0 commit comments

Comments
 (0)