X-Git-Url: http://git.dj3c1t.com/index.cgi?a=blobdiff_plain;f=mw%2Fenv%2Fmodules%2Fmw_env_config.php;h=a9fa106c5a84f35df64cb9c1be31c31f5187b0ec;hb=HEAD;hp=64da6d33eac1e51e3607f7868a333867efbae7e2;hpb=36ed114046cbe3d72a3589230e9f306a54fcc79d;p=mtweb diff --git a/mw/env/modules/mw_env_config.php b/mw/env/modules/mw_env_config.php index 64da6d3..a9fa106 100644 --- a/mw/env/modules/mw_env_config.php +++ b/mw/env/modules/mw_env_config.php @@ -2,14 +2,15 @@ class mw_env_config extends mw_env{ - var $xml_parser; - var $config_file; - var $PATHES; - var $PARAMS; - var $CONFIG; - var $bdd; - - function load_config($bdd, $CONFIG){ + public $xml_parser; + public $config_file; + public $PATHES; + public $PARAMS; + public $CONFIG; + public $bdd; + public $actions; + + public function load_config($bdd, $CONFIG){ if(true){ $this->bdd = $bdd; $this->bdd["table_prefix"] = array(); @@ -34,7 +35,7 @@ else $this->erreur("impossible de trouver le fichier de configuration pour l'installation", true); } - function _load_config($app_config_file, $bdd){ + public function _load_config($app_config_file, $bdd){ $this->xml_parser->parse(file_get_contents($app_config_file)); $app_config = $this->xml_parser->data["config"][0]; if(isset($app_config["subs"]["params"])){ @@ -50,52 +51,92 @@ if(isset($app_config["subs"]["bdd"][0]["subs"]["table_prefix_code"])){ $this->add_table_prefix( array( - $app_config["subs"]["bdd"][0]["subs"]["table_prefix_code"][0]["data"] => $bdd["table_prefix"] + $app_config["subs"]["bdd"][0]["subs"]["table_prefix_code"][0]["data"] => isset($bdd["table_prefix"]) ? $bdd["table_prefix"] : "" ) ); } + if(isset($app_config["subs"]["actions"][0]["subs"]["module"])){ + foreach($app_config["subs"]["actions"][0]["subs"]["module"] as $module_elt){ + $module_name = $module_elt["attrs"]["name"]; + if(!isset($this->actions[$module_name])) $this->actions[$module_name] = array( + "controleurs" => array(), + "module_allowed" => false, + "is_public" => false + ); + if(isset($module_elt["subs"]["controleur"])){ + foreach($module_elt["subs"]["controleur"] as $controleur_elt){ + $controleur_name = $controleur_elt["attrs"]["name"]; + if(!isset($this->actions[$module_name]["controleurs"][$controleur_name])) $this->actions[$module_name]["controleurs"][$controleur_name] = array( + "als" => array(), + "controleur_allowed" => false, + "is_public" => false + ); + if(isset($controleur_elt["subs"]["al"])){ + $al_index = 0; + foreach($controleur_elt["subs"]["al"] as $al_elt){ + $action_title = $al_elt["attrs"]["title"]; + if(isset($al_elt["subs"]["action"])){ + foreach($al_elt["subs"]["action"] as $action_elt){ + if(!isset($this->actions[$module_name]["controleurs"][$controleur_name]["als"][$al_index])){ + $this->actions[$module_name]["controleurs"][$controleur_name]["als"][$al_index] = array( + "title" => $action_title, + "action_allowed" => false, + "is_public" => false, + "actions" => array() + ); + } + $this->actions[$module_name]["controleurs"][$controleur_name]["als"][$al_index]["actions"][] = $action_elt["attrs"]["name"]; + } + } + $al_index++; + } + } + } + } + } + } } - function get_config_file(){ + public function get_config_file(){ return $this->config_file; } - function set_config_file($config_file){ + public function set_config_file($config_file){ $this->config_file = $config_file; } - function get_PATHES(){ + public function get_PATHES(){ return $this->PATHES; } - function path($name){ + public function path($name){ return isset($this->PATHES[$name]) ? $this->PATHES[$name] : ""; } - function set_PATHES($PATHES){ + public function set_PATHES($PATHES){ foreach($PATHES as $path_name => $path_value){ if($path_value && substr($path_value, -1) != "/") $PATHES[$path_name] .= "/"; } $this->PATHES = $PATHES; } - function get_PARAMS(){ + public function get_PARAMS(){ return $this->PARAMS; } - function param($name){ + public function param($name){ return isset($this->PARAMS[$name]) ? $this->PARAMS[$name] : ""; } - function get_CONFIG(){ + public function get_CONFIG(){ return $this->CONFIG; } - function config($name){ + public function config($name){ return isset($this->CONFIG[$name]) ? $this->CONFIG[$name] : null; } - function set_config($config){ + public function set_config($config){ if(is_array($config)){ foreach($config as $key => $value) $this->CONFIG[$key] = $value; return true; @@ -103,19 +144,32 @@ return false; } - function get_bdd(){ + public function get_bdd(){ return $this->bdd; } - function bdd($name){ + public function bdd($name){ return isset($this->bdd[$name]) ? $this->bdd[$name] : null; } - function set_bdd($key, $value){ + public function set_bdd($key, $value){ $this->bdd[$key] = $value; } - function add_table_prefix($table_prefix){ + public function bdd_ready(){ + if(!$this->bdd("sgbd")) return "aucun sgbd defini"; + $data = $this->data(); + if(!$data) return "objet data non defini"; + if(($res = $this->data_upgrade_required()) !== false){ + if($res === true){ + return "la base de donnees doit etre mise a jour"; + } + else return $res; + } + return true; + } + + public function add_table_prefix($table_prefix){ if(is_array($table_prefix)){ foreach($table_prefix as $prefix_code => $prefix) $this->bdd["table_prefix"][$prefix_code] = $prefix; return true; @@ -123,6 +177,8 @@ return false; } - } + public function get_actions(){ + return isset($this->actions) ? $this->actions : array(); + } -?> \ No newline at end of file + }