Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/util.php')
-rw-r--r--lib/util.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/util.php b/lib/util.php
index 2f74bfe5841..51d8cc4d643 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -246,4 +246,35 @@ class OC_Util {
return $errors;
}
+
+ /**
+ * Check if the user is logged in, redirects to home if not
+ */
+ public static function checkLoggedIn(){
+ // Check if we are a user
+ if( !OC_User::isLoggedIn()){
+ header( 'Location: '.OC_Helper::linkTo( '', 'index.php' , true));
+ exit();
+ }
+ }
+
+ /**
+ * Check if the user is a admin, redirects to home if not
+ */
+ public static function checkAdminUser(){
+ // Check if we are a user
+ self::checkLoggedIn();
+ if( !OC_Group::inGroup( OC_User::getUser(), 'admin' )){
+ header( 'Location: '.OC_Helper::linkTo( '', 'index.php' , true));
+ exit();
+ }
+ }
+
+ /**
+ * Redirect to the user default page
+ */
+ public static function redirectToDefaultPage(){
+ header( 'Location: '.OC::$WEBROOT.'/'.OC_Appconfig::getValue('core', 'defaultpage', 'files/index.php'));
+ exit();
+ }
}