示例#1
0
 /**
  * Returns an array of team ids associated with a given team set id
  *
  * @param id $team_set_id
  * @return array of team ids
  */
 public function getTeamIds($team_set_id)
 {
     $teams_arr = TeamSetManager::getUnformattedTeamsFromSet($team_set_id);
     $team_ids = array();
     if (is_array($teams_arr)) {
         foreach ($teams_arr as $team) {
             $team_ids[] = $team['id'];
         }
     }
     return $team_ids;
 }
 /**
  * This function will pull out the various teams in this teamset and return them in a collection
  *
  * {@inheritDoc}
  */
 public function apiFormatField(array &$data, SugarBean $bean, array $args, $fieldName, $properties, array $fieldList = null, ServiceBase $service = null)
 {
     $this->ensureApiFormatFieldArguments($fieldList, $service);
     if (empty($bean->teamList)) {
         require_once 'modules/Teams/TeamSetManager.php';
         $teamList = TeamSetManager::getUnformattedTeamsFromSet($bean->team_set_id);
         if (!is_array($teamList)) {
             // No teams on this bean yet.
             $teamList = array();
         }
     } else {
         $teamList = $bean->teamList;
     }
     foreach ($teamList as $idx => $team) {
         // Check team name as well for cases in which team_name is selected
         // but team_id is not
         if ($team['id'] == $bean->team_id || $team['name'] == $bean->team_name) {
             $teamList[$idx]['primary'] = true;
         } else {
             $teamList[$idx]['primary'] = false;
         }
     }
     $data[$fieldName] = $teamList;
     // These are just confusing to people on the other side of the API
     unset($data['team_set_id']);
     unset($data['team_id']);
 }