/**
  * 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 .= "&nbsp;<a href=\"#\" style='text-decoration:none;' id='more_feather' onclick=\"SUGAR.utils.showHelpTips(this,'" . $body . "')\" >+</a>";
                 }
                 return $result;
             } else {
                 return '';
             }
         } else {
             return '';
         }
     } else {
         return '';
     }
 }
示例#2
0
 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);
 }
 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;
 }
示例#4
0
 /**
  * getInstance
  * Singleton method to return static instance of TrackerManager
  * @returns static TrackerManager instance
  */
 static function getInstance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new TeamSetManager();
         //Set global variable for tracker monitor instances that are disabled
         self::$instance->setup();
     }
     // if
     return self::$instance;
 }
示例#5
0
 /**
  * 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;
 }
if (!empty($_REQUEST['campaign_id'])) {
    $web_form_campaign = $_REQUEST['campaign_id'];
}
if (!empty($_REQUEST['assigned_user_id'])) {
    $web_assigned_user = $_REQUEST['assigned_user_id'];
}
if (isset($_REQUEST['team_name']) && !empty($_REQUEST['team_name'])) {
    require_once 'include/SugarFields/SugarFieldHandler.php';
    $sfh = new SugarFieldHandler();
    $sf = $sfh->getSugarField('Teamset', true);
    $teamIds = $sf->getTeamsFromRequest('team_name');
    $web_team_user = $sf->getPrimaryTeamIdFromRequest('team_name', $_POST);
    $teamSet = BeanFactory::getBean('TeamSets');
    $web_team_set_id_user = $teamSet->addTeams($teamIds);
    require_once 'modules/Teams/TeamSetManager.php';
    TeamSetManager::add($web_team_set_id_user, 'leads');
}
$lead = BeanFactory::getBean('Leads');
$fieldsMetaData = BeanFactory::getBean('EditCustomFields');
$xtpl = new XTemplate('modules/Campaigns/WebToLeadForm.html');
$xtpl->assign("MOD", $mod_strings);
$xtpl->assign("APP", $app_strings);
$Web_To_Lead_Form_html = '';
$Web_To_Lead_Form_html .= '<link rel="stylesheet" type="text/css" media="all" href="' . getJSPath(SugarThemeRegistry::current()->getCSSURL('calendar-win2k-cold-1.css')) . '">';
$Web_To_Lead_Form_html .= "<script type=\"text/javascript\" src='" . getJSPath($site_url . '/cache/include/javascript/sugar_grp1.js') . "'></script>";
$Web_To_Lead_Form_html .= "<form action='{$web_post_url}' name='WebToLeadForm' method='POST' id='WebToLeadForm'>";
$Web_To_Lead_Form_html .= "<table width='100%' style='border-top: 1px solid;\nborder-bottom: 1px solid;\npadding: 10px 6px 12px 10px;\nbackground-color: rgb(233, 243, 255);\nfont-size: 12px;\nbackground-repeat: repeat-x;\nbackground-position: center top;'>";
$Web_To_Lead_Form_html .= "<tr align='center' style='color: rgb(0, 105, 225); font-family: Arial,Verdana,Helvetica,sans-serif; font-size: 18px; font-weight: bold; margin-bottom: 0px; margin-top: 0px;'><TD COLSPAN='4'><b><h2>{$web_form_header}</h2></b></TD></tr>";
$Web_To_Lead_Form_html .= "<tr align='center' style='color: rgb(0, 105, 225); font-family: Arial,Verdana,Helvetica,sans-serif; font-size: 2px; font-weight: normal; margin-bottom: 0px; margin-top: 0px;'><TD COLSPAN='4'>&nbsp</TD></tr>";
$Web_To_Lead_Form_html .= "<tr align='left' style='color: rgb(0, 105, 225); font-family: Arial,Verdana,Helvetica,sans-serif; font-size: 12px; font-weight: normal; margin-bottom: 0px; margin-top: 0px;'><TD COLSPAN='4'>{$web_form_description}</TD></tr>";
$Web_To_Lead_Form_html .= "<tr align='center' style='color: rgb(0, 105, 225); font-family: Arial,Verdana,Helvetica,sans-serif; font-size: 8px; font-weight: normal; margin-bottom: 0px; margin-top: 0px;'><TD COLSPAN='4'>&nbsp</TD></tr>";
示例#7
0
 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;
 }
 /**
  * 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']);
 }
function create_campaign_summary($focus)
{
    global $mod_strings, $app_strings;
    $fields = array();
    $fields[] = 'name';
    $fields[] = 'assigned_user_name';
    $fields[] = 'status';
    $fields[] = 'team_name';
    $fields[] = 'start_date';
    $fields[] = 'end_date';
    if ($focus->campaign_type == 'NewsLetter') {
        $fields[] = 'frequency';
    }
    $fields[] = 'content';
    $fields[] = 'budget';
    $fields[] = 'actual_cost';
    $fields[] = 'expected_revenue';
    $fields[] = 'expected_cost';
    $fields[] = 'impressions';
    $fields[] = 'objective';
    //create edit view status and input buttons
    $cmp_input = '';
    //create edit campaign button
    $cmp_input = "<input id='wiz_next_button' name='SUBMIT'  ";
    $cmp_input .= "onclick=\"this.form.return_module.value='Campaigns';";
    $cmp_input .= "this.form.module.value='Campaigns';";
    $cmp_input .= "this.form.action.value='WizardNewsletter';";
    $cmp_input .= "this.form.return_action.value='WizardHome';";
    $cmp_input .= "this.form.direct_step.value='1';";
    $cmp_input .= "this.form.record.value='" . $focus->id . "';";
    $cmp_input .= "this.form.return_id.value='" . $focus->id . "';\" ";
    $cmp_input .= "class='button' value='" . $mod_strings['LBL_EDIT_EXISTING'] . "' type='submit'> ";
    //create view status button
    if ($focus->campaign_type == 'NewsLetter' || $focus->campaign_type == 'Email') {
        $cmp_input .= " <input id='wiz_status_button' name='SUBMIT'  ";
        $cmp_input .= "onclick=\"this.form.return_module.value='Campaigns';";
        $cmp_input .= "this.form.module.value='Campaigns';";
        $cmp_input .= "this.form.action.value='TrackDetailView';";
        $cmp_input .= "this.form.return_action.value='WizardHome';";
        $cmp_input .= "this.form.record.value='" . $focus->id . "';";
        $cmp_input .= "this.form.return_id.value='" . $focus->id . "';\" ";
        $cmp_input .= "class='button' value='" . $mod_strings['LBL_TRACK_BUTTON_TITLE'] . "' type='submit'>";
    }
    //create view roi button
    $cmp_input .= " <input id='wiz_status_button' name='SUBMIT'  ";
    $cmp_input .= "onclick=\"this.form.return_module.value='Campaigns';";
    $cmp_input .= "this.form.module.value='Campaigns';";
    $cmp_input .= "this.form.action.value='RoiDetailView';";
    $cmp_input .= "this.form.return_action.value='WizardHome';";
    $cmp_input .= "this.form.record.value='" . $focus->id . "';";
    $cmp_input .= "this.form.return_id.value='" . $focus->id . "';\" ";
    $cmp_input .= "class='button' value='" . $mod_strings['LBL_TRACK_ROI_BUTTON_LABEL'] . "' type='submit'>";
    //Create Campaign Header
    $cmpgn_tbl = "<p><table class='edit view' width='100%' border='0' cellspacing='0' cellpadding='0'>";
    $cmpgn_tbl .= "<tr><td class='dataField' align='left'><h4 class='dataLabel'> " . $mod_strings['LBL_LIST_CAMPAIGN_NAME'] . '  ' . $mod_strings['LBL_WIZ_NEWSLETTER_TITLE_SUMMARY'] . " </h4></td>";
    $cmpgn_tbl .= "<td align='right'>{$cmp_input}</td></tr>";
    $colorclass = '';
    foreach ($fields as $key) {
        if (!empty($focus->{$key})) {
            $cmpgn_tbl .= "<tr><td scope='row' width='15%'>" . $mod_strings[$focus->field_name_map[$key]['vname']] . "</td>\n";
            if ($key == 'team_name') {
                require_once 'modules/Teams/TeamSetManager.php';
                $cmpgn_tbl .= "<td scope='row'>" . TeamSetManager::getCommaDelimitedTeams($focus->team_set_id, $focus->team_id, true) . "</td></tr>\n";
            } else {
                $cmpgn_tbl .= "<td scope='row'>" . $focus->{$key} . "</td></tr>\n";
            }
        }
    }
    $cmpgn_tbl .= "</table></p>";
    return $cmpgn_tbl;
}
示例#10
0
             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++;
 while ($row = $db->fetchByAssoc($res)) {
     if ($row['id'] == $_POST['fromuser']) {
         $fromusername = $row['user_name'];
     }
     if ($row['id'] == $_POST['touser']) {
         $tousername = $row['user_name'];
     }
 }
 //rrs bug: 31056 - instead of setting the team_id let's set the team_set_id and set the team_id as the primary
 $teamSetField = new SugarFieldTeamset('Teamset');
 $teams = $teamSetField->getTeamsFromRequest('team_name');
 $team_ids = array_keys($teams);
 $team_id = $teamSetField->getPrimaryTeamIdFromRequest('team_name', $_REQUEST);
 $teamSet = BeanFactory::getBean('TeamSets');
 $team_set_id = $teamSet->addTeams($team_ids);
 $toteamname = TeamSetManager::getCommaDelimitedTeams($team_set_id, $team_id, true);
 echo "{$mod_strings_users['LBL_REASS_DESC_PART2']}\n";
 echo "<form action=\"index.php?module=Users&action=reassignUserRecords&execute=true\" method=post>\n";
 echo "<BR>{$mod_strings_users['LBL_REASS_NOTES_TITLE']}\n";
 echo "<ul>\n";
 echo "<li>* {$mod_strings_users['LBL_REASS_NOTES_ONE']}\n";
 echo "<li>* {$mod_strings_users['LBL_REASS_NOTES_TWO']}\n";
 echo "<li>* {$mod_strings_users['LBL_REASS_NOTES_THREE']}\n";
 echo "</ul>\n";
 require_once 'include/SugarSmarty/plugins/function.sugar_help.php';
 $sugar_smarty = new Sugar_Smarty();
 $help_img = smarty_function_sugar_help(array("text" => $mod_strings['LBL_REASS_VERBOSE_HELP']), $sugar_smarty);
 echo "<BR><input type=checkbox name=verbose> {$mod_strings_users['LBL_REASS_VERBOSE_OUTPUT']}" . $help_img . "<BR>\n";
 unset($_SESSION['reassignRecords']['modules']);
 $beanListFlip = $_SESSION['reassignRecords']['assignedModuleListCache'];
 foreach ($_POST['modules'] as $module) {
示例#12
0
/**
 * getExportContentsFromResult
 *
 * This is a function to handle the processing of generating the export contents.
 *
 * @param Mixed $focus SugarBean instance we are retrieving export results for
 * @param Mixed $result database result resource from the export SQL
 * @param bool $members used to indicate whether or not to apply filtering for header rows; false by default
 * @param array $remove_from_members Array of header columns to filter out; empty by default
 * @param bool $populate boolean used to indicate whether or not to populate with test data; false by default
 * @return string
 */
