X-Git-Url: http://git.dj3c1t.com/?a=blobdiff_plain;f=app%2Fdata%2Fmodules%2Fxml%2Fsml_data_install.php;fp=app%2Fdata%2Fmodules%2Fxml%2Fsml_data_install.php;h=e3c49a03c287ef0ead991fd3b1cdfd74cb0ae83c;hb=aa56057fe2634113eb8d1a50ed54b6a8988645a8;hp=0000000000000000000000000000000000000000;hpb=7d287d32ecd625ad3c21e9aa2aa122c86f9ec671;p=mw_sourceml diff --git a/app/data/modules/xml/sml_data_install.php b/app/data/modules/xml/sml_data_install.php new file mode 100644 index 0000000..e3c49a0 --- /dev/null +++ b/app/data/modules/xml/sml_data_install.php @@ -0,0 +1,266 @@ +sgbd(); + + $RES = true; + $res = $sgbd->data_exists("sml_authors"); if(isset($res)){ if($res) $RES = 1; } else $RES = -1; + $res = $sgbd->data_exists("sml_classes"); if(isset($res)){ if($res) $RES = 1; } else $RES = -1; + $res = $sgbd->data_exists("sml_licences"); if(isset($res)){ if($res) $RES = 1; } else $RES = -1; + $res = $sgbd->data_exists("sml_sources"); if(isset($res)){ if($res) $RES = 1; } else $RES = -1; + $res = $sgbd->data_exists("sml_sources_access"); if(isset($res)){ if($res) $RES = 1; } else $RES = -1; + $res = $sgbd->data_exists("sml_sources_authors"); if(isset($res)){ if($res) $RES = 1; } else $RES = -1; + $res = $sgbd->data_exists("sml_sources_infos"); if(isset($res)){ if($res) $RES = 1; } else $RES = -1; + $res = $sgbd->data_exists("sml_source_cache"); if(isset($res)){ if($res) $RES = 1; } else $RES = -1; + $res = $sgbd->data_exists("sml_source_compositions"); if(isset($res)){ if($res) $RES = 1; } else $RES = -1; + $res = $sgbd->data_exists("sml_source_derivations"); if(isset($res)){ if($res) $RES = 1; } else $RES = -1; + $res = $sgbd->data_exists("sml_source_documents"); if(isset($res)){ if($res) $RES = 1; } else $RES = -1; + $res = $sgbd->data_exists("sml_sources_invitations"); if(isset($res)){ if($res) $RES = 1; } else $RES = -1; + + if($RES === -1) return "impossible de savoir si les tables existent deja. installation annulee"; + if($RES === 1) return "des tables existent deja en base. installation annulee"; + + if(!($version = $env->version("mw_sourceml"))){ + return "impossible de lire la version de sourceml"; + } + + if(!$sgbd->create_data("sml_authors")) return "impossible de creer la table sml_authors"; + if(!$sgbd->create_data("sml_classes")) return "impossible de creer la table sml_classes"; + if(!$sgbd->create_data("sml_licences")) return "impossible de creer la table sml_licences"; + if(!$sgbd->create_data("sml_sources")) return "impossible de creer la table sml_sources"; + if(!$sgbd->create_data("sml_sources_access")) return "impossible de creer la table sml_sources_access"; + if(!$sgbd->create_data("sml_sources_authors")) return "impossible de creer la table sml_sources_authors"; + if(!$sgbd->create_data("sml_sources_infos")) return "impossible de creer la table sml_sources_infos"; + if(!$sgbd->create_data("sml_source_cache")) return "impossible de creer la table sml_source_cache"; + if(!$sgbd->create_data("sml_source_compositions")) return "impossible de creer la table sml_source_compositions"; + if(!$sgbd->create_data("sml_source_derivations")) return "impossible de creer la table sml_source_derivations"; + if(!$sgbd->create_data("sml_source_documents")) return "impossible de creer la table sml_source_documents"; + if(!$sgbd->create_data("sml_sources_invitations")) return "impossible de creer la table sml_sources_invitations"; + + $ERROR = false; + + // ------------------------------------ sml_licences + + if(!$ERROR) if( + !$sgbd->add_data( + "sml_licences", + array( + "nom" => "Creative commons by-sa 2.0", + "url" => "http://creativecommons.org/licenses/by-sa/2.0/deed.fr" + ) + ) + ) $ERROR = true; + if(!$ERROR) if( + !$sgbd->add_data( + "sml_licences", + array( + "nom" => "Creative Commons by-nc-nd 2.5", + "url" => "http://creativecommons.org/licenses/by-nc-nd/2.5/" + ) + ) + ) $ERROR = true; + if(!$ERROR) if( + !$sgbd->add_data( + "sml_licences", + array( + "nom" => "Creative Commons by-nc-sa 2.5", + "url" => "http://creativecommons.org/licenses/by-nc-sa/2.5/" + ) + ) + ) $ERROR = true; + if(!$ERROR) if( + !$sgbd->add_data( + "sml_licences", + array( + "nom" => "Creative Commons by-nc 2.5", + "url" => "http://creativecommons.org/licenses/by-nc/2.5/" + ) + ) + ) $ERROR = true; + if(!$ERROR) if( + !$sgbd->add_data( + "sml_licences", + array( + "nom" => "Creative Commons by-nd 2.5", + "url" => "http://creativecommons.org/licenses/by-nd/2.5/" + ) + ) + ) $ERROR = true; + if(!$ERROR) if( + !$sgbd->add_data( + "sml_licences", + array( + "nom" => "Creative Commons by-sa 2.5", + "url" => "http://creativecommons.org/licenses/by-sa/2.5/" + ) + ) + ) $ERROR = true; + if(!$ERROR) if( + !$sgbd->add_data( + "sml_licences", + array( + "nom" => "Creative Commons by 2.5", + "url" => "http://creativecommons.org/licenses/by/2.5/" + ) + ) + ) $ERROR = true; + if(!$ERROR) if( + !$sgbd->add_data( + "sml_licences", + array( + "nom" => "Licence Art Libre", + "url" => "http://artlibre.org/licence/lal/" + ) + ) + ) $ERROR = true; + if(!$ERROR) if( + !$sgbd->add_data( + "sml_licences", + array( + "nom" => "Licence C Reaction", + "url" => "http://morne.free.fr/Necktar7/creactionfr.htm" + ) + ) + ) $ERROR = true; + if(!$ERROR) if( + !$sgbd->add_data( + "sml_licences", + array( + "nom" => "Yellow OpenMusic License", + "url" => "http://openmusic.linuxtag.org/yellow.html" + ) + ) + ) $ERROR = true; + if(!$ERROR) if( + !$sgbd->add_data( + "sml_licences", + array( + "nom" => "Green OpenMusic License", + "url" => "http://openmusic.linuxtag.org/green.html" + ) + ) + ) $ERROR = true; + + // ------------------------------------ sml_classes + + if(!$ERROR) if( + !$sgbd->add_data( + "sml_classes", + array( + "nom" => "album" + ) + ) + ) $ERROR = true; + if(!$ERROR) if( + !$sgbd->add_data( + "sml_classes", + array( + "nom" => "morceau" + ) + ) + ) $ERROR = true; + if(!$ERROR) if( + !$sgbd->add_data( + "sml_classes", + array( + "nom" => "piste" + ) + ) + ) $ERROR = true; + + // ------------------------------------ sml_sources_access + + if(!$ERROR) if( + !$sgbd->add_data( + "sml_sources_access", + array( + "nom" => "admin", + "intitule" => "administrateur" + ) + ) + ) $ERROR = true; + if(!$ERROR) if( + !$sgbd->add_data( + "sml_sources_access", + array( + "nom" => "editeur", + "intitule" => "éditeur" + ) + ) + ) $ERROR = true; + if(!$ERROR) if( + !$sgbd->add_data( + "sml_sources_access", + array( + "nom" => "contributeur", + "intitule" => "contributeur" + ) + ) + ) $ERROR = true; + + // ------------------------------------ versions + + if(!$ERROR) if( + !$sgbd->add_data( + "versions", + array( + "application" => "mw_sourceml", + "version" => $version + ) + ) + ) $ERROR = true; + + if($ERROR){ + return "les tables ont ete ajoutees en base mais impossible d'y enregistrer les valeurs par defaut."; + } + + return true; + } + + // --------------------------------------------------------------------------------- + // uninstall + // + + function mw_sourceml_uninstall_xml($plugin, $env){ + $sgbd = $this->sgbd(); + if(!$plugin->disable($env)) return "impossible de desactiver le plugin"; + + $ERROR = false; + + if(!$ERROR) if(!$sgbd->remove_data("sml_authors")) $ERROR = true; + if(!$ERROR) if(!$sgbd->remove_data("sml_classes")) $ERROR = true; + if(!$ERROR) if(!$sgbd->remove_data("sml_licences")) $ERROR = true; + if(!$ERROR) if(!$sgbd->remove_data("sml_sources")) $ERROR = true; + if(!$ERROR) if(!$sgbd->remove_data("sml_sources_access")) $ERROR = true; + if(!$ERROR) if(!$sgbd->remove_data("sml_sources_authors")) $ERROR = true; + if(!$ERROR) if(!$sgbd->remove_data("sml_sources_infos")) $ERROR = true; + if(!$ERROR) if(!$sgbd->remove_data("sml_source_cache")) $ERROR = true; + if(!$ERROR) if(!$sgbd->remove_data("sml_source_compositions")) $ERROR = true; + if(!$ERROR) if(!$sgbd->remove_data("sml_source_derivations")) $ERROR = true; + if(!$ERROR) if(!$sgbd->remove_data("sml_source_documents")) $ERROR = true; + if(!$ERROR) if(!$sgbd->remove_data("sml_sources_invitations")) $ERROR = true; + + if(!$ERROR) if( + !$this->data_delete( + array( + "table_name" => "versions", + "index_name" => "application", + "index_value" => "mw_sourceml" + ) + ) + ) $ERROR = true; + + if($ERROR){ + return "erreur lors de la suppression des tables"; + } + + return true; + } + + }