@@ -104,46 +104,37 @@ public function getMemberGroups($user, $vo)
104104 }
105105
106106
107- public function getSpGroups ($ spEntityId, $ vo )
107+ public function getSpGroups ($ spEntityId )
108108 {
109- $ resources = $ this ->connector ->get ('resourcesManager ' , 'getResources ' , array (
110- 'vo ' => $ vo ->getId (),
109+ $ perunAttr = $ this ->connector ->get ('facilitiesManager ' , 'getFacilitiesByAttribute ' , array (
110+ 'attributeName ' => 'urn:perun:facility:attribute-def:def:entityID ' ,
111+ 'attributeValue ' => $ spEntityId ,
112+ ))[0 ];
113+ $ facility = new sspmod_perun_model_Facility ($ perunAttr ['id ' ], $ perunAttr ['name ' ], $ perunAttr ['description ' ], $ spEntityId );
114+
115+ $ perunAttrs = $ this ->connector ->get ('facilitiesManager ' , 'getAssignedResources ' , array (
116+ 'facility ' => $ facility ->getId (),
111117 ));
112118
113- $ spFacilityIds = array ();
114- $ spResources = array ();
115- foreach ($ resources as $ resource ) {
116- if (!array_key_exists ($ resource ['facilityId ' ], $ spFacilityIds )) {
117- $ attribute = $ this ->connector ->get ('attributesManager ' , 'getAttribute ' , array (
118- 'facility ' => $ resource ['facilityId ' ],
119- 'attributeName ' => 'urn:perun:facility:attribute-def:def:entityID ' ,
120- ));
121- if ($ attribute ['value ' ] === $ spEntityId ) {
122- $ spFacilityIds [$ resource ['facilityId ' ]] = true ;
123- } else {
124- $ spFacilityIds [$ resource ['facilityId ' ]] = false ;
125- }
126- }
127- if ($ spFacilityIds [$ resource ['facilityId ' ]]) {
128- array_push ($ spResources , $ resource );
129- }
119+ $ resources = array ();
120+ foreach ($ perunAttrs as $ perunAttr ) {
121+ array_push ($ resources , new sspmod_perun_model_Resource ($ perunAttr ['id ' ], $ perunAttr ['voId ' ], $ perunAttr ['facilityId ' ], $ perunAttr ['name ' ]));
130122 }
131123
132124 $ spGroups = array ();
133- foreach ($ spResources as $ spResource ) {
134- $ groups = $ this -> connector -> get ('resourcesManager ' , 'getAssignedGroups ' , array (
135- 'resource ' => $ spResource [ ' id ' ] ,
125+ foreach ($ resources as $ resource ) {
126+ $ groups = sspmod_perun_RpcConnector:: get ('resourcesManager ' , 'getAssignedGroups ' , array (
127+ 'resource ' => $ resource -> getId () ,
136128 ));
137- $ convertedGroups = array ();
129+
138130 foreach ($ groups as $ group ) {
139131 $ attr = $ this ->connector ->get ('attributesManager ' , 'getAttribute ' , array (
140132 'group ' => $ group ['id ' ],
141133 'attributeName ' => 'urn:perun:group:attribute-def:virt:voShortName '
142134 ));
143135 $ uniqueName = $ attr ['value ' ] . ": " . $ group ['name ' ];
144- array_push ($ convertedGroups , new sspmod_perun_model_Group ($ group ['id ' ], $ group ['voId ' ], $ group ['name ' ], $ uniqueName , $ group ['description ' ]));
136+ array_push ($ spGroups , new sspmod_perun_model_Group ($ group ['id ' ],$ group ['voId ' ], $ group ['name ' ], $ uniqueName , $ group ['description ' ]));
145137 }
146- $ spGroups = array_merge ($ spGroups , $ convertedGroups );
147138 }
148139
149140 $ spGroups = $ this ->removeDuplicateEntities ($ spGroups );
0 commit comments