From 4d8ee4bd8d37ec4508dd965a0c48769593c7923b Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Wed, 14 Oct 2015 06:33:24 +0000 Subject: [PATCH] dblayerauthzgroups : allow the user to be provided by auth object directely git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2368 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- dblayerauthzgroups.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/dblayerauthzgroups.php b/dblayerauthzgroups.php index e7ea224..d686d89 100644 --- a/dblayerauthzgroups.php +++ b/dblayerauthzgroups.php @@ -15,6 +15,8 @@ class dblayerauthzgroups extends dblayer public $module = null; /** The user name for authzgroups */ public $user = null; + /** The auth information (email, lastname, firstname) */ + public $auth = null; /** The default group(s) when creating a new object. Can be a string or an array with multiple groups */ public $createGroup = null; @@ -47,6 +49,9 @@ class dblayerauthzgroups extends dblayer { if ($this->module === null) throw new Exception ("No module defined for dblayerauthzgroups", 500); + if ($this->auth !== null && array_key_exists ("email", $this->auth) && + $this->user === null) + $this->user = $this->auth["email"]; if ($this->user === null) throw new Exception ("No user defined for dblayerauthzgroups", 500); if ($this->authzgroups === null) @@ -71,6 +76,9 @@ class dblayerauthzgroups extends dblayer // TODO : If foreign keys, do we check if the access is allowed too ? if ($this->module === null) throw new Exception ("No module defined for dblayerauthzgroups", 500); + if ($this->auth !== null && array_key_exists ("email", $this->auth) && + $this->user === null) + $this->user = $this->auth["email"]; if ($this->user === null) throw new Exception ("No user defined for dblayerauthzgroups", 500); if ($this->authzgroups === null) @@ -103,6 +111,9 @@ class dblayerauthzgroups extends dblayer { if ($this->module === null) throw new Exception ("No module defined for dblayerauthzgroups", 500); + if ($this->auth !== null && array_key_exists ("email", $this->auth) && + $this->user === null) + $this->user = $this->auth["email"]; if ($this->user === null) throw new Exception ("No user defined for dblayerauthzgroups", 500); if ($this->authzgroups === null) @@ -123,6 +134,9 @@ class dblayerauthzgroups extends dblayer { if ($this->module === null) throw new Exception ("No module defined for dblayerauthzgroups", 500); + if ($this->auth !== null && array_key_exists ("email", $this->auth) && + $this->user === null) + $this->user = $this->auth["email"]; if ($this->user === null) throw new Exception ("No user defined for dblayerauthzgroups", 500); if ($this->authzgroups === null) @@ -162,6 +176,9 @@ class dblayerauthzgroups extends dblayer { if ($this->module === null) throw new Exception ("No module defined for dblayerauthzgroups", 500); + if ($this->auth !== null && array_key_exists ("email", $this->auth) && + $this->user === null) + $this->user = $this->auth["email"]; if ($this->user === null) throw new Exception ("No user defined for dblayerauthzgroups", 500); if ($this->authzgroups === null) @@ -181,6 +198,9 @@ class dblayerauthzgroups extends dblayer { if ($this->module === null) throw new Exception ("No module defined for dblayerauthzgroups", 500); + if ($this->auth !== null && array_key_exists ("email", $this->auth) && + $this->user === null) + $this->user = $this->auth["email"]; if ($this->user === null) throw new Exception ("No user defined for dblayerauthzgroups", 500); if ($this->authzgroups === null) @@ -200,6 +220,9 @@ class dblayerauthzgroups extends dblayer { if ($this->module === null) throw new Exception ("No module defined for dblayerauthzgroups", 500); + if ($this->auth !== null && array_key_exists ("email", $this->auth) && + $this->user === null) + $this->user = $this->auth["email"]; if ($this->user === null) throw new Exception ("No user defined for dblayerauthzgroups", 500); if ($this->authzgroups === null) @@ -214,6 +237,9 @@ class dblayerauthzgroups extends dblayer { if ($this->module === null) throw new Exception ("No module defined for dblayerauthzgroups", 500); + if ($this->auth !== null && array_key_exists ("email", $this->auth) && + $this->user === null) + $this->user = $this->auth["email"]; if ($this->user === null) throw new Exception ("No user defined for dblayerauthzgroups", 500); if ($this->authzgroups === null) @@ -249,6 +275,13 @@ class dblayerauthzgroups extends dblayer return $this; } + /** Set the auth property */ + public function authSet ($auth) + { + $this->auth = $auth; + return $this; + } + /** Set the user property */ public function userSet ($user) {