[icinga-checkins] icinga.org: icinga-web/master: * Fixed principal inheritance

git at icinga.org git at icinga.org
Wed Aug 31 18:08:35 CEST 2011


Module: icinga-web
Branch: master
Commit: e12c66c36749dbc4a535a610a6e8acf97076f5d5
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=e12c66c36749dbc4a535a610a6e8acf97076f5d5

Author: Jannis Moßhammer <jannis.mosshammer at netways.de>
Date:   Fri Aug 26 16:03:59 2011 +0200

* Fixed principal inheritance

---

 app/modules/AppKit/lib/database/models/NsmUser.php |   23 ++++++++++++++-----
 1 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/app/modules/AppKit/lib/database/models/NsmUser.php b/app/modules/AppKit/lib/database/models/NsmUser.php
index 3b9c3da..9b0f1e8 100644
--- a/app/modules/AppKit/lib/database/models/NsmUser.php
+++ b/app/modules/AppKit/lib/database/models/NsmUser.php
@@ -317,7 +317,19 @@ class NsmUser extends BaseNsmUser {
         return $this->principals_list;
     }
 
-
+    private function getRoleIds() {
+        $ids = array();
+        foreach($this->NsmRole as $role) {
+            $ids[] = $role->role_id;
+            while ($role->hasParent()){
+                $role = $role->parent;
+                $ids[] = $role->role_id;        
+            }
+        }
+         
+        return $ids;
+    }
+    
     /**
      * Return all principals belonging to this
      * user
@@ -326,17 +338,16 @@ class NsmUser extends BaseNsmUser {
     public function getPrincipals() {
 
         if ($this->principals === null) {
-
+            $roles = $this->getRoleIds();
             $this->principals = Doctrine_Query::create()
                                 ->select('p.*')
                                 ->from('NsmPrincipal p INDEXBY p.principal_id')
-                                ->leftJoin('p.NsmRole r')
-                                ->leftJoin('r.NsmUserRole ur')
-                                ->andWhere('ur.usro_user_id=? or p.principal_user_id=?', array($this->user_id, $this->user_id))
+                                ->andWhereIn('p.principal_role_id',$roles)
+                                ->orWhere('p.principal_user_id = ?',$this->user_id)
                                 ->execute();
 
         }
-
+        
         return $this->principals;
     }
 





More information about the icinga-checkins mailing list