header( "Content-Type: application/jsonrequest" );
// Check if we are a user
-if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){
+if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( OC_USER::getUser(), 'admin' )){
echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" )));
exit();
}
header( "Content-Type: application/jsonrequest" );
// Check if we are a user
-if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){
+if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( OC_USER::getUser(), 'admin' )){
echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" )));
exit();
}
header( "Content-Type: application/jsonrequest" );
// Check if we are a user
-if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){
+if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( OC_USER::getUser(), 'admin' )){
echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" )));
exit();
}
header( "Content-Type: application/jsonrequest" );
// Check if we are a user
-if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){
+if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( OC_USER::getUser(), 'admin' )){
echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" )));
exit();
}
header( "Content-Type: application/jsonrequest" );
// Check if we are a user
-if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){
+if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( OC_USER::getUser(), 'admin' )){
echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" )));
exit();
}
header( "Content-Type: application/jsonrequest" );
// Check if we are a user
-if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){
+if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( OC_USER::getUser(), 'admin' )){
echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" )));
exit();
}
require_once('../lib/base.php');
include_once('../lib/installer.php');
require( 'template.php' );
-if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){
+if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( OC_USER::getUser(), 'admin' )){
header( "Location: ".OC_HELPER::linkTo( "", "index.php" ));
exit();
}
require_once('../lib/base.php');
require( 'template.php' );
-if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){
+if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( OC_USER::getUser(), 'admin' )){
header( "Location: ".OC_HELPER::linkTo( "index.php" ));
exit();
}
require_once('../lib/base.php');
require( 'template.php' );
-if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){
+if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( OC_USER::getUser(), 'admin' )){
header( "Location: ".OC_HELPER::linkTo( "index.php" ));
exit();
}
*/
public function __construct($path,$expiretime=0){
if($path and OC_FILESYSTEM::file_exists($path) and OC_FILESYSTEM::is_readable($path)){
- $user=$_SESSION['user_id'];
+ $user=OC_USER::getUser();
$token=sha1("$user-$path-$expiretime");
$query=OC_DB::prepare("INSERT INTO *PREFIX*publiclink VALUES(?,?,?,?)");
$result=$query->execute(array($token,$path,$user,$expiretime));
*/
static public function getLinks(){
$query=OC_DB::prepare("SELECT * FROM *PREFIX*publiclink WHERE user=?");
- return $query->execute(array($_SESSION['user_id']))->fetchAll();
+ return $query->execute(array(OC_USER::getUser()))->fetchAll();
}
/**
static public function delete($token){
$query=OC_DB::prepare("SELECT user,path FROM *PREFIX*publiclink WHERE token=?");
$result=$query->execute(array($token))->fetchAll();
- if(count($result)>0 and $result[0]['user']==$_SESSION['user_id']){
+ if(count($result)>0 and $result[0]['user']==OC_USER::getUser()){
$query=OC_DB::prepare("DELETE FROM *PREFIX*publiclink WHERE token=?");
$query->execute(array($token));
}
// Check if we are a user
-if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){
+if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( OC_USER::getUser(), 'admin' )){
header( "Location: ".OC_HELPER::linkTo( "index.php" ));
exit();
}
// If we are not forced to load a specific user we load the one that is logged in
if( $user == "" && OC_USER::isLoggedIn()){
- $user = $_SESSION['user_id'];
+ $user = OC_USER::getUser();
}
if( $user != "" ){ //if we aren't logged in, there is no use to set up the filesystem
else{
$available=self::findAvailableLanguages( $app );
}
- if( isset($_SESSION['user_id']) && $_SESSION['user_id'] && OC_PREFERENCES::getValue( $_SESSION['user_id'], 'core', 'lang' )){
- $lang = OC_PREFERENCES::getValue( $_SESSION['user_id'], 'core', 'lang' );
+ if( OC_USER::getUser() && OC_PREFERENCES::getValue( OC_USER::getUser(), 'core', 'lang' )){
+ $lang = OC_PREFERENCES::getValue( OC_USER::getUser(), 'core', 'lang' );
self::$language = $lang;
if( array_search( $lang, $available ) !== false ){
return $lang;
}
}
+ /**
+ * @brief get the user idea of the user currently logged in.
+ * @return string uid or false
+ */
+ public static function getUser(){
+ if( isset($_SESSION['user_id']) AND $_SESSION['user_id'] ){
+ return $_SESSION['user_id'];
+ }
+ else{
+ return false;
+ }
+ }
+
/**
* @brief Autogenerate a password
* @returns string
$selectedActions[]=$action;
}
}
- OC_PREFERENCES::setValue($_SESSION['user_id'],'log','actions',implode(',',$selectedActions));
- OC_PREFERENCES::setValue($_SESSION['user_id'],'log','pagesize',$_POST['size']);
+ OC_PREFERENCES::setValue(OC_USER::getUser(),'log','actions',implode(',',$selectedActions));
+ OC_PREFERENCES::setValue(OC_USER::getUser(),'log','pagesize',$_POST['size']);
}
//clear log entries
elseif(isset($_POST['clear'])){
$logs=OC_LOG::get();
-$selectedActions=explode(',',OC_PREFERENCES::getValue($_SESSION['user_id'],'log','actions',implode(',',$allActions)));
+$selectedActions=explode(',',OC_PREFERENCES::getValue(OC_USER::getUser(),'log','actions',implode(',',$allActions)));
$logs=OC_LOG::filterAction($logs,$selectedActions);
-$pageSize=OC_PREFERENCES::getValue($_SESSION['user_id'],'log','pagesize',20);
+$pageSize=OC_PREFERENCES::getValue(OC_USER::getUser(),'log','pagesize',20);
$pageCount=ceil(count($logs)/$pageSize);
$page=isset($_GET['page'])?$_GET['page']:0;
if($page>=$pageCount){
// Get data
if( isset( $_POST['lang'] ) ){
$lang=$_POST['lang'];
- OC_PREFERENCES::setValue( $_SESSION['user_id'], 'core', 'lang', $lang );
+ OC_PREFERENCES::setValue( OC_USER::getUser(), 'core', 'lang', $lang );
echo json_encode( array( "status" => "success", "data" => array( "message" => $l->t("Language changed") )));
}else{
echo json_encode( array( "status" => "error", "data" => array( "message" => $l->t("Invalid request") )));
$total=$free+$used;
$relative=round(($used/$total)*100);
-$lang=OC_PREFERENCES::getValue( $_SESSION['user_id'], 'core', 'lang', 'en' );
+$lang=OC_PREFERENCES::getValue( OC_USER::getUser(), 'core', 'lang', 'en' );
$languages=OC_L10N::findAvailableLanguages();
//put the current language in the front
unset($languages[array_search($lang,$languages)]);