Commit c4ec434b authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Don't allow users to leave institutions that have registration off (bug 3384)


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent 59431940
......@@ -35,31 +35,35 @@ require_once('pieforms/pieform.php');
$institutions = get_records_assoc('institution', '', '', '', 'name,displayname,registerallowed');
// For all institutions the user is already a member of, create a
// button to leave the institution
// button to leave the institution, unless the institution does not
// allow registration.
$member = $USER->get('institutions');
if (!empty($member)) {
$elements = array();
foreach ($member as $i) {
$elements[] = array(
'type' => 'submit',
'class' => 'btn-del',
'name' => '_leave_' . $i->institution,
'confirm' => get_string('reallyleaveinstitution'),
'title' => get_string('youareamemberof', 'mahara',
$institutions[$i->institution]->displayname),
'value' => get_string('leaveinstitution')
);
$elements[] = array(
'type' => 'html',
'name' => '_leavehtml_' . $i->institution,
'value' => '<br>',
);
if ($institutions[$i->institution]->registerallowed) {
$elements[] = array(
'type' => 'submit',
'class' => 'btn-del',
'name' => '_leave_' . $i->institution,
'confirm' => get_string('reallyleaveinstitution'),
'title' => get_string('youareamemberof', 'mahara', $institutions[$i->institution]->displayname),
'value' => get_string('leaveinstitution')
);
}
else {
$elements[] = array(
'type' => 'html',
'name' => '_noleave_' . $i->institution,
'title' => get_string('youareamemberof', 'mahara', $institutions[$i->institution]->displayname),
'value' => '',
);
}
unset($institutions[$i->institution]);
}
$memberform = pieform(array(
'name' => 'leaveinstitution',
'method' => 'post',
'renderer' => 'oneline',
'plugintype' => 'core',
'pluginname' => 'account',
'elements' => $elements
......@@ -103,7 +107,6 @@ if (!empty($requested)) {
$requestedform = pieform(array(
'name' => 'cancelrequest',
'method' => 'post',
'renderer' => 'oneline',
'plugintype' => 'core',
'pluginname' => 'account',
'elements' => $elements
......@@ -152,7 +155,6 @@ if (!empty($invited)) {
$invitedform = pieform(array(
'name' => 'confirminvite',
'method' => 'post',
'renderer' => 'oneline',
'plugintype' => 'core',
'pluginname' => 'account',
'elements' => $elements
......@@ -202,12 +204,12 @@ if (!empty($institutions) &&
$joinform = pieform(array(
'name' => 'requestmembership',
'method' => 'post',
'renderer' => 'oneline',
'plugintype' => 'core',
'pluginname' => 'account',
'elements' => array(
'institution' => array(
'type' => 'select',
'title' => get_string('institution'),
'collapseifoneoption' => false,
'options' => $options,
'defaultvalue' => key($options),
......
......@@ -437,7 +437,7 @@ $string['institutionexpiry'] = 'Institution expiry date';
$string['institutionexpirydescription'] = 'The date at which this institutions membership of %s will be suspended.';
$string['institutionupdatedsuccessfully'] = 'Institution updated successfully.';
$string['registrationallowed'] = 'Registration allowed?';
$string['registrationalloweddescription2'] = 'Whether users can register for your site for this institution using the registration form';
$string['registrationalloweddescription2'] = 'Whether users can register for your site for this institution using the registration form. If registration is off, non-members cannot request membership of the institution, and members cannot leave the institution voluntarily.';
$string['defaultmembershipperiod'] = 'Default membership period';
$string['defaultmembershipperioddescription'] = 'How long new members remain associated with the institution';
$string['authenticatedby'] = 'Authentication Method';
......
......@@ -513,6 +513,9 @@ $string['institutionmemberconfirmsubject'] = 'Institution membership confirmatio
$string['institutionmemberconfirmmessage'] = 'You have been added as a member of %s.';
$string['institutionmemberrejectsubject'] = 'Institution membership request declined';
$string['institutionmemberrejectmessage'] = 'Your request for membership of %s was declined.';
$string['Memberships'] = 'Memberships';
$string['Requests'] = 'Requests';
$string['Invitations'] = 'Invitations';
$string['config'] = 'Config';
......
{include file="header.tpl"}
<p>{str tag="institutionmembershipdescription"}</p>
{$memberform}
{$requestedform}
{$invitedform}
{if $memberform}
<h3>{str tag=Memberships}</h3>
{$memberform}
{/if}
{if $requestedform}
<h3>{str tag=Requests}</h3>
{$requestedform}
{/if}
{if $invitedform}
<h3>{str tag=Invitations}</h3>
{$invitedform}
{/if}
{if $joinform}
<h3>{str tag="requestmembershipofaninstitution"}</h3>
{$joinform}
......
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