From: dj3c1t Date: Mon, 23 Dec 2013 22:01:48 +0000 (+0100) Subject: list_user_roles non bloquant X-Git-Tag: mtweb.0.13.1~1 X-Git-Url: http://git.dj3c1t.com/index.cgi?a=commitdiff_plain;h=0203b41650cb99aa63c69a00432d8a39553f1eb6;p=mtweb list_user_roles non bloquant --- diff --git a/mw/app/data/models/users.php b/mw/app/data/models/users.php index 7a310db..e9eb8ad 100644 --- a/mw/app/data/models/users.php +++ b/mw/app/data/models/users.php @@ -86,7 +86,9 @@ $data = $this->env->data(); if(parent::load($index_name, $index_value) === false) return false; if($this->get_id()){ - if(($this->roles = $data->list_user_roles($this->get_id())) === false) return false; + if(($this->roles = $data->list_user_roles($this->get_id())) === false){ + $this->roles = array(); + } } return true; } diff --git a/mw/app/data/modules/xml/mw_data_xml_users.php b/mw/app/data/modules/xml/mw_data_xml_users.php index 67b6fe4..96dc87d 100644 --- a/mw/app/data/modules/xml/mw_data_xml_users.php +++ b/mw/app/data/modules/xml/mw_data_xml_users.php @@ -99,42 +99,17 @@ } function user_by_id($id){ - if(!isset($this->users)) $this->users = array(); - if(isset($this->users[$id])) return $this->users[$id]; - $sgbd = $this->sgbd(); - if(($user = $sgbd->get_data("users", $id)) !== false){ - $this->users[$id] = $user; - if(($roles = $this->list_user_roles($user["id"])) !== false) $user["roles"] = $roles; - else $user = false; - } - return $user; + $env = $this->env(); + $user = $env->get_model("users"); + if($user->load("id", $id) === false) return false; + return $user->get_values(); } function user($login){ - $sgbd = $this->sgbd(); - $user = array(); - if($rst = $sgbd->open_data("users")){ - while($v_rst = $sgbd->fetch_data($rst)){ - if(isset($v_rst)){ - if(isset($v_rst["login"]) && $v_rst["login"] == $login){ - $user = $v_rst; - break; - } - } - else $user = false; - } - $sgbd->close_data($rst); - if($user){ - if(($roles = $this->list_user_roles($user["id"])) !== false) $user["roles"] = $roles; - else $user = false; - } - } - else $user = false; - if($user !== false){ - if(!isset($this->users)) $this->users = array(); - if($user) $this->users[$user["id"]] = $user; - } - return $user; + $env = $this->env(); + $user = $env->get_model("users"); + if($user->load("login", $login) === false) return false; + return $user->get_values(); } function user_exists($login){