Merge branch 'master' into oc_error

This commit is contained in:
Georg Ehrke 2012-03-30 18:43:09 +02:00
commit 7e53d82ff3
27 changed files with 177 additions and 67 deletions

View File

@ -7,4 +7,7 @@
<licence>AGPL</licence> <licence>AGPL</licence>
<author>Robin Appelman</author> <author>Robin Appelman</author>
<require>3</require> <require>3</require>
<types>
<filesystem/>
</types>
</info> </info>

View File

@ -7,4 +7,7 @@
<licence>AGPL</licence> <licence>AGPL</licence>
<author>Robin Appelman</author> <author>Robin Appelman</author>
<require>3</require> <require>3</require>
<types>
<filesystem/>
</types>
</info> </info>

View File

@ -0,0 +1,11 @@
<?php
/**
* Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
OC::$CLASSPATH['OC_Filestorage_FTP']='apps/files_external/lib/ftp.php';
OC::$CLASSPATH['OC_Filestorage_DAV']='apps/files_external/lib/webdav.php';
OC::$CLASSPATH['OC_Filestorage_Google']='apps/files_external/lib/google.php';

View File

@ -0,0 +1,13 @@
<?xml version="1.0"?>
<info>
<id>files_external</id>
<name>External storage support</name>
<description>Mount external storage sources</description>
<version>0.1</version>
<licence>AGPL</licence>
<author>Robin Appelman</author>
<require>3</require>
<types>
<filesystem/>
</types>
</info>

View File

@ -12,7 +12,7 @@ class Test_Filestorage_FTP extends Test_FileStorage {
public function setUp(){ public function setUp(){
$id=uniqid(); $id=uniqid();
$this->config=include('apps/files_remote/tests/config.php'); $this->config=include('apps/files_external/tests/config.php');
$this->config['ftp']['root'].='/'.$id;//make sure we have an new empty folder to work in $this->config['ftp']['root'].='/'.$id;//make sure we have an new empty folder to work in
$this->instance=new OC_Filestorage_FTP($this->config['ftp']); $this->instance=new OC_Filestorage_FTP($this->config['ftp']);
} }

View File

@ -27,7 +27,7 @@ class Test_Filestorage_Google extends Test_FileStorage {
public function setUp(){ public function setUp(){
$id=uniqid(); $id=uniqid();
$this->config=include('apps/files_remote/tests/config.php'); $this->config=include('apps/files_external/tests/config.php');
$this->config['google']['root'].='/'.$id;//make sure we have an new empty folder to work in $this->config['google']['root'].='/'.$id;//make sure we have an new empty folder to work in
$this->instance=new OC_Filestorage_Google($this->config['google']); $this->instance=new OC_Filestorage_Google($this->config['google']);
} }
@ -35,4 +35,4 @@ class Test_Filestorage_Google extends Test_FileStorage {
public function tearDown(){ public function tearDown(){
$this->instance->rmdir('/'); $this->instance->rmdir('/');
} }
} }

View File

@ -12,7 +12,7 @@ class Test_Filestorage_DAV extends Test_FileStorage {
public function setUp(){ public function setUp(){
$id=uniqid(); $id=uniqid();
$this->config=include('apps/files_remote/tests/config.php'); $this->config=include('apps/files_external/tests/config.php');
$this->config['webdav']['root'].='/'.$id;//make sure we have an new empty folder to work in $this->config['webdav']['root'].='/'.$id;//make sure we have an new empty folder to work in
$this->instance=new OC_Filestorage_DAV($this->config['webdav']); $this->instance=new OC_Filestorage_DAV($this->config['webdav']);
} }

View File

@ -1,11 +0,0 @@
<?php
/**
* Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
OC::$CLASSPATH['OC_Filestorage_FTP']='apps/files_remote/lib/ftp.php';
OC::$CLASSPATH['OC_Filestorage_DAV']='apps/files_remote/lib/webdav.php';
OC::$CLASSPATH['OC_Filestorage_Google']='apps/files_remote/lib/google.php';

View File

@ -1,10 +0,0 @@
<?xml version="1.0"?>
<info>
<id>files_remote</id>
<name>Remote storage support</name>
<description>Mount remote storage sources</description>
<version>0.1</version>
<licence>AGPL</licence>
<author>Robin Appelman</author>
<require>3</require>
</info>

View File

@ -8,4 +8,7 @@
<author>Michael Gapczynski</author> <author>Michael Gapczynski</author>
<require>2</require> <require>2</require>
<default_enable/> <default_enable/>
<types>
<filesystem/>
</types>
</info> </info>

View File

@ -32,14 +32,14 @@ $l = new OC_L10N('gallery');
OC_App::register(array( OC_App::register(array(
'order' => 20, 'order' => 20,
'id' => 'gallery', 'id' => 'gallery',
'name' => 'Gallery')); 'name' => 'Pictures'));
OC_App::addNavigationEntry( array( OC_App::addNavigationEntry( array(
'id' => 'gallery_index', 'id' => 'gallery_index',
'order' => 20, 'order' => 20,
'href' => OC_Helper::linkTo('gallery', 'index.php'), 'href' => OC_Helper::linkTo('gallery', 'index.php'),
'icon' => OC_Helper::imagePath('core', 'places/picture.svg'), 'icon' => OC_Helper::imagePath('core', 'places/picture.svg'),
'name' => $l->t('Gallery'))); 'name' => $l->t('Pictures')));
class OC_GallerySearchProvider implements OC_Search_Provider{ class OC_GallerySearchProvider implements OC_Search_Provider{
static function search($query){ static function search($query){

View File

@ -1,11 +1,11 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<info> <info>
<id>gallery</id> <id>gallery</id>
<name>Gallery</name> <name>Pictures</name>
<version>0.4</version> <version>0.4</version>
<licence>AGPL</licence> <licence>AGPL</licence>
<author>Bartek Przybylski</author> <author>Bartek Przybylski</author>
<require>2</require> <require>2</require>
<description>Gallery application for ownCloud</description> <description>Dedicated pictures application</description>
<default_enable/> <default_enable/>
</info> </info>

View File

@ -2,7 +2,7 @@
<info> <info>
<id>remoteStorage</id> <id>remoteStorage</id>
<name>remoteStorage compatibility</name> <name>remoteStorage compatibility</name>
<description>Enables your users to use ownCloud as their remote storage for unhosted applications.</description> <description>Enables you to use ownCloud as their remote storage for unhosted applications. This app requires the Webfinger app to be enabled as well. More info on <a href="http://unhosted.org">the website of the unhosted movement</a>.</description>
<version>0.5</version> <version>0.5</version>
<licence>AGPL or MIT</licence> <licence>AGPL or MIT</licence>
<author>Michiel de Jong</author> <author>Michiel de Jong</author>

View File

@ -64,6 +64,15 @@
<length>512</length> <length>512</length>
</field> </field>
<field>
<name>path_hash</name>
<type>text</type>
<default>
</default>
<notnull>true</notnull>
<length>32</length>
</field>
<field> <field>
<name>parent</name> <name>parent</name>
<type>integer</type> <type>integer</type>
@ -79,7 +88,7 @@
<default> <default>
</default> </default>
<notnull>true</notnull> <notnull>true</notnull>
<length>512</length> <length>300</length>
</field> </field>
<field> <field>
@ -159,14 +168,13 @@
<length>1</length> <length>1</length>
</field> </field>
<!--<index> <index>
<name>fscache_path_index</name> <name>fscache_path_hash_index</name>
<unique>true</unique>
<field> <field>
<name>path</name> <name>path_hash</name>
<sorting>ascending</sorting> <sorting>ascending</sorting>
</field> </field>
</index>--> </index>
<index> <index>
<name>parent_index</name> <name>parent_index</name>
@ -176,6 +184,14 @@
</field> </field>
</index> </index>
<index>
<name>name_index</name>
<field>
<name>name</name>
<sorting>ascending</sorting>
</field>
</index>
<index> <index>
<name>parent_name_index</name> <name>parent_name_index</name>
<field> <field>

View File

@ -21,6 +21,9 @@
* *
*/ */
// only need filesystem apps
$RUNTIME_APPTYPES=array('filesystem');
// Init owncloud // Init owncloud
require_once('../../lib/base.php'); require_once('../../lib/base.php');

