Commit 28714c43 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Show admin header link for institutional admins

parent 2297d50a
...@@ -83,6 +83,7 @@ class User { ...@@ -83,6 +83,7 @@ class User {
'accountprefs' => array(), 'accountprefs' => array(),
'activityprefs' => array(), 'activityprefs' => array(),
'institutions' => array(), 'institutions' => array(),
'admininstitutions' => array(),
'sesskey' => '' 'sesskey' => ''
); );
$this->attributes = array(); $this->attributes = array();
...@@ -345,7 +346,6 @@ class User { ...@@ -345,7 +346,6 @@ class User {
return true; return true;
} }
public function join_institution($institution) { public function join_institution($institution) {
$institutions = $this->get('institutions'); $institutions = $this->get('institutions');
if (!isset($institutions[$institution])) { if (!isset($institutions[$institution])) {
...@@ -357,6 +357,16 @@ class User { ...@@ -357,6 +357,16 @@ class User {
} }
} }
public function in_institution($institution, $role = null) {
$institutions = $this->get('institutions');
return isset($institutions[$institution])
&& (is_null($role) || $institutions[$institution]->{$role});
}
public function is_institutional_admin() {
$a = $this->get('admininstitutions');
return !empty($a);
}
} }
...@@ -453,7 +463,15 @@ class LiveUser extends User { ...@@ -453,7 +463,15 @@ class LiveUser extends User {
if (empty($user->id)) $this->commit(); if (empty($user->id)) $this->commit();
$this->activityprefs = load_activity_preferences($user->id); $this->activityprefs = load_activity_preferences($user->id);
$this->accountprefs = load_account_preferences($user->id); $this->accountprefs = load_account_preferences($user->id);
$this->institutions = load_user_institutions($user->id); $institutions = load_user_institutions($user->id);
$admininstitutions = array();
foreach ($institutions as $i) {
if ($i->admin) {
$admininstitutions[$i->institution] = true;
}
}
$this->institutions = $institutions;
$this->admininstitutions = $admininstitutions;
$this->commit(); $this->commit();
} }
......
...@@ -35,11 +35,13 @@ ...@@ -35,11 +35,13 @@
<div id="globalTabs"> <div id="globalTabs">
<ul> <ul>
<li id="globalnav-logout"><a href="{$WWWROOT}?logout">Logout</a></li> <li id="globalnav-logout"><a href="{$WWWROOT}?logout">Logout</a></li>
{if $USER->get('admin')} {if $USER->get('admin') || $USER->is_institutional_admin()}
{if $ADMIN} {if $ADMIN || $INSTITUTIONALADMIN}
<li id="globalnav-returntosite"><a href="{$WWWROOT}">Return to Site</a></li> <li id="globalnav-returntosite"><a href="{$WWWROOT}">Return to Site</a></li>
{else} {elseif $USER->get('admin')}
<li id="globalnav-siteadmin"><a href="{$WWWROOT}admin/">Site Administration</a></li> <li id="globalnav-siteadmin"><a href="{$WWWROOT}admin/">Site Administration</a></li>
{else}
<li id="globalnav-siteadmin"><a href="{$WWWROOT}admin/">User Administration</a></li>
{/if} {/if}
{* <li><a href="" onclick="createLoggingPane(); return false;">Create Logging Pane</a></li> *} {* <li><a href="" onclick="createLoggingPane(); return false;">Create Logging Pane</a></li> *}
{/if} {/if}
......
Supports Markdown
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