/** * list the Commands that can be added to this ServiceContract. * * This depends on user's teams * @param User $user * @return string[] */ private function getCmdSetCandidates(ServiceContract $contract, User $user) { $cmdsetCandidates = array(); $lTeamList = $user->getLeadedTeamList(); $managedTeamList = $user->getManagedTeamList(); $mTeamList = $user->getDevTeamList(); $teamList = $mTeamList + $lTeamList + $managedTeamList; $contractCmdSets = $contract->getCommandSets(CommandSet::type_general); foreach ($teamList as $teamid => $name) { $team = TeamCache::getInstance()->getTeam($teamid); $commandsetList = $team->getCommandSetList(); foreach ($commandsetList as $cid => $cmdset) { // remove CmdSets already in this contract. if (!array_key_exists($cid, $contractCmdSets)) { $cmdsetCandidates[$cid] = $cmdset->getName(); } } } asort($cmdsetCandidates); return $cmdsetCandidates; }