Move isadmin to external file

This commit is contained in:
Lukas Reschke 2013-01-21 21:25:38 +01:00
parent 39da6f8166
commit 3ed7d5d521
3 changed files with 25 additions and 3 deletions

20
settings/js/isadmin.php Normal file
View File

@ -0,0 +1,20 @@
<?php
/**
* Copyright (c) 2013 Lukas Reschke <lukas@statuscode.ch>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
// Set the content type to Javascript
header("Content-type: text/javascript");
// Disallow caching
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
if (OC_User::isAdminUser(OC_User::getUser())) {
echo("var isadmin = true;");
} else {
echo("var isadmin = false;");
}

View File

@ -60,3 +60,5 @@ $this->create('settings_ajax_setloglevel', '/settings/ajax/setloglevel.php')
->actionInclude('settings/ajax/setloglevel.php');
$this->create('settings_ajax_setsecurity', '/settings/ajax/setsecurity.php')
->actionInclude('settings/ajax/setsecurity.php');
$this->create('isadmin', '/settings/js/isadmin.js')
->actionInclude('settings/js/isadmin.php');

View File

@ -13,9 +13,9 @@ $items = array_flip($_['subadmingroups']);
unset($items['admin']);
$_['subadmingroups'] = array_flip($items);
?>
<script>
var isadmin = <?php echo $_['isadmin']?'true':'false'; ?>;
</script>
<script type="text/javascript" src="<?php echo OC_Helper::linkToRoute('isadmin');?>"></script>
<div id="controls">
<form id="newuser" autocomplete="off">
<input id="newusername" type="text" placeholder="<?php echo $l->t('Name')?>" /> <input