[icinga-checkins] icinga.org: icinga-web/master: * Fixed user provider not showing hostgroup credentials for root

git at icinga.org git at icinga.org
Mon Nov 21 17:57:32 CET 2011


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

Author: Jannis Mosshammer <jannis.mosshammer at netways.de>
Date:   Mon Nov 21 17:33:28 2011 +0100

* Fixed user provider not showing hostgroup credentials for root

---

 .../DataProvider/UserProviderAction.class.php      |   49 ++++++++++---------
 1 files changed, 26 insertions(+), 23 deletions(-)

diff --git a/app/modules/AppKit/actions/DataProvider/UserProviderAction.class.php b/app/modules/AppKit/actions/DataProvider/UserProviderAction.class.php
index 759da6b..746e0df 100644
--- a/app/modules/AppKit/actions/DataProvider/UserProviderAction.class.php
+++ b/app/modules/AppKit/actions/DataProvider/UserProviderAction.class.php
@@ -23,7 +23,7 @@ class AppKit_DataProvider_UserProviderAction extends AppKitBaseAction {
     public function getCredentials() {
         return array('appkit.admin', 'appkit.admin.users');
     }
-    
+
     private function getUserAsArray(NsmUser $user) {
         return array(
             "id" => $user->user_id,
@@ -38,7 +38,7 @@ class AppKit_DataProvider_UserProviderAction extends AppKitBaseAction {
             "disabled" => $user->user_disabled
         );
     }
-    
+
     private function formatUser(NsmUser $user, $simple = false) {
 
         $userObject = $this->getUserAsArray($user);
@@ -47,7 +47,7 @@ class AppKit_DataProvider_UserProviderAction extends AppKitBaseAction {
         $groups = $user->NsmRole;
         $userObject["roles"] = array();
         foreach($groups as $role) {
-            
+
             $userObject["roles"][] = array(
                 "id" => $role->role_id,
                 "name" => $role->role_name,
@@ -56,21 +56,24 @@ class AppKit_DataProvider_UserProviderAction extends AppKitBaseAction {
             );
         }
 
-        $principals = $user->getPrincipals();
-        
+
+
         $userObject["principals"] = array();
-        foreach($principals as $principal)
-            $targets = $principal->NsmPrincipalTarget;
-            
-            foreach($targets as $t)
-                
-                $userObject["principals"][] = array(
-                    "target" => $t->NsmTarget->toArray(),
-                    "values" => $t->NsmTargetValue->toArray()
-                );
+        $targets = $user->getTargets();
+
+        foreach($targets as $t) {
+            if($t->target_type != "icinga")
+                continue;
+            $userObject["principals"][] = array(
+                "target" => $t->toArray(),
+                "values" => $user->getTargetValues($t->target_name)->toArray()
+
+            );
+        }
+
         return $userObject;
     }
-    
+
     public function executeRead(AgaviRequestDataHolder $rd) {
         $useradmin = $this->getContext()->getModel('UserAdmin', 'AppKit');
         $userId = $rd->getParameter('userId',false);
@@ -86,9 +89,9 @@ class AppKit_DataProvider_UserProviderAction extends AppKitBaseAction {
             else
                 $sort = false;
         }
-        
-        
-        
+
+
+
         $result;
 
         // return a single user when an id is provided
@@ -98,11 +101,11 @@ class AppKit_DataProvider_UserProviderAction extends AppKitBaseAction {
             if (!$user instanceof NsmUser) {
                 return "{}";
             }
-            
+
             $result = $this->formatUser($user);
 
             $this->setAttribute("user", $result);
-            
+
         } else {	//return list of all users if no id is provided
             $users;
 
@@ -120,7 +123,7 @@ class AppKit_DataProvider_UserProviderAction extends AppKitBaseAction {
        }
        return 'Success';
     }
-    
+
     public function executeWrite(AgaviRequestDataHolder $rd) {
         // We need the execute method to work with parameter od the request!
         try {
@@ -162,7 +165,7 @@ class AppKit_DataProvider_UserProviderAction extends AppKitBaseAction {
 
         return 'Success';
     }
-    
+
     public function executeRemove(AgaviRequestDataHolder $rd) {
 
         try {
@@ -189,7 +192,7 @@ class AppKit_DataProvider_UserProviderAction extends AppKitBaseAction {
 
         return 'Success';
     }
-    
+
     public function handleError(AgaviRequestDataHolder $rd) {
         return 'Success';
     }





More information about the icinga-checkins mailing list