summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <icewind1991@gmail.com>2010-08-05 02:44:54 +0200
committerRobin Appelman <icewind1991@gmail.com>2010-08-05 02:47:34 +0200
commit5f53165efb10612d6ba1effbf06321ae3c83eb36 (patch)
tree05c12753ff05496cb1112028b37913daf8b79d69
parent8b2ff8dcad92e66fe35edcafbb43a60d20ef19d7 (diff)
downloadnextcloud-server-5f53165efb10612d6ba1effbf06321ae3c83eb36.tar.gz
nextcloud-server-5f53165efb10612d6ba1effbf06321ae3c83eb36.zip
provide a function to load the data from a plugin.xml file
-rw-r--r--inc/lib_base.php3
-rw-r--r--inc/lib_plugin.php110
-rw-r--r--inc/lib_user.php2
-rw-r--r--plugins/music/plugin.xml4
-rw-r--r--plugins/test/plugin.xml4
5 files changed, 97 insertions, 26 deletions
diff --git a/inc/lib_base.php b/inc/lib_base.php
index d11137da307..32d5f17a41a 100644
--- a/inc/lib_base.php
+++ b/inc/lib_base.php
@@ -89,6 +89,9 @@ oc_require_once('lib_plugin.php');
OC_PLUGIN::loadPlugins();
+if(!isset($CONFIG_BACKEND)){
+ $CONFIG_BACKEND='database';
+}
OC_USER::setBackend($CONFIG_BACKEND);
if(!is_dir($CONFIG_DATADIRECTORY_ROOT)){
diff --git a/inc/lib_plugin.php b/inc/lib_plugin.php
index 6c63139b747..c846fe25603 100644
--- a/inc/lib_plugin.php
+++ b/inc/lib_plugin.php
@@ -31,16 +31,10 @@ class OC_PLUGIN{
*/
static public function load($id){
global $SERVERROOT;
- if(is_dir($SERVERROOT.'/plugins/'.$id) and is_file($SERVERROOT.'/plugins/'.$id.'/plugin.xml')){
- $plugin=new DOMDocument();
- $plugin->load($SERVERROOT.'/plugins/'.$id.'/plugin.xml');
- if($plugin->documentElement->getAttribute('version')!=='1.0'){ //we only support this for now
- return false;
- }
- $minVersion=$plugin->getElementsByTagName('require');
- if($minVersion->length>0){
- $minVersion=$minVersion->item(0)->textContent;
- $minVersion=explode('.',$minVersion);
+ $data=self::getPluginData($id);
+ if($data){
+ if(isset($data['info']['require'])){
+ $minVersion=explode('.',$data['info']['require']);
$version=OC_UTIL::getVersion();
$roundTo=count($minVersion);
while(count($version)>$roundTo){
@@ -55,16 +49,8 @@ class OC_PLUGIN{
}
}
}
- $pluginId=$plugin->getElementsByTagName('id')->item(0)->textContent;
- if($pluginId==$id){//sanity check for plugins installed in the wrong folder
- $childs=$plugin->getElementsByTagName('runtime')->item(0)->childNodes;
- foreach($childs as $child){
- if($child->nodeType==XML_ELEMENT_NODE and $child->tagName=='include'){
- $file=$SERVERROOT.'/plugins/'.$id.'/'.$child->textContent;
- include($file);
- }
- }
- return true;
+ foreach($data['runtime'] as $include){
+ include($SERVERROOT.'/plugins/'.$id.'/'.$include);
}
}
return false;
@@ -150,6 +136,90 @@ class OC_PLUGIN{
self::saveBlacklist($blacklist);
}
}
+
+ /**
+ ( Load data from the plugin.xml of a plugin, either identified by the plugin or the path of the plugin.xml file
+ * @param string id
+ *( @return array
+ */
+ public static function getPluginData($id){
+ global $SERVERROOT;
+ if(is_file($id)){
+ $file=$id;
+ }
+ if(!is_dir($SERVERROOT.'/plugins/'.$id) or !is_file($SERVERROOT.'/plugins/'.$id.'/plugin.xml')){
+ return false;
+ }else{
+ $file=$SERVERROOT.'/plugins/'.$id.'/plugin.xml';
+ }
+ $data=array();
+ $plugin=new DOMDocument();
+ $plugin->load($file);
+ $data['version']=$plugin->documentElement->getAttribute('version');
+ $info=$plugin->getElementsByTagName('info');
+ if($info->length>0){
+ $info=$info->item(0);
+ $data['info']=array();
+ foreach($info->childNodes as $child){
+ if($child->nodeType==XML_ELEMENT_NODE){
+ $data['info'][$child->tagName]=$child->textContent;
+ }
+ }
+ }
+ $runtime=$plugin->getElementsByTagName('runtime');
+ if($runtime->length>0){
+ $runtime=$runtime->item(0);
+ $data['runtime']=array();
+ foreach($runtime->childNodes as $child){
+ if($child->nodeType==XML_ELEMENT_NODE and $child->tagName=='include'){
+ $data['runtime'][]=$child->textContent;
+ }
+ }
+ }
+ $install=$plugin->getElementsByTagName('install');
+ if($install->length>0){
+ $install=$install->item(0);
+ $data['install']=array();
+ foreach($install->childNodes as $child){
+ if($child->nodeType==XML_ELEMENT_NODE){
+ $data['install']['include']=array();
+ $data['install']['dialog']=array();
+ $data['install']['database']=array();
+ switch($child->tagName){
+ case 'include':
+ $data['install']['include'][]=$child->textContent;
+ break;
+ case 'dialog':
+ $data['install']['dialog'][]=$child->textContent;
+ break;
+ case 'database':
+ $data['install']['database'][]=$child->textContent;
+ break;
+ }
+ }
+ }
+ }
+ $uninstall=$plugin->getElementsByTagName('uninstall');
+ if($uninstall->length>0){
+ $uninstall=$uninstall->item(0);
+ $data['uninstall']=array();
+ foreach($uninstall->childNodes as $child){
+ if($child->nodeType==XML_ELEMENT_NODE){
+ $data['uninstall']['include']=array();
+ $data['uninstall']['dialog']=array();
+ switch($child->tagName){
+ case 'include':
+ $data['uninstall']['include'][]=$child->textContent;
+ break;
+ case 'dialog':
+ $data['uninstall']['dialog'][]=$child->textContent;
+ break;
+ }
+ }
+ }
+ }
+ return $data;
+ }
}
?>
diff --git a/inc/lib_user.php b/inc/lib_user.php
index 0d9b1c5dda6..73faf77a166 100644
--- a/inc/lib_user.php
+++ b/inc/lib_user.php
@@ -21,7 +21,6 @@
*
*/
-global $CONFIG_BACKEND;
@@ -39,7 +38,6 @@ if ( !isset($_SESSION['group_id_cache']) ) {
$_SESSION['group_id_cache'] = array();
}
-OC_USER::setBackend($CONFIG_BACKEND);
diff --git a/plugins/music/plugin.xml b/plugins/music/plugin.xml
index bac4f5e8e22..2ef3c08343c 100644
--- a/plugins/music/plugin.xml
+++ b/plugins/music/plugin.xml
@@ -1,13 +1,13 @@
<?xml version="1.0"?>
<plugin version='1.0'>
- <meta>
+ <info>
<id>music</id>
<name>Music player for ownCloud</name>
<version>0.1</version>
<licence>AGPL</licence>
<author>2010 Frank Karlitschek karlitschek@kde.org</author>
<require>1.1</require>
- </meta>
+ </info>
<runtime>
<include>lib_music.php</include>
</runtime>
diff --git a/plugins/test/plugin.xml b/plugins/test/plugin.xml
index b666b5bc53c..b9207c27637 100644
--- a/plugins/test/plugin.xml
+++ b/plugins/test/plugin.xml
@@ -1,13 +1,13 @@
<?xml version="1.0"?>
<plugin version='1.0'>
- <meta>
+ <info>
<id>test</id>
<name>Test plugin</name>
<version>0.1</version>
<licence>AGPL</licence>
<author>2010 Frank Karlitschek karlitschek@kde.org</author>
<require>1.1</require>
- </meta>
+ </info>
<runtime>
<include>lib_test.php</include>
</runtime>