/** * Format the display to be similiar to what we do in a listview * Difference is since we already have the team_set_id we will grab all of the teams and not do an ajax request like * we do in a list view. * @param string $cell */ function &displayListPlain($layout_def) { $value = $this->_get_list_value($layout_def); if (!empty($value)) { $teams = TeamSetManager::getTeamsFromSet($value); if (!empty($teams)) { if (!empty($teams[0]['display_name'])) { $result = $teams[0]['display_name']; if (!empty($_REQUEST['to_csv']) || !empty($_REQUEST['to_pdf'])) { // if for csv export, we don't generate html $result = ''; foreach ($teams as $row) { $result .= $row['display_name'] . ", "; } //get rid of the trailing comma $result = substr($result, 0, -2); } else { $body = ''; foreach ($teams as $row) { $body .= $row['display_name'] . '<br/>'; } $result .= " <a href=\"#\" style='text-decoration:none;' id='more_feather' onclick=\"SUGAR.utils.showHelpTips(this,'" . $body . "')\" >+</a>"; } return $result; } else { return ''; } } else { return ''; } } else { return ''; } }
function setup() { $this->related_module = 'Teams'; $this->value_name = 'team_set_id_values'; $this->vardef['name'] = $this->name; $secondaries = array(); $primary = false; $this->bean->{$this->value_name} = array('role_field' => 'team_name'); if (!empty($this->bean->team_set_id)) { require_once 'modules/Teams/TeamSetManager.php'; $teams = TeamSetManager::getTeamsFromSet($this->bean->team_set_id); foreach ($teams as $row) { if (empty($primary) && $this->bean->team_id == $row['id']) { $this->bean->{$this->value_name} = array_merge($this->bean->{$this->value_name}, array('primary' => array('id' => $row['id'], 'name' => $row['display_name']))); $primary = true; } else { $secondaries['secondaries'][] = array('id' => $row['id'], 'name' => $row['display_name']); } } //foreach } $this->bean->{$this->value_name} = array_merge($this->bean->{$this->value_name}, $secondaries); $this->skipModuleQuickSearch = true; $this->showSelectButton = false; }
public function action_DisplayInlineTeams() { $this->view = 'ajax'; $body = ''; $primary_team_id = isset($_REQUEST['team_id']) ? $_REQUEST['team_id'] : ''; $caption = ''; if (!empty($_REQUEST['team_set_id'])) { require_once 'modules/Teams/TeamSetManager.php'; $teams = TeamSetManager::getTeamsFromSet($_REQUEST['team_set_id']); foreach ($teams as $row) { if ($row['id'] == $primary_team_id) { $body = $row['display_name'] . '*<br/>' . $body; } else { $body .= $row['display_name'] . '<br/>'; } } } global $theme; $json = getJSONobj(); $retArray = array(); $retArray['body'] = $body; $retArray['caption'] = $caption; $retArray['width'] = '100'; $retArray['theme'] = $theme; echo 'result = ' . $json->encode($retArray); }
/** * Returns an array of teams from a team set id * * @param string $teamSetId UUID from SugarCRM. * * @return array List of teams with metadata */ public function getTeamsFromTeamSet($teamSetId) { require_once 'modules/Teams/TeamSetManager.php'; $teams = \TeamSetManager::getTeamsFromSet($teamSetId); // Fetch more details from the team foreach ($teams as $key => $team) { $teamFields = $this->sugarBean->getBean('Teams', $team['id'])->fetched_row; $teams[$key] = array_merge($team, $teamFields); } return $teams; }
break; default: display_field_value($mergeBeanArray[$id]->{$field_array}['name']); $field_name = "main." . $section_name . ".merge_cell_field_value"; break; } $json_data = array('field_name' => $field_array['name'], 'field_type' => $field_check); //add an array of fields/values to the json array //for setting all the values for merge if ($field_check == 'relate' or $field_check == 'link') { $temp_array = array(); $json_data['popup_fields'] = array($field_array['name'] => $mergeBeanArray[$id]->{$field_array}['name'], $field_array['id_name'] => $mergeBeanArray[$id]->{$field_array}['id_name']); } else { if ($field_check == 'teamset') { $json_data['field_value'] = TeamSetManager::getCommaDelimitedTeams($mergeBeanArray[$id]->team_set_id, $mergeBeanArray[$id]->team_id, true); $json_data['field_value2'] = TeamSetManager::getTeamsFromSet($mergeBeanArray[$id]->team_set_id); $json_data['field_value3'] = $mergeBeanArray[$id]->team_set_id; } else { if ($field_check == 'multienum') { $json_data['field_value'] = unencodeMultienum($mergeBeanArray[$id]->{$field_array}['name']); } else { $json_data['field_value'] = $mergeBeanArray[$id]->{$field_array}['name']; } } } $encoded_json_data = $json->encode($json_data); $xtpl->assign('ENCODED_JSON_DATA', $encoded_json_data); $xtpl->parse($field_name); } $xtpl->parse("main." . $section_name); $field_count++;
/** * Handles the special-cased `team_set_id` field when fetching rows for the * Audit Log API. It is needed in order to prevent processing this field as * type `relate`. * * @param array $row A row of database-queried audit table results. * @return array The API-formatted $row. */ protected function handleTeamSetField($row = array()) { if (empty($row)) { return $row; } $row['field_name'] = 'team_name'; require_once 'modules/Teams/TeamSetManager.php'; $row['before_value_string'] = TeamSetManager::getTeamsFromSet($row['before_value_string']); $row['after_value_string'] = TeamSetManager::getTeamsFromSet($row['after_value_string']); $row = $this->formatRowForApi($row); return $row; }
function get_list_view_data() { global $mod_strings; $temp_array = $this->get_list_view_array(); $temp_array['ENCODED_NAME'] = $this->name; $this->load_relationship('teams'); require_once 'modules/Teams/TeamSetManager.php'; $teams = TeamSetManager::getTeamsFromSet($this->team_set_id); if (count($teams) > 1) { $temp_array['TEAM_NAME'] .= "<span id='div_{$this->id}_teams'>\n\t\t\t\t\t\t<a href=\"#\" onMouseOver=\"javascript:toggleMore('div_{$this->id}_teams','img_{$this->id}_teams', 'Teams', 'DisplayInlineTeams', 'team_set_id={$this->team_set_id}&team_id={$this->team_id}');\" onFocus=\"javascript:toggleMore('div_{$this->id}_teams','img_{$this->id}_teams', 'Teams', 'DisplayInlineTeams', 'team_set_id={$this->team_set_id}');\" id='more_feather' class=\"utilsLink\">\n\t\t\t\t\t " . SugarThemeRegistry::current()->getImage('MoreDetail', "style='padding: 0px 0px 0px 0px' border='0'", 8, 7, ".png", $mod_strings['LBL_MORE_DETAIL']) . "\n\t\t\t\t\t\t</a>\n\t\t\t\t\t\t</span>"; } return $temp_array; }
/** * Returns all the user data to be sent in the REST API call for a normal * `/me` call. * * This data is dependent on the platform used. Each own platform has a * different data set to be sent in the response. * * @param string $platform The platform of the request. * @param array $options A list of options like `category` to retrieve the * basic user info. Will use `global` if no `category` is supplied. * @return array The user's data to be used in a `/me` request. */ protected function getUserData($platform, array $options) { $current_user = $this->getUserBean(); // Get the basics $category = isset($options['category']) ? $options['category'] : 'global'; $user_data = $this->getBasicUserInfo($platform, $category); // Fill in the rest $user_data['type'] = self::TYPE_USER; if ($current_user->isAdmin()) { $user_data['type'] = self::TYPE_ADMIN; } $user_data['show_wizard'] = $this->shouldShowWizard($category); $user_data['id'] = $current_user->id; $current_user->_create_proper_name_field(); $user_data['full_name'] = $current_user->full_name; $user_data['user_name'] = $current_user->user_name; $user_data['roles'] = ACLRole::getUserRoles($current_user->id); $user_data = $this->setExpiredPassword($user_data); $user_data['picture'] = $current_user->picture; $user_data['acl'] = $this->getAcls($platform); $user_data['is_manager'] = User::isManager($current_user->id); $user_data['is_top_level_manager'] = false; $user_data['reports_to_id'] = $current_user->reports_to_id; $user_data['reports_to_name'] = $current_user->reports_to_name; if ($user_data['is_manager']) { $user_data['is_top_level_manager'] = User::isTopLevelManager($current_user->id); } // Address information $user_data['address_street'] = $current_user->address_street; $user_data['address_city'] = $current_user->address_city; $user_data['address_state'] = $current_user->address_state; $user_data['address_country'] = $current_user->address_country; $user_data['address_postalcode'] = $current_user->address_postalcode; require_once 'modules/Teams/TeamSetManager.php'; $teams = $current_user->get_my_teams(); $my_teams = array(); foreach ($teams as $id => $name) { $my_teams[] = array('id' => $id, 'name' => $name); } $user_data['my_teams'] = $my_teams; $defaultTeams = TeamSetManager::getTeamsFromSet($current_user->team_set_id); foreach ($defaultTeams as $id => $team) { $defaultTeams[$id]['primary'] = false; if ($team['id'] == $current_user->team_id) { $defaultTeams[$id]['primary'] = true; } } $user_data['preferences']['default_teams'] = $defaultTeams; // Send back a hash of this data for use by the client $user_data['_hash'] = $current_user->getUserMDHash(); return array('current_user' => $user_data); }
/** * pre_process_editview * * This method handles three editview scenarios: * 1) rendering the widget when creating a duplicate * 2) rendering the widget when going from a subpanel quick create form to a full form * 3) rendering the widget on a regular edit view of an existing record * */ private function pre_process_editview() { $this->displayParams['primaryChecked'] = true; if (empty($_REQUEST['record'])) { $isDuplicate = isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true' && $this->bean->aclAccess('edit'); if ($isDuplicate) { $dupBean = BeanFactory::getBean($_REQUEST['module']); $dupBean->retrieve($_REQUEST['record']); $full_form_values = array(); $full_form_values['primary'] = array('id' => $dupBean->team_id, 'name' => $dupBean->team_name); $teams = array(); require_once 'modules/Teams/TeamSetManager.php'; $team_ids = TeamSetManager::getTeamsFromSet($dupBean->team_set_id); foreach ($team_ids as $row) { if ($dupBean->team_id != $row['id']) { $full_form_values['secondaries'][] = array('id' => $row['id'], 'name' => $row['display_name']); } } //foreach $this->bean->{$this->value_name} = array_merge($this->bean->{$this->value_name}, $full_form_values); //If this request is coming from a subpanel quick create, we have to store the selected values } else { if (isset($_REQUEST['full_form'])) { require_once 'include/SugarFields/SugarFieldHandler.php'; $sfh = new SugarFieldHandler(); $sf = $sfh->getSugarField('Teamset', true); $teams = $sf->getTeamsFromRequest('team_name'); $full_form_values = array(); if (!empty($teams)) { $primary = $_REQUEST["primary_team_name_collection"]; $key = 'id_team_name_collection_' . $primary; //Get the $_REQUEST index key $primary = $_REQUEST[$key]; $primaryTeam = array('id' => $primary, 'name' => $teams[$primary]); unset($teams[$primary]); //Unset the primary team $full_form_values['primary'] = $primaryTeam; foreach ($teams as $team_id => $team_name) { $full_form_values['secondaries'][] = array('id' => $team_id, 'name' => $team_name); } } $this->bean->{$this->value_name} = array_merge($this->bean->{$this->value_name}, $full_form_values); } else { if (!empty($this->bean) && $this->add_user_private_team) { // fixing bug #40003: Teams revert to self when Previewing a report // check if array consists of subarray 'secondaries' that means we don't need to remerge it again if (!array_key_exists('secondaries', $this->bean->{$this->value_name})) { require_once 'modules/Teams/TeamSetManager.php'; $teams = TeamSetManager::getTeamsFromSet($GLOBALS['current_user']->team_set_id); $primary = false; $secondaries = array(); foreach ($teams as $row) { if (empty($primary) && $row['id'] == $GLOBALS['current_user']->team_id) { $this->bean->{$this->value_name} = array_merge($this->bean->{$this->value_name}, array('primary' => array('id' => $row['id'], 'name' => $row['display_name']))); $primary = true; } else { $secondaries['secondaries'][] = array('id' => $row['id'], 'name' => $row['display_name']); } } //foreach $this->bean->{$this->value_name} = array_merge($this->bean->{$this->value_name}, $secondaries); } } } } //if-else } }