/** * 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; }
/** * find CommandSets associated to all the teams i am member of. * (observed teams excluded)) * * @param User $user * @return string[] */ private function getParentCmdSetCandidates(User $user) { $parentCmdSets = array(); $lTeamList = $user->getLeadedTeamList(); $managedTeamList = $user->getManagedTeamList(); $mTeamList = $user->getDevTeamList(); $teamList = $mTeamList + $lTeamList + $managedTeamList; foreach ($teamList as $tid => $name) { $team = TeamCache::getInstance()->getTeam($tid); $cmdsetList = $team->getCommandSetList(); foreach ($cmdsetList as $csid => $cmdset) { $parentCmdSets[$csid] = $cmdset->getName(); } } return $parentCmdSets; }
/** * list the Commands that can be added to this CommandSet. * * This depends on user's teams * @param User $user * @return string[] */ private function getCmdSetCandidates(CommandSet $cmdset, User $user) { $cmdCandidates = array(); $lTeamList = $user->getLeadedTeamList(); $managedTeamList = $user->getManagedTeamList(); $mTeamList = $user->getDevTeamList(); $teamList = $mTeamList + $lTeamList + $managedTeamList; $cmds = $cmdset->getCommands(Command::type_general); foreach ($teamList as $tid => $name) { $team = TeamCache::getInstance()->getTeam($tid); $cmdList = $team->getCommands(); foreach ($cmdList as $cid => $cmd) { // remove Cmds already in this cset. if (!array_key_exists($cid, $cmds)) { $cmdCandidates[$cid] = $cmd->getReference() . " " . $cmd->getName(); } } } asort($cmdCandidates); return $cmdCandidates; }