function getExportContentFromResult($focus, $result, $members = false, $remove_from_members = array(), $populate = false)
{
    global $current_user, $locale, $app_strings;
    $sampleRecordNum = 5;
    $delimiter = getDelimiter();
    $timedate = TimeDate::getInstance();
    $db = DBManagerFactory::getInstance();
    $fields_array = $db->getFieldsArray($result, true);
    // check if ID field is contained in query result
    $is_id_exported = in_array('id', $fields_array);
    //set up the order on the header row
    $fields_array = get_field_order_mapping($focus->module_dir, $fields_array, true, $focus->fields_to_exclude);
    //set up labels to be used for the header row
    $field_labels = array();
    foreach ($fields_array as $key => $dbname) {
        //Remove fields that are only used for logic
        if ($members && in_array($dbname, $remove_from_members)) {
            continue;
        }
        //default to the db name of label does not exist
        $field_labels[$key] = translateForExport($dbname, $focus);
    }
    $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
    if ($locale->getExportCharset() == 'UTF-8' && !preg_match('/macintosh|mac os x|mac_powerpc/i', $user_agent)) {
        //Bug 55520 - add BOM to the exporting CSV so any symbols are displayed correctly in Excel
        $BOM = "";
        $content = $BOM;
    } else {
        $content = '';
    }
    $pre_id = '';
    // Setup the "header" row with proper delimiters
    $content .= "\"" . implode("\"" . getDelimiter() . "\"", array_values($field_labels)) . "\"\r\n";
    if ($populate) {
        //this is a sample request with no data, so create fake datarows
        $content .= returnFakeDataRow($focus, $fields_array, $sampleRecordNum);
    } else {
        $records = array();
        //process retrieved record
        $isAdminUser = is_admin($current_user);
        while ($val = $db->fetchByAssoc($result, false)) {
            //order the values in the record array
            $val = get_field_order_mapping($focus->module_dir, $val);
            $new_arr = array();
            if (!$isAdminUser) {
                $focus->id = !empty($val['id']) ? $val['id'] : '';
                $focus->assigned_user_id = !empty($val['assigned_user_id']) ? $val['assigned_user_id'] : '';
                $focus->created_by = !empty($val['created_by']) ? $val['created_by'] : '';
                $focus->ACLFilterFieldList($val, array(), array("blank_value" => true));
            }
            if ($members) {
                if ($is_id_exported && $pre_id == $val['id']) {
                    continue;
                }
                if (isset($val['ea_deleted']) && isset($val['primary_email_address']) && ($val['ea_deleted'] == 1 || $val['ear_deleted'] == 1)) {
                    $val['primary_email_address'] = '';
                }
                unset($val['ea_deleted']);
                unset($val['ear_deleted']);
                unset($val['primary_address']);
            }
            $pre_id = $is_id_exported ? $val['id'] : '';
            require_once 'include/SugarFields/SugarFieldHandler.php';
            //replace user_name with full name if use_real_name preference setting is enabled
            //and this is a user name field
            $useRealNames = $current_user->getPreference('use_real_names');
            foreach ($val as $key => $value) {
                //if key is not part of field map, then continue
                if (!isset($fields_array[$key])) {
                    continue;
                }
                //getting content values depending on their types
                $fieldNameMapKey = $fields_array[$key];
                if (isset($focus->field_name_map[$fieldNameMapKey]) && $focus->field_name_map[$fieldNameMapKey]['type']) {
                    $sfh = SugarFieldHandler::getSugarField($focus->field_name_map[$fieldNameMapKey]['type']);
                    $value = $sfh->exportSanitize($value, $focus->field_defs[$key], $focus, $val);
                }
                if (isset($focus->field_name_map[$fields_array[$key]]['custom_type']) && $focus->field_name_map[$fields_array[$key]]['custom_type'] == 'teamset') {
                    require_once 'modules/Teams/TeamSetManager.php';
                    $value = TeamSetManager::getCommaDelimitedTeams($val['team_set_id'], !empty($val['team_id']) ? $val['team_id'] : '');
                }
                if ($useRealNames) {
                    $value = formatRealNameField($focus, $fields_array, $key, $value);
                }
                // Keep as $key => $value for post-processing
                $new_arr[$key] = str_replace('"', '""', $value);
            }
            //foreach
            // Use Bean ID as key for records if it exists
            if ($is_id_exported) {
                $records[$pre_id] = $new_arr;
            } else {
                $records[] = $new_arr;
            }
        }
        // Check if we're going to export non-primary emails
        if ($is_id_exported && $focus->hasEmails()) {
            // Add header column
            $field_labels['email_addresses_non_primary'] = translateForExport('email_addresses_non_primary', $focus);
            // $records keys are bean ids
            $keys = array_keys($records);
            $email_data = getNonPrimaryEmailsData($focus, $keys);
            foreach (array_keys($records) as $bean_id) {
                $records[$bean_id]['email_addresses_non_primary'] = isset($email_data[$bean_id]) ? $email_data[$bean_id] : '';
            }
        }
        // Write the export data
        foreach ($records as $record) {
            $line = implode("\"" . $delimiter . "\"", $record);
            $line = "\"" . $line;
            $line .= "\"\r\n";
            $content .= $line;
        }
    }
    return $content;
}
示例#13
0
 /**
  * Delete a team and all team memberships.  This method will only work if no items are assigned to the team.
  */
 function delete_team()
 {
     //todo: Verify that no items are still assigned to this team.
     if ($this->id == $this->global_team) {
         $msg = $GLOBALS['app_strings']['LBL_MASSUPDATE_DELETE_GLOBAL_TEAM'];
         $GLOBALS['log']->fatal($msg);
         die($msg);
     }
     //Check if the associated user is deleted
     $user = BeanFactory::getBean('Users', $this->associated_user_id);
     if ($this->private == 1 && (!empty($user->id) && $user->deleted != 1)) {
         $msg = string_format($GLOBALS['app_strings']['LBL_MASSUPDATE_DELETE_USER_EXISTS'], array(Team::getDisplayName($this->name, $this->name_2), $user->full_name));
         $GLOBALS['log']->error($msg);
         SugarApplication::appendErrorMessage($msg);
         return false;
     }
     // Update team_memberships table and set deleted = 1
     $query = "UPDATE team_memberships SET deleted = 1 WHERE team_id='{$this->id}'";
     $this->db->query($query, true, "Error deleting memberships while deleting team: ");
     // Update teams and set deleted = 1
     $this->deleted = 1;
     $this->save();
     require_once 'modules/Teams/TeamSetManager.php';
     TeamSetManager::flushBackendCache();
     //clean up any team sets that use this team id
     TeamSetManager::removeTeamFromSets($this->id);
     // Take the item off the recently viewed lists
     $tracker = BeanFactory::getBean('Trackers');
     $tracker->makeInvisibleForAll($this->id);
 }
