From e990ef35426b7dde59ec74eb1568a8cfbd69f316 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Sun, 18 Sep 2011 21:31:56 +0200 Subject: Move some common code to OC_Util Created the following function: - checkLoggedIn - checkAdminUser - redirectToDefaultPage --- search/ajax/search.php | 7 ++----- search/index.php | 8 ++------ 2 files changed, 4 insertions(+), 11 deletions(-) (limited to 'search') diff --git a/search/ajax/search.php b/search/ajax/search.php index c65fbbc63fa..9472f97e189 100644 --- a/search/ajax/search.php +++ b/search/ajax/search.php @@ -26,10 +26,7 @@ require_once('../../lib/base.php'); // Check if we are a user -if( !OC_User::isLoggedIn()){ - header( "Location: ".OC_Helper::linkTo( '', 'index.php' )); - exit(); -} +OC_Util::checkLoggedIn(); $query=(isset($_GET['query']))?$_GET['query']:''; if($query){ @@ -39,4 +36,4 @@ if($query){ echo 'false'; } -?> \ No newline at end of file +?> diff --git a/search/index.php b/search/index.php index c781c31f549..518695c56d2 100644 --- a/search/index.php +++ b/search/index.php @@ -26,10 +26,7 @@ require_once('../lib/base.php'); // Check if we are a user -if( !OC_User::isLoggedIn()){ - header( "Location: ".OC_Helper::linkTo( '', 'index.php' )); - exit(); -} +OC_Util::checkLoggedIn(); // Load the files we need OC_Util::addStyle( 'search', 'search' ); @@ -38,8 +35,7 @@ $query=(isset($_POST['query']))?$_POST['query']:''; if($query){ $results=OC_Search::search($query); }else{ - header("Location: ".OC::$WEBROOT.'/'.OC_Appconfig::getValue("core", "defaultpage", "files/index.php")); - exit(); + OC_Util::redirectToDefaultPage(); } $resultTypes=array(); -- cgit v1.2.3