Commit e168d22f authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1828309: Allow adding members to an institution with admin/staff role



Via the addUserAsMember() function

By creating addUserAsStaff() and addUserAsAdmin() wrappers

behatnotneeded

Change-Id: Ie6c973377cb81e5aeb904b07103a324456796599
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 77433f09
......@@ -291,7 +291,7 @@ class Institution {
$this->verifyReady();
}
public function addUserAsMember($user) {
public function addUserAsMember($user, $staff=null, $admin=null) {
global $USER;
if ($this->isFull()) {
$this->send_admin_institution_is_full_message();
......@@ -326,6 +326,12 @@ class Institution {
$userinst->usr = $user->id;
$now = time();
$userinst->ctime = db_format_timestamp($now);
if ($staff) {
$userinst->staff = true;
}
if ($admin) {
$userinst->admin = true;
}
$defaultexpiry = $this->defaultmembershipperiod;
if (!empty($defaultexpiry)) {
$userinst->expiry = db_format_timestamp($now + $defaultexpiry);
......@@ -365,6 +371,16 @@ class Institution {
db_commit();
}
public function addUserAsStaff($user) {
// Only to be used to add a member to an institution and bump ther permissions to staff
$this->addUserAsMember($user, true);
}
public function addUserAsAdmin($user) {
// Only to be used to add a member to an institution and bump ther permissions to admin
$this->addUserAsMember($user, null, true);
}
public function add_members($userids) {
global $USER;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment