aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorGeorg Ehrke <dev@georgswebsite.de>2012-06-06 10:12:54 +0200
committerGeorg Ehrke <dev@georgswebsite.de>2012-06-06 10:12:54 +0200
commitfa0c45b005665876d9365674c247fc9212f05df9 (patch)
tree8546c0c5dbd5884477ca164019850bc46aa9918e /lib
parentb8275691e77f6328da29770ae95fddccc70862a8 (diff)
parentfce614b82c61a0d2e45ffe05bbe030d842f3ca16 (diff)
downloadnextcloud-server-fa0c45b005665876d9365674c247fc9212f05df9.tar.gz
nextcloud-server-fa0c45b005665876d9365674c247fc9212f05df9.zip
Merge branch 'master' into oc_error
Diffstat (limited to 'lib')
-rwxr-xr-xlib/app.php37
-rw-r--r--lib/base.php48
-rw-r--r--lib/cache.php54
-rw-r--r--lib/cache/apc.php46
-rw-r--r--lib/cache/file.php76
-rw-r--r--lib/cache/xcache.php40
-rw-r--r--lib/connector/sabre/directory.php6
-rw-r--r--lib/filecache.php9
-rw-r--r--lib/files.php14
-rw-r--r--lib/filesystem.php4
-rw-r--r--lib/group.php14
-rw-r--r--lib/group/backend.php62
-rw-r--r--lib/group/database.php22
-rw-r--r--lib/group/example.php7
-rw-r--r--lib/helper.php6
-rw-r--r--lib/image.php15
-rw-r--r--lib/log/owncloud.php2
-rw-r--r--lib/minimizer.php40
-rw-r--r--lib/minimizer/css.php73
-rw-r--r--lib/minimizer/js.php62
-rw-r--r--lib/public/app.php3
-rw-r--r--lib/template.php10
-rw-r--r--lib/user.php33
-rw-r--r--lib/user/backend.php40
-rw-r--r--lib/user/example.php30
-rw-r--r--lib/util.php20
26 files changed, 606 insertions, 167 deletions
diff --git a/lib/app.php b/lib/app.php
index 124b76cdc3d..667633e2647 100755
--- a/lib/app.php
+++ b/lib/app.php
@@ -35,6 +35,7 @@ class OC_App{
static private $personalForms = array();
static private $appInfo = array();
static private $appTypes = array();
+ static private $loadedApps = array();
/**
* @brief loads all apps
@@ -48,24 +49,26 @@ class OC_App{
* if $types is set, only apps of those types will be loaded
*/
public static function loadApps($types=null){
- // Did we already load everything?
- if( self::$init ){
- return true;
- }
-
// Load the enabled apps here
$apps = self::getEnabledApps();
// prevent app.php from printing output
ob_start();
foreach( $apps as $app ){
- if((is_null($types) or self::isType($app,$types))){
+ if((is_null($types) or self::isType($app,$types)) && !in_array($app, self::$loadedApps)){
self::loadApp($app);
+ self::$loadedApps[] = $app;
}
}
ob_end_clean();
- self::$init = true;
-
+ if (!defined('DEBUG') || !DEBUG){
+ if (is_null($types)) {
+ OC_Util::$core_scripts = OC_Util::$scripts;
+ OC_Util::$scripts = array();
+ OC_Util::$core_styles = OC_Util::$styles;
+ OC_Util::$styles = array();
+ }
+ }
// return
return true;
}
@@ -121,7 +124,7 @@ class OC_App{
*/
public static function setAppTypes($app){
$appData=self::getAppInfo($app);
-
+
if(isset($appData['types'])){
$appTypes=implode(',',$appData['types']);
}else{
@@ -183,7 +186,7 @@ class OC_App{
if($app!==false){
// check if the app is compatible with this version of ownCloud
$info=OC_App::getAppInfo($app);
- $version=OC_Util::getVersion();
+ $version=OC_Util::getVersion();
if(!isset($info['require']) or ($version[0]>$info['require'])){
OC_Log::write('core','App "'.$info['name'].'" can\'t be installed because it is not compatible with this version of ownCloud',OC_Log::ERROR);
return false;
@@ -487,13 +490,13 @@ class OC_App{
}
}
}
-
+
// check if the current enabled apps are compatible with the current ownCloud version. disable them if not.
// this is important if you upgrade ownCloud and have non ported 3rd party apps installed
$apps =OC_App::getEnabledApps();
$version=OC_Util::getVersion();
foreach($apps as $app) {
-
+
// check if the app is compatible with this version of ownCloud
$info=OC_App::getAppInfo($app);
if(!isset($info['require']) or ($version[0]>$info['require'])){
@@ -501,12 +504,12 @@ class OC_App{
OC_App::disable( $app );
}
-
-
+
+
}
-
-
-
+
+
+
}
/**
diff --git a/lib/base.php b/lib/base.php
index e6fcb9ec4de..a439651f4a6 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -31,17 +31,13 @@ class OC{
*/
public static $CLASSPATH = array();
/**
- * $_SERVER['DOCUMENTROOT'] but without symlinks
- */
- public static $DOCUMENTROOT = '';
- /**
* The installation path for owncloud on the server (e.g. /srv/http/owncloud)
*/
public static $SERVERROOT = '';
/**
* the current request path relative to the owncloud root (e.g. files/index.php)
*/
- public static $SUBURI = '';
+ private static $SUBURI = '';
/**
* the owncloud root path for http requests (e.g. owncloud/)
*/
@@ -51,10 +47,6 @@ class OC{
*/
public static $CONFIG_DATADIRECTORY = '';
/**
- * the folder that stores the data for the root filesystem (e.g. /srv/http/owncloud/data)
- */
- public static $CONFIG_DATADIRECTORY_ROOT = '';
- /**
* The installation path of the 3rdparty folder on the server (e.g. /srv/http/owncloud/3rdparty)
*/
public static $THIRDPARTYROOT = '';
@@ -130,7 +122,7 @@ class OC{
public static function initPaths(){
// calculate the documentroot
- OC::$DOCUMENTROOT=realpath($_SERVER['DOCUMENT_ROOT']);
+ $DOCUMENTROOT=realpath($_SERVER['DOCUMENT_ROOT']);
OC::$SERVERROOT=str_replace("\\",'/',substr(__FILE__,0,-13));
OC::$SUBURI=substr(realpath($_SERVER["SCRIPT_FILENAME"]),strlen(OC::$SERVERROOT));
$scriptName=$_SERVER["SCRIPT_NAME"];
@@ -146,7 +138,7 @@ class OC{
}
OC::$WEBROOT=substr($scriptName,0,strlen($scriptName)-strlen(OC::$SUBURI));
// try a new way to detect the WEBROOT which is simpler and also works with the app directory outside the owncloud folder. let´s see if this works for everybody
-// OC::$WEBROOT=substr(OC::$SERVERROOT,strlen(OC::$DOCUMENTROOT));
+// OC::$WEBROOT=substr(OC::$SERVERROOT,strlen($DOCUMENTROOT));
if(OC::$WEBROOT!='' and OC::$WEBROOT[0]!=='/'){
@@ -291,18 +283,9 @@ class OC{
public static function loadfile(){
if(file_exists(OC::$APPSROOT . '/apps/' . OC::$REQUESTEDAPP . '/' . OC::$REQUESTEDFILE)){
if(substr(OC::$REQUESTEDFILE, -3) == 'css'){
- $appswebroot = (string) OC::$APPSWEBROOT;
- $webroot = (string) OC::$WEBROOT;
- $filepath = OC::$APPSROOT . '/apps/' . OC::$REQUESTEDAPP . '/' . OC::$REQUESTEDFILE;
- header('Content-Type: text/css');
- OC_Response::enableCaching();
- OC_Response::setLastModifiedHeader(filemtime($filepath));
- $cssfile = file_get_contents($filepath);
- $cssfile = str_replace('%appswebroot%', $appswebroot, $cssfile);
- $cssfile = str_replace('%webroot%', $webroot, $cssfile);
- OC_Response::setETagHeader(md5($cssfile));
- header('Content-Length: '.strlen($cssfile));
- echo $cssfile;
+ $file = 'apps/' . OC::$REQUESTEDAPP . '/' . OC::$REQUESTEDFILE;
+ $minimizer = new OC_Minimizer_CSS();
+ $minimizer->output(array(array(OC::$APPSROOT, OC::$APPSWEBROOT, $file)));
exit;
}elseif(substr(OC::$REQUESTEDFILE, -3) == 'php'){
require_once(OC::$APPSROOT . '/apps/' . OC::$REQUESTEDAPP . '/' . OC::$REQUESTEDFILE);
@@ -381,16 +364,18 @@ class OC{
// CSRF protection
if(isset($_SERVER['HTTP_REFERER'])) $referer=$_SERVER['HTTP_REFERER']; else $referer='';
- $protocol=OC_Helper::serverProtocol().'://';
+ $refererhost=parse_url($referer);
+ if(isset($refererhost['host'])) $refererhost=$refererhost['host']; else $refererhost='';
+ $server=OC_Helper::serverHost();
+ $serverhost=explode(':',$server);
+ $serverhost=$serverhost['0'];
if(!self::$CLI){
- $server=$protocol.OC_Helper::serverHost();
- if(($_SERVER['REQUEST_METHOD']=='POST') and (substr($referer,0,strlen($server))<>$server)) {
- $url = $protocol.OC_Helper::serverProtocol().OC::$WEBROOT.'/index.php';
+ if(($_SERVER['REQUEST_METHOD']=='POST') and ($refererhost<>$serverhost)) {
+ $url = OC_Helper::serverProtocol().'://'.$server.OC::$WEBROOT.'/index.php';
header("Location: $url");
exit();
}
}
-
self::initSession();
self::initTemplateEngine();
self::checkUpgrade();
@@ -440,7 +425,12 @@ class OC{
//make sure temporary files are cleaned up
register_shutdown_function(array('OC_Helper','cleanTmp'));
-
+
+ if (!OC_AppConfig::getValue('core', 'remote_core.css', false)) {
+ OC_AppConfig::setValue('core', 'remote_core.css', '/core/minimizer.php');
+ OC_AppConfig::setValue('core', 'remote_core.js', '/core/minimizer.php');
+ }
+
//parse the given parameters
self::$REQUESTEDAPP = (isset($_GET['app'])?str_replace(array('\0', '/', '\\', '..'), '', strip_tags($_GET['app'])):OC_Config::getValue('defaultapp', 'files'));
if(substr_count(self::$REQUESTEDAPP, '?') != 0){
diff --git a/lib/cache.php b/lib/cache.php
new file mode 100644
index 00000000000..70f11f35518
--- /dev/null
+++ b/lib/cache.php
@@ -0,0 +1,54 @@
+<?php
+/**
+ * Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+class OC_Cache {
+ static protected $cache;
+
+ static protected function init() {
+ self::$cache = new OC_Cache_File();
+ }
+
+ static public function get($key) {
+ if (!self::$cache) {
+ self::init();
+ }
+ return self::$cache->get($key);
+ }
+
+ static public function set($key, $value, $ttl=0) {
+ if (empty($key)) {
+ return false;
+ }
+ if (!self::$cache) {
+ self::init();
+ }
+ return self::$cache->set($key, $value, $ttl);
+ }
+
+ static public function hasKey($key) {
+ if (!self::$cache) {
+ self::init();
+ }
+ return self::$cache->hasKey($key);
+ }
+
+ static public function remove($key) {
+ if (!self::$cache) {
+ self::init();
+ }
+ return self::$cache->remove($key);
+ }
+
+ static public function clear() {
+ if (!self::$cache) {
+ self::init();
+ }
+ return self::$cache->clear();
+ }
+
+}
diff --git a/lib/cache/apc.php b/lib/cache/apc.php
new file mode 100644
index 00000000000..f814afbe494
--- /dev/null
+++ b/lib/cache/apc.php
@@ -0,0 +1,46 @@
+<?php
+/**
+ * Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+class OC_Cache_APC {
+ /**
+ * entries in APC gets namespaced to prevent collisions between owncloud instances and users
+ */
+ protected function getNameSpace() {
+ return OC_Util::getInstanceId().'/'.OC_User::getUser().'/';
+ }
+
+ public function get($key) {
+ $result = apc_fetch($this->getNamespace().$key, $success);
+ if (!$success) {
+ return null;
+ }
+ return $result;
+ }
+
+ public function set($key, $value, $ttl=0) {
+ return apc_store($this->getNamespace().$key, $value, $ttl);
+ }
+
+ public function hasKey($key) {
+ return apc_exists($this->getNamespace().$key);
+ }
+
+ public function remove($key) {
+ return apc_delete($this->getNamespace().$key);
+ }
+
+ public function clear(){
+ $ns = $this->getNamespace();
+ $cache = apc_cache_info('user');
+ foreach($cache['cache_list'] as $entry) {
+ if (strpos($entry['info'], $ns) === 0) {
+ apc_delete($entry['info']);
+ }
+ }
+ }
+}
diff --git a/lib/cache/file.php b/lib/cache/file.php
new file mode 100644
index 00000000000..0b7d3e30508
--- /dev/null
+++ b/lib/cache/file.php
@@ -0,0 +1,76 @@
+<?php
+/**
+ * Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+
+class OC_Cache_File{
+ protected function getStorage() {
+ if(OC_User::isLoggedIn()){
+ $subdir = 'cache';
+ $view = new OC_FilesystemView('/'.OC_User::getUser());
+ if(!$view->file_exists($subdir)) {
+ $view->mkdir($subdir);
+ }
+ return new OC_FilesystemView('/'.OC_User::getUser().'/'.$subdir);
+ }else{
+ OC_Log::write('core','Can\'t get cache storage, user not logged in', OC_Log::ERROR);
+ return false;
+ }
+ }
+
+ public function get($key) {
+ if ($this->hasKey($key)) {
+ $storage = $this->getStorage();
+ return $storage->file_get_contents($key);
+ }
+ return null;
+ }
+
+ public function set($key, $value, $ttl=0) {
+ $storage = $this->getStorage();
+ if ($storage and $storage->file_put_contents($key, $value)) {
+ if ($ttl === 0) {
+ $ttl = 86400; // 60*60*24
+ }
+ return $storage->touch($key, time() + $ttl);
+ }
+ return false;
+ }
+
+ public function hasKey($key) {
+ $storage = $this->getStorage();
+ if ($storage && $storage->is_file($key)) {
+ $mtime = $storage->filemtime($key);
+ if ($mtime < time()) {
+ $storage->unlink($key);
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ public function remove($key) {
+ $storage = $this->getStorage();
+ if(!$storage){
+ return false;
+ }
+ return $storage->unlink($key);
+ }
+
+ public function clear(){
+ $storage = $this->getStorage();
+ if($storage and $storage->is_dir('/')){
+ $dh=$storage->opendir('/');
+ while($file=readdir($dh)){
+ if($file!='.' and $file!='..'){
+ $storage->unlink('/'.$file);
+ }
+ }
+ }
+ }
+}
diff --git a/lib/cache/xcache.php b/lib/cache/xcache.php
new file mode 100644
index 00000000000..b57338929e0
--- /dev/null
+++ b/lib/cache/xcache.php
@@ -0,0 +1,40 @@
+<?php
+/**
+ * Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+class OC_Cache_XCache {
+ /**
+ * entries in XCache gets namespaced to prevent collisions between owncloud instances and users
+ */
+ protected function getNameSpace() {
+ return OC_Util::getInstanceId().'/'.OC_User::getUser().'/';
+ }
+
+ public function get($key) {
+ return xcache_get($this->getNamespace().$key);
+ }
+
+ public function set($key, $value, $ttl=0) {
+ if($ttl>0){
+ return xcache_set($this->getNamespace().$key,$value,$ttl);
+ }else{
+ return xcache_set($this->getNamespace().$key,$value);
+ }
+ }
+
+ public function hasKey($key) {
+ return xcache_isset($this->getNamespace().$key);
+ }
+
+ public function remove($key) {
+ return xcache_unset($this->getNamespace().$key);
+ }
+
+ public function clear(){
+ return xcache_unset_by_prefix($this->getNamespace());
+ }
+}
diff --git a/lib/connector/sabre/directory.php b/lib/connector/sabre/directory.php
index 935d3b0abe4..e74d832cb00 100644
--- a/lib/connector/sabre/directory.php
+++ b/lib/connector/sabre/directory.php
@@ -118,8 +118,10 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
*/
public function delete() {
- foreach($this->getChildren() as $child) $child->delete();
- OC_Filesystem::rmdir($this->path);
+ if ($this->path != "/Shared") {
+ foreach($this->getChildren() as $child) $child->delete();
+ OC_Filesystem::rmdir($this->path);
+ }
}
diff --git a/lib/filecache.php b/lib/filecache.php
index a29e29928a8..3fb8e4113cb 100644
--- a/lib/filecache.php
+++ b/lib/filecache.php
@@ -169,6 +169,15 @@ class OC_FileCache{
$newParent=self::getParentId($newPath);
$query=OC_DB::prepare('UPDATE *PREFIX*fscache SET parent=? ,name=?, path=?, path_hash=? WHERE path_hash=?');
$query->execute(array($newParent,basename($newPath),$newPath,md5($newPath),md5($oldPath)));
+
+ $query=OC_DB::prepare('SELECT path FROM *PREFIX*fscache WHERE path LIKE ?');
+ $oldLength=strlen($oldPath);
+ $updateQuery=OC_DB::prepare('UPDATE *PREFIX*fscache SET path=?, path_hash=? WHERE path_hash=?');
+ while($row= $query->execute(array($oldPath.'/%'))->fetchRow()){
+ $old=$row['path'];
+ $new=$newPath.substr($old,$oldLength);
+ $updateQuery->execute(array($new,md5($new),md5($old)));
+ }
}
/**
diff --git a/lib/files.php b/lib/files.php
index 79d214665de..705b7a6ca66 100644
--- a/lib/files.php
+++ b/lib/files.php
@@ -170,7 +170,7 @@ class OC_Files {
* @param file $target
*/
public static function move($sourceDir,$source,$targetDir,$target){
- if(OC_User::isLoggedIn()){
+ if(OC_User::isLoggedIn() && ($sourceDir != '' || $source != 'Shared')){
$targetFile=self::normalizePath($targetDir.'/'.$target);
$sourceFile=self::normalizePath($sourceDir.'/'.$source);
return OC_Filesystem::rename($sourceFile,$targetFile);
@@ -224,7 +224,7 @@ class OC_Files {
* @param file $name
*/
public static function delete($dir,$file){
- if(OC_User::isLoggedIn()){
+ if(OC_User::isLoggedIn() && ($dir!= '' || $file != 'Shared')) {
$file=$dir.'/'.$file;
return OC_Filesystem::unlink($file);
}
@@ -373,10 +373,12 @@ class OC_Files {
}
}
- //supress errors in case we don't have permissions for it
- if(@file_put_contents(OC::$SERVERROOT.'/.htaccess', $htaccess)) {
- return OC_Helper::computerFileSize($size);
- }
+ //check for write permissions
+ if(is_writable(OC::$SERVERROOT.'/.htaccess')) {
+ file_put_contents(OC::$SERVERROOT.'/.htaccess', $htaccess);
+ return OC_Helper::computerFileSize($size);
+ } else { OC_Log::write('files','Can\'t write upload limit to '.OC::$SERVERROOT.'/.htaccess. Please check the file permissions',OC_Log::WARN); }
+
return false;
}
diff --git a/lib/filesystem.php b/lib/filesystem.php
index 6b3c254c5e9..84d45f5f24b 100644
--- a/lib/filesystem.php
+++ b/lib/filesystem.php
@@ -290,8 +290,10 @@ class OC_Filesystem{
}
/**
- * get the fake root
+ * @brief get the relative path of the root data directory for the current user
* @return string
+ *
+ * Returns path like /admin/files
*/
static public function getRoot(){
return self::$defaultInstance->getRoot();
diff --git a/lib/group.php b/lib/group.php
index 7967e1a581b..ceee5fa4edb 100644
--- a/lib/group.php
+++ b/lib/group.php
@@ -84,7 +84,7 @@ class OC_Group {
OC_Hook::emit( "OC_Group", "pre_createGroup", array( "run" => &$run, "gid" => $gid ));
if($run){
- //create the user in the first backend that supports creating users
+ //create the group in the first backend that supports creating groups
foreach(self::$_usedBackends as $backend){
if(!$backend->implementsActions(OC_GROUP_BACKEND_CREATE_GROUP))
continue;
@@ -141,9 +141,6 @@ class OC_Group {
*/
public static function inGroup( $uid, $gid ){
foreach(self::$_usedBackends as $backend){
- if(!$backend->implementsActions(OC_GROUP_BACKEND_IN_GROUP))
- continue;
-
if($backend->inGroup($uid,$gid)){
return true;
}
@@ -228,9 +225,6 @@ class OC_Group {
public static function getUserGroups( $uid ){
$groups=array();
foreach(self::$_usedBackends as $backend){
- if(!$backend->implementsActions(OC_GROUP_BACKEND_GET_USER_GROUPS))
- continue;
-
$groups=array_merge($backend->getUserGroups($uid),$groups);
}
asort($groups);
@@ -246,9 +240,6 @@ class OC_Group {
public static function getGroups(){
$groups=array();
foreach(self::$_usedBackends as $backend){
- if(!$backend->implementsActions(OC_GROUP_BACKEND_GET_GROUPS))
- continue;
-
$groups=array_merge($backend->getGroups(),$groups);
}
asort($groups);
@@ -276,9 +267,6 @@ class OC_Group {
public static function usersInGroup($gid){
$users=array();
foreach(self::$_usedBackends as $backend){
- if(!$backend->implementsActions(OC_GROUP_BACKEND_GET_USERS))
- continue;
-
$users=array_merge($backend->usersInGroup($gid),$users);
}
return $users;
diff --git a/lib/group/backend.php b/lib/group/backend.php
index 3b652599462..24778afd1e5 100644
--- a/lib/group/backend.php
+++ b/lib/group/backend.php
@@ -31,12 +31,8 @@ define('OC_GROUP_BACKEND_NOT_IMPLEMENTED', -501);
*/
define('OC_GROUP_BACKEND_CREATE_GROUP', 0x00000001);
define('OC_GROUP_BACKEND_DELETE_GROUP', 0x00000010);
-define('OC_GROUP_BACKEND_IN_GROUP', 0x00000100);
-define('OC_GROUP_BACKEND_ADD_TO_GROUP', 0x00001000);
-define('OC_GROUP_BACKEND_REMOVE_FROM_GOUP', 0x00010000);
-define('OC_GROUP_BACKEND_GET_USER_GROUPS', 0x00100000);
-define('OC_GROUP_BACKEND_GET_USERS', 0x01000000);
-define('OC_GROUP_BACKEND_GET_GROUPS', 0x10000000);
+define('OC_GROUP_BACKEND_ADD_TO_GROUP', 0x00000100);
+define('OC_GROUP_BACKEND_REMOVE_FROM_GOUP', 0x00001000);
/**
* Abstract base class for user management
@@ -45,14 +41,10 @@ abstract class OC_Group_Backend {
protected $possibleActions = array(
OC_GROUP_BACKEND_CREATE_GROUP => 'createGroup',
OC_GROUP_BACKEND_DELETE_GROUP => 'deleteGroup',
- OC_GROUP_BACKEND_IN_GROUP => 'inGroup',
OC_GROUP_BACKEND_ADD_TO_GROUP => 'addToGroup',
OC_GROUP_BACKEND_REMOVE_FROM_GOUP => 'removeFromGroup',
- OC_GROUP_BACKEND_GET_USER_GROUPS => 'getUserGroups',
- OC_GROUP_BACKEND_GET_USERS => 'usersInGroup',
- OC_GROUP_BACKEND_GET_GROUPS => 'getGroups'
);
-
+
/**
* @brief Get all supported actions
* @returns bitwise-or'ed actions
@@ -70,7 +62,7 @@ abstract class OC_Group_Backend {
return $actions;
}
-
+
/**
* @brief Check if backend implements actions
* @param $actions bitwise-or'ed actions
@@ -84,14 +76,54 @@ abstract class OC_Group_Backend {
}
/**
+ * @brief is user in group?
+ * @param $uid uid of the user
+ * @param $gid gid of the group
+ * @returns true/false
+ *
+ * Checks whether the user is member of a group or not.
+ */
+ public function inGroup($uid, $gid){
+ return in_array($gid, $this->getUserGroups($uid));
+ }
+
+ /**
+ * @brief Get all groups a user belongs to
+ * @param $uid Name of the user
+ * @returns array with group names
+ *
+ * This function fetches all groups a user belongs to. It does not check
+ * if the user exists at all.
+ */
+ public function getUserGroups($uid){
+ return array();
+ }
+
+ /**
+ * @brief get a list of all groups
+ * @returns array with group names
+ *
+ * Returns a list with all groups
+ */
+ public function getGroups(){
+ return array();
+ }
+
+ /**
* check if a group exists
* @param string $gid
* @return bool
*/
public function groupExists($gid){
- if(!$this->implementsActions(OC_GROUP_BACKEND_GET_GROUPS)){
- return false;
- }
return in_array($gid, $this->getGroups());
}
+
+ /**
+ * @brief get a list of all users in a group
+ * @returns array with user ids
+ */
+ public function usersInGroup($gid){
+ return array();
+ }
+
}
diff --git a/lib/group/database.php b/lib/group/database.php
index af55de1f427..fb173665eb8 100644
--- a/lib/group/database.php
+++ b/lib/group/database.php
@@ -41,7 +41,7 @@
* Class for group management in a SQL Database (e.g. MySQL, SQLite)
*/
class OC_Group_Database extends OC_Group_Backend {
- static private $userGroupCache=array();
+ private $userGroupCache=array();
/**
* @brief Try to create a new group
@@ -51,7 +51,7 @@ class OC_Group_Database extends OC_Group_Backend {
* Trys to create a new group. If the group name already exists, false will
* be returned.
*/
- public static function createGroup( $gid ){
+ public function createGroup( $gid ){
// Check for existence
$query = OC_DB::prepare( "SELECT gid FROM `*PREFIX*groups` WHERE gid = ?" );
$result = $query->execute( array( $gid ));
@@ -76,7 +76,7 @@ class OC_Group_Database extends OC_Group_Backend {
*
* Deletes a group and removes it from the group_user-table
*/
- public static function deleteGroup( $gid ){
+ public function deleteGroup( $gid ){
// Delete the group
$query = OC_DB::prepare( "DELETE FROM `*PREFIX*groups` WHERE gid = ?" );
$result = $query->execute( array( $gid ));
@@ -96,7 +96,7 @@ class OC_Group_Database extends OC_Group_Backend {
*
* Checks whether the user is member of a group or not.
*/
- public static function inGroup( $uid, $gid ){
+ public function inGroup( $uid, $gid ){
// check
$query = OC_DB::prepare( "SELECT uid FROM `*PREFIX*group_user` WHERE gid = ? AND uid = ?" );
$result = $query->execute( array( $gid, $uid ));
@@ -112,9 +112,9 @@ class OC_Group_Database extends OC_Group_Backend {
*
* Adds a user to a group.
*/
- public static function addToGroup( $uid, $gid ){
+ public function addToGroup( $uid, $gid ){
// No duplicate entries!
- if( !self::inGroup( $uid, $gid )){
+ if( !$this->inGroup( $uid, $gid )){
$query = OC_DB::prepare( "INSERT INTO `*PREFIX*group_user` ( `uid`, `gid` ) VALUES( ?, ? )" );
$result = $query->execute( array( $uid, $gid ));
return true;
@@ -131,7 +131,7 @@ class OC_Group_Database extends OC_Group_Backend {
*
* removes the user from a group.
*/
- public static function removeFromGroup( $uid, $gid ){
+ public function removeFromGroup( $uid, $gid ){
$query = OC_DB::prepare( "DELETE FROM *PREFIX*group_user WHERE uid = ? AND gid = ?" );
$result = $query->execute( array( $uid, $gid ));
@@ -146,7 +146,7 @@ class OC_Group_Database extends OC_Group_Backend {
* This function fetches all groups a user belongs to. It does not check
* if the user exists at all.
*/
- public static function getUserGroups( $uid ){
+ public function getUserGroups( $uid ){
// No magic!
$query = OC_DB::prepare( "SELECT gid FROM `*PREFIX*group_user` WHERE uid = ?" );
$result = $query->execute( array( $uid ));
@@ -165,7 +165,7 @@ class OC_Group_Database extends OC_Group_Backend {
*
* Returns a list with all groups
*/
- public static function getGroups(){
+ public function getGroups(){
$query = OC_DB::prepare( "SELECT gid FROM `*PREFIX*groups`" );
$result = $query->execute();
@@ -176,12 +176,12 @@ class OC_Group_Database extends OC_Group_Backend {
return $groups;
}
-
+
/**
* @brief get a list of all users in a group
* @returns array with user ids
*/
- public static function usersInGroup($gid){
+ public function usersInGroup($gid){
$query=OC_DB::prepare('SELECT uid FROM *PREFIX*group_user WHERE gid=?');
$users=array();
$result=$query->execute(array($gid));
diff --git a/lib/group/example.php b/lib/group/example.php
index b2de119553c..c18562db7a4 100644
--- a/lib/group/example.php
+++ b/lib/group/example.php
@@ -94,6 +94,13 @@ abstract class OC_Group_Example {
public static function getGroups(){}
/**
+ * check if a group exists
+ * @param string $gid
+ * @return bool
+ */
+ public function groupExists($gid){}
+
+ /**
* @brief get a list of all users in a group
* @returns array with user ids
*/
diff --git a/lib/helper.php b/lib/helper.php
index f8f84b91ae3..decc1d61336 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -120,7 +120,7 @@ class OC_Helper {
*/
public static function linkToAbsolute( $app, $file ) {
$urlLinkTo = self::linkTo( $app, $file );
- $urlLinkTo = OC_Helper::serverProtocol(). '://' . self::serverHost() . $urlLinkTo;
+ $urlLinkTo = self::serverProtocol(). '://' . self::serverHost() . $urlLinkTo;
return $urlLinkTo;
}
@@ -131,8 +131,8 @@ class OC_Helper {
*
* Returns a absolute url to the given service.
*/
- public static function linkToRemote( $service ) {
- return self::linkToAbsolute( '', 'remote.php') . '/' . $service . '/';
+ public static function linkToRemote( $service, $add_slash = true ) {
+ return self::linkToAbsolute( '', 'remote.php') . '/' . $service . ($add_slash?'/':'');
}
/**
diff --git a/lib/image.php b/lib/image.php
index 4c53dc32f58..a6bb92cea27 100644
--- a/lib/image.php
+++ b/lib/image.php
@@ -187,15 +187,22 @@ class OC_Image {
}
/**
- * @returns Returns a base64 encoded string suitable for embedding in a VCard.
+ * @returns Returns the raw image data.
*/
- function __toString() {
+ function data() {
ob_start();
$res = imagepng($this->resource);
if (!$res) {
- OC_Log::write('core','OC_Image->__toString. Error writing image',OC_Log::ERROR);
+ OC_Log::write('core','OC_Image->data. Error getting image data.',OC_Log::ERROR);
}
- return base64_encode(ob_get_clean());
+ return ob_get_clean();
+ }
+
+ /**
+ * @returns Returns a base64 encoded string suitable for embedding in a VCard.
+ */
+ function __toString() {
+ return base64_encode($this->data());
}
/**
diff --git a/lib/log/owncloud.php b/lib/log/owncloud.php
index 5913d8b5b83..92914af8fca 100644
--- a/lib/log/owncloud.php
+++ b/lib/log/owncloud.php
@@ -63,7 +63,7 @@ class OC_Log_Owncloud {
self::init();
$minLevel=OC_Config::getValue( "loglevel", OC_Log::WARN );
$entries = array();
- $handle = fopen(self::$logFile, 'r');
+ $handle = @fopen(self::$logFile, 'r');
if ($handle) {
// Just a guess to set the file pointer to the right spot
$maxLineLength = 150;
diff --git a/lib/minimizer.php b/lib/minimizer.php
new file mode 100644
index 00000000000..9f9ef086c4a
--- /dev/null
+++ b/lib/minimizer.php
@@ -0,0 +1,40 @@
+<?php
+
+abstract class OC_Minimizer
+{
+ protected $files = array();
+
+ protected function appendIfExist($root, $webroot, $file) {
+ if (is_file($root.'/'.$file)) {
+ $this->files[] = array($root, $webroot, $file);
+ return true;
+ }
+ return false;
+ }
+
+ public function getLastModified($files) {
+ $last_modified = 0;
+ foreach($files as $file_info) {
+ $file = $file_info[0] . '/' . $file_info[2];
+ $filemtime = filemtime($file);
+ if ($filemtime > $last_modified) {
+ $last_modified = $filemtime;
+ }
+ }
+ return $last_modified;
+ }
+
+ abstract public function minimizeFiles($files);
+
+ public function output($files) {
+ header('Content-Type: '.$this->contentType);
+ OC_Response::enableCaching();
+ $last_modified = $this->getLastModified($files);
+ OC_Response::setLastModifiedHeader($last_modified);
+
+ $out = $this->minimizeFiles($files);
+ OC_Response::setETagHeader(md5($out));
+ header('Content-Length: '.strlen($out));
+ echo $out;
+ }
+}
diff --git a/lib/minimizer/css.php b/lib/minimizer/css.php
new file mode 100644
index 00000000000..4637417579e
--- /dev/null
+++ b/lib/minimizer/css.php
@@ -0,0 +1,73 @@
+<?php
+
+require_once('mediawiki/CSSMin.php');
+
+class OC_Minimizer_CSS extends OC_Minimizer
+{
+ protected $contentType = 'text/css';
+
+ public function findFiles($styles) {
+ // Read the selected theme from the config file
+ $theme=OC_Config::getValue( "theme" );
+
+ // Read the detected formfactor and use the right file name.
+ $fext = OC_Template::getFormFactorExtension();
+ foreach($styles as $style){
+ // is it in 3rdparty?
+ if($this->appendIfExist(OC::$THIRDPARTYROOT, OC::$THIRDPARTYWEBROOT, $style.'.css')) {
+
+ // or in apps?
+ }elseif($this->appendIfExist(OC::$APPSROOT, OC::$APPSWEBROOT, "apps/$style$fext.css" )) {
+ }elseif($this->appendIfExist(OC::$APPSROOT, OC::$APPSWEBROOT, "apps/$style.css" )) {
+
+ // or in the owncloud root?
+ }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "$style$fext.css" )) {
+ }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "$style.css" )) {
+
+ // or in core ?
+ }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "core/$style$fext.css" )) {
+ }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "core/$style.css" )) {
+
+ }else{
+ echo('css file not found: style:'.$style.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT);
+ die();
+ }
+ }
+ // Add the theme css files. you can override the default values here
+ if(!empty($theme)) {
+ foreach($styles as $style){
+ if($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/apps/$style$fext.css" )) {
+ }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/apps/$style.css" )) {
+
+ }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/$style$fext.css" )) {
+ }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/$style.css" )) {
+
+ }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/core/$style$fext.css" )) {
+ }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/core/$style.css" )) {
+ }
+ }
+ }
+ return $this->files;
+ }
+
+ public function minimizeFiles($files) {
+ $css_out = '';
+ $appswebroot = (string) OC::$APPSWEBROOT;
+ $webroot = (string) OC::$WEBROOT;
+ foreach($files as $file_info) {
+ $file = $file_info[0] . '/' . $file_info[2];
+ $css_out .= '/* ' . $file . ' */' . "\n";
+ $css = file_get_contents($file);
+ if (strpos($file, OC::$APPSROOT) == 0) {
+ $css = str_replace('%appswebroot%', $appswebroot, $css);
+ $css = str_replace('%webroot%', $webroot, $css);
+ }
+ $remote = $file_info[1];
+ $remote .= '/';
+ $remote .= dirname($file_info[2]);
+ $css_out .= CSSMin::remap($css, dirname($file), $remote, true);
+ }
+ $css_out = CSSMin::minify($css_out);
+ return $css_out;
+ }
+}
diff --git a/lib/minimizer/js.php b/lib/minimizer/js.php
new file mode 100644
index 00000000000..4ddaa79d81a
--- /dev/null
+++ b/lib/minimizer/js.php
@@ -0,0 +1,62 @@
+<?php
+
+require_once('mediawiki/JavaScriptMinifier.php');
+
+class OC_Minimizer_JS extends OC_Minimizer
+{
+ protected $contentType = 'application/javascript';
+
+ public function findFiles($scripts) {
+ // Read the selected theme from the config file
+ $theme=OC_Config::getValue( "theme" );
+
+ // Read the detected formfactor and use the right file name.
+ $fext = OC_Template::getFormFactorExtension();
+ // Add the core js files or the js files provided by the selected theme
+ foreach($scripts as $script){
+ // Is it in 3rd party?
+ if($this->appendIfExist(OC::$THIRDPARTYROOT, OC::$THIRDPARTYWEBROOT, $script.'.js')) {
+
+ // Is it in apps and overwritten by the theme?
+ }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/apps/$script$fext.js" )) {
+ }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/apps/$script.js" )) {
+
+ // Is it part of an app?
+ }elseif($this->appendIfExist(OC::$APPSROOT, OC::$APPSWEBROOT, "apps/$script$fext.js" )) {
+ }elseif($this->appendIfExist(OC::$APPSROOT, OC::$APPSWEBROOT, "apps/$script.js" )) {
+
+ // Is it in the owncloud root but overwritten by the theme?
+ }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/$script$fext.js" )) {
+ }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/$script.js" )) {
+
+ // Is it in the owncloud root ?
+ }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "$script$fext.js" )) {
+ }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "$script.js" )) {
+
+ // Is in core but overwritten by a theme?
+ }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/core/$script$fext.js" )) {
+ }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/core/$script.js" )) {
+
+ // Is it in core?
+ }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "core/$script$fext.js" )) {
+ }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "core/$script.js" )) {
+
+ }else{
+ echo('js file not found: script:'.$script.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT);
+ die();
+ }
+ }
+ return $this->files;
+ }
+
+ public function minimizeFiles($files) {
+ $js_out = '';
+ foreach($files as $file_info) {
+ $file = $file_info[0] . '/' . $file_info[2];
+ $js_out .= '/* ' . $file . ' */' . "\n";
+ $js_out .= file_get_contents($file);
+ }
+ $js_out = JavaScriptMinifier::minify($js_out);
+ return $js_out;
+ }
+}
diff --git a/lib/public/app.php b/lib/public/app.php
index 1f84087f076..9e2108818bf 100644
--- a/lib/public/app.php
+++ b/lib/public/app.php
@@ -36,7 +36,8 @@ namespace OCP;
class App {
/**
- * @brief makes owncloud aware of this app
+ * @brief Makes owncloud aware of this app
+ * @brief This call is deprecated and not necessary to use.
* @param $data array with all information
* @returns true/false
*
diff --git a/lib/template.php b/lib/template.php
index a15cfcc457b..14833a1e5b5 100644
--- a/lib/template.php
+++ b/lib/template.php
@@ -166,7 +166,7 @@ class OC_Template{
/**
* @brief Returns the formfactor extension for current formfactor
*/
- protected function getFormFactorExtension()
+ static public function getFormFactorExtension()
{
$formfactor=$_SESSION['formfactor'];
if($formfactor=='default') {
@@ -196,7 +196,7 @@ class OC_Template{
$theme=OC_Config::getValue( "theme" );
// Read the detected formfactor and use the right file name.
- $fext = $this->getFormFactorExtension();
+ $fext = self::getFormFactorExtension();
$app = $this->application;
// Check if it is a app template or not.
@@ -379,8 +379,9 @@ class OC_Template{
$theme=OC_Config::getValue( "theme" );
// Read the detected formfactor and use the right file name.
- $fext = $this->getFormFactorExtension();
+ $fext = self::getFormFactorExtension();
+ $page->assign('jsfiles', array());
// Add the core js files or the js files provided by the selected theme
foreach(OC_Util::$scripts as $script){
// Is it in 3rd party?
@@ -417,6 +418,7 @@ class OC_Template{
}
}
// Add the css files
+ $page->assign('cssfiles', array());
foreach(OC_Util::$styles as $style){
// is it in 3rdparty?
if($page->appendIfExist('cssfiles', OC::$THIRDPARTYROOT, OC::$THIRDPARTYWEBROOT, $style.'.css')) {
@@ -434,7 +436,7 @@ class OC_Template{
}elseif($page->appendIfExist('cssfiles', OC::$SERVERROOT, OC::$WEBROOT, "core/$style.css" )) {
}else{
- echo('css file not found: style:'.$script.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT);
+ echo('css file not found: style:'.$style.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT);
die();
}
}
diff --git a/lib/user.php b/lib/user.php
index 17c11322b80..f1903093d6d 100644
--- a/lib/user.php
+++ b/lib/user.php
@@ -129,7 +129,7 @@ class OC_User {
if(trim($password) == ''){
throw new Exception('A valid password must be provided');
}
-
+
// Check if user already exists
if( self::userExists($uid) ){
throw new Exception('The username is already being used');
@@ -168,9 +168,7 @@ class OC_User {
if( $run ){
//delete the user from all backends
foreach(self::$_usedBackends as $backend){
- if($backend->implementsActions(OC_USER_BACKEND_DELETE_USER)){
- $backend->deleteUser($uid);
- }
+ $backend->deleteUser($uid);
}
// We have to delete the user from all groups
foreach( OC_Group::getUserGroups( $uid ) as $i ){
@@ -242,12 +240,13 @@ class OC_User {
* Checks if the user is logged in
*/
public static function isLoggedIn(){
- if( isset($_SESSION['user_id']) AND $_SESSION['user_id'] AND self::userExists($_SESSION['user_id']) ){
- return true;
- }
- else{
- return false;
+ if( isset($_SESSION['user_id']) AND $_SESSION['user_id']) {
+ OC_App::loadApps(array('authentication'));
+ if (self::userExists($_SESSION['user_id']) ){
+ return true;
+ }
}
+ return false;
}
/**
@@ -331,11 +330,9 @@ class OC_User {
public static function getUsers(){
$users=array();
foreach(self::$_usedBackends as $backend){
- if($backend->implementsActions(OC_USER_BACKEND_GET_USERS)){
- $backendUsers=$backend->getUsers();
- if(is_array($backendUsers)){
- $users=array_merge($users,$backendUsers);
- }
+ $backendUsers=$backend->getUsers();
+ if(is_array($backendUsers)){
+ $users=array_merge($users,$backendUsers);
}
}
asort($users);
@@ -349,11 +346,9 @@ class OC_User {
*/
public static function userExists($uid){
foreach(self::$_usedBackends as $backend){
- if($backend->implementsActions(OC_USER_BACKEND_USER_EXISTS)){
- $result=$backend->userExists($uid);
- if($result===true){
- return true;
- }
+ $result=$backend->userExists($uid);
+ if($result===true){
+ return true;
}
}
return false;
diff --git a/lib/user/backend.php b/lib/user/backend.php
index c31d4b5785b..be068a63ce0 100644
--- a/lib/user/backend.php
+++ b/lib/user/backend.php
@@ -32,11 +32,8 @@ define('OC_USER_BACKEND_NOT_IMPLEMENTED', -501);
* actions that user backends can define
*/
define('OC_USER_BACKEND_CREATE_USER', 0x000001);
-define('OC_USER_BACKEND_DELETE_USER', 0x000010);
-define('OC_USER_BACKEND_SET_PASSWORD', 0x000100);
-define('OC_USER_BACKEND_CHECK_PASSWORD', 0x001000);
-define('OC_USER_BACKEND_GET_USERS', 0x010000);
-define('OC_USER_BACKEND_USER_EXISTS', 0x100000);
+define('OC_USER_BACKEND_SET_PASSWORD', 0x000010);
+define('OC_USER_BACKEND_CHECK_PASSWORD', 0x000100);
/**
@@ -49,11 +46,8 @@ abstract class OC_User_Backend {
protected $possibleActions = array(
OC_USER_BACKEND_CREATE_USER => 'createUser',
- OC_USER_BACKEND_DELETE_USER => 'deleteUser',
OC_USER_BACKEND_SET_PASSWORD => 'setPassword',
OC_USER_BACKEND_CHECK_PASSWORD => 'checkPassword',
- OC_USER_BACKEND_GET_USERS => 'getUsers',
- OC_USER_BACKEND_USER_EXISTS => 'userExists'
);
/**
@@ -85,4 +79,34 @@ abstract class OC_User_Backend {
public function implementsActions($actions){
return (bool)($this->getSupportedActions() & $actions);
}
+
+ /**
+ * @brief delete a user
+ * @param $uid The username of the user to delete
+ * @returns true/false
+ *
+ * Deletes a user
+ */
+ public function deleteUser( $uid ){
+ return false;
+ }
+
+ /**
+ * @brief Get a list of all users
+ * @returns array with all uids
+ *
+ * Get a list of all users.
+ */
+ public function getUsers(){
+ return array();
+ }
+
+ /**
+ * @brief check if a user exists
+ * @param string $uid the username
+ * @return boolean
+ */
+ public function userExists($uid){
+ return false;
+ }
}
diff --git a/lib/user/example.php b/lib/user/example.php
index 18bc6bce00d..7f3fd1b8578 100644
--- a/lib/user/example.php
+++ b/lib/user/example.php
@@ -40,17 +40,6 @@ abstract class OC_User_Example extends OC_User_Backend {
}
/**
- * @brief delete a user
- * @param $uid The username of the user to delete
- * @returns true/false
- *
- * Deletes a user
- */
- public function deleteUser( $uid ){
- return OC_USER_BACKEND_NOT_IMPLEMENTED;
- }
-
- /**
* @brief Set password
* @param $uid The username
* @param $password The new password
@@ -74,23 +63,4 @@ abstract class OC_User_Example extends OC_User_Backend {
public function checkPassword($uid, $password){
return OC_USER_BACKEND_NOT_IMPLEMENTED;
}
-
- /**
- * @brief Get a list of all users
- * @returns array with all uids
- *
- * Get a list of all users.
- */
- public function getUsers(){
- return OC_USER_BACKEND_NOT_IMPLEMENTED;
- }
-
- /**
- * @brief check if a user exists
- * @param string $uid the username
- * @return boolean
- */
- public function userExists($uid){
- return OC_USER_BACKEND_NOT_IMPLEMENTED;
- }
}
diff --git a/lib/util.php b/lib/util.php
index fda60587b82..20888fa71f4 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -10,6 +10,8 @@ class OC_Util {
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 = "", $root = "files" ){// configure the initial filesystem based on the configuration
@@ -29,7 +31,7 @@ class OC_Util {
}
// Check if apps folder is writable.
- if(!is_writable(OC::$SERVERROOT."/apps/")) {
+ if(OC_Config::getValue('writable_appsdir', true) && !is_writable(OC::$SERVERROOT."/apps/")) {
$tmpl = new OC_Template( '', 'error', 'guest' );
$tmpl->assign('errors',array(1=>array('error'=>"Can't write into apps directory 'apps'",'hint'=>"You can usually fix this by giving the webserver user write access to the config directory in owncloud")));
$tmpl->printPage();
@@ -39,7 +41,7 @@ class OC_Util {
// Create root dir.
if(!is_dir($CONFIG_DATADIRECTORY_ROOT)){
$success=@mkdir($CONFIG_DATADIRECTORY_ROOT);
- if(!$success) {
+ if(!$success) {
$tmpl = new OC_Template( '', 'error', 'guest' );
$tmpl->assign('errors',array(1=>array('error'=>"Can't create data directory (".$CONFIG_DATADIRECTORY_ROOT.")",'hint'=>"You can usually fix this by giving the webserver write access to the ownCloud directory '".OC::$SERVERROOT."' (in a terminal, use the command 'chown -R www-data:www-data /path/to/your/owncloud/install/data' ")));
$tmpl->printPage();
@@ -58,7 +60,6 @@ class OC_Util {
self::$rootMounted=true;
}
if( $user != "" ){ //if we aren't logged in, there is no use to set up the filesystem
-
OC::$CONFIG_DATADIRECTORY = $CONFIG_DATADIRECTORY_ROOT."/$user/$root";
if( !is_dir( OC::$CONFIG_DATADIRECTORY )){
mkdir( OC::$CONFIG_DATADIRECTORY, 0755, true );
@@ -329,4 +330,17 @@ class OC_Util {
}
exit();
}
+
+ /**
+ * get an id unqiue for this instance
+ * @return string
+ */
+ public static function getInstanceId(){
+ $id=OC_Config::getValue('instanceid',null);
+ if(is_null($id)){
+ $id=uniqid();
+ OC_Config::setValue('instanceid',$id);
+ }
+ return $id;
+ }
}