示例#14
0
 /**
  * Commit any unsaved changes to the database
  *
  */
 public function save($checkForUpdate = true, $usedDefaultTeam = false)
 {
     if ($this->_saved == false) {
         //disable_team_sanity_check can be set to allow for us to just take the values provided on the bean blindly rather than
         //doing a check to confirm whether the data is correct.
         if (empty($GLOBALS['sugar_config']['disable_team_sanity_check'])) {
             if (!empty($this->_bean->team_id)) {
                 if (empty($this->_teamList)) {
                     //we have added this logic here to account for side quick create. If you use side quick create then we do not set the team_id nor the team_set_id
                     //from the UI. In that case the team_id will be set in SugarBean.php by the current user's default team but the team_set_id will still not be set
                     //we have to hold off on setting the team_set_id until in here so we can be sure to check that it is not waiting to be saved to the db and is being held in
                     //_teamList.  So we use $usedDefaultTeam to signify that we did in fact not have a team_id until we set it in SugarBean.php and that this is not an
                     //update so we do not have a team_set_id on the bean. In that case we can use the current user's default team set.
                     if ($usedDefaultTeam && empty($this->_bean->team_set_id) && isset($GLOBALS['current_user']) && isset($GLOBALS['current_user']->team_set_id)) {
                         $this->_bean->team_set_id = $GLOBALS['current_user']->team_set_id;
                     }
                     //this is a safety check to ensure we actually do have a set team_set_id
                     if (!empty($this->_bean->team_set_id)) {
                         $this->_teamList = $this->_teamSet->getTeamIds($this->_bean->team_set_id);
                     }
                 }
                 //this stmt is intended to handle the situation where the code has set the team_id but not the team_set_id as may be the case
                 //from SOAP.
                 if (!in_array($this->_bean->team_id, $this->_teamList)) {
                     $this->_teamList[] = $this->_bean->team_id;
                 }
             }
             //we need to check if the assigned_user has access to any of the teams on this record,
             //if they do not then we need to be sure to add their private team to the list.
             //If assigned_user_id is not set on the object as is the case with Documents, then use created_by
             //we added 'disable_team_access_check' config entry to allow for admins to revert back to the way things were
             //pre 5.5. So that they could disable this check and if the assigned_user was not a member of one of the
             //teams on this record we would just leave it alone.
             //Exclude user's module so additional teams are NOT added to a user record
             if ($this->_bean->module_dir != 'Users' && empty($GLOBALS['sugar_config']['disable_team_access_check']) && empty($this->_bean->in_workflow)) {
                 $assigned_user_id = null;
                 if (isset($this->_bean->assigned_user_id)) {
                     $assigned_user_id = $this->_bean->assigned_user_id;
                 } else {
                     if (isset($this->_bean->created_by)) {
                         $assigned_user_id = $this->_bean->created_by;
                     }
                 }
                 if (!empty($assigned_user_id) && !$this->_teamSet->isUserAMember($assigned_user_id, '', $this->_teamList)) {
                     $privateTeamId = User::staticGetPrivateTeamID($assigned_user_id);
                     if (!empty($privateTeamId)) {
                         $this->_teamList[] = $privateTeamId;
                     }
                 }
             }
             if (!empty($this->_teamList)) {
                 $this->_bean->team_set_id = $this->_teamSet->addTeams($this->_teamList);
             }
         }
         //fi empty($GLOBALS['sugar_config']['disable_team_sanity_check']))
         //if this bean already exists in the database, and is not new with id
         //and if we are not saving this bean from Import or Mass Update, then perform the query
         //otherwise the bean should be saved later.
         $runUpdate = false;
         if ($checkForUpdate) {
             $runUpdate = !empty($this->_bean->id) && empty($this->_bean->new_with_id) && !empty($this->_bean->save_from_post);
         }
         if ($runUpdate) {
             $GLOBALS['db']->query("UPDATE {$this->_bean->table_name} SET team_set_id = '{$this->_bean->team_set_id}' WHERE id = '{$this->_bean->id}'");
         }
         //keep track of what we put into the database so we can clean things up later
         TeamSetManager::saveTeamSetModule($this->_bean->team_set_id, $this->_bean->table_name);
         $this->_saved = true;
     }
 }
