Select Git revision
util.php 15.26 KiB
<?php
/**
* Class for utility functions
*
*/
class OC_Util {
public static $scripts=array();
public static $styles=array();
public static $headers=array();
private static $rootMounted=false;
private static $fsSetup=false;
public static $core_styles=array();
public static $core_scripts=array();
// Can be set up
public static function setupFS( $user = '' ){// configure the initial filesystem based on the configuration
if(self::$fsSetup){//setting up the filesystem twice can only lead to trouble
return false;
}
$CONFIG_DATADIRECTORY = OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" );
//first set up the local "root" storage
if(!self::$rootMounted){
OC_Filesystem::mount('OC_Filestorage_Local',array('datadir'=>$CONFIG_DATADIRECTORY),'/');
self::$rootMounted=true;
}
// If we are not forced to load a specific user we load the one that is logged in
if( $user == "" && OC_User::isLoggedIn()){
$user = OC_User::getUser();
}
if( $user != "" ){ //if we aren't logged in, there is no use to set up the filesystem
$user_dir = '/'.$user.'/files';
$userdirectory = $CONFIG_DATADIRECTORY.$user_dir;
if( !is_dir( $userdirectory )){
mkdir( $userdirectory, 0755, true );
}
//jail the user into his "home" directory
OC_Filesystem::init($user_dir);
$quotaProxy=new OC_FileProxy_Quota();
OC_FileProxy::register($quotaProxy);
self::$fsSetup=true;
// Load personal mount config
if (is_file($CONFIG_DATADIRECTORY.'/'.$user.'/mount.php')) {
$mountConfig = include($CONFIG_DATADIRECTORY.'/'.$user.'/mount.php');
if (isset($mountConfig['user'][$user])) {
foreach ($mountConfig['user'][$user] as $mountPoint => $options) {
OC_Filesystem::mount($options['class'], $options['options'], $mountPoint);
}
}
}
OC_Hook::emit('OC_Filesystem', 'setup', array('user' => $user, 'user_dir' => $user_dir));
}
}
public static function tearDownFS(){
OC_Filesystem::tearDown();
self::$fsSetup=false;
}
/**
* get the current installed version of ownCloud
* @return array
*/
public static function getVersion(){
return array(4,80,1);
}