Skip to content
Snippets Groups Projects
Commit 6da5a2fd authored by Brice Maron's avatar Brice Maron
Browse files

Add possibility to choose the installation folder

parent dd98afc5
No related branches found
No related tags found
No related merge requests found
...@@ -33,17 +33,17 @@ $CONFIG = array( ...@@ -33,17 +33,17 @@ $CONFIG = array(
* If the apps dir is not writable, you can't download&install extra apps * If the apps dir is not writable, you can't download&install extra apps
* in the admin apps menu. * in the admin apps menu.
*/ */
"writable_appsdir" => true,
// "datadirectory" => "", // "datadirectory" => "",
"apps_paths" => array( "apps_paths" => array(
/* Set an array of path for your apps directories /* Set an array of path for your apps directories
key 'path' is for the fs path an the key url is for the http path to your key 'path' is for the fs path an the key 'url' is for the http path to your
applications paths applications paths. 'writable' indicate if the user can install apps in this folder.
*/ */
array( array(
'path'=> '/var/www/owncloud/apps', 'path'=> '/var/www/owncloud/apps',
'url' => '/apps', 'url' => '/apps',
'writable' => true,
), ),
), ),
); );
......
...@@ -322,17 +322,39 @@ class OC_App{ ...@@ -322,17 +322,39 @@ class OC_App{
return $list; return $list;
} }
/**
* 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. * Get the directory for the given app.
* If the app is defined in multiple directory, the first one is taken. (false if not found) * If the app is defined in multiple directory, the first one is taken. (false if not found)
*/ */
public static function getAppPath($appid) { public static function getAppPath($appid) {
foreach(OC::$APPSROOTS as $dir) { if( ($dir = self::findAppInDirectories($appid)) != false) {
if(file_exists($dir['path'].'/'.$appid)) { return $dir['path'].'/'.$appid;
return $dir['path'].'/'.$appid;
}
} }
return false;
} }
/** /**
...@@ -340,12 +362,9 @@ class OC_App{ ...@@ -340,12 +362,9 @@ class OC_App{
* If the app is defined in multiple directory, the first one is taken. (false if not found) * If the app is defined in multiple directory, the first one is taken. (false if not found)
*/ */
public static function getAppWebPath($appid) { public static function getAppWebPath($appid) {
foreach(OC::$APPSROOTS as $dir) { if( ($dir = self::findAppInDirectories($appid)) != false) {
if(file_exists($dir['path'].'/'.$appid)) { return $dir['url'].'/'.$appid;
return $dir['url'].'/'.$appid;
}
} }
return false;
} }
/** /**
......
...@@ -169,9 +169,9 @@ class OC{ ...@@ -169,9 +169,9 @@ class OC{
OC::$APPSROOTS[] = $paths; OC::$APPSROOTS[] = $paths;
} }
}elseif(file_exists(OC::$SERVERROOT.'/apps')){ }elseif(file_exists(OC::$SERVERROOT.'/apps')){
OC::$APPSROOTS[] = array('path'=> OC::$SERVERROOT.'/apps', 'url' => OC::$WEBROOT.'/apps/'); OC::$APPSROOTS[] = array('path'=> OC::$SERVERROOT.'/apps', 'url' => OC::$WEBROOT.'/apps/', 'writable' => true);
}elseif(file_exists(OC::$SERVERROOT.'/../apps')){ }elseif(file_exists(OC::$SERVERROOT.'/../apps')){
OC::$APPSROOTS[] = array('path'=> rtrim(dirname(OC::$SERVERROOT), '/').'/apps', 'url' => rtrim(dirname(OC::$WEBROOT), '/').'/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::$APPSROOT=rtrim(dirname(OC::$SERVERROOT), '/');
} }
......
...@@ -126,8 +126,6 @@ class OC_Installer{ ...@@ -126,8 +126,6 @@ class OC_Installer{
return false; return false;
} }
$info=OC_App::getAppInfo($extractDir.'/appinfo/info.xml',true); $info=OC_App::getAppInfo($extractDir.'/appinfo/info.xml',true);
$basedir=OC_App::getAppPath($info['id']);
// check the code for not allowed calls // check the code for not allowed calls
if(!OC_Installer::checkCode($info['id'],$extractDir)){ 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); 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{ ...@@ -153,6 +151,7 @@ class OC_Installer{
return false; return false;
} }
$basedir=OC_App::getInstallPath().'/'.$info['id'];
//check if the destination directory already exists //check if the destination directory already exists
if(is_dir($basedir)){ if(is_dir($basedir)){
OC_Log::write('core','App directory already exists',OC_Log::WARN); OC_Log::write('core','App directory already exists',OC_Log::WARN);
......
...@@ -29,13 +29,15 @@ class OC_Util { ...@@ -29,13 +29,15 @@ class OC_Util {
$tmpl->printPage(); $tmpl->printPage();
exit; exit;
} }
// Check if apps folder is writable. // Check if there is a writable install folder.
if(OC_Config::getValue('writable_appsdir', true) && !is_writable(OC::$SERVERROOT."/apps/")) { if(OC_Config::getValue('appstoreenabled', true)) {
$tmpl = new OC_Template( '', 'error', 'guest' ); if( OC_App::getInstallPath() === null || !is_writable(OC_App::getInstallPath())) {
$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 = new OC_Template( '', 'error', 'guest' );
$tmpl->printPage(); $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")));
exit; $tmpl->printPage();
exit;
}
} }
// Create root dir. // Create root dir.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment