Commit 89ba3f0c authored by Richard Mansfield's avatar Richard Mansfield
Browse files

use can_edit_institution()

parent 2cc3ca26
...@@ -142,7 +142,7 @@ if (count($authinstances) > 1) { ...@@ -142,7 +142,7 @@ if (count($authinstances) > 1) {
$options = array(); $options = array();
foreach ($authinstances as $authinstance) { foreach ($authinstances as $authinstance) {
if ($USER->get('admin') || $USER->is_institutional_admin($authinstance->name)) { if ($USER->can_edit_institution($authinstance->name)) {
$options[$authinstance->id] = $authinstance->displayname. ': '.$authinstance->instancename; $options[$authinstance->id] = $authinstance->displayname. ': '.$authinstance->instancename;
} }
} }
...@@ -292,7 +292,7 @@ function edituser_institution_submit(Pieform $form, $values) { ...@@ -292,7 +292,7 @@ function edituser_institution_submit(Pieform $form, $values) {
global $USER; global $USER;
foreach ($userinstitutions as $i) { foreach ($userinstitutions as $i) {
if ($USER->get('admin') || $USER->is_institutional_admin($i->institution)) { if ($USER->can_edit_institution($i->institution)) {
if (isset($values[$i->institution.'_submit'])) { if (isset($values[$i->institution.'_submit'])) {
$newuser = (object) array( $newuser = (object) array(
'usr' => $user->id, 'usr' => $user->id,
......
...@@ -85,7 +85,7 @@ if (count($authinstances) > 1) { ...@@ -85,7 +85,7 @@ if (count($authinstances) > 1) {
$options = array(); $options = array();
foreach ($authinstances as $authinstance) { foreach ($authinstances as $authinstance) {
if ($USER->get('admin') || $USER->is_institutional_admin($authinstance->name)) { if ($USER->can_edit_institution($authinstance->name)) {
$options[$authinstance->id .'_'. $authinstance->name] = $authinstance->displayname. ': '.$authinstance->instancename; $options[$authinstance->id .'_'. $authinstance->name] = $authinstance->displayname. ': '.$authinstance->instancename;
} }
} }
...@@ -157,7 +157,7 @@ function uploadcsv_validate(Pieform $form, $values) { ...@@ -157,7 +157,7 @@ function uploadcsv_validate(Pieform $form, $values) {
$break = strpos($values['authinstance'], '_'); $break = strpos($values['authinstance'], '_');
$authinstance = substr($values['authinstance'], 0, $break); $authinstance = substr($values['authinstance'], 0, $break);
$institution = substr($values['authinstance'], $break+1); $institution = substr($values['authinstance'], $break+1);
if (!$USER->get('admin') && !$USER->is_institutional_admin($institution)) { if (!$USER->can_edit_institution($institution)) {
$form->set_error('authinstance', get_string('notadminforinstitution', 'admin')); $form->set_error('authinstance', get_string('notadminforinstitution', 'admin'));
return; return;
} }
......
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