Commit 5904e1de authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Add institution select to Institution members page for admins with >1 institution

parent eeeb98f6
...@@ -44,6 +44,9 @@ $institution = param_alphanum('institution', false); ...@@ -44,6 +44,9 @@ $institution = param_alphanum('institution', false);
if (!$institution || !$USER->is_institutional_admin($institution)) { if (!$institution || !$USER->is_institutional_admin($institution)) {
$institution = empty($institutionelement['value']) ? $institutionelement['defaultvalue'] : $institutionelement['value']; $institution = empty($institutionelement['value']) ? $institutionelement['defaultvalue'] : $institutionelement['value'];
} }
else if (!empty($institution)) {
$institutionelement['defaultvalue'] = $institution;
}
// Show either requesters, members, or nonmembers on the left hand side // Show either requesters, members, or nonmembers on the left hand side
$usertype = param_alpha('usertype', 'requesters'); $usertype = param_alpha('usertype', 'requesters');
...@@ -61,6 +64,7 @@ $usertypeselector = pieform(array( ...@@ -61,6 +64,7 @@ $usertypeselector = pieform(array(
), ),
'defaultvalue' => $usertype 'defaultvalue' => $usertype
), ),
'institution' => $institutionelement,
) )
)); ));
...@@ -113,12 +117,16 @@ $userlistform = pieform(array( ...@@ -113,12 +117,16 @@ $userlistform = pieform(array(
'name' => 'institutionusers', 'name' => 'institutionusers',
'elements' => array( 'elements' => array(
'users' => $userlistelement, 'users' => $userlistelement,
'institution' => $institutionelement,
'usertype' => array( 'usertype' => array(
'type' => 'hidden', 'type' => 'hidden',
'value' => $usertype, 'value' => $usertype,
'rules' => array('regex' => '/^[a-z]+$/') 'rules' => array('regex' => '/^[a-z]+$/')
), ),
'institution' => array(
'type' => 'hidden',
'value' => $institution,
'rules' => array('regex' => '/^[a-zA-Z0-9]+$/')
),
'update' => array( 'update' => array(
'type' => 'hidden', 'type' => 'hidden',
'value' => $update, 'value' => $update,
...@@ -170,10 +178,18 @@ function institutionusers_submit(Pieform $form, $values) { ...@@ -170,10 +178,18 @@ function institutionusers_submit(Pieform $form, $values) {
$wwwroot = get_config('wwwroot'); $wwwroot = get_config('wwwroot');
$js = <<< EOF $js = <<< EOF
function reloadUsers() {
var inst = '';
if ($('usertypeselect_institution')) {
inst = '&institution=' + $('usertypeselect_institution').value;
}
window.location.href = '{$wwwroot}admin/users/institutionusers.php?usertype='+$('usertypeselect_usertype').value+inst;
}
addLoadEvent(function() { addLoadEvent(function() {
connect($('usertypeselect_usertype'), 'onchange', function () { connect($('usertypeselect_usertype'), 'onchange', reloadUsers);
window.location.href = '{$wwwroot}admin/users/institutionusers.php?usertype='+$('usertypeselect_usertype').value; if ($('usertypeselect_institution')) {
}); connect($('usertypeselect_institution'), 'onchange', reloadUsers);
}
}); });
EOF; EOF;
......
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