maj version dans config.xml
[mw_sourceml] / mw_sourceml.php
index 740a25a..66db9de 100644 (file)
@@ -2,15 +2,44 @@
 
   class mw_sourceml extends mw_plugin{
 
-    function title(){
+    public function title(){
       return "SourceML";
     }
 
-    function description(){
+    public function description(){
       return "Publication de sources musicales";
     }
 
-    function init($env){
+    public function loaded($env){
+      $AUTO_ACTIVATE = false;
+      if(!$env->bdd("sgbd") || ($plugin_data = $env->plugin_data("mw_sourceml")) === false) return;
+      if(!isset($plugin_data["installed"]) || !$plugin_data["installed"]){
+        $data = $env->data();
+        $sgbd = $data->sgbd();
+        if($env->bdd("sgbd") == "xml"){
+          $AUTO_ACTIVATE = $sgbd->data_exists("sources");
+        }
+        else{
+          $AUTO_ACTIVATE = $sgbd->table_exists("#--sources");
+        }
+      }
+      if($AUTO_ACTIVATE){
+        if(
+          $env->set_plugin_data(
+            "mw_sourceml",
+            array(
+              "installed" => true,
+              "enabled" => true,
+              "priorite" => 0
+            )
+          )
+        ){
+          $env->load_plugin("mw_sourceml");
+        }
+      }
+    }
+
+    public function init($env){
 
       $env->set_link("admin/sourceml", $env->url("admin/sourceml"), "SourceML", 50);
       $env->set_link("admin/sourceml/licences", $env->url("admin/licences"), "Licences", 10);
@@ -34,7 +63,7 @@
       return true;
     }
 
-    function nb_invitations($env){
+    public function nb_invitations($env){
       if($user = $env->user()){
         $data = $env->data();
         if($groupes = $data->groupes($user["id"])){
@@ -46,7 +75,7 @@
       return 0;
     }
 
-    function enable($env){
+    public function enable($env){
       $data = $env->data();
       if(
             ($data->config("site_name") == "mtweb")
@@ -70,7 +99,7 @@
       return true;
     }
 
-    function install($env){
+    public function install($env){
       $data = $env->data();
       $res = true;
       if(
       return $res;
     }
 
-    function uninstall($env){
+    public function uninstall($env){
       $data = $env->data();
       $res = true;
       if(