3 class mw_data_xml_install extends mw_data{
5 function install_xml($params){
9 $host = isset($params["host"]) ? $params["host"] : "";
10 $base = isset($params["base"]) ? $params["base"] : "";
11 $user = isset($params["user"]) ? $params["user"] : "";
12 $password = isset($params["password"]) ? $params["password"] : "";
13 if(!$host || !$base) return "paramètres manquant pour la base XML";
14 $host .= substr($host, -1) == "/" ? "" : "/";
16 $parent_dir = dirname($host);
17 if(is_dir($parent_dir)) @mkdir($host);
18 if(!is_dir($host)) return "impossible de créer le répertoire des données XML";
20 $base_dir = $host.$base;
21 if(!is_dir($base_dir)) @mkdir($base_dir);
22 if(!is_dir($base_dir)) return "impossible de créer le dossier de la base XML";
23 $base .= substr($base, -1) == "/" ? "" : "/";
31 || !$sgbd->select_db($base)
33 return "impossible de se connecter à la base XML";
37 if(!$ERROR && !$EXISTS) $EXISTS = $sgbd->data_exists("actions_roles");
38 $ERROR = !isset($EXISTS);
39 if(!$ERROR && !$EXISTS) $EXISTS = $sgbd->data_exists("config");
40 $ERROR = !isset($EXISTS);
41 if(!$ERROR && !$EXISTS) $EXISTS = $sgbd->data_exists("roles");
42 $ERROR = !isset($EXISTS);
43 if(!$ERROR && !$EXISTS) $EXISTS = $sgbd->data_exists("users");
44 $ERROR = !isset($EXISTS);
45 if(!$ERROR && !$EXISTS) $EXISTS = $sgbd->data_exists("users_roles");
46 $ERROR = !isset($EXISTS);
48 return "impossible de savoir si les tables existent deja";
51 return "des tables a installer existent deja en base. installation annulee";
53 if(!$ERROR) if(!$sgbd->create_data("actions_roles")) $ERROR = true;
54 if(!$ERROR) if(!$sgbd->create_data("config")) $ERROR = true;
55 if(!$ERROR) if(!$sgbd->create_data("roles")) $ERROR = true;
56 if(!$ERROR) if(!$sgbd->create_data("users")) $ERROR = true;
57 if(!$ERROR) if(!$sgbd->create_data("users_roles")) $ERROR = true;
59 return "imposible de creer les tables en base";
62 // ------------------------------------ actions_roles
85 "action" => "users/identification",
100 // ------------------------------------ config
105 "key" => "site_name",
123 "key" => "description",
141 "key" => "start_action",
150 "key" => "contact_form",
177 "key" => "start_action_params",
186 "key" => "out_navig_menu_top",
195 "key" => "out_colonne",
204 "key" => "default_allow",
210 // ------------------------------------ roles
212 $res = $sgbd->add_data(
216 "intitule" => "invité"
220 if(!isset($res)) $ERROR = true;
227 "intitule" => "administrateur"
236 "intitule" => "membre"
244 "nom" => "webmaster",
245 "intitule" => "webmaster"
251 return "les tables ont ete ajoutees en base mais impossible d'y enregistrer les valeurs par defaut.";