示例#15
0
function reportCriteriaWithResult(&$reporter, &$args)
{
    global $current_user, $theme;
    global $current_language;
    global $mod_strings, $app_strings, $timedate;
    global $sugar_config, $sugar_version;
    global $app_list_strings;
    $sort_by = '';
    $sort_dir = '';
    $summary_sort_by = '';
    $summary_sort_dir = '';
    $report_type = '';
    $smarty = new Sugar_Smarty();
    if (isset($reporter->report_def['order_by'][0]['name']) && isset($reporter->report_def['order_by'][0]['table_key'])) {
        $sort_by = $reporter->report_def['order_by'][0]['table_key'] . ":" . $reporter->report_def['order_by'][0]['name'];
    }
    // if
    if (isset($reporter->report_def['order_by'][0]['sort_dir'])) {
        $sort_dir = $reporter->report_def['order_by'][0]['sort_dir'];
    }
    // if
    if (!empty($reporter->report_def['summary_order_by'][0]['group_function']) && $reporter->report_def['summary_order_by'][0]['group_function'] == 'count') {
        $summary_sort_by = $reporter->report_def['summary_order_by'][0]['table_key'] . ":" . 'count';
    } else {
        if (isset($reporter->report_def['summary_order_by'][0]['name'])) {
            $summary_sort_by = $reporter->report_def['summary_order_by'][0]['table_key'] . ":" . $reporter->report_def['summary_order_by'][0]['name'];
            if (!empty($reporter->report_def['summary_order_by'][0]['group_function'])) {
                $summary_sort_by .= ":" . $reporter->report_def['summary_order_by'][0]['group_function'];
            } else {
                if (!empty($reporter->report_def['summary_order_by'][0]['column__function'])) {
                    $summary_sort_by .= ":" . $reporter->report_def['summary_order_by'][0]['column_function'];
                }
            }
            // else if
        }
    }
    // else if
    if (isset($reporter->report_def['summary_order_by'][0]['sort_dir'])) {
        $summary_sort_dir = $reporter->report_def['summary_order_by'][0]['sort_dir'];
    }
    // if
    if (isset($reporter->report_def['report_type'])) {
        $report_type = $reporter->report_def['report_type'];
    }
    // if
    $issetSaveResults = false;
    $isSaveResults = false;
    if (isset($args['save_result'])) {
        $issetSaveResults = true;
        $smarty->assign('save_report_as_str', $_REQUEST['save_report_as']);
        if ($args['save_result']) {
            $isSaveResults = true;
        }
        // if
    }
    // if
    $buttonDuplicateAsOrigin = '<a onclick=\'document.EditView.to_pdf.value="";document.EditView.to_csv.value="";document.EditView.action.value="ReportsWizard";document.EditView.save_as.value="true";' . 'document.EditView.submit();\' href=\'#\'>' . $mod_strings['LBL_DUPLICATE_AS_ORIGINAL'] . '</a>';
    $buttonDuplicateAsSummation = '<a onclick=\'document.EditView.to_pdf.value="";document.EditView.to_csv.value="";document.EditView.action.value="ReportsWizard";document.EditView.save_as.value="true";' . 'document.EditView.save_as_report_type.value="summation";document.EditView.submit();\' href=\'#\'>' . $mod_strings['LBL_DUPLICATE_AS_SUMMATON'] . '</a>';
    $buttonDuplicateAsDetail = '<a onclick=\'document.EditView.to_pdf.value="";document.EditView.to_csv.value="";document.EditView.action.value="ReportsWizard";document.EditView.save_as.value="true";' . 'document.EditView.save_as_report_type.value="summation_with_details";document.EditView.submit();\' href=\'#\'>' . $mod_strings['LBL_DUPLICATE_AS_SUMMATION_DETAILS'] . '</a>';
    $buttonDuplicateAsMatrix = '<a onclick=\'document.EditView.to_pdf.value="";document.EditView.to_csv.value="";document.EditView.action.value="ReportsWizard";document.EditView.save_as.value="true";' . 'document.EditView.save_as_report_type.value="matrix";document.EditView.submit();\' href=\'#\'>' . $mod_strings['LBL_DUPLICATE_AS_MATRIX'] . '</a>';
    $buttonDuplicateAsTabular = '<a onclick=\'document.EditView.to_pdf.value="";document.EditView.to_csv.value="";document.EditView.action.value="ReportsWizard";document.EditView.save_as.value="true";' . 'document.EditView.save_as_report_type.value="tabular";document.EditView.submit();\' href=\'#\'>' . $mod_strings['LBL_DUPLICATE_AS_ROWS_AND_COLS'] . '</a>';
    if ($report_type == 'tabular') {
        $duplicateButtons = array('<input class="button" onclick="showDuplicateOverlib(this,\'tabular\');" type="button" ' . ' value="' . $app_strings['LBL_DUPLICATE_BUTTON_LABEL'] . '">', $buttonDuplicateAsOrigin, $buttonDuplicateAsSummation, $buttonDuplicateAsDetail, $buttonDuplicateAsMatrix);
    } else {
        if ($report_type == 'summary' && (!empty($reporter->report_def['display_columns']) && count($reporter->report_def['display_columns']) > 0)) {
            $canCovertToMatrix = 0;
            if (!empty($reporter->report_def['group_defs']) && count($reporter->report_def['group_defs']) <= 3) {
                $canCovertToMatrix = 1;
            }
            $duplicateButtons = array('<input type=button class="button" onclick="showDuplicateOverlib(this,\'summation_with_details\',' . $canCovertToMatrix . ');" type="button" ' . 'value="' . $app_strings['LBL_DUPLICATE_BUTTON_LABEL'] . '"/>', $buttonDuplicateAsOrigin, $buttonDuplicateAsSummation, $buttonDuplicateAsTabular);
            if ($canCovertToMatrix) {
                $duplicateButtons[] = $buttonDuplicateAsMatrix;
            }
        } else {
            if ($report_type == 'summary' && !empty($reporter->report_def['layout_options'])) {
                $duplicateButtons = array('<input class="button" onclick="showDuplicateOverlib(this,\'matrix\');" type="button" ' . ' value="' . $app_strings['LBL_DUPLICATE_BUTTON_LABEL'] . '">', $buttonDuplicateAsOrigin, $buttonDuplicateAsSummation, $buttonDuplicateAsDetail, $buttonDuplicateAsTabular);
            } else {
                if ($report_type == 'summary') {
                    $canCovertToMatrix = 0;
                    if (!empty($reporter->report_def['group_defs']) && count($reporter->report_def['group_defs']) <= 3) {
                        $canCovertToMatrix = 1;
                    }
                    $duplicateButtons = array('<input class="button" onclick="showDuplicateOverlib(this,\'summation\',' . $canCovertToMatrix . ');" type="button" ' . 'value="' . $app_strings['LBL_DUPLICATE_BUTTON_LABEL'] . '" >', $buttonDuplicateAsOrigin, $buttonDuplicateAsDetail, $buttonDuplicateAsTabular);
                    if ($canCovertToMatrix) {
                        $duplicateButtons[] = $buttonDuplicateAsMatrix;
                    }
                }
            }
        }
    }
    $smarty->assign('duplicateButtons', $duplicateButtons);
    $smarty->assign('mod_strings', $mod_strings);
    $smarty->assign('app_strings', $app_strings);
    $smarty->assign('current_language', $current_language);
    $smarty->assign('sugar_config', $sugar_config);
    $smarty->assign('sugar_version', $sugar_version);
    $smarty->assign('issetSaveResults', $issetSaveResults);
    $smarty->assign('isSaveResults', $isSaveResults);
    $smarty->assign('report_type', $report_type);
    $smarty->assign('reportDetailView', getReportDetailViewString($reporter, $args));
    $smarty->assign('reporter', $reporter);
    $smarty->assign('reporterArgs', $args);
    $form_header = get_form_header($mod_strings['LBL_TITLE'] . ": " . $args['reporter']->saved_report->name, "", false);
    $smarty->assign('form_header', $form_header);
    $smarty->assign('report_offset', $reporter->report_offset);
    $smarty->assign('sort_by', $sort_by);
    $smarty->assign('sort_dir', $sort_dir);
    $smarty->assign('summary_sort_by', $summary_sort_by);
    $smarty->assign('summary_sort_dir', $summary_sort_dir);
    if (isset($_REQUEST['save_as']) && $_REQUEST['save_as'] == 'true') {
        $report_id = '';
    } else {
        if (isset($reporter->saved_report->id)) {
            $report_id = $reporter->saved_report->id;
        } elseif (!empty($_REQUEST['record'])) {
            $report_id = $_REQUEST['record'];
        } else {
            $report_id = '';
        }
    }
    // else
    $smarty->assign('report_id', $report_id);
    $smarty->assign('to_pdf', isset($_REQUEST['to_pdf']) ? $_REQUEST['to_pdf'] : "");
    $smarty->assign('to_csv', isset($_REQUEST['to_csv']) ? $_REQUEST['to_csv'] : "");
    $isAdmin = false;
    if ($current_user->is_admin) {
        $isAdmin = true;
    }
    // if
    $smarty->assign('isAdmin', $isAdmin);
    if ($isAdmin) {
        $smarty->assign('show_query', true);
        if (!empty($_REQUEST['show_query'])) {
            $smarty->assign('show_query_checked', true);
        }
        // if
    }
    // if
    $schedule_value = $app_strings['LBL_LINK_NONE'];
    if (isset($args['reporter']->saved_report->schedule_id) && $args['reporter']->saved_report->active == 1) {
        $schedule_value = $timedate->to_display_date_time($args['reporter']->saved_report->next_run);
    }
    // if
    $smarty->assign('schedule_value', $schedule_value);
    $current_favorites = $current_user->getPreference('favorites', 'Reports');
    if (!is_array($current_favorites)) {
        $current_favorites = array();
    }
    $report_ids_array = array_keys($current_favorites, $current_user->id);
    if (!is_array($report_ids_array)) {
        $report_ids_array = array();
    }
    // if
    if (isset($args['warnningMessage'])) {
        $smarty->assign('warnningMessage', $args['warnningMessage']);
    }
    // if
    if (!empty($args['reporter']->saved_report)) {
        $context = array("bean" => $args['reporter']->saved_report);
    } else {
        $context = array();
    }
    $report_edit_access = SugarACL::checkAccess('Reports', 'edit', $context);
    $smarty->assign('report_edit_access', $report_edit_access);
    $report_delete_access = SugarACL::checkAccess('Reports', 'delete', $context);
    $smarty->assign('report_delete_access', $report_delete_access);
    $report_export_access = SugarACL::checkAccess('Reports', 'export', $context);
    $smarty->assign('report_export_access', $report_export_access);
    //check to see if exporting is allowed
    $isExportAccess = hasExportAccess($args);
    $smarty->assign('report_export_as_csv_access', $isExportAccess);
    $smarty->assign('form_submit', empty($_REQUEST['form_submit']) ? false : $_REQUEST['form_submit']);
    $global_json = getJSONobj();
    global $ACLAllowedModules;
    $ACLAllowedModules = getACLAllowedModules();
    $smarty->assign('ACLAllowedModules', $global_json->encode(array_keys($ACLAllowedModules)));
    template_reports_filters($smarty, $args);
    $smarty->assign('reporter_report_type', $args['reporter']->report_type);
    $smarty->assign('current_user_id', $current_user->id);
    $smarty->assign('md5_current_user_id', md5($current_user->id));
    if (!hasRuntimeFilter($reporter)) {
        //$showRunReportButton = false;
        $smarty->assign('filterTabStyle', "display:none");
    } else {
        $smarty->assign('filterTabStyle', "display:''");
    }
    $smarty->assign('reportResultHeader', $mod_strings['LBL_REPORT_RESULTS']);
    $reportDetailsButtonTitle = $mod_strings['LBL_REPORT_HIDE_DETAILS'];
    $reportDetailsTableStyle = '';
    if (isset($args['reportCache'])) {
        $reportCache = $args['reportCache'];
        if (!empty($reportCache->report_options_array)) {
            if (array_key_exists("showDetails", $reportCache->report_options_array) && !$reportCache->report_options_array['showDetails']) {
                $reportDetailsButtonTitle = $mod_strings['LBL_REPORT_SHOW_DETAILS'];
                $reportDetailsTableStyle = 'display:none';
            }
        }
        // if
    }
    // if
    $smarty->assign('reportDetailsButtonTitle', $reportDetailsButtonTitle);
    $smarty->assign('reportDetailsTableStyle', $reportDetailsTableStyle);
    $smarty->assign('cache_path', sugar_cached(''));
    template_reports_request_vars_js($smarty, $reporter, $args);
    //custom chart code
    require_once 'include/SugarCharts/SugarChartFactory.php';
    $sugarChart = SugarChartFactory::getInstance();
    $resources = $sugarChart->getChartResources();
    $smarty->assign('chartResources', $resources);
    $smarty->assign('id', empty($_REQUEST['id']) ? false : $_REQUEST['id']);
    //Bug#51609: Create action buttons for report view. Previously existed in _reportCriteriaWithResult.tpl
    $buttons = array();
    $buttons[] = <<<EOD
        <input name="runReportButton" id="runReportButton" type="submit" class="button" accessKey="{$mod_strings['LBL_RUN_REPORT_BUTTON_KEY']}" title="{$mod_strings['LBL_RUN_BUTTON_TITLE']}"
               onclick="this.form.to_pdf.value='';this.form.to_csv.value='';this.form.save_report.value='';" value="{$mod_strings['LBL_RUN_REPORT_BUTTON_LABEL']}">
EOD;
    $reportName = $args['reporter']->saved_report->name;
    $shareButtonCode = "parent.SUGAR.App.bwc.shareRecord('Reports', '{$report_id}', '{$reportName}');";
    $buttons[] = <<<EOD
        <input type="button" class="button" name="shareReportButton" id="shareReportButton" accessKey="{$app_strings['LBL_SHARE_BUTTON_KEY']}" value="{$app_strings['LBL_SHARE_BUTTON_LABEL']}" title="{$app_strings['LBL_SHARE_BUTTON_TITLE']}"
               onclick="{$shareButtonCode}">
EOD;
    if ($report_edit_access) {
        $buttons[] = <<<EOD
            <input type="submit" class="button" name="editReportButton" id="editReportButton" accessKey="{$app_strings['LBL_EDIT_BUTTON_KEY']}" value="{$app_strings['LBL_EDIT_BUTTON_LABEL']}" title="{$app_strings['LBL_EDIT_BUTTON_TITLE']}"
               onclick="this.form.to_pdf.value='';this.form.to_csv.value='';this.form.action.value='ReportsWizard';">
EOD;
    }
    array_push($buttons, $duplicateButtons);
    if ($report_edit_access) {
        $buttons[] = <<<EOD
        <input type="button" class="button"  name="scheduleReportButton" id="scheduleReportButton" value="{$mod_strings['LBL_REPORT_SCHEDULE_TITLE']}"
               onclick="schedulePOPUP()">
EOD;
    }
    if ($report_export_access) {
        //workaround for SP-1685, Need to clear bwcModel so change confirmation doesn't fire after making a PDF.
        $buttons[] = <<<EOD
        <input type="submit" class="button" name="printPDFButton" id="printPDFButton" accessKey="{$app_strings['LBL_VIEW_PDF_BUTTON_KEY']}" value="{$app_strings['LBL_VIEW_PDF_BUTTON_LABEL']}" title="{$app_strings['LBL_VIEW_PDF_BUTTON_TITLE']}"
               onclick="if (window&&window.parent&&window.parent.App&&window.parent.App.controller
               &&window.parent.App.controller.layout
               &&window.parent.App.controller.layout._components[0]
               &&window.parent.App.controller.layout._components[0].bwcModel
               &&window.parent.App.controller.layout._components[0].bwcModel.clear)
               {window.parent.App.controller.layout._components[0].bwcModel.clear({silent:true});this.form.save_report.value='';this.form.to_csv.value='';this.form.to_pdf.value='on'}">
EOD;
    }
    if ($isExportAccess) {
        $buttons[] = <<<EOD
        <input type="button" class="button"  name="exportReportButton" id="exportReportButton" value="{$mod_strings['LBL_EXPORT']}" onclick="do_export();">
EOD;
    }
    if ($report_delete_access) {
        $buttons[] = <<<EOD
        <input type="button" class="button"  name="deleteReportButton" id="deleteReportButton" accessKey="{$app_strings['LBL_DELETE_BUTTON_KEY']}" value="{$app_strings['LBL_DELETE_BUTTON_LABEL']}" title="{$app_strings['LBL_DELETE_BUTTON_TITLE']}"
               onclick="if (confirm(SUGAR.language.get('app_strings','NTC_DELETE_CONFIRMATION'))){this.form.to_pdf.value='';this.form.to_csv.value='';this.form.is_delete.value='1';this.form.action.value='ReportsWizard';this.form.submit();}">
EOD;
    }
    $smarty->assign('action_button', $buttons);
    $reportType = $reporter->report_def['report_type'] == 'tabular' ? $mod_strings['LBL_ROWS_AND_COLUMNS_REPORT'] : $mod_strings['LBL_SUMMATION_REPORT'];
    if (!empty($reporter->report_def['display_columns']) && !empty($reporter->report_def['group_defs'])) {
        $reportType = $mod_strings['LBL_SUMMATION_WITH_DETAILS'];
    }
    // if
    if (isset($reporter->report_def['layout_options'])) {
        $reportType = $mod_strings['LBL_MATRIX_REPORT'];
    }
    // if
    $fullTableList = $reporter->report_def['full_table_list'];
    $fullTableListArray = array();
    foreach ($fullTableList as $key => $value) {
        if (!isset($value['name'])) {
            if (!isset($fullTableListArray[$value['module']])) {
                $module_str = $value['module'];
                if (isset($app_list_strings['moduleList'][$module_str])) {
                    $module_str = $app_list_strings['moduleList'][$module_str];
                }
                $fullTableListArray[$value['module']] = $module_str;
            }
            // if
        } else {
            if (!isset($fullTableListArray[$value['name']])) {
                $fullTableListArray[$value['name']] = $value['name'];
            }
            // if
        }
        // else
    }
    // foreach
    $displayColumnsList = $reporter->report_def['display_columns'];
    $displayColumnsArray = array();
    foreach ($displayColumnsList as $key => $value) {
        $displayColumnsArray[] = $value['label'];
    }
    // foreach
    $group_defs = $reporter->report_def['group_defs'];
    $group_defsArray = array();
    if (!empty($group_defs)) {
        foreach ($group_defs as $key => $value) {
            $group_defsArray[] = $value['label'];
        }
        // foreach
    }
    // if
    $summary_columnsList = $reporter->report_def['summary_columns'];
    $summaryColumnsArray = array();
    if (!empty($summary_columnsList)) {
        foreach ($summary_columnsList as $key => $value) {
            $summaryColumnsArray[] = $value['label'];
        }
        // foreach
    }
    // if
    $summaryAndGroupDefData = "";
    if (!empty($group_defs) && !empty($summary_columnsList)) {
        $summaryAndGroupDefData = '<tr><td wrap="true">';
        $summaryAndGroupDefData = $summaryAndGroupDefData . "<b>" . $mod_strings['LBL_GROUP_BY'] . ": </b>" . implode(", ", $group_defsArray) . "</td><td wrap=\"true\">";
        $summaryAndGroupDefData = $summaryAndGroupDefData . "<b>" . $mod_strings['LBL_SUMMARY_COLUMNS'] . ": </b>" . implode(", ", $summaryColumnsArray) . "</td></tr>";
    } else {
        if (!empty($group_defs) || !empty($summary_columnsList)) {
            $summaryAndGroupDefData = '<tr><td wrap="true">';
            if (!empty($group_defs)) {
                $summaryAndGroupDefData = $summaryAndGroupDefData . "<b>" . $mod_strings['LBL_GROUP_BY'] . ": </b>" . implode(", ", $group_defsArray) . "</td><td wrap=\"true\">&nbsp;</td>";
            }
            // if
            if (!empty($summary_columnsList)) {
                $summaryAndGroupDefData = $summaryAndGroupDefData . "<b>" . $mod_strings['LBL_SUMMARY_COLUMNS'] . ": </b>" . implode(", ", $summaryColumnsArray) . "</td><td wrap=\"true\">&nbsp;</td>";
            }
            // if
        }
    }
    // else
    $reportFilters = "";
    if (isset($reporter->report_def['filters_def']) && !isset($reporter->report_def['filters_def']['Filter_1'][0])) {
        $reportFilters = " " . $mod_strings['LBL_NONE_STRING'];
    } else {
        $reportFilters = "<span id=\"filter_results\" valign=\"bottom\">&nbsp;<img id=\"filter_results_image\" src=\"" . SugarThemeRegistry::current()->getImageURL('basic_search.gif') . "\" width=\"8px\" height=\"10px\" onclick=\"showFilterString();\"></span><span id=\"filter_results_text\" style=\"visibility:hidden;\"></span>";
    }
    // else
    $smarty->assign('reportFilters', $reportFilters);
    $smarty->assign('reportName', $reportName);
    $smarty->assign('reportType', $reportType);
    $smarty->assign('reportModuleList', implode(", ", $fullTableListArray));
    $smarty->assign('reportDisplayColumnsList', implode(", ", $displayColumnsArray));
    require_once 'modules/Teams/TeamSetManager.php';
    $smarty->assign('reportTeam', TeamSetManager::getCommaDelimitedTeams($args['reporter']->saved_report->team_set_id, $args['reporter']->saved_report->team_id, true));
    $smarty->assign('reportAssignedToName', $args['reporter']->saved_report->assigned_user_name);
    $smarty->assign('summaryAndGroupDefData', $summaryAndGroupDefData);
    // Set fiscal start date
    $admin = BeanFactory::getBean('Administration');
    $config = $admin->getConfigForModule('Forecasts', 'base');
    if (!empty($config['is_setup']) && !empty($config['timeperiod_start_date'])) {
        $smarty->assign("fiscalStartDate", $config['timeperiod_start_date']);
    }
    $smarty->assign('ENTROPY', mt_rand());
    echo $smarty->fetch("modules/Reports/templates/_reportCriteriaWithResult.tpl");
    reportResults($reporter, $args);
}
 /**
  * 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
     }
 }
示例#17
0
                    $field_name = "main." . $section_name . ".merge_cell_field_value";
                    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'] = $mergeBeanArray[$id]->team_set_id;
                    $json_data['field_value3'] = $mergeBeanArray[$id]->team_id;
                } 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++;
    }
}
$header_cols = array();
示例#18
0
 /**
  * @Deprecated
  */
 public function get_audit_list()
 {
     global $focus, $genericAssocFieldsArray, $moduleAssocFieldsArray, $current_user, $timedate, $app_strings;
     $audit_list = array();
     if (!empty($_REQUEST['record'])) {
         $result = $focus->retrieve($_REQUEST['record']);
         if ($result == null || !$focus->ACLAccess('', $focus->isOwner($current_user->id))) {
             sugar_die($app_strings['ERROR_NO_RECORD']);
         }
     }
     if ($focus->is_AuditEnabled()) {
         $order = ' order by ' . $focus->get_audit_table_name() . '.date_created desc';
         //order by contacts_audit.date_created desc
         $query = "SELECT " . $focus->get_audit_table_name() . ".*, users.user_name FROM " . $focus->get_audit_table_name() . ", users WHERE " . $focus->get_audit_table_name() . ".created_by = users.id AND " . $focus->get_audit_table_name() . ".parent_id = '{$focus->id}'" . $order;
         $result = $focus->db->query($query);
         // We have some data.
         require 'metadata/audit_templateMetaData.php';
         $fieldDefs = $dictionary['audit']['fields'];
         while (($row = $focus->db->fetchByAssoc($result)) != null) {
             if (!ACLField::hasAccess($row['field_name'], $focus->module_dir, $GLOBALS['current_user']->id, $focus->isOwner($GLOBALS['current_user']->id))) {
                 continue;
             }
             //If the team_set_id field has a log entry, we retrieve the list of teams to display
             if ($row['field_name'] == 'team_set_id') {
                 $row['field_name'] = 'team_name';
                 require_once 'modules/Teams/TeamSetManager.php';
                 $row['before_value_string'] = TeamSetManager::getCommaDelimitedTeams($row['before_value_string']);
                 $row['after_value_string'] = TeamSetManager::getCommaDelimitedTeams($row['after_value_string']);
             }
             $temp_list = array();
             foreach ($fieldDefs as $field) {
                 if (array_key_exists($field['name'], $row)) {
                     if (($field['name'] == 'before_value_string' || $field['name'] == 'after_value_string') && (array_key_exists($row['field_name'], $genericAssocFieldsArray) || !empty($moduleAssocFieldsArray[$focus->object_name]) && array_key_exists($row['field_name'], $moduleAssocFieldsArray[$focus->object_name]))) {
                         $temp_list[$field['name']] = Audit::getAssociatedFieldName($row['field_name'], $row[$field['name']]);
                     } else {
                         $temp_list[$field['name']] = $row[$field['name']];
                     }
                     if ($field['name'] == 'date_created') {
                         $date_created = '';
                         if (!empty($temp_list[$field['name']])) {
                             $date_created = $timedate->to_display_date_time($temp_list[$field['name']]);
                             $date_created = !empty($date_created) ? $date_created : $temp_list[$field['name']];
                         }
                         $temp_list[$field['name']] = $date_created;
                     }
                     if (($field['name'] == 'before_value_string' || $field['name'] == 'after_value_string') && ($row['data_type'] == "enum" || $row['data_type'] == "multienum")) {
                         global $app_list_strings;
                         $enum_keys = unencodeMultienum($temp_list[$field['name']]);
                         $enum_values = array();
                         foreach ($enum_keys as $enum_key) {
                             if (isset($focus->field_defs[$row['field_name']]['options'])) {
                                 $domain = $focus->field_defs[$row['field_name']]['options'];
                                 if (isset($app_list_strings[$domain][$enum_key])) {
                                     $enum_values[] = $app_list_strings[$domain][$enum_key];
                                 }
                             }
                         }
                         if (!empty($enum_values)) {
                             $temp_list[$field['name']] = implode(', ', $enum_values);
                         }
                         if ($temp_list['data_type'] === 'date') {
                             $temp_list[$field['name']] = $timedate->to_display_date($temp_list[$field['name']], false);
                         }
                     } elseif (($field['name'] == 'before_value_string' || $field['name'] == 'after_value_string') && $row['data_type'] == "datetimecombo") {
                         if (!empty($temp_list[$field['name']]) && $temp_list[$field['name']] != 'NULL') {
                             $temp_list[$field['name']] = $timedate->to_display_date_time($temp_list[$field['name']]);
                         } else {
                             $temp_list[$field['name']] = '';
                         }
                     } elseif ($field['name'] == 'field_name') {
                         global $mod_strings;
                         if (isset($focus->field_defs[$row['field_name']]['vname'])) {
                             $label = $focus->field_defs[$row['field_name']]['vname'];
                             $temp_list[$field['name']] = translate($label, $focus->module_dir);
                         }
                     }
                 }
             }
             $temp_list['created_by'] = $row['user_name'];
             $audit_list[] = $temp_list;
         }
     }
     return $audit_list;
 }
