first part of the abstraction work of the apps folder. more to come
This commit is contained in:
parent
8148480cfe
commit
ab96fa67c8
10 changed files with 95 additions and 70 deletions
|
@ -11,7 +11,7 @@ require_once('../../../../lib/base.php');
|
|||
OC_JSON::checkLoggedIn();
|
||||
OC_Util::checkAppEnabled('calendar');
|
||||
$nl = "\n";
|
||||
$progressfile = OC::$SERVERROOT . '/apps/calendar/import_tmp/' . md5(session_id()) . '.txt';
|
||||
$progressfile = OC::$APPSROOT . '/apps/calendar/import_tmp/' . md5(session_id()) . '.txt';
|
||||
if(is_writable('import_tmp/')){
|
||||
$progressfopen = fopen($progressfile, 'w');
|
||||
fwrite($progressfopen, '10');
|
||||
|
@ -117,4 +117,4 @@ sleep(3);
|
|||
if(is_writable('import_tmp/')){
|
||||
unlink($progressfile);
|
||||
}
|
||||
OC_JSON::success();
|
||||
OC_JSON::success();
|
||||
|
|
|
@ -25,7 +25,7 @@ $nodes = array(
|
|||
|
||||
// Fire up server
|
||||
$server = new Sabre_DAV_Server($nodes);
|
||||
$server->setBaseUri(OC::$WEBROOT.'/apps/calendar/caldav.php');
|
||||
$server->setBaseUri(OC::$APPSROOT.'/apps/calendar/caldav.php');
|
||||
// Add plugins
|
||||
$server->addPlugin(new Sabre_DAV_Auth_Plugin($authBackend,'ownCloud'));
|
||||
$server->addPlugin(new Sabre_CalDAV_Plugin());
|
||||
|
|
|
@ -39,7 +39,7 @@ $nodes = array(
|
|||
|
||||
// Fire up server
|
||||
$server = new Sabre_DAV_Server($nodes);
|
||||
$server->setBaseUri(OC::$WEBROOT.'/apps/contacts/carddav.php');
|
||||
$server->setBaseUri(OC::$APPSROOT.'/apps/contacts/carddav.php');
|
||||
// Add plugins
|
||||
$server->addPlugin(new Sabre_DAV_Auth_Plugin($authBackend,'ownCloud'));
|
||||
$server->addPlugin(new Sabre_CardDAV_Plugin());
|
||||
|
|
|
@ -66,7 +66,7 @@ if(count($pathParts) >= 3 && $pathParts[0] == '') {
|
|||
$server = new Sabre_DAV_Server($publicDir);
|
||||
|
||||
// Path to our script
|
||||
$server->setBaseUri(OC::$WEBROOT."/apps/remoteStorage/WebDAV.php/$ownCloudUser");
|
||||
$server->setBaseUri(OC::$APPSROOT."/apps/remoteStorage/WebDAV.php/$ownCloudUser");
|
||||
|
||||
// Auth backend
|
||||
$authBackend = new OC_Connector_Sabre_Auth_ro_oauth(
|
||||
|
|
18
lib/app.php
18
lib/app.php
|
@ -58,8 +58,8 @@ class OC_App{
|
|||
$apps = OC_Appconfig::getApps();
|
||||
foreach( $apps as $app ){
|
||||
if( self::isEnabled( $app )){
|
||||
if(is_file(OC::$SERVERROOT.'/apps/'.$app.'/appinfo/app.php')){
|
||||
require( 'apps/'.$app.'/appinfo/app.php' );
|
||||
if(is_file(OC::$APPSROOT.'/apps/'.$app.'/appinfo/app.php')){
|
||||
require( $app.'/appinfo/app.php' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -268,7 +268,7 @@ class OC_App{
|
|||
if(is_file($appid)){
|
||||
$file=$appid;
|
||||
}else{
|
||||
$file=OC::$SERVERROOT.'/apps/'.$appid.'/appinfo/info.xml';
|
||||
$file=OC::$APPSROOT.'/apps/'.$appid.'/appinfo/info.xml';
|
||||
if(!is_file($file)){
|
||||
return array();
|
||||
}
|
||||
|
@ -363,9 +363,9 @@ class OC_App{
|
|||
*/
|
||||
public static function getAllApps(){
|
||||
$apps=array();
|
||||
$dh=opendir(OC::$SERVERROOT.'/apps');
|
||||
$dh=opendir(OC::$APPSROOT.'/apps');
|
||||
while($file=readdir($dh)){
|
||||
if(is_file(OC::$SERVERROOT.'/apps/'.$file.'/appinfo/app.php')){
|
||||
if(is_file(OC::$APPSROOT.'/apps/'.$file.'/appinfo/app.php')){
|
||||
$apps[]=$file;
|
||||
}
|
||||
}
|
||||
|
@ -396,11 +396,11 @@ class OC_App{
|
|||
* @param string appid
|
||||
*/
|
||||
public static function updateApp($appid){
|
||||
if(file_exists(OC::$SERVERROOT.'/apps/'.$appid.'/appinfo/database.xml')){
|
||||
OC_DB::updateDbFromStructure(OC::$SERVERROOT.'/apps/'.$appid.'/appinfo/database.xml');
|
||||
if(file_exists(OC::$APPSROOT.'/apps/'.$appid.'/appinfo/database.xml')){
|
||||
OC_DB::updateDbFromStructure(OC::$APPSROOT.'/apps/'.$appid.'/appinfo/database.xml');
|
||||
}
|
||||
if(file_exists(OC::$SERVERROOT.'/apps/'.$appid.'/appinfo/update.php')){
|
||||
include OC::$SERVERROOT.'/apps/'.$appid.'/appinfo/update.php';
|
||||
if(file_exists(OC::$APPSROOT.'/apps/'.$appid.'/appinfo/update.php')){
|
||||
include OC::$APPSROOT.'/apps/'.$appid.'/appinfo/update.php';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
27
lib/base.php
27
lib/base.php
|
@ -62,6 +62,14 @@ class OC{
|
|||
* the root path of the 3rdparty folder for http requests (e.g. owncloud/3rdparty)
|
||||
*/
|
||||
public static $THIRDPARTYWEBROOT = '';
|
||||
/**
|
||||
* The installation path of the apps folder on the server (e.g. /srv/http/owncloud)
|
||||
*/
|
||||
public static $APPSROOT = '';
|
||||
/**
|
||||
* the root path of the apps folder for http requests (e.g. owncloud)
|
||||
*/
|
||||
public static $APPSWEBROOT = '';
|
||||
|
||||
/**
|
||||
* SPL autoload
|
||||
|
@ -179,9 +187,26 @@ class OC{
|
|||
exit;
|
||||
}
|
||||
|
||||
// search the apps folder
|
||||
if(file_exists(OC::$SERVERROOT.'/apps')){
|
||||
OC::$APPSROOT=OC::$SERVERROOT;
|
||||
OC::$APPSWEBROOT=OC::$WEBROOT;
|
||||
}elseif(file_exists(OC::$SERVERROOT.'/../apps')){
|
||||
$url_tmp=explode('/',OC::$WEBROOT);
|
||||
$length=count($url_tmp);
|
||||
unset($url_tmp[$length-1]);
|
||||
OC::$APPSWEBROOT=implode('/',$url_tmp);
|
||||
$root_tmp=explode('/',OC::$SERVERROOT);
|
||||
$length=count($root_tmp);
|
||||
unset($root_tmp[$length-1]);
|
||||
OC::$APPSROOT=implode('/',$root_tmp);
|
||||
}else{
|
||||
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;
|
||||
}
|
||||
|
||||
// set the right include path
|
||||
set_include_path(OC::$SERVERROOT.'/lib'.PATH_SEPARATOR.OC::$SERVERROOT.'/config'.PATH_SEPARATOR.OC::$THIRDPARTYROOT.'/3rdparty'.PATH_SEPARATOR.get_include_path().PATH_SEPARATOR.OC::$SERVERROOT);
|
||||
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.get_include_path().PATH_SEPARATOR.OC::$SERVERROOT);
|
||||
|
||||
// Redirect to installer if not installed
|
||||
if (!OC_Config::getValue('installed', false) && OC::$SUBURI != '/index.php') {
|
||||
|
|
|
@ -39,8 +39,8 @@ class OC_Helper {
|
|||
if( $app != '' ){
|
||||
$app .= '/';
|
||||
// Check if the app is in the app folder
|
||||
if( file_exists( OC::$SERVERROOT . '/apps/'. $app.$file )){
|
||||
$urlLinkTo = OC::$WEBROOT . '/apps/' . $app . $file;
|
||||
if( file_exists( OC::$APPSROOT . '/apps/'. $app.$file )){
|
||||
$urlLinkTo = OC::$APPSWEBROOT . '/apps/' . $app . $file;
|
||||
}
|
||||
else{
|
||||
$urlLinkTo = OC::$WEBROOT . '/' . $app . $file;
|
||||
|
@ -89,8 +89,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::$SERVERROOT."/apps/$app/img/$image" )){
|
||||
return OC::$WEBROOT."/apps/$app/img/$image";
|
||||
}elseif( file_exists( OC::$APPSROOT."/apps/$app/img/$image" )){
|
||||
return OC::$APPSWEBROOT."/apps/$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" )){
|
||||
|
|
|
@ -103,7 +103,7 @@ class OC_Installer{
|
|||
return false;
|
||||
}
|
||||
$info=OC_App::getAppInfo($extractDir.'/appinfo/info.xml');
|
||||
$basedir=OC::$SERVERROOT.'/apps/'.$info['id'];
|
||||
$basedir=OC::$APPSROOT.'/apps/'.$info['id'];
|
||||
|
||||
//check if an app with the same id is already installed
|
||||
if(self::isInstalled( $info['id'] )){
|
||||
|
@ -244,10 +244,10 @@ class OC_Installer{
|
|||
* If $enabled is false, apps are installed as disabled.
|
||||
*/
|
||||
public static function installShippedApps(){
|
||||
$dir = opendir( OC::$SERVERROOT."/apps" );
|
||||
$dir = opendir( OC::$APPSROOT."/apps" );
|
||||
while( false !== ( $filename = readdir( $dir ))){
|
||||
if( substr( $filename, 0, 1 ) != '.' and is_dir(OC::$SERVERROOT."/apps/$filename") ){
|
||||
if( file_exists( OC::$SERVERROOT."/apps/$filename/appinfo/app.php" )){
|
||||
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_Installer::installShippedApp($filename);
|
||||
$enabled = isset($info['default_enable']);
|
||||
|
@ -270,15 +270,15 @@ class OC_Installer{
|
|||
*/
|
||||
public static function installShippedApp($app){
|
||||
//install the database
|
||||
if(is_file(OC::$SERVERROOT."/apps/$app/appinfo/database.xml")){
|
||||
OC_DB::createDbFromStructure(OC::$SERVERROOT."/apps/$app/appinfo/database.xml");
|
||||
if(is_file(OC::$APPSROOT."/apps/$app/appinfo/database.xml")){
|
||||
OC_DB::createDbFromStructure(OC::$APPSROOT."/apps/$app/appinfo/database.xml");
|
||||
}
|
||||
|
||||
//run appinfo/install.php
|
||||
if(is_file(OC::$SERVERROOT."/apps/$app/appinfo/install.php")){
|
||||
include(OC::$SERVERROOT."/apps/$app/appinfo/install.php");
|
||||
if(is_file(OC::$APPSROOT."/apps/$app/appinfo/install.php")){
|
||||
include(OC::$APPSROOT."/apps/$app/appinfo/install.php");
|
||||
}
|
||||
$info=OC_App::getAppInfo(OC::$SERVERROOT."/apps/$app/appinfo/info.xml");
|
||||
$info=OC_App::getAppInfo(OC::$APPSROOT."/apps/$app/appinfo/info.xml");
|
||||
OC_Appconfig::setValue($app,'installed_version',$info['version']);
|
||||
return $info;
|
||||
}
|
||||
|
|
|
@ -243,8 +243,8 @@ class OC_L10N{
|
|||
$i18ndir = OC::$SERVERROOT.'/core/l10n/';
|
||||
if($app != ''){
|
||||
// Check if the app is in the app folder
|
||||
if(file_exists(OC::$SERVERROOT.'/apps/'.$app.'/l10n/')){
|
||||
$i18ndir = OC::$SERVERROOT.'/apps/'.$app.'/l10n/';
|
||||
if(file_exists(OC::$APPSROOT.'/apps/'.$app.'/l10n/')){
|
||||
$i18ndir = OC::$APPSROOT.'/apps/'.$app.'/l10n/';
|
||||
}
|
||||
else{
|
||||
$i18ndir = OC::$SERVERROOT.'/'.$app.'/l10n/';
|
||||
|
|
|
@ -170,39 +170,39 @@ 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::$SERVERROOT."/apps/$app/templates/" )){
|
||||
// Check if the template is overwritten by the selected theme
|
||||
if( file_exists( OC::$SERVERROOT."/themes/$theme/apps/$app/templates/"."$name$fext.php" )){
|
||||
$template = OC::$SERVERROOT."/themes/$theme/apps/$app/templates/"."$name$fext.php";
|
||||
$path = OC::$SERVERROOT."/themes/$theme/apps/$app/templates/";
|
||||
}elseif( file_exists( OC::$SERVERROOT."/themes/$theme/apps/$app/templates/"."$name.php" )){
|
||||
$template = OC::$SERVERROOT."/themes/$theme/apps/$app/templates/"."$name.php";
|
||||
$path = OC::$SERVERROOT."/themes/$theme/apps/$app/templates/";
|
||||
}elseif( OC::$SERVERROOT."/apps/$app/templates/"."$name$fext.php" ){
|
||||
$template = OC::$SERVERROOT."/apps/$app/templates/"."$name$fext.php";
|
||||
$path = OC::$SERVERROOT."/apps/$app/templates/";
|
||||
}else{
|
||||
$template = OC::$SERVERROOT."/apps/$app/templates/"."$name.php";
|
||||
$path = OC::$SERVERROOT."/apps/$app/templates/";
|
||||
}
|
||||
}else{
|
||||
// Check if the template is overwritten by the selected theme
|
||||
if( file_exists( OC::$SERVERROOT."/themes/$theme/$app/templates/"."$name$fext.php" )){
|
||||
$template = OC::$SERVERROOT."/themes/$theme/$app/templates/"."$name$fext.php";
|
||||
$path = OC::$SERVERROOT."/themes/$theme/$app/templates/";
|
||||
}elseif( file_exists( OC::$SERVERROOT."/themes/$theme/$app/templates/"."$name.php" )){
|
||||
$template = OC::$SERVERROOT."/themes/$theme/$app/templates/"."$name.php";
|
||||
$path = OC::$SERVERROOT."/themes/$theme/$app/templates/";
|
||||
}elseif( file_exists( OC::$SERVERROOT."/$app/templates/"."$name$fext.php" )){
|
||||
$template = OC::$SERVERROOT."/$app/templates/"."$name$fext.php";
|
||||
$path = OC::$SERVERROOT."/$app/templates/";
|
||||
}else{
|
||||
$template = OC::$SERVERROOT."/$app/templates/"."$name.php";
|
||||
$path = OC::$SERVERROOT."/$app/templates/";
|
||||
}
|
||||
// Check if the app is in the app folder or in the root
|
||||
if( file_exists( OC::$APPSROOT."/apps/$app/templates/" )){
|
||||
// Check if the template is overwritten by the selected theme
|
||||
if( file_exists( OC::$SERVERROOT."/themes/$theme/apps/$app/templates/"."$name$fext.php" )){
|
||||
$template = OC::$SERVERROOT."/themes/$theme/apps/$app/templates/"."$name$fext.php";
|
||||
$path = OC::$SERVERROOT."/themes/$theme/apps/$app/templates/";
|
||||
}elseif( file_exists( OC::$SERVERROOT."/themes/$theme/apps/$app/templates/"."$name.php" )){
|
||||
$template = OC::$SERVERROOT."/themes/$theme/apps/$app/templates/"."$name.php";
|
||||
$path = OC::$SERVERROOT."/themes/$theme/apps/$app/templates/";
|
||||
}elseif( OC::$APPSROOT."/apps/$app/templates/"."$name$fext.php" ){
|
||||
$template = OC::$APPSROOT."/apps/$app/templates/"."$name$fext.php";
|
||||
$path = OC::$APPSROOT."/apps/$app/templates/";
|
||||
}else{
|
||||
$template = OC::$APPSROOT."/apps/$app/templates/"."$name.php";
|
||||
$path = OC::$APPSROOT."/apps/$app/templates/";
|
||||
}
|
||||
}else{
|
||||
// Check if the template is overwritten by the selected theme
|
||||
if( file_exists( OC::$SERVERROOT."/themes/$theme/$app/templates/"."$name$fext.php" )){
|
||||
$template = OC::$SERVERROOT."/themes/$theme/$app/templates/"."$name$fext.php";
|
||||
$path = OC::$SERVERROOT."/themes/$theme/$app/templates/";
|
||||
}elseif( file_exists( OC::$SERVERROOT."/themes/$theme/$app/templates/"."$name.php" )){
|
||||
$template = OC::$SERVERROOT."/themes/$theme/$app/templates/"."$name.php";
|
||||
$path = OC::$SERVERROOT."/themes/$theme/$app/templates/";
|
||||
}elseif( file_exists( OC::$SERVERROOT."/$app/templates/"."$name$fext.php" )){
|
||||
$template = OC::$SERVERROOT."/$app/templates/"."$name$fext.php";
|
||||
$path = OC::$SERVERROOT."/$app/templates/";
|
||||
}else{
|
||||
$template = OC::$SERVERROOT."/$app/templates/"."$name.php";
|
||||
$path = OC::$SERVERROOT."/$app/templates/";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}else{
|
||||
// Check if the template is overwritten by the selected theme
|
||||
if( file_exists( OC::$SERVERROOT."/themes/$theme/core/templates/"."$name$fext.php" )){
|
||||
|
@ -357,10 +357,10 @@ class OC_Template{
|
|||
$page->append( "jsfiles", OC::$WEBROOT."/themes/$theme/apps/$script.js" );
|
||||
|
||||
// Is it part of an app?
|
||||
}elseif(is_file(OC::$SERVERROOT."/apps/$script$fext.js" )){
|
||||
$page->append( "jsfiles", OC::$WEBROOT."/apps/$script$fext.js" );
|
||||
}elseif(is_file(OC::$SERVERROOT."/apps/$script.js" )){
|
||||
$page->append( "jsfiles", OC::$WEBROOT."/apps/$script.js" );
|
||||
}elseif(is_file(OC::$APPSROOT."/apps/$script$fext.js" )){
|
||||
$page->append( "jsfiles", OC::$APPSWEBROOT."/apps/$script$fext.js" );
|
||||
}elseif(is_file(OC::$APPSROOT."/apps/$script.js" )){
|
||||
$page->append( "jsfiles", OC::$APPSWEBROOT."/apps/$script.js" );
|
||||
|
||||
// Is it in the owncloud root but overwritten by the theme?
|
||||
}elseif(is_file(OC::$SERVERROOT."/themes/$theme/$script$fext.js" )){
|
||||
|
@ -394,10 +394,10 @@ class OC_Template{
|
|||
if(is_file(OC::$THIRDPARTYROOT."/$style.css" )){
|
||||
$page->append( "cssfiles", OC::$THIRDPARTYWEBROOT."/$style.css" );
|
||||
// or in apps?
|
||||
}elseif(is_file(OC::$SERVERROOT."/apps/$style$fext.css" )){
|
||||
$page->append( "cssfiles", OC::$WEBROOT."/apps/$style$fext.css" );
|
||||
}elseif(is_file(OC::$SERVERROOT."/apps/$style.css" )){
|
||||
$page->append( "cssfiles", OC::$WEBROOT."/apps/$style.css" );
|
||||
}elseif(is_file(OC::$APPSROOT."/apps/$style$fext.css" )){
|
||||
$page->append( "cssfiles", OC::$APPSWEBROOT."/apps/$style$fext.css" );
|
||||
}elseif(is_file(OC::$APPSROOT."/apps/$style.css" )){
|
||||
$page->append( "cssfiles", OC::$APPSWEBROOT."/apps/$style.css" );
|
||||
// or in the owncloud root?
|
||||
}elseif(is_file(OC::$SERVERROOT."/$style$fext.css" )){
|
||||
$page->append( "cssfiles", OC::$WEBROOT."/$style$fext.css" );
|
||||
|
|
Loading…
Reference in a new issue