コード例 #1
0
 /**
  * @param SimpleXMLElement $xml_element_ugroups
  *
  * @return array
  */
 private function getUgroupsFromXMLToAdd(Project $project, SimpleXMLElement $xml_element_ugroups)
 {
     $ugroups = array();
     $project_members = array();
     $rng_path = realpath(dirname(__FILE__) . '/../xml/resources/ugroups.rng');
     $this->xml_validator->validate($xml_element_ugroups, $rng_path);
     $this->logger->debug("XML Ugroups is valid");
     foreach ($xml_element_ugroups->ugroup as $ugroup) {
         $ugroup_name = (string) $ugroup['name'];
         $ugroup_description = (string) $ugroup['description'];
         $dynamic_ugroup_id = $this->ugroup_manager->getDynamicUGoupIdByName($ugroup_name);
         if ($this->ugroup_manager->getUGroupByName($project, $ugroup_name) && empty($dynamic_ugroup_id)) {
             $this->logger->debug("Ugroup {$ugroup_name} already exists in project -> skipped");
             continue;
         }
         $users = $this->getListOfUgroupMember($ugroup);
         if ($dynamic_ugroup_id == ProjectUGroup::PROJECT_MEMBERS) {
             $project_members = $users;
         } else {
             $ugroups[$ugroup_name]['name'] = $ugroup_name;
             $ugroups[$ugroup_name]['description'] = $ugroup_description;
             $ugroups[$ugroup_name]['users'] = $users;
         }
     }
     return array($ugroups, $project_members);
 }