示例#19
0
 /**
  * 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);
 }
示例#20
0
 //		loggedQuery(file_get_contents(dirname(__FILE__) . '/sql/update-user-preferences.sql'));
 //	}
 if ($module == 'Users') {
     $content = 'YTo0OntzOjg6InRpbWV6b25lIjtzOjE1OiJBbWVyaWNhL1Bob2VuaXgiO3M6MjoidXQiO2k6MTtzOjI0OiJIb21lX1RFQU1OT1RJQ0VfT1JERVJfQlkiO3M6MTA6ImRhdGVfc3RhcnQiO3M6MTI6InVzZXJQcml2R3VpZCI7czozNjoiYTQ4MzYyMTEtZWU4OS0wNzE0LWE0YTItNDY2OTg3YzI4NGY0Ijt9';
     $result = $GLOBALS['db']->query("SELECT id from users where id LIKE 'seed-Users%'");
     while ($row = $GLOBALS['db']->fetchByAssoc($result)) {
         $hashed_id = md5($row['id']);
         $curdt = $datetime = date('Y-m-d H:i:s');
         $stmt = "INSERT INTO user_preferences(id,category,date_entered,date_modified,assigned_user_id,contents) values ('" . $hashed_id . "', 'global', '" . $curdt . "', '" . $curdt . "', '" . $row['id'] . "', '" . $content . "')";
         loggedQuery($stmt);
     }
 }
 if ($module == 'Teams') {
     require_once 'modules/Teams/TeamSet.php';
     require_once 'modules/Teams/TeamSetManager.php';
     TeamSetManager::flushBackendCache();
     $teams_data = array();
     $result = $GLOBALS['db']->query("SELECT id FROM teams");
     while ($row = $GLOBALS['db']->fetchByAssoc($result)) {
         $teams_data[$row['id']] = $row['id'];
     }
     sort($teams_data);
     //Now generate the random team_sets
     $results = array();
     $max_teams_per_set = 10;
     if (isset($opts['s']) && $opts['s'] > 0) {
         $max_teams_per_set = $opts['s'];
     }
     foreach ($teams_data as $team_id) {
         //If there are more than 20 teams, a reasonable number of teams for a maximum team set is 10
         if ($max_teams_per_set == 1) {
示例#21
0
$xtpl->assign('EMAIL_TEMPLATE', $emailTemplate);
$xtpl->assign('FROM_NAME', $from_name);
$xtpl->assign('FROM_ADDR', $from_addr);
$xtpl->assign('DEFAULT_FROM_NAME', $default_from_name);
$xtpl->assign('DEFAULT_FROM_ADDR', $default_from_addr);
$xtpl->assign('REPLY_TO_NAME', $reply_to_name);
$xtpl->assign('REPLY_TO_ADDR', $reply_to_addr);
$xtpl->assign('ONLY_SINCE', $onlySince);
$xtpl->assign('FILTER_DOMAIN', $filterDomain);
$xtpl->assign('EMAIL_NUM_AUTOREPLIES_24_HOURS', $email_num_autoreplies_24_hours);
if (!empty($focus->port)) {
    $xtpl->assign('PORT', $focus->port);
}
if (!empty($focus->team_id)) {
    require_once 'modules/Teams/TeamSetManager.php';
    $team_name = TeamSetManager::getCommaDelimitedTeams($focus->team_set_id, $focus->team_id, true);
    if (!isset($team_name) || empty($team_name)) {
        $team_name = $app_strings['NTC_NO_ITEMS_DISPLAY'];
    }
    $xtpl->assign('TEAM_NAME', $team_name);
}
if ($focus->handleIsPersonal()) {
    $xtpl->assign('LBL_GROUP_QUEUE', $mod_strings['LBL_ASSIGN_TO_USER']);
} else {
    $xtpl->assign('LBL_GROUP_QUEUE', $mod_strings['LBL_GROUP_QUEUE']);
}
//Overrides for bounce mailbox accounts
if ($focus->mailbox_type == 'bounce') {
    $xtpl->assign('MODULE_TITLE', getClassicModuleTitle('InboundEmail', array($mod_strings['LBL_BOUNCE_MODULE_NAME'], $focus->name), true));
} else {
    if ($focus->is_personal == '1') {
示例#22
0
 protected function setupAdvancedTabTeamSettings()
 {
     global $sugar_config;
     $authclass = '';
     if (!empty($sugar_config['authenticationClass'])) {
         $this->ss->assign('EXTERNAL_AUTH_CLASS_1', $sugar_config['authenticationClass']);
         $this->ss->assign('EXTERNAL_AUTH_CLASS', $sugar_config['authenticationClass']);
         $authclass = $sugar_config['authenticationClass'];
     } else {
         if (!empty($GLOBALS['system_config']->settings['system_ldap_enabled'])) {
             $this->ss->assign('EXTERNAL_AUTH_CLASS_1', translate('LBL_LDAP', 'Users'));
             $this->ss->assign('EXTERNAL_AUTH_CLASS', translate('LBL_LDAP_AUTHENTICATION', 'Users'));
             $authclass = 'LDAPAuthenticate';
         }
     }
     if (!empty($this->bean->external_auth_only)) {
         $this->ss->assign('EXTERNAL_AUTH_ONLY_CHECKED', 'CHECKED');
     }
     if ($this->is_super_admin && !empty($authclass)) {
         $this->ss->assign('DISPLAY_EXTERNAL_AUTH', true);
     }
     if (!empty($this->bean->id)) {
         require_once 'include/SugarFields/Fields/Teamset/EmailSugarFieldTeamsetCollection.php';
         // Display only the teams the user we're editing belongs to
         $teamsWidget = new EmailSugarFieldTeamsetCollection($this->bean, $this->bean->field_defs, 'get_non_private_teams_array', $this->viewType);
         $teamsWidget->user_id = $this->bean->id;
         $this->ss->assign('DEFAULT_TEAM_OPTIONS', $teamsWidget->get_code());
         require_once 'modules/Teams/TeamSetManager.php';
         $default_teams = TeamSetManager::getCommaDelimitedTeams($this->bean->team_set_id, $this->bean->team_id, true);
         $this->ss->assign("DEFAULT_TEAM_LIST", $default_teams);
     }
     $this->ss->assign('SHOW_TEAM_SELECTION', !empty($this->bean->id));
     $this->ss->assign('IS_PORTALONLY', '0');
     if (isset($sugar_config['enable_web_services_user_creation']) && $sugar_config['enable_web_services_user_creation'] && (!empty($this->bean->portal_only) && $this->bean->portal_only) || isset($_REQUEST['usertype']) && $_REQUEST['usertype'] == 'portal') {
         $this->ss->assign('IS_PORTALONLY', '1');
         $this->usertype = 'PORTAL_ONLY';
     }
 }
示例#23
0
 /**
  * Given an array of team_ids, determine if the set already exists, if it does return the set_id, if not,
  * create the set and return the id.
  *
  * @param array $team_ids
  * @return id	the id of the newly created team set
  */
 public function addTeams($team_ids)
 {
     if (!is_array($team_ids)) {
         $team_ids = array($team_ids);
     }
     $stats = $this->_getStatistics($team_ids);
     $team_md5 = $stats['team_md5'];
     $team_count = $stats['team_count'];
     $this->primary_team_id = $stats['primary_team_id'];
     $team_ids = $stats['team_ids'];
     //we may already have this team set id in cache, so let's not bother to run a select
     //just return
     $teamSetIdFromMD5 = TeamSetManager::getTeamSetIdFromMD5($team_md5);
     if (!is_null($teamSetIdFromMD5)) {
         return $teamSetIdFromMD5;
     }
     $sql = "SELECT id FROM {$this->table_name} WHERE team_md5 = '{$team_md5}'";
     $result = $this->db->query($sql);
     $row = $this->db->fetchByAssoc($result);
     if (!$row) {
         //we did not find a set with this combination of teams
         //so we should create the set and associate the teams with the set and return the set id.
         if (count($team_ids) == 1) {
             $this->new_with_id = true;
             $this->id = $team_ids[0];
             if ($this->db->getOne(sprintf("SELECT id FROM %s WHERE id='%s'", $this->table_name, $this->db->quote($this->id)))) {
                 $GLOBALS['log']->error("Detected duplicate team set for {$this->id}");
                 // Reset new_with_id so we overwrite this wrong set
                 $this->new_with_id = false;
             }
         }
         $this->team_md5 = $team_md5;
         $this->primary_team_id = $this->getPrimaryTeamId();
         $this->name = $team_md5;
         $this->team_count = $team_count;
         $this->save();
         foreach ($team_ids as $team_id) {
             $this->_addTeamToSet($team_id);
         }
         TeamSetManager::addTeamSetMD5($this->id, $this->team_md5);
         return $this->id;
     } else {
         TeamSetManager::addTeamSetMD5($row['id'], $team_md5);
         return $row['id'];
     }
 }
