From 3ed7d5d5215de51294cff53c0f9c30cfc2484a4f Mon Sep 17 00:00:00 2001
From: Lukas Reschke <lukas@statuscode.ch>
Date: Mon, 21 Jan 2013 21:25:38 +0100
Subject: [PATCH] Move isadmin to external file

---
 settings/js/isadmin.php      | 20 ++++++++++++++++++++
 settings/routes.php          |  2 ++
 settings/templates/users.php |  6 +++---
 3 files changed, 25 insertions(+), 3 deletions(-)
 create mode 100644 settings/js/isadmin.php

diff --git a/settings/js/isadmin.php b/settings/js/isadmin.php
new file mode 100644
index 0000000000..8b31f8a7cf
--- /dev/null
+++ b/settings/js/isadmin.php
@@ -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;");
+}
\ No newline at end of file
diff --git a/settings/routes.php b/settings/routes.php
index 9b5bf80923..bac1f61fc5 100644
--- a/settings/routes.php
+++ b/settings/routes.php
@@ -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');
diff --git a/settings/templates/users.php b/settings/templates/users.php
index 6cbbca2404..5e588f9ead 100644
--- a/settings/templates/users.php
+++ b/settings/templates/users.php
@@ -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
-- 
GitLab