View File

@ -1,5 +1,8 @@
<?php <?php
// only need filesystem apps
$RUNTIME_APPTYPES=array('filesystem');
// Init owncloud // Init owncloud
require_once('../../lib/base.php'); require_once('../../lib/base.php');

View File

@ -1,5 +1,8 @@
<?php <?php
// no need for apps
$RUNTIME_NOAPPS=false;
// Init owncloud // Init owncloud
require_once('../../lib/base.php'); require_once('../../lib/base.php');

View File

@ -26,6 +26,9 @@
// Do not load FS ... // Do not load FS ...
$RUNTIME_NOSETUPFS = true; $RUNTIME_NOSETUPFS = true;
// only need filesystem apps
$RUNTIME_APPTYPES=array('filesystem');
require_once('../lib/base.php'); require_once('../lib/base.php');
// Backends // Backends

View File

@ -34,16 +34,20 @@ class OC_App{
static private $settingsForms = array(); static private $settingsForms = array();
static private $adminForms = array(); static private $adminForms = array();
static private $personalForms = array(); static private $personalForms = array();
static private $appInfo = array();
/** /**
* @brief loads all apps * @brief loads all apps
* @param array $types
* @returns true/false * @returns true/false
* *
* This function walks through the owncloud directory and loads all apps * This function walks through the owncloud directory and loads all apps
* it can find. A directory contains an app if the file /appinfo/app.php * it can find. A directory contains an app if the file /appinfo/app.php
* exists. * exists.
*
* if $types is set, only apps of those types will be loaded
*/ */
public static function loadApps(){ public static function loadApps($types=null){
// Did we allready load everything? // Did we allready load everything?
if( self::$init ){ if( self::$init ){
return true; return true;
@ -51,13 +55,15 @@ class OC_App{
// Our very own core apps are hardcoded // Our very own core apps are hardcoded
foreach( array('files', 'settings') as $app ){ foreach( array('files', 'settings') as $app ){
require( $app.'/appinfo/app.php' ); if(is_null($types) or self::isType($app,$types)){
require( $app.'/appinfo/app.php' );
}
} }
// The rest comes here // The rest comes here
$apps = OC_Appconfig::getApps(); $apps = self::getEnabledApps();
foreach( $apps as $app ){ foreach( $apps as $app ){
if( self::isEnabled( $app )){ if(is_null($types) or self::isType($app,$types)){
if(is_file(OC::$APPSROOT.'/apps/'.$app.'/appinfo/app.php')){ if(is_file(OC::$APPSROOT.'/apps/'.$app.'/appinfo/app.php')){
require( $app.'/appinfo/app.php' ); require( $app.'/appinfo/app.php' );
} }
@ -70,6 +76,41 @@ class OC_App{
return true; return true;
} }
/**
* check if an app is of a sepcific type
* @param string $app
* @param string/array $types
*/
public static function isType($app,$types){
if(is_string($types)){
$types=array($types);
}
$appData=self::getAppInfo($app);
if(!isset($appData['types'])){
return false;
}
$appTypes=$appData['types'];
foreach($types as $type){
if(array_search($type,$appTypes)!==false){
return true;
}
}
return false;
}
/**
* get all enabled apps
*/
public static function getEnabledApps(){
$apps=array();
$query = OC_DB::prepare( 'SELECT appid FROM *PREFIX*appconfig WHERE configkey = "enabled" AND configvalue="yes"' );
$query->execute();
while($row=$query->fetchRow()){
$apps[]=$row['appid'];
}
return $apps;
}
/** /**
* @brief checks whether or not an app is enabled * @brief checks whether or not an app is enabled
* @param $app app * @param $app app
@ -265,24 +306,36 @@ class OC_App{
/** /**
* @brief Read app metadata from the info.xml file * @brief Read app metadata from the info.xml file
* @param string $appid id of the app or the path of the info.xml file * @param string $appid id of the app or the path of the info.xml file
* @param boolean path (optional)
* @returns array * @returns array
*/ */
public static function getAppInfo($appid){ public static function getAppInfo($appid,$path=false){
if(is_file($appid)){ if($path){
$file=$appid; $file=$appid;
}else{ }else{
$file=OC::$APPSROOT.'/apps/'.$appid.'/appinfo/info.xml'; if(isset(self::$appInfo[$appid])){
if(!is_file($file)){ return self::$appInfo[$appid];
return array();
} }
$file=OC::$APPSROOT.'/apps/'.$appid.'/appinfo/info.xml';
} }
$data=array(); $data=array();
$content=file_get_contents($file); $content=file_get_contents($file);
if(!$content){
return;
}
$xml = new SimpleXMLElement($content); $xml = new SimpleXMLElement($content);
$data['info']=array(); $data['info']=array();
foreach($xml->children() as $child){ foreach($xml->children() as $child){
$data[$child->getName()]=(string)$child; if($child->getName()=='types'){
$data['types']=array();
foreach($child->children() as $type){
$data['types'][]=$type->getName();
}
}else{
$data[$child->getName()]=(string)$child;
}
} }
self::$appInfo[$appid]=$data;
return $data; return $data;
} }
@ -381,9 +434,8 @@ class OC_App{
*/ */
public static function updateApps(){ public static function updateApps(){
// The rest comes here // The rest comes here
$apps = OC_Appconfig::getApps(); $versions = self::getAppVersions();
foreach( $apps as $app ){ foreach( $versions as $app=>$installedVersion ){
$installedVersion=OC_Appconfig::getValue($app,'installed_version');
$appInfo=OC_App::getAppInfo($app); $appInfo=OC_App::getAppInfo($app);
if (isset($appInfo['version'])) { if (isset($appInfo['version'])) {
$currentVersion=$appInfo['version']; $currentVersion=$appInfo['version'];
@ -395,6 +447,19 @@ class OC_App{
} }
} }
/**
* get the installed version of all papps
*/
public static function getAppVersions(){
$versions=array();
$query = OC_DB::prepare( 'SELECT appid, configvalue FROM *PREFIX*appconfig WHERE configkey = "installed_version"' );
$result = $query->execute();
while($row = $result->fetchRow()){
$versions[$row['appid']]=$row['configvalue'];
}
return $versions;
}
/** /**
* update the database for the app and call the update script * update the database for the app and call the update script
* @param string appid * @param string appid

View File

@ -333,8 +333,13 @@ class OC{
// Load Apps // Load Apps
// This includes plugins for users and filesystems as well // This includes plugins for users and filesystems as well
global $RUNTIME_NOAPPS; global $RUNTIME_NOAPPS;
global $RUNTIME_APPTYPES;
if(!$RUNTIME_NOAPPS ){ if(!$RUNTIME_NOAPPS ){
OC_App::loadApps(); if($RUNTIME_APPTYPES){
OC_App::loadApps($RUNTIME_APPTYPES);
}else{
OC_App::loadApps();
}
} }
//make sure temporary files are cleaned up //make sure temporary files are cleaned up

View File

@ -59,8 +59,8 @@ class OC_FileCache{
$root=''; $root='';
} }
$path=$root.$path; $path=$root.$path;
$query=OC_DB::prepare('SELECT ctime,mtime,mimetype,size,encrypted,versioned,writable FROM *PREFIX*fscache WHERE path=?'); $query=OC_DB::prepare('SELECT ctime,mtime,mimetype,size,encrypted,versioned,writable FROM *PREFIX*fscache WHERE path_hash=?');
$result=$query->execute(array($path))->fetchRow(); $result=$query->execute(array(md5($path)))->fetchRow();
if(is_array($result)){ if(is_array($result)){
return $result; return $result;
}else{ }else{
@ -111,8 +111,8 @@ class OC_FileCache{
} }
$mimePart=dirname($data['mimetype']); $mimePart=dirname($data['mimetype']);
$user=OC_User::getUser(); $user=OC_User::getUser();
$query=OC_DB::prepare('INSERT INTO *PREFIX*fscache(parent, name, path, size, mtime, ctime, mimetype, mimepart,user,writable,encrypted,versioned) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)'); $query=OC_DB::prepare('INSERT INTO *PREFIX*fscache(parent, name, path, path_hash, size, mtime, ctime, mimetype, mimepart,user,writable,encrypted,versioned) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)');
$result=$query->execute(array($parent,basename($path),$path,$data['size'],$data['mtime'],$data['ctime'],$data['mimetype'],$mimePart,$user,$data['writable'],$data['encrypted'],$data['versioned'])); $result=$query->execute(array($parent,basename($path),$path,md5($path),$data['size'],$data['mtime'],$data['ctime'],$data['mimetype'],$mimePart,$user,$data['writable'],$data['encrypted'],$data['versioned']));
if(OC_DB::isError($result)){ if(OC_DB::isError($result)){
OC_Log::write('files','error while writing file('.$path.') to cache',OC_Log::ERROR); OC_Log::write('files','error while writing file('.$path.') to cache',OC_Log::ERROR);
} }
@ -162,8 +162,8 @@ class OC_FileCache{
$oldPath=$root.$oldPath; $oldPath=$root.$oldPath;
$newPath=$root.$newPath; $newPath=$root.$newPath;
$newParent=self::getParentId($newPath); $newParent=self::getParentId($newPath);
$query=OC_DB::prepare('UPDATE *PREFIX*fscache SET parent=? ,name=?, path=? WHERE path=?'); $query=OC_DB::prepare('UPDATE *PREFIX*fscache SET parent=? ,name=?, path=?, path_hash=? WHERE path_hash=?');
$query->execute(array($newParent,basename($newPath),$newPath,$oldPath)); $query->execute(array($newParent,basename($newPath),$newPath,md5($newPath),md5($oldPath)));
} }
/** /**
@ -285,12 +285,12 @@ class OC_FileCache{
* @return int * @return int
*/ */
private static function getFileId($path){ private static function getFileId($path){
$query=OC_DB::prepare('SELECT id FROM *PREFIX*fscache WHERE path=?'); $query=OC_DB::prepare('SELECT id FROM *PREFIX*fscache WHERE path_hash=?');
if(OC_DB::isError($query)){ if(OC_DB::isError($query)){
OC_Log::write('files','error while getting file id of '.$path,OC_Log::ERROR); OC_Log::write('files','error while getting file id of '.$path,OC_Log::ERROR);
return -1; return -1;
} }
$result=$query->execute(array($path)); $result=$query->execute(array(md5($path)));
if(OC_DB::isError($result)){ if(OC_DB::isError($result)){
OC_Log::write('files','error while getting file id of '.$path,OC_Log::ERROR); OC_Log::write('files','error while getting file id of '.$path,OC_Log::ERROR);
return -1; return -1;
@ -367,8 +367,8 @@ class OC_FileCache{
} }
} }
$path=$root.$path; $path=$root.$path;
$query=OC_DB::prepare('SELECT ctime,mtime,mimetype,size,encrypted,versioned,writable FROM *PREFIX*fscache WHERE path=?'); $query=OC_DB::prepare('SELECT ctime,mtime,mimetype,size,encrypted,versioned,writable FROM *PREFIX*fscache WHERE path_hash=?');
$result=$query->execute(array($path))->fetchRow(); $result=$query->execute(array(md5($path)))->fetchRow();
if(is_array($result)){ if(is_array($result)){
if(isset(self::$savedData[$path])){ if(isset(self::$savedData[$path])){
$result=array_merge($result,self::$savedData[$path]); $result=array_merge($result,self::$savedData[$path]);
@ -389,8 +389,8 @@ class OC_FileCache{
} }
} }
$path=$root.$path; $path=$root.$path;
$query=OC_DB::prepare('SELECT size FROM *PREFIX*fscache WHERE path=?'); $query=OC_DB::prepare('SELECT size FROM *PREFIX*fscache WHERE path_hash=?');
$result=$query->execute(array($path)); $result=$query->execute(array(md5($path)));
if($row=$result->fetchRow()){ if($row=$result->fetchRow()){
return $row['size']; return $row['size'];
}else{//file not in cache }else{//file not in cache
@ -579,8 +579,8 @@ class OC_FileCache{
$mtime=$view->filemtime($path); $mtime=$view->filemtime($path);
$isDir=$view->is_dir($path); $isDir=$view->is_dir($path);
$path=$root.$path; $path=$root.$path;
$query=OC_DB::prepare('SELECT mtime FROM *PREFIX*fscache WHERE path=?'); $query=OC_DB::prepare('SELECT mtime FROM *PREFIX*fscache WHERE path_hash=?');
$result=$query->execute(array($path)); $result=$query->execute(array(md5($path)));
if($row=$result->fetchRow()){ if($row=$result->fetchRow()){
$cachedMTime=$row['mtime']; $cachedMTime=$row['mtime'];
return ($mtime>$cachedMTime); return ($mtime>$cachedMTime);

View File

@ -123,7 +123,7 @@ class OC_Installer{
} }
return false; return false;
} }
$info=OC_App::getAppInfo($extractDir.'/appinfo/info.xml'); $info=OC_App::getAppInfo($extractDir.'/appinfo/info.xml',true);
$basedir=OC::$APPSROOT.'/apps/'.$info['id']; $basedir=OC::$APPSROOT.'/apps/'.$info['id'];
//check if an app with the same id is already installed //check if an app with the same id is already installed
@ -296,7 +296,7 @@ class OC_Installer{
if(is_file(OC::$APPSROOT."/apps/$app/appinfo/install.php")){ if(is_file(OC::$APPSROOT."/apps/$app/appinfo/install.php")){
include(OC::$APPSROOT."/apps/$app/appinfo/install.php"); include(OC::$APPSROOT."/apps/$app/appinfo/install.php");
} }
$info=OC_App::getAppInfo(OC::$APPSROOT."/apps/$app/appinfo/info.xml"); $info=OC_App::getAppInfo($app);
OC_Appconfig::setValue($app,'installed_version',$info['version']); OC_Appconfig::setValue($app,'installed_version',$info['version']);
return $info; return $info;
} }

View File

@ -66,7 +66,7 @@ class OC_Util {
* @return array * @return array
*/ */
public static function getVersion(){ public static function getVersion(){
return array(3,00,3); return array(3,00,4);
} }
/** /**