示例#24
0
function bpminbox_check_special_fields($field_name, $source_object, $use_past_array = false, $context = null)
{
    global $locale;
    // FIXME: Special cases for known non-db but allowed fields
    if ($field_name == 'full_name') {
        if ($use_past_array == false) {
            //use the future value
            return $locale->getLocaleFormattedName($source_object->first_name, $source_object->last_name);
        } else {
            //use the past value
            return $locale->getLocaleFormattedName($source_object->fetched_row['first_name'], $source_object->fetched_row['last_name']);
        }
    } elseif ($field_name == 'modified_by_name' && $use_past_array) {
        return $source_object->old_modified_by_name;
    } elseif ($field_name == 'assigned_user_name' && $use_past_array) {
        // We have to load the user here since fetched_row only has the ID, not the name
        return bpminbox_get_username_by_id($source_object->fetched_row['assigned_user_id']);
    } elseif ($field_name == 'team_name') {
        require_once 'modules/Teams/TeamSetManager.php';
        if ($use_past_array == false) {
            if (empty($source_object->team_set_id)) {
                if (!empty($source_object->teams)) {
                    $source_object->teams->save();
                }
            }
            $team_set_id = $source_object->team_set_id;
            $team_id = $source_object->team_id;
        } else {
            $team_set_id = $source_object->fetched_row['team_set_id'];
            $team_id = $source_object->fetched_row['team_id'];
        }
        return TeamSetManager::getCommaDelimitedTeams($team_set_id, $team_id, true);
    } else {
        /* One off exception for if we are getting future date_created value.
            Use the fetched row for it. - jgreen
           */
        if ($use_past_array == false && $field_name != "date_entered") {
            //use the future value
            return bpminbox_get_display_text($source_object, $field_name, $source_object->{$field_name}, null, null, $context);
        } else {
            //use the past value
            return bpminbox_get_display_text($source_object, $field_name, $source_object->fetched_row[$field_name], null, null, $context);
        }
    }
    //In future, check for maybe currency type
    //end function check_special_fields
}
示例#25
0
function clean_up_team_sets()
{
    require_once 'modules/Teams/TeamSetManager.php';
    TeamSetManager::cleanUp();
}
示例#26
0
}
$xtpl->assign("NAME", $focus->name);
$xtpl->assign("DESCRIPTION", $focus->description);
$xtpl->assign("SUBJECT", $focus->subject);
$xtpl->assign("BODY", $focus->body);
$xtpl->assign("BODY_HTML", json_encode(from_html($focus->body_html)));
$xtpl->assign("DATE_MODIFIED", $focus->date_modified);
$xtpl->assign("DATE_ENTERED", $focus->date_entered);
$xtpl->assign("ASSIGNED_USER_NAME", $focus->assigned_user_name);
$xtpl->assign("TYPE", $app_list_strings['emailTemplates_type_list'][$focus->type]);
if ($focus->ACLAccess('EditView')) {
    $xtpl->parse("main.edit");
    //$xtpl->out("EDIT");
}
require_once 'modules/Teams/TeamSetManager.php';
$xtpl->assign('TEAM', TeamSetManager::getCommaDelimitedTeams($focus->team_set_id, $focus->team_id, true));
if (!empty($focus->body)) {
    $xtpl->assign('ALT_CHECKED', 'CHECKED');
} else {
    $xtpl->assign('ALT_CHECKED', '');
}
if ($focus->published == 'on') {
    $xtpl->assign("PUBLISHED", "CHECKED");
}
///////////////////////////////////////////////////////////////////////////////
////	NOTES (attachements, etc.)
///////////////////////////////////////////////////////////////////////////////
$note = BeanFactory::getBean('Notes');
$where = "notes.parent_id='{$focus->id}'";
$notes_list = $note->get_full_list("notes.name", $where, true);
if (!isset($notes_list)) {
示例#27
0
 /**
  * This function returns the detail view for email in new 2.0 interface
  *
  */
 function getDetailViewForEmail2($emailId)
 {
     require_once 'include/DetailView/DetailView.php';
     global $app_strings, $app_list_strings;
     global $mod_strings;
     $smarty = new Sugar_Smarty();
     // SETTING DEFAULTS
     $focus = BeanFactory::getBean('Emails', $emailId);
     $detailView->ss = new Sugar_Smarty();
     $detailView = new DetailView();
     $title = "";
     $offset = 0;
     if ($focus->type == 'out') {
         $title = getClassicModuleTitle('Emails', array($mod_strings['LBL_SENT_MODULE_NAME'], $focus->name), true);
     } elseif ($focus->type == 'draft') {
         $title = getClassicModuleTitle('Emails', array($mod_strings['LBL_LIST_FORM_DRAFTS_TITLE'], $focus->name), true);
     } elseif ($focus->type == 'inbound') {
         $title = getClassicModuleTitle('Emails', array($mod_strings['LBL_INBOUND_TITLE'], $focus->name), true);
     }
     $smarty->assign("emailTitle", $title);
     // DEFAULT TO TEXT IF NO HTML CONTENT:
     $html = trim(from_html($focus->description_html));
     if (empty($html)) {
         $smarty->assign('SHOW_PLAINTEXT', 'true');
     } else {
         $smarty->assign('SHOW_PLAINTEXT', 'false');
     }
     //if not empty or set to test (from test campaigns)
     if (!empty($focus->parent_type) && $focus->parent_type != 'test') {
         $smarty->assign('PARENT_MODULE', $focus->parent_type);
         $smarty->assign('PARENT_TYPE', $app_list_strings['record_type_display'][$focus->parent_type] . ":");
     }
     global $gridline;
     $smarty->assign('MOD', $mod_strings);
     $smarty->assign('APP', $app_strings);
     $smarty->assign('GRIDLINE', $gridline);
     $smarty->assign('PRINT_URL', 'index.php?' . $GLOBALS['request_string']);
     $smarty->assign('ID', $focus->id);
     $smarty->assign('TYPE', $focus->type);
     $smarty->assign('PARENT_NAME', $focus->parent_name);
     $smarty->assign('PARENT_ID', $focus->parent_id);
     $smarty->assign('NAME', $focus->name);
     $smarty->assign('ASSIGNED_TO', $focus->assigned_user_name);
     $smarty->assign('DATE_MODIFIED', $focus->date_modified);
     $smarty->assign('DATE_ENTERED', $focus->date_entered);
     $smarty->assign('DATE_START', $focus->date_start);
     $smarty->assign('TIME_START', $focus->time_start);
     $smarty->assign('FROM', $focus->from_addr);
     $smarty->assign('TO', nl2br($focus->to_addrs));
     $smarty->assign('CC', nl2br($focus->cc_addrs));
     $smarty->assign('BCC', nl2br($focus->bcc_addrs));
     $smarty->assign('CREATED_BY', $focus->created_by_name);
     $smarty->assign('MODIFIED_BY', $focus->modified_by_name);
     $smarty->assign('DATE_SENT', $focus->date_entered);
     $smarty->assign('EMAIL_NAME', 'RE: ' . $focus->name);
     $smarty->assign("TAG", $focus->listviewACLHelper());
     $smarty->assign("SUGAR_VERSION", $GLOBALS['sugar_version']);
     $smarty->assign("JS_CUSTOM_VERSION", $GLOBALS['sugar_config']['js_custom_version']);
     require_once 'modules/Teams/TeamSetManager.php';
     $smarty->assign("TEAM", TeamSetManager::getCommaDelimitedTeams($focus->team_set_id, $focus->team_id, true));
     if (!empty($focus->reply_to_email)) {
         $replyTo = "\n\t\t\t\t<tr>\n\t\t        <td class=\"tabDetailViewDL\"><slot>" . $mod_strings['LBL_REPLY_TO_NAME'] . "</slot></td>\n\t\t        <td colspan=3 class=\"tabDetailViewDF\"><slot>" . $focus->reply_to_addr . "</slot></td>\n\t\t        </tr>";
         $smarty->assign("REPLY_TO", $replyTo);
     }
     ///////////////////////////////////////////////////////////////////////////////
     ////	JAVASCRIPT VARS
     $jsVars = '';
     $jsVars .= "var showRaw = '{$mod_strings['LBL_BUTTON_RAW_LABEL']}';";
     $jsVars .= "var hideRaw = '{$mod_strings['LBL_BUTTON_RAW_LABEL_HIDE']}';";
     $smarty->assign("JS_VARS", $jsVars);
     ///////////////////////////////////////////////////////////////////////////////
     ////	NOTES (attachements, etc.)
     ///////////////////////////////////////////////////////////////////////////////
     $note = BeanFactory::getBean('Notes');
     $where = "notes.parent_id='{$focus->id}'";
     //take in account if this is from campaign and the template id is stored in the macros.
     if (isset($macro_values) && isset($macro_values['email_template_id'])) {
         $where = "notes.parent_id='{$macro_values['email_template_id']}'";
     }
     $notes_list = $note->get_full_list("notes.name", $where, true);
     if (!isset($notes_list)) {
         $notes_list = array();
     }
     $attachments = '';
     for ($i = 0; $i < count($notes_list); $i++) {
         $the_note = $notes_list[$i];
         $attachments .= "<a href=\"index.php?entryPoint=download&id={$the_note->id}&type=Notes\">" . $the_note->name . "</a><br />";
         $focus->cid2Link($the_note->id, $the_note->file_mime_type);
     }
     $smarty->assign('DESCRIPTION', nl2br($focus->description));
     $smarty->assign('DESCRIPTION_HTML', from_html($focus->description_html));
     $smarty->assign("ATTACHMENTS", $attachments);
     ///////////////////////////////////////////////////////////////////////////////
     ////    SUBPANELS
     ///////////////////////////////////////////////////////////////////////////////
     $show_subpanels = true;
     if ($show_subpanels) {
         require_once 'include/SubPanel/SubPanelTiles.php';
         $subpanel = new SubPanelTiles($focus, 'Emails');
         $smarty->assign("SUBPANEL", $subpanel->display());
     }
     $meta['html'] = $smarty->fetch("modules/Emails/templates/emailDetailView.tpl");
     return $meta;
 }