aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rwxr-xr-xlib/app.php73
-rw-r--r--lib/base.php50
-rw-r--r--lib/helper.php8
-rw-r--r--lib/installer.php43
-rw-r--r--lib/l10n.php4
-rw-r--r--lib/minimizer/css.php13
-rw-r--r--lib/template.php4
7 files changed, 126 insertions, 69 deletions
diff --git a/lib/app.php b/lib/app.php
index c08e977b032..1a2dc370d69 100755
--- a/lib/app.php
+++ b/lib/app.php
@@ -83,7 +83,7 @@ class OC_App{
* @param string app
*/
public static function loadApp($app){
- if(is_file(OC::$APPSROOT.'/apps/'.$app.'/appinfo/app.php')){
+ if(is_file(self::getAppPath($app).'/appinfo/app.php')){
require_once( $app.'/appinfo/app.php' );
}
}
@@ -328,10 +328,55 @@ class OC_App{
}
/**
+ * Get the path where to install apps
+ */
+ public static function getInstallPath() {
+ if(OC_Config::getValue('appstoreenabled', true)==false) {
+ return false;
+ }
+
+ foreach(OC::$APPSROOTS as $dir) {
+ if(isset($dir['writable']) && $dir['writable']===true)
+ return $dir['path'];
+ }
+
+ OC_Log::write('core','No application directories are marked as writable.',OC_Log::ERROR);
+ return null;
+ }
+
+
+ protected static function findAppInDirectories($appid) {
+ foreach(OC::$APPSROOTS as $dir) {
+ if(file_exists($dir['path'].'/'.$appid)) {
+ return $dir;
+ }
+ }
+ }
+ /**
+ * Get the directory for the given app.
+ * If the app is defined in multiple directory, the first one is taken. (false if not found)
+ */
+ public static function getAppPath($appid) {
+ if( ($dir = self::findAppInDirectories($appid)) != false) {
+ return $dir['path'].'/'.$appid;
+ }
+ }
+
+ /**
+ * Get the path for the given app on the access
+ * If the app is defined in multiple directory, the first one is taken. (false if not found)
+ */
+ public static function getAppWebPath($appid) {
+ if( ($dir = self::findAppInDirectories($appid)) != false) {
+ return $dir['url'].'/'.$appid;
+ }
+ }
+
+ /**
* get the last version of the app, either from appinfo/version or from appinfo/info.xml
*/
public static function getAppVersion($appid){
- $file=OC::$APPSROOT.'/apps/'.$appid.'/appinfo/version';
+ $file= self::getAppPath($appid).'/appinfo/version';
$version=@file_get_contents($file);
if($version){
return $version;
@@ -354,7 +399,7 @@ class OC_App{
if(isset(self::$appInfo[$appid])){
return self::$appInfo[$appid];
}
- $file=OC::$APPSROOT.'/apps/'.$appid.'/appinfo/info.xml';
+ $file= self::getAppPath($appid).'/appinfo/info.xml';
}
$data=array();
$content=@file_get_contents($file);
@@ -467,10 +512,12 @@ class OC_App{
*/
public static function getAllApps(){
$apps=array();
- $dh=opendir(OC::$APPSROOT.'/apps');
- while($file=readdir($dh)){
- if($file[0]!='.' and is_file(OC::$APPSROOT.'/apps/'.$file.'/appinfo/app.php')){
- $apps[]=$file;
+ foreach(OC::$APPSROOTS as $apps_dir) {
+ $dh=opendir($apps_dir['path']);
+ while($file=readdir($dh)){
+ if($file[0]!='.' and is_file($apps_dir['path'].'/'.$file.'/appinfo/app.php')){
+ $apps[]=$file;
+ }
}
}
return $apps;
@@ -536,24 +583,24 @@ class OC_App{
* @param string appid
*/
public static function updateApp($appid){
- if(file_exists(OC::$APPSROOT.'/apps/'.$appid.'/appinfo/database.xml')){
- OC_DB::updateDbFromStructure(OC::$APPSROOT.'/apps/'.$appid.'/appinfo/database.xml');
+ if(file_exists(self::getAppPath($appid).'/appinfo/database.xml')){
+ OC_DB::updateDbFromStructure(self::getAppPath($appid).'/appinfo/database.xml');
}
if(!self::isEnabled($appid)){
return;
}
- if(file_exists(OC::$APPSROOT.'/apps/'.$appid.'/appinfo/update.php')){
+ if(file_exists(self::getAppPath($appid).'/appinfo/update.php')){
self::loadApp($appid);
- include OC::$APPSROOT.'/apps/'.$appid.'/appinfo/update.php';
+ include self::getAppPath($appid).'/appinfo/update.php';
}
//set remote/public handelers
$appData=self::getAppInfo($appid);
foreach($appData['remote'] as $name=>$path){
- OCP\CONFIG::setAppValue('core', 'remote_'.$name, '/apps/'.$appid.'/'.$path);
+ OCP\CONFIG::setAppValue('core', 'remote_'.$name, $path);
}
foreach($appData['public'] as $name=>$path){
- OCP\CONFIG::setAppValue('core', 'public_'.$name, '/apps/'.$appid.'/'.$path);
+ OCP\CONFIG::setAppValue('core', 'public_'.$name, $appid.'/'.$path);
}
self::setAppTypes($appid);
diff --git a/lib/base.php b/lib/base.php
index b6ca19568fe..2f16f7dab4c 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -51,13 +51,9 @@ class OC{
*/
public static $THIRDPARTYWEBROOT = '';
/**
- * The installation path of the apps folder on the server (e.g. /srv/http/owncloud)
+ * The installation path array of the apps folder on the server (e.g. /srv/http/owncloud) 'path' and web path in 'url'
*/
- public static $APPSROOT = '';
- /**
- * the root path of the apps folder for http requests (e.g. owncloud)
- */
- public static $APPSWEBROOT = '';
+ public static $APPSROOTS = array();
/*
* requested app
*/
@@ -132,29 +128,34 @@ class OC{
echo("3rdparty directory not found! Please put the ownCloud 3rdparty folder in the ownCloud folder or the folder above. You can also configure the location in the config.php file.");
exit;
}
-
// search the apps folder
- if(OC_Config::getValue('appsroot', '')<>''){
- OC::$APPSROOT=OC_Config::getValue('appsroot', '');
- OC::$APPSWEBROOT=OC_Config::getValue('appsurl', '');
+ $config_paths = OC_Config::getValue('apps_paths', array());
+ if(! empty($config_paths)){
+ foreach($config_paths as $paths) {
+ if( isset($paths['url']) && isset($paths['path']))
+ OC::$APPSROOTS[] = $paths;
+ }
}elseif(file_exists(OC::$SERVERROOT.'/apps')){
- OC::$APPSROOT=OC::$SERVERROOT;
- OC::$APPSWEBROOT=OC::$WEBROOT;
+ OC::$APPSROOTS[] = array('path'=> OC::$SERVERROOT.'/apps', 'url' => OC::$WEBROOT.'/apps/', 'writable' => true);
}elseif(file_exists(OC::$SERVERROOT.'/../apps')){
+ OC::$APPSROOTS[] = array('path'=> rtrim(dirname(OC::$SERVERROOT), '/').'/apps', 'url' => rtrim(dirname(OC::$WEBROOT), '/').'/apps/', 'writable' => true);
OC::$APPSROOT=rtrim(dirname(OC::$SERVERROOT), '/');
- OC::$APPSWEBROOT=rtrim(dirname(OC::$WEBROOT), '/');
- }else{
+ }
+
+ if(empty(OC::$APPSROOTS)){
echo("apps directory not found! Please put the ownCloud apps folder in the ownCloud folder or the folder above. You can also configure the location in the config.php file.");
exit;
}
+ $paths = array();
+ foreach( OC::$APPSROOTS as $path)
+ $paths[] = $path['path'];
// set the right include path
set_include_path(
OC::$SERVERROOT.'/lib'.PATH_SEPARATOR.
OC::$SERVERROOT.'/config'.PATH_SEPARATOR.
OC::$THIRDPARTYROOT.'/3rdparty'.PATH_SEPARATOR.
- OC::$APPSROOT.PATH_SEPARATOR.
- OC::$APPSROOT.'/apps'.PATH_SEPARATOR.
+ implode($paths,PATH_SEPARATOR).PATH_SEPARATOR.
get_include_path().PATH_SEPARATOR.
OC::$SERVERROOT
);
@@ -232,24 +233,25 @@ class OC{
}
public static function loadapp(){
- if(file_exists(OC::$APPSROOT . '/apps/' . OC::$REQUESTEDAPP . '/index.php')){
- require_once(OC::$APPSROOT . '/apps/' . OC::$REQUESTEDAPP . '/index.php');
+ if(file_exists(OC_App::getAppPath(OC::$REQUESTEDAPP) . '/index.php')){
+ require_once(OC_App::getAppPath(OC::$REQUESTEDAPP) . '/index.php');
}else{
trigger_error('The requested App was not found.', E_USER_ERROR);//load default app instead?
}
}
public static function loadfile(){
- if(file_exists(OC::$APPSROOT . '/apps/' . OC::$REQUESTEDAPP . '/' . OC::$REQUESTEDFILE)){
+ if(file_exists(OC_App::getAppPath(OC::$REQUESTEDAPP) . '/' . OC::$REQUESTEDFILE)){
if(substr(OC::$REQUESTEDFILE, -3) == 'css'){
- $file = 'apps/' . OC::$REQUESTEDAPP . '/' . OC::$REQUESTEDFILE;
+ $file = OC_App::getAppWebPath(OC::$REQUESTEDAPP). '/' . OC::$REQUESTEDFILE;
$minimizer = new OC_Minimizer_CSS();
- $minimizer->output(array(array(OC::$APPSROOT, OC::$APPSWEBROOT, $file)), $file);
+ $minimizer->output(array(array(OC_App::getAppPath(OC::$REQUESTEDAPP), OC_App::getAppWebPath(OC::$REQUESTEDAPP), OC::$REQUESTEDFILE)),$file);
exit;
}elseif(substr(OC::$REQUESTEDFILE, -3) == 'php'){
- require_once(OC::$APPSROOT . '/apps/' . OC::$REQUESTEDAPP . '/' . OC::$REQUESTEDFILE);
+ require_once(OC_App::getAppPath(OC::$REQUESTEDAPP). '/' . OC::$REQUESTEDFILE);
}
}else{
+ die();
header('HTTP/1.0 404 Not Found');
exit;
}
@@ -391,8 +393,8 @@ class OC{
$_GET['getfile'] = $file;
}
if(!is_null(self::$REQUESTEDFILE)){
- $subdir = OC::$APPSROOT . '/apps/' . self::$REQUESTEDAPP . '/' . self::$REQUESTEDFILE;
- $parent = OC::$APPSROOT . '/apps/' . self::$REQUESTEDAPP;
+ $subdir = OC_App::getAppPath(OC::$REQUESTEDAPP) . '/' . self::$REQUESTEDFILE;
+ $parent = OC_App::getAppPath(OC::$REQUESTEDAPP);
if(!OC_Helper::issubdirectory($subdir, $parent)){
self::$REQUESTEDFILE = null;
header('HTTP/1.0 404 Not Found');
diff --git a/lib/helper.php b/lib/helper.php
index 480c3fe930e..37914b73e17 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -40,7 +40,7 @@ class OC_Helper {
if( $app != '' ){
$app .= '/';
// Check if the app is in the app folder
- if( file_exists( OC::$APPSROOT . '/apps/'. $app.$file )){
+ if( file_exists( OC_App::getAppPath($app).'/'.$file )){
if(substr($file, -3) == 'php' || substr($file, -3) == 'css'){
if(substr($app, -1, 1) == '/'){
$app = substr($app, 0, strlen($app) - 1);
@@ -48,7 +48,7 @@ class OC_Helper {
$urlLinkTo = OC::$WEBROOT . '/?app=' . $app;
$urlLinkTo .= ($file!='index.php')?'&getfile=' . urlencode($file):'';
}else{
- $urlLinkTo = OC::$APPSWEBROOT . '/apps/' . $app . $file;
+ $urlLinkTo = OC_App::getAppWebPath($app) . $file;
}
}
else{
@@ -150,8 +150,8 @@ class OC_Helper {
// Check if the app is in the app folder
if( file_exists( OC::$SERVERROOT."/themes/$theme/apps/$app/img/$image" )){
return OC::$WEBROOT."/themes/$theme/apps/$app/img/$image";
- }elseif( file_exists( OC::$APPSROOT."/apps/$app/img/$image" )){
- return OC::$APPSWEBROOT."/apps/$app/img/$image";
+ }elseif( file_exists(OC_App::getAppPath($app)."/img/$image" )){
+ return OC_App::getAppWebPath($app)."/img/$image";
}elseif( !empty( $app ) and file_exists( OC::$SERVERROOT."/themes/$theme/$app/img/$image" )){
return OC::$WEBROOT."/themes/$theme/$app/img/$image";
}elseif( !empty( $app ) and file_exists( OC::$SERVERROOT."/$app/img/$image" )){
diff --git a/lib/installer.php b/lib/installer.php
index 34c6f8c7bb9..c0903f93d51 100644
--- a/lib/installer.php
+++ b/lib/installer.php
@@ -126,8 +126,6 @@ class OC_Installer{
return false;
}
$info=OC_App::getAppInfo($extractDir.'/appinfo/info.xml',true);
- $basedir=OC::$APPSROOT.'/apps/'.$info['id'];
-
// check the code for not allowed calls
if(!OC_Installer::checkCode($info['id'],$extractDir)){
OC_Log::write('core','App can\'t be installed because of not allowed code in the App',OC_Log::ERROR);
@@ -153,6 +151,7 @@ class OC_Installer{
return false;
}
+ $basedir=OC_App::getInstallPath().'/'.$info['id'];
//check if the destination directory already exists
if(is_dir($basedir)){
OC_Log::write('core','App directory already exists',OC_Log::WARN);
@@ -197,10 +196,10 @@ class OC_Installer{
//set remote/public handelers
foreach($info['remote'] as $name=>$path){
- OCP\CONFIG::setAppValue('core', 'remote_'.$name, '/apps/'.$info['id'].'/'.$path);
+ OCP\CONFIG::setAppValue('core', 'remote_'.$name, $app.'/'.$path);
}
foreach($info['public'] as $name=>$path){
- OCP\CONFIG::setAppValue('core', 'public_'.$name, '/apps/'.$info['id'].'/'.$path);
+ OCP\CONFIG::setAppValue('core', 'public_'.$name, $app.'/'.$path);
}
OC_App::setAppTypes($info['id']);
@@ -287,22 +286,24 @@ class OC_Installer{
* This function installs all apps found in the 'apps' directory that should be enabled by default;
*/
public static function installShippedApps(){
- $dir = opendir( OC::$APPSROOT."/apps" );
- while( false !== ( $filename = readdir( $dir ))){
- if( substr( $filename, 0, 1 ) != '.' and is_dir(OC::$APPSROOT."/apps/$filename") ){
- if( file_exists( OC::$APPSROOT."/apps/$filename/appinfo/app.php" )){
- if(!OC_Installer::isInstalled($filename)){
- $info=OC_App::getAppInfo($filename);
- $enabled = isset($info['default_enable']);
- if( $enabled ){
- OC_Installer::installShippedApp($filename);
- OC_Appconfig::setValue($filename,'enabled','yes');
+ foreach(OC::$APPSROOTS as $app_dir) {
+ $dir = opendir( $app_dir['path'] );
+ while( false !== ( $filename = readdir( $dir ))){
+ if( substr( $filename, 0, 1 ) != '.' and is_dir($app_dir['path']."/$filename") ){
+ if( file_exists( $app_dir['path']."/$filename/appinfo/app.php" )){
+ if(!OC_Installer::isInstalled($filename)){
+ $info=OC_App::getAppInfo($filename);
+ $enabled = isset($info['default_enable']);
+ if( $enabled ){
+ OC_Installer::installShippedApp($filename);
+ OC_Appconfig::setValue($filename,'enabled','yes');
+ }
}
}
}
}
+ closedir( $dir );
}
- closedir( $dir );
}
/**
@@ -312,23 +313,23 @@ class OC_Installer{
*/
public static function installShippedApp($app){
//install the database
- if(is_file(OC::$APPSROOT."/apps/$app/appinfo/database.xml")){
- OC_DB::createDbFromStructure(OC::$APPSROOT."/apps/$app/appinfo/database.xml");
+ if(is_file(OC_App::getAppPath($app)."/appinfo/database.xml")){
+ OC_DB::createDbFromStructure(OC_App::getAppPath($app)."/appinfo/database.xml");
}
//run appinfo/install.php
- if(is_file(OC::$APPSROOT."/apps/$app/appinfo/install.php")){
- include(OC::$APPSROOT."/apps/$app/appinfo/install.php");
+ if(is_file(OC_App::getAppPath($app)."/appinfo/install.php")){
+ include(OC_App::getAppPath($app)."/appinfo/install.php");
}
$info=OC_App::getAppInfo($app);
OC_Appconfig::setValue($app,'installed_version',OC_App::getAppVersion($app));
//set remote/public handelers
foreach($info['remote'] as $name=>$path){
- OCP\CONFIG::setAppValue('core', 'remote_'.$name, '/apps/'.$app.'/'.$path);
+ OCP\CONFIG::setAppValue('core', 'remote_'.$name, $app.'/'.$path);
}
foreach($info['public'] as $name=>$path){
- OCP\CONFIG::setAppValue('core', 'public_'.$name, '/apps/'.$app.'/'.$path);
+ OCP\CONFIG::setAppValue('core', 'public_'.$name, $app.'/'.$path);
}
OC_App::setAppTypes($info['id']);
diff --git a/lib/l10n.php b/lib/l10n.php
index 0f01e927ff9..4acbc5dcebc 100644
--- a/lib/l10n.php
+++ b/lib/l10n.php
@@ -289,8 +289,8 @@ class OC_L10N{
$i18ndir = OC::$SERVERROOT.'/core/l10n/';
if($app != ''){
// Check if the app is in the app folder
- if(file_exists(OC::$APPSROOT.'/apps/'.$app.'/l10n/')){
- $i18ndir = OC::$APPSROOT.'/apps/'.$app.'/l10n/';
+ if(file_exists(OC_App::getAppPath($app).'/l10n/')){
+ $i18ndir = OC_App::getAppPath($app).'/l10n/';
}
else{
$i18ndir = OC::$SERVERROOT.'/'.$app.'/l10n/';
diff --git a/lib/minimizer/css.php b/lib/minimizer/css.php
index da502bfa9e8..97099adbdf6 100644
--- a/lib/minimizer/css.php
+++ b/lib/minimizer/css.php
@@ -8,14 +8,21 @@ class OC_Minimizer_CSS extends OC_Minimizer
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);
+
+ $in_root = false;
+ foreach(OC::$APPSROOTS as $app_root) {
+ if(strpos($file, $app_root['path']) == 0) {
+ $in_root = $app_root['url'];
+ break;
+ }
+ }
+ if ($in_root !== false) {
+ $css = str_replace('%appswebroot%', $in_root, $css);
$css = str_replace('%webroot%', $webroot, $css);
}
$remote = $file_info[1];
diff --git a/lib/template.php b/lib/template.php
index 8fb0133b289..3b48c27b9b4 100644
--- a/lib/template.php
+++ b/lib/template.php
@@ -242,10 +242,10 @@ class OC_Template{
// Check if it is a app template or not.
if( $app != "" ){
// Check if the app is in the app folder or in the root
- if( file_exists( OC::$APPSROOT."/apps/$app/templates/" )){
+ if( file_exists(OC_App::getAppPath($app)."/templates/" )){
// Check if the template is overwritten by the selected theme
if ($this->checkPathForTemplate(OC::$SERVERROOT."/themes/$theme/apps/$app/templates/", $name, $fext)) {
- }elseif ($this->checkPathForTemplate(OC::$APPSROOT."/apps/$app/templates/", $name, $fext)) {
+ }elseif ($this->checkPathForTemplate(OC_App::getAppPath($app)."/templates/", $name, $fext)) {
}
}else{
// Check if the template is overwritten by the selected theme