diff options
-rw-r--r-- | apps/bookmarks/ajax/addBookmark.php | 4 | ||||
-rw-r--r-- | apps/bookmarks/templates/list.php | 2 | ||||
-rw-r--r-- | apps/calendar/appinfo/remote.php | 4 | ||||
-rw-r--r-- | apps/contacts/appinfo/remote.php | 4 | ||||
-rw-r--r-- | apps/media/remote.php | 4 | ||||
-rw-r--r-- | apps/media/server/xml.server.php | 4 | ||||
-rw-r--r-- | apps/user_webfinger/webfinger.php | 2 | ||||
-rw-r--r-- | config/config.sample.php | 15 | ||||
-rw-r--r-- | core/js/js.js | 8 | ||||
-rw-r--r-- | core/templates/layout.guest.php | 2 | ||||
-rw-r--r-- | core/templates/layout.user.php | 2 | ||||
-rwxr-xr-x | lib/app.php | 73 | ||||
-rw-r--r-- | lib/base.php | 50 | ||||
-rw-r--r-- | lib/helper.php | 8 | ||||
-rw-r--r-- | lib/installer.php | 43 | ||||
-rw-r--r-- | lib/l10n.php | 4 | ||||
-rw-r--r-- | lib/minimizer/css.php | 29 | ||||
-rw-r--r-- | lib/minimizer/js.php | 17 | ||||
-rw-r--r-- | lib/template.php | 105 | ||||
-rwxr-xr-x | lib/util.php | 16 | ||||
-rw-r--r-- | public.php | 6 | ||||
-rw-r--r-- | remote.php | 19 |
22 files changed, 264 insertions, 157 deletions
diff --git a/apps/bookmarks/ajax/addBookmark.php b/apps/bookmarks/ajax/addBookmark.php index a2eb506f85e..d66aab58960 100644 --- a/apps/bookmarks/ajax/addBookmark.php +++ b/apps/bookmarks/ajax/addBookmark.php @@ -30,6 +30,6 @@ $RUNTIME_NOSETUPFS=true; OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('bookmarks'); -require_once(OC::$APPSROOT . '/apps/bookmarks/bookmarksHelper.php'); -$id = addBookmark($_POST['url'], $_POST['title'], $_POST['tags']); +require_once(OC_App::getAppPath('bookmarks').'/bookmarksHelper.php'); +$id = addBookmark($_GET['url'], $_GET['title'], $_GET['tags']); OCP\JSON::success(array('data' => $id));
\ No newline at end of file diff --git a/apps/bookmarks/templates/list.php b/apps/bookmarks/templates/list.php index fdd2b19f79a..84436ae7409 100644 --- a/apps/bookmarks/templates/list.php +++ b/apps/bookmarks/templates/list.php @@ -20,7 +20,7 @@ <div id="firstrun" style="display: none;"> <?php echo $l->t('You have no bookmarks'); - require_once(OC::$APPSROOT . '/apps/bookmarks/templates/bookmarklet.php'); + require_once(OC_App::getAppPath('bookmarks') .'/templates/bookmarklet.php'); createBookmarklet(); ?> </div> diff --git a/apps/calendar/appinfo/remote.php b/apps/calendar/appinfo/remote.php index 3bd8737ee97..7ab546245f6 100644 --- a/apps/calendar/appinfo/remote.php +++ b/apps/calendar/appinfo/remote.php @@ -7,8 +7,8 @@ */ OCP\App::checkAppEnabled('calendar'); -if(substr($_SERVER["REQUEST_URI"],0,strlen(OC::$APPSWEBROOT . '/apps/calendar/caldav.php')) == OC::$APPSWEBROOT . '/apps/calendar/caldav.php'){ - $baseuri = OC::$APPSWEBROOT . '/apps/calendar/caldav.php'; +if(substr($_SERVER["REQUEST_URI"],0,strlen(OC_App::getAppWebPath('calendar').'/caldav.php')) == OC_App::getAppWebPath('calendar'). '/caldav.php'){ + $baseuri = OC_App::getAppWebPath('calendar').'/caldav.php'; } // only need authentication apps diff --git a/apps/contacts/appinfo/remote.php b/apps/contacts/appinfo/remote.php index ef50e4ad39f..5add3bc6889 100644 --- a/apps/contacts/appinfo/remote.php +++ b/apps/contacts/appinfo/remote.php @@ -22,8 +22,8 @@ OCP\App::checkAppEnabled('contacts'); -if(substr($_SERVER["REQUEST_URI"],0,strlen(OC::$APPSWEBROOT . '/apps/contacts/carddav.php')) == OC::$APPSWEBROOT . '/apps/contacts/carddav.php'){ - $baseuri = OC::$APPSWEBROOT . '/apps/contacts/carddav.php'; +if(substr($_SERVER["REQUEST_URI"],0,strlen(OC_App::getAppWebPath('contacts').'/carddav.php')) == OC_App::getAppWebPath('contacts').'/carddav.php'){ + $baseuri = OC_App::getAppWebPath('contacts').'/carddav.php'; } // only need authentication apps diff --git a/apps/media/remote.php b/apps/media/remote.php index 01add42b315..0535077cef1 100644 --- a/apps/media/remote.php +++ b/apps/media/remote.php @@ -5,7 +5,7 @@ $RUNTIME_APPTYPES=array('filesystem','authentication'); OC_App::loadApps($RUNTIME_APPTYPES); if($path_info == '/ampache' || $path_info == '/ampache/'){ - require_once(OC::$APPSROOT . '/apps/media/index.php'); + require_once(OC_App::getAppPath('media').'/index.php'); }else{ - require_once(OC::$APPSROOT . '/apps/media/server/xml.server.php'); + require_once(OC_App::getAppPath('media').'/server/xml.server.php'); } diff --git a/apps/media/server/xml.server.php b/apps/media/server/xml.server.php index 6cb6c91ca06..796da130a47 100644 --- a/apps/media/server/xml.server.php +++ b/apps/media/server/xml.server.php @@ -22,8 +22,8 @@ */ OCP\App::checkAppEnabled('media'); - require_once(OC::$APPSROOT . '/apps/media/lib_collection.php'); - require_once(OC::$APPSROOT . '/apps/media/lib_ampache.php'); + require_once(OC_App::getAppPath('media').'/lib_collection.php'); + require_once(OC_App::getAppPath('media').'/lib_ampache.php'); $arguments=$_POST; if(!isset($_POST['action']) and isset($_GET['action'])){ diff --git a/apps/user_webfinger/webfinger.php b/apps/user_webfinger/webfinger.php index e75c546c2cb..67cbba54a4c 100644 --- a/apps/user_webfinger/webfinger.php +++ b/apps/user_webfinger/webfinger.php @@ -59,7 +59,7 @@ echo "{\"links\":["; $apps = OC_Appconfig::getApps(); foreach($apps as $app) { if(OCP\App::isEnabled($app)) { - if(is_file(OC::$APPSROOT . '/apps/' . $app . '/appinfo/webfinger.php')) { + if(is_file(OC_App::getAppPath($app). '/appinfo/webfinger.php')) { require($app . '/appinfo/webfinger.php'); } } diff --git a/config/config.sample.php b/config/config.sample.php index bb13b1f8ea3..5af5a6efc02 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -90,11 +90,22 @@ $CONFIG = array( * If the apps dir is not writable, you can't download&install extra apps * in the admin apps menu. */ -"writable_appsdir" => true, +// "datadirectory" => "", +"apps_paths" => array( + +/* 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 + applications paths. 'writable' indicate if the user can install apps in this folder. +*/ + array( + 'path'=> '/var/www/owncloud/apps', + 'url' => '/apps', + 'writable' => true, + ), + ), /* The directory where the user data is stored, default to data in the owncloud * directory. The sqlite database is also stored here, when sqlite is used. */ -// "datadirectory" => "" ); ?> diff --git a/core/js/js.js b/core/js/js.js index 89a20a529f3..a1ad0c77184 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -31,7 +31,7 @@ t.cache={}; OC={ webroot:oc_webroot, - appswebroot:oc_appswebroot, + appswebroots:oc_appswebroots, currentUser:(typeof oc_current_user!=='undefined')?oc_current_user:false, coreApps:['', 'admin','log','search','settings','core','3rdparty'], /** @@ -63,10 +63,8 @@ OC={ link+= file; } }else if(file.substring(file.length-3) != 'php' && !isCore){ - link=OC.appswebroot; - link+='/'; - link+='apps/'; - link+=app+'/'; + link=OC.appswebroots[app]; + link+='/'+app+'/'; if(type){ link+=type+'/'; } diff --git a/core/templates/layout.guest.php b/core/templates/layout.guest.php index 55cc8008d9a..4cdbfd16e52 100644 --- a/core/templates/layout.guest.php +++ b/core/templates/layout.guest.php @@ -12,7 +12,7 @@ <?php endforeach; ?> <script type="text/javascript"> var oc_webroot = '<?php echo OC::$WEBROOT; ?>'; - var oc_appswebroot = '<?php echo OC::$APPSWEBROOT; ?>'; + var oc_appswebroots = <?php echo $_['apps_paths'] ?>; </script> <?php if (!empty(OC_Util::$core_scripts)): ?> <script type="text/javascript" src="<?php echo OC_Helper::linkToRemote('core.js', false) ?>"></script> diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php index e271acf10ee..fabc28f6637 100644 --- a/core/templates/layout.user.php +++ b/core/templates/layout.user.php @@ -12,7 +12,7 @@ <?php endforeach; ?> <script type="text/javascript"> var oc_webroot = '<?php echo OC::$WEBROOT; ?>'; - var oc_appswebroot = '<?php echo OC::$APPSWEBROOT; ?>'; + var oc_appswebroots = <?php echo $_['apps_paths'] ?>; var oc_current_user = '<?php echo OC_User::getUser() ?>'; </script> <?php if (!empty(OC_Util::$core_scripts)): ?> diff --git a/lib/app.php b/lib/app.php index 0c51e3c5532..1dcccee1da0 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; @@ -535,23 +582,23 @@ 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')){ - include OC::$APPSROOT.'/apps/'.$appid.'/appinfo/update.php'; + if(file_exists(self::getAppPath($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 f85710ddfcf..a0f5e83dd47 100644 --- a/lib/base.php +++ b/lib/base.php @@ -55,13 +55,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 */ @@ -165,29 +161,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 ); @@ -273,24 +274,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))); + $minimizer->output(array(array(OC_App::getAppPath(OC::$REQUESTEDAPP), OC_App::getAppWebPath(OC::$REQUESTEDAPP), OC::$REQUESTEDFILE))); 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; } @@ -446,8 +448,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 2ded7b13c38..73d4b659a34 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 3596c992bae..887652e2b85 100644 --- a/lib/l10n.php +++ b/lib/l10n.php @@ -267,8 +267,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 4637417579e..c7e5d96e06b 100644 --- a/lib/minimizer/css.php +++ b/lib/minimizer/css.php @@ -16,10 +16,6 @@ class OC_Minimizer_CSS extends OC_Minimizer // 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" )) { @@ -29,8 +25,16 @@ class OC_Minimizer_CSS extends OC_Minimizer }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(); + $append = false; + foreach( OC::$APPSROOTS as $apps_dir) + { + if($this->appendIfExist($apps_dir['path'], $apps_dir['url'], "$style$fext.css", true)) { $append =true; break; } + elseif($this->appendIfExist($apps_dir['path'], $apps_dir['url'], "$style.css", true )) { $append =true; break; } + } + if(! $append) { + echo('css file not found: style:'.$script.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT); + die(); + } } } // Add the theme css files. you can override the default values here @@ -52,14 +56,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/minimizer/js.php b/lib/minimizer/js.php index 4ddaa79d81a..dd7d15de061 100644 --- a/lib/minimizer/js.php +++ b/lib/minimizer/js.php @@ -21,10 +21,6 @@ class OC_Minimizer_JS extends OC_Minimizer }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" )) { @@ -42,8 +38,17 @@ class OC_Minimizer_JS extends OC_Minimizer }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(); + // Is it part of an app? + $append = false; + foreach( OC::$APPSROOTS as $apps_dir) + { + if($this->appendIfExist($apps_dir['path'], $apps_dir['url'], "$script$fext.js" , true)) { $append =true; break; } + elseif($this->appendIfExist($apps_dir['path'], $apps_dir['url'], "$script.js", true )) { $append =true; break; } + } + if(! $append) { + echo('js file not found: script:'.$script.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT); + die(); + } } } return $this->files; diff --git a/lib/template.php b/lib/template.php index a3700e133e7..149859aa8a5 100644 --- a/lib/template.php +++ b/lib/template.php @@ -205,10 +205,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 @@ -339,29 +339,38 @@ class OC_Template{ } } - /* + /** * @brief append the $file-url if exist at $root * @param $type of collection to use when appending * @param $root path to check * @param $web base for path * @param $file the filename + * @param $in_app boolean is part of an app? (default false) */ - public function appendIfExist($type, $root, $web, $file) { - if (is_file($root.'/'.$file)) { - $pathes = explode('/', $file); - if($type == 'cssfiles' && $root == OC::$APPSROOT && $pathes[0] == 'apps'){ - $app = $pathes[1]; - unset($pathes[0]); - unset($pathes[1]); - $path = implode('/', $pathes); - $this->append( $type, OC_Helper::linkTo($app, $path)); - }else{ - $this->append( $type, $web.'/'.$file); - } - return true; - } - return false; - } + public function appendIfExist($type, $root, $web, $file, $in_app = false) { + + if (is_file($root.'/'.$file)) { + $pathes = explode('/', $file); + $in_root = false; + foreach(OC::$APPSROOTS as $app_root) { + if($root == $app_root['path']) { + $in_root = true; + break; + } + } + if($type == 'cssfiles' && $in_root && $in_app){ + $app = $pathes[0]; + unset($pathes[0]); + $path = implode('/', $pathes); + $this->append( $type, OC_Helper::linkTo($app, $path)); + }else{ + $this->append( $type, $web.'/'.$file); + } + return true; + } + return false; + } + /** * @brief Proceeds the template * @returns content @@ -397,6 +406,11 @@ class OC_Template{ }else{ $page = new OC_Template( "core", "layout.guest" ); } + $apps_paths = array(); + foreach(OC_App::getEnabledApps() as $app){ + $apps_paths[$app] = OC_App::getAppWebPath($app); + } + $page->assign( 'apps_paths', str_replace('\\/', '/',json_encode($apps_paths)) , false); // Ugly unescape slashes waiting for better solution // Read the selected theme from the config file $theme=OC_Config::getValue( "theme" ); @@ -408,16 +422,12 @@ class OC_Template{ // 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? - if($page->appendIfExist('jsfiles', OC::$THIRDPARTYROOT, OC::$THIRDPARTYWEBROOT, $script.'.js')) { + if($page->appendIfExist('jsfiles', OC::$THIRDPARTYROOT, OC::$THIRDPARTYWEBROOT, $script.'.js')) { // Is it in apps and overwritten by the theme? }elseif($page->appendIfExist('jsfiles', OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/apps/$script$fext.js" )) { }elseif($page->appendIfExist('jsfiles', OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/apps/$script.js" )) { - // Is it part of an app? - }elseif($page->appendIfExist('jsfiles', OC::$APPSROOT, OC::$APPSWEBROOT, "apps/$script$fext.js" )) { - }elseif($page->appendIfExist('jsfiles', OC::$APPSROOT, OC::$APPSWEBROOT, "apps/$script.js" )) { - // Is it in the owncloud root but overwritten by the theme? }elseif($page->appendIfExist('jsfiles', OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/$script$fext.js" )) { }elseif($page->appendIfExist('jsfiles', OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/$script.js" )) { @@ -435,20 +445,24 @@ class OC_Template{ }elseif($page->appendIfExist('jsfiles', OC::$SERVERROOT, OC::$WEBROOT, "core/$script.js" )) { }else{ - echo('js file not found: script:'.$script.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT); - die(); - + // Is it part of an app? + $append = false; + foreach( OC::$APPSROOTS as $apps_dir) + { + if($page->appendIfExist('jsfiles', $apps_dir['path'], $apps_dir['url'], "$script$fext.js" , true)) { $append =true; break; } + elseif($page->appendIfExist('jsfiles', $apps_dir['path'], $apps_dir['url'], "$script.js", true )) { $append =true; break; } + } + if(! $append) { + echo('js file not found: script:'.$script.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT); + die(); + } } } // 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')) { - - // or in apps? - }elseif($page->appendIfExist('cssfiles', OC::$APPSROOT, OC::$APPSWEBROOT, "apps/$style$fext.css" )) { - }elseif($page->appendIfExist('cssfiles', OC::$APPSROOT, OC::$APPSWEBROOT, "apps/$style.css" )) { + if($page->appendIfExist('cssfiles', OC::$THIRDPARTYROOT, OC::$THIRDPARTYWEBROOT, $style.'.css')) { // or in the owncloud root? }elseif($page->appendIfExist('cssfiles', OC::$SERVERROOT, OC::$WEBROOT, "$style$fext.css" )) { @@ -459,22 +473,31 @@ class OC_Template{ }elseif($page->appendIfExist('cssfiles', OC::$SERVERROOT, OC::$WEBROOT, "core/$style.css" )) { }else{ - echo('css file not found: style:'.$style.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT); - die(); + // or in apps? + $append = false; + foreach( OC::$APPSROOTS as $apps_dir) + { + if($page->appendIfExist('cssfiles', $apps_dir['path'], $apps_dir['url'], "$style$fext.css", true)) { $append =true; break; } + elseif($page->appendIfExist('cssfiles', $apps_dir['path'], $apps_dir['url'], "$style.css", true )) { $append =true; break; } + } + if(! $append) { + echo('css file not found: style:'.$script.' 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(OC_Util::$styles as $style){ - if($page->appendIfExist('cssfiles', OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/apps/$style$fext.css" )) { - }elseif($page->appendIfExist('cssfiles', OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/apps/$style.css" )) { + if($page->appendIfExist('cssfiles', OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/apps/$style$fext.css" )) { + }elseif($page->appendIfExist('cssfiles', OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/apps/$style.css" )) { - }elseif($page->appendIfExist('cssfiles', OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/$style$fext.css" )) { - }elseif($page->appendIfExist('cssfiles', OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/$style.css" )) { + }elseif($page->appendIfExist('cssfiles', OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/$style$fext.css" )) { + }elseif($page->appendIfExist('cssfiles', OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/$style.css" )) { - }elseif($page->appendIfExist('cssfiles', OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/core/$style$fext.css" )) { - }elseif($page->appendIfExist('cssfiles', OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/core/$style.css" )) { - } + }elseif($page->appendIfExist('cssfiles', OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/core/$style$fext.css" )) { + }elseif($page->appendIfExist('cssfiles', OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/core/$style.css" )) { + } } } diff --git a/lib/util.php b/lib/util.php index 0266a8ecc5f..cedbe3fa460 100755 --- a/lib/util.php +++ b/lib/util.php @@ -29,13 +29,15 @@ class OC_Util { $tmpl->printPage(); exit; } - - // Check if apps folder is writable. - 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(); - exit; + + // Check if there is a writable install folder. + if(OC_Config::getValue('appstoreenabled', true)) { + if( OC_App::getInstallPath() === null || !is_writable(OC_App::getInstallPath())) { + $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(); + exit; + } } // Create root dir. diff --git a/public.php b/public.php index f974e1c50d2..19c02a7a027 100644 --- a/public.php +++ b/public.php @@ -8,8 +8,8 @@ if(is_null($file)){ exit; } -$parts=explode('/',$file); -$app=$parts[2]; +$parts=explode('/',$file,2); +$app=$parts[0]; OC_App::loadApp($app); -require_once(OC::$APPSROOT . $file); +require_once(OC_App::getAppPath($app) .'/'. $parts[1]); diff --git a/remote.php b/remote.php index b1be50f36a7..9fb73c4ce1d 100644 --- a/remote.php +++ b/remote.php @@ -21,9 +21,16 @@ if(is_null($file)){ exit; } -$parts=explode('/',$file); -$app=$parts[2]; -OC_App::loadApp($app); - -$baseuri = OC::$WEBROOT . '/remote.php/'.$service.'/'; -require_once(OC::$APPSROOT . $file); +if(count(explode('/',$file)) == 3) { + $parts=explode('/',$file); + $app=$parts[2]; + OC_App::loadApp($app); + $baseuri = OC::$WEBROOT . '/remote.php/'.$service.'/'; + require_once( OC::$SERVERROOT.$file); +} else { + $parts=explode('/', $file, 2); + $app=$parts[0]; + OC_App::loadApp($app); + $baseuri = OC::$WEBROOT . '/remote.php/'.$service.'/'; + require_once(OC_App::getAppPath($app) .'/'. $parts[1]); +} |