/** * Renders the frame for emails */ function displayEmailFrame() { require_once "include/OutboundEmail/OutboundEmail.php"; global $app_strings, $app_list_strings; global $mod_strings; global $sugar_config; global $current_user; global $locale; global $timedate; global $theme; global $sugar_version; global $sugar_flavor; global $current_language; global $server_unique_key; $this->preflightUserCache(); $ie = new InboundEmail(); // focus listView $list = array('mbox' => 'Home', 'ieId' => '', 'name' => 'Home', 'unreadChecked' => 0, 'out' => array()); $this->_generateComposeConfigData('email_compose'); //Check quick create module access $QCAvailableModules = $this->_loadQuickCreateModules(); //Get the quickSearch js needed for assigned user id on Search Tab require_once 'include/QuickSearchDefaults.php'; $qsd = QuickSearchDefaults::getQuickSearchDefaults(); $qsd->setFormName('advancedSearchForm'); $quicksearchAssignedUser = "******"; $quicksearchAssignedUser .= "sqs_objects['advancedSearchForm_assigned_user_name']=" . json_encode($qsd->getQSUser()) . ";"; $qsd->setFormName('Distribute'); $quicksearchAssignedUser .= "sqs_objects['Distribute_assigned_user_name']=" . json_encode($qsd->getQSUser()) . ";"; $this->smarty->assign('quickSearchForAssignedUser', $quicksearchAssignedUser); /////////////////////////////////////////////////////////////////////// //// BASIC ASSIGNS $this->smarty->assign("currentUserId", $current_user->id); $this->smarty->assign("CURRENT_USER_EMAIL", $current_user->email1); $this->smarty->assign("currentUserName", $current_user->name); $this->smarty->assign('yuiPath', 'modules/Emails/javascript/yui-ext/'); $this->smarty->assign('app_strings', $app_strings); $this->smarty->assign('mod_strings', $mod_strings); $this->smarty->assign('theme', $theme); $this->smarty->assign('sugar_config', $sugar_config); $this->smarty->assign('is_admin', $current_user->is_admin); $this->smarty->assign('sugar_version', $sugar_version); $this->smarty->assign('sugar_flavor', $sugar_flavor); $this->smarty->assign('current_language', $current_language); $this->smarty->assign('server_unique_key', $server_unique_key); $this->smarty->assign('qcModules', json_encode($QCAvailableModules)); $extAllDebugValue = "ext-all.js"; $this->smarty->assign('extFileName', $extAllDebugValue); // settings: general $e2UserPreferences = $this->getUserPrefsJS(); $emailSettings = $e2UserPreferences['emailSettings']; /////////////////////////////////////////////////////////////////////// //// USER SETTINGS // settings: accounts $cuDatePref = $current_user->getUserDateTimePreferences(); $this->smarty->assign('dateFormat', $cuDatePref['date']); $this->smarty->assign('dateFormatExample', str_replace(array("Y", "m", "d"), array("yyyy", "mm", "dd"), $cuDatePref['date'])); $this->smarty->assign('calFormat', $timedate->get_cal_date_format()); $this->smarty->assign('TIME_FORMAT', $timedate->get_user_time_format()); $ieAccounts = $ie->retrieveByGroupId($current_user->id); $ieAccountsOptions = "<option value=''>{$app_strings['LBL_NONE']}</option>\n"; foreach ($ieAccounts as $k => $v) { $disabled = !$v->is_personal ? "DISABLED" : ""; $group = !$v->is_personal ? $app_strings['LBL_EMAIL_GROUP'] . "." : ""; $ieAccountsOptions .= "<option value='{$v->id}' {$disabled}>{$group}{$v->name}</option>\n"; } $this->smarty->assign('ieAccounts', $ieAccountsOptions); $this->smarty->assign('rollover', $this->rolloverStyle); $protocol = filterInboundEmailPopSelection($app_list_strings['dom_email_server_type']); $this->smarty->assign('PROTOCOL', get_select_options_with_id($protocol, '')); $this->smarty->assign('MAIL_SSL_OPTIONS', get_select_options_with_id($app_list_strings['email_settings_for_ssl'], '')); $this->smarty->assign('ie_mod_strings', return_module_language($current_language, 'InboundEmail')); $charsetSelectedValue = isset($emailSettings['defaultOutboundCharset']) ? $emailSettings['defaultOutboundCharset'] : false; if (!$charsetSelectedValue) { $charsetSelectedValue = $current_user->getPreference('default_export_charset', 'global'); if (!$charsetSelectedValue) { $charsetSelectedValue = $locale->getPrecedentPreference('default_email_charset'); } } $charset = array('options' => $locale->getCharsetSelect(), 'selected' => $charsetSelectedValue); $this->smarty->assign('charset', $charset); $emailCheckInterval = array('options' => $app_strings['LBL_EMAIL_CHECK_INTERVAL_DOM'], 'selected' => $emailSettings['emailCheckInterval']); $this->smarty->assign('emailCheckInterval', $emailCheckInterval); $this->smarty->assign('attachmentsSearchOptions', $app_list_strings['checkbox_dom']); $this->smarty->assign('sendPlainTextChecked', $emailSettings['sendPlainText'] == 1 ? 'CHECKED' : ''); $this->smarty->assign('showNumInList', get_select_options_with_id($app_list_strings['email_settings_num_dom'], $emailSettings['showNumInList'])); //// END USER SETTINGS /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// //// SIGNATURES $prependSignature = $current_user->getPreference('signature_prepend') ? 'true' : 'false'; $defsigID = $current_user->getPreference('signature_default'); $this->smarty->assign('signatures', $current_user->getSignatures(false, $defsigID)); $this->smarty->assign('signaturesSettings', $current_user->getSignatures(false, $defsigID, false)); $signatureButtons = $current_user->getSignatureButtons('SUGAR.email2.settings.createSignature', !empty($defsigID)); if (!empty($defsigID)) { $signatureButtons = $signatureButtons . '<span name="delete_sig" id="delete_sig" style="visibility:inherit;"><input class="button" onclick="javascript:SUGAR.email2.settings.deleteSignature();" value="' . $app_strings['LBL_EMAIL_DELETE'] . '" type="button" tabindex="392"> </span>'; } else { $signatureButtons = $signatureButtons . '<span name="delete_sig" id="delete_sig" style="visibility:hidden;"><input class="button" onclick="javascript:SUGAR.email2.settings.deleteSignature();" value="' . $app_strings['LBL_EMAIL_DELETE'] . '" type="button" tabindex="392"> </span>'; } $this->smarty->assign('signatureButtons', $signatureButtons); $this->smarty->assign('signaturePrepend', $prependSignature == 'true' ? 'CHECKED' : ''); //// END SIGNATURES /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// //// EMAIL TEMPLATES $email_templates_arr = $this->getEmailTemplatesArray(); natcasesort($email_templates_arr); $this->smarty->assign('EMAIL_TEMPLATE_OPTIONS', get_select_options_with_id($email_templates_arr, '')); //// END EMAIL TEMPLATES /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// //// FOLDERS & TreeView $this->smarty->assign('groupUserOptions', $ie->getGroupsWithSelectOptions(array('' => $app_strings['LBL_EMAIL_CREATE_NEW']))); $tree = $this->getMailboxNodes(); // preloaded folder $preloadFolder = 'lazyLoadFolder = '; $focusFolderSerial = $current_user->getPreference('focusFolder', 'Emails'); if (!empty($focusFolderSerial)) { $focusFolder = unserialize($focusFolderSerial); //$focusFolder['ieId'], $focusFolder['folder'] $preloadFolder .= json_encode($focusFolder) . ";"; } else { $preloadFolder .= "new Object();"; } //// END FOLDERS /////////////////////////////////////////////////////////////////////// $out = ""; $out .= $this->smarty->fetch("modules/Emails/templates/_baseEmail.tpl"); $out .= $tree->generate_header(); $out .= $tree->generateNodesNoInit(true, 'email2treeinit'); $out .= <<<eoq \t\t\t<script type="text/javascript" language="javascript"> \t\t\t\tvar loader = new YAHOO.util.YUILoader({ \t\t\t\t require : [ \t\t\t\t \t"layout", "element", "tabview", "menu", \t\t\t\t \t"cookie", "sugarwidgets" \t\t\t\t ], \t\t\t\t loadOptional: true, \t\t\t\t skin: { base: 'blank', defaultSkin: '' }, \t\t\t\t onSuccess: email2init, \t\t\t\t allowRollup: true, \t\t\t\t base: "include/javascript/yui/build/" \t\t\t\t}); \t\t\t\tloader.addModule({ \t\t\t\t name :"sugarwidgets", \t\t\t\t type : "js", \t\t\t\t fullpath: "include/javascript/sugarwidgets/SugarYUIWidgets.js", \t\t\t\t varName: "YAHOO.SUGAR", \t\t\t\t requires: ["datatable", "dragdrop", "treeview", "tabview", "calendar"] \t\t\t\t}); \t\t\t\tloader.insert(); \t\t\t\t{$preloadFolder}; \t\t\t</script> eoq; return $out; }
$GLOBALS['log']->debug("isDuplicate found - duplicating record of id: " . $focus->id); $focus->id = ""; } $GLOBALS['log']->info("InboundEmail Edit View"); /* End standard EditView setup logic */ /* Start custom setup logic */ // status drop down $status = get_select_options_with_id_separate_key($app_list_strings['user_status_dom'], $app_list_strings['user_status_dom'], $focus->status); // Groups $selectGroups = '<option value="new">' . $mod_strings['LBL_CREATE_NEW_GROUP'] . '</option>'; // handle if this I-E is personal or group $isPersonal = false; if (!empty($focus->id)) { $isPersonal = $focus->handleIsPersonal(); } if ($selects = $focus->getGroupsWithSelectOptions()) { $selectGroups .= $selects; } if ($isPersonal) { // stomp out standard $selectGroups = '<option value="' . $focus->group_id . '">' . $focus->getUserNameFromGroupId() . '</option>'; } // default MAILBOX value if (empty($focus->mailbox)) { $mailbox = 'INBOX'; } else { $mailbox = $focus->mailbox; } // service options breakdown $tls = ''; $notls = '';
/** * Renders the frame for emails */ function displayEmailFrame() { require_once "include/OutboundEmail/OutboundEmail.php"; global $app_strings, $app_list_strings; global $mod_strings; global $sugar_config; global $current_user; global $locale; global $timedate; global $theme; global $sugar_version; global $sugar_flavor; global $current_language; global $server_unique_key; $this->preflightUserCache(); $json = getJSONobj(); $ie = new InboundEmail(); $out = '<script type="text/javascript" language="Javascript" src="modules/Emails/javascript/vars.js"></script>'; // focus listView $list = array('mbox' => 'Home', 'ieId' => '', 'name' => 'Home', 'unreadChecked' => 0, 'out' => array()); // lang pack $lang = "var app_strings = new Object();\n"; foreach ($app_strings as $k => $v) { if (strpos($k, 'LBL_EMAIL_') !== false) { $lang .= "app_strings.{$k} = '{$v}';\n"; } } $modStrings = "var mod_strings = new Object();\n"; foreach ($mod_strings as $k => $v) { $v = str_replace("'", "\\'", $v); $modStrings .= "mod_strings.{$k} = '{$v}';\n"; } $lang .= "\n\n{$modStrings}\n"; // link drop-down $parent_types = $app_list_strings['record_type_display']; $disabled_parent_types = ACLController::disabledModuleList($parent_types, false, 'list'); foreach ($disabled_parent_types as $disabled_parent_type) { unset($parent_types[$disabled_parent_type]); } $linkBeans = $json->encode(get_select_options_with_id($parent_types, '')); //TinyMCE Config require_once "include/SugarTinyMCE.php"; $tiny = new SugarTinyMCE(); $tinyConf = $tiny->getConfig(); //Check quick create module access $QCAvailibleModules = array(); $QCModules = array('Bugs', 'Cases', 'Contacts', 'Leads', 'Tasks'); foreach ($QCModules as $module) { $class = substr($module, 0, strlen($module) - 1); require_once "modules/{$module}/{$class}.php"; if ($class == "Case") { $class = "aCase"; } $seed = new $class(); if ($seed->ACLAccess('edit')) { $QCAvailibleModules[] = $module; } } /////////////////////////////////////////////////////////////////////// //// BASIC ASSIGNS $charsets = $json->encode($locale->getCharsetSelect()); $this->smarty->assign('yuiPath', 'modules/Emails/javascript/yui-ext/'); $this->smarty->assign('app_strings', $app_strings); $this->smarty->assign('mod_strings', $mod_strings); $this->smarty->assign('theme', $theme); $this->smarty->assign('lang', $lang); $this->smarty->assign('linkBeans', $linkBeans); $this->smarty->assign('sugar_config', $sugar_config); $this->smarty->assign('emailCharsets', $charsets); $this->smarty->assign('is_admin', $current_user->is_admin); $this->smarty->assign('sugar_version', $sugar_version); $this->smarty->assign('sugar_flavor', $sugar_flavor); $this->smarty->assign('current_language', $current_language); $this->smarty->assign('server_unique_key', $server_unique_key); $this->smarty->assign('tinyMCE', $tinyConf); $this->smarty->assign('qcModules', $json->encode($QCAvailibleModules)); $extAllDebugValue = "ext-all.js"; $this->smarty->assign('extFileName', $extAllDebugValue); //#20776 jchi $peopleTables = array("users", "contacts", "leads", "prospects"); $filterPeopleTables = array(); global $app_list_strings, $app_strings; $filterPeopleTables['LBL_DROPDOWN_LIST_ALL'] = $app_strings['LBL_DROPDOWN_LIST_ALL']; foreach ($peopleTables as $table) { $module = ucfirst($table); $class = substr($module, 0, strlen($module) - 1); require_once "modules/{$module}/{$class}.php"; $person = new $class(); if (!$person->ACLAccess('list')) { continue; } $filterPeopleTables[$person->table_name] = $app_list_strings['moduleList'][$person->module_dir]; } $this->smarty->assign('listOfPersons', get_select_options_with_id($filterPeopleTables, '')); // settings: general $e2UserPreferences = $this->getUserPrefsJS(); $emailSettings = $e2UserPreferences['emailSettings']; /////////////////////////////////////////////////////////////////////// //// USER SETTINGS // settings: accounts $cuDatePref = $current_user->getUserDateTimePreferences(); $this->smarty->assign('dateFormat', $cuDatePref['date']); $this->smarty->assign('dateFormatExample', str_replace(array("Y", "m", "d"), array("yyyy", "mm", "dd"), $cuDatePref['date'])); $this->smarty->assign('calFormat', $timedate->get_cal_date_format()); $viewRawEmail = 'false'; if (isset($sugar_config['email_inbound_save_raw']) && $sugar_config['email_inbound_save_raw'] == true) { $viewRawEmail = 'true'; } $this->smarty->assign('viewRawSource', $viewRawEmail); $ieAccounts = $ie->retrieveByGroupId($current_user->id); $ieAccountsOptions = "<option value=''>{$app_strings['LBL_NONE']}</option>\n"; foreach ($ieAccounts as $k => $v) { $disabled = !$v->is_personal ? "DISABLED" : ""; $group = !$v->is_personal ? $app_strings['LBL_EMAIL_GROUP'] . "." : ""; $ieAccountsOptions .= "<option value='{$v->id}' {$disabled}>{$group}{$v->name}</option>\n"; } $this->smarty->assign('ieAccounts', $ieAccountsOptions); $this->smarty->assign('rollover', $this->rolloverStyle); $this->smarty->assign('PROTOCOL', get_select_options_with_id($app_list_strings['dom_email_server_type'], '')); $this->smarty->assign('MAIL_SSL_OPTIONS', get_select_options_with_id($app_list_strings['email_settings_for_ssl'], '')); $this->smarty->assign('ie_mod_strings', return_module_language($current_language, 'InboundEmail')); // outbound opts $oe = new OutboundEmail(); $outbounds = $oe->getUserMailers($current_user); $smtpOptions = "SUGAR.mailers = "; $smtpOptions .= $json->encode($outbounds, false); $charset = array('options' => $locale->getCharsetSelect(), 'selected' => $emailSettings['defaultOutboundCharset']); $this->smarty->assign('charset', $charset); $emailCheckInterval = array('options' => $app_strings['LBL_EMAIL_CHECK_INTERVAL_DOM'], 'selected' => $emailSettings['emailCheckInterval']); $this->smarty->assign('emailCheckInterval', $emailCheckInterval); $emailSettings['layoutStyle'] == '2rows' ? $this->smarty->assign('rowsChecked', 'CHECKED') : $this->smarty->assign('colsChecked', 'CHECKED'); //$this->smarty->assign('autoImportChecked', ($emailSettings['autoImport'] == 1) ? 'CHECKED' : ""); $this->smarty->assign('alwaysSaveOutboundChecked', $emailSettings['alwaysSaveOutbound'] ? 'CHECKED' : ""); $this->smarty->assign('sendPlainTextChecked', $emailSettings['sendPlainText'] == 1 ? 'CHECKED' : ''); $this->smarty->assign('tabPositionChecked', $emailSettings['tabPosition'] == 'bottom' ? 'CHECKED' : ''); $this->smarty->assign('showNumInList', get_select_options_with_id($app_strings['LBL_EMAIL_SETTING_NUM_DOM'], $emailSettings['showNumInList'])); $this->smarty->assign('fullScreenChecked', $emailSettings['fullScreen'] == 1 ? "CHECKED" : ""); $this->smarty->assign('userPrefs', $json->encode($this->getUserPrefsJS())); //// END USER SETTINGS /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// //// SIGNATURES $prependSignature = $current_user->getPreference('signature_prepend') ? 'true' : 'false'; $defsigID = $current_user->getPreference('signature_default'); $defaultSignature = $current_user->getDefaultSignature(); $sigJson = !empty($defaultSignature) ? $json->encode(array($defaultSignature['id'] => from_html($defaultSignature['signature_html']))) : "new Object()"; $this->smarty->assign('defaultSignature', $sigJson); $this->smarty->assign('signatures', $current_user->getSignatures(false, $defsigID)); $this->smarty->assign('signaturesSettings', $current_user->getSignatures(false, $defsigID, false)); $signatureButtons = $current_user->getSignatureButtons('SUGAR.email2.settings.createSignature', !empty($defsigID)); if (!empty($defsigID)) { $signatureButtons = $signatureButtons . '<span name="delete_sig" id="delete_sig" style="visibility:inherit;"><input class="button" onclick="javascript:SUGAR.email2.settings.deleteSignature();" value="' . $app_strings['LBL_EMAIL_DELETE'] . '" type="button" tabindex="392"> </span>'; } else { $signatureButtons = $signatureButtons . '<span name="delete_sig" id="delete_sig" style="visibility:hidden;"><input class="button" onclick="javascript:SUGAR.email2.settings.deleteSignature();" value="' . $app_strings['LBL_EMAIL_DELETE'] . '" type="button" tabindex="392"> </span>'; } $this->smarty->assign('signatureButtons', $signatureButtons); $this->smarty->assign('signaturePrepend', $prependSignature == 'true' ? 'CHECKED' : ''); $this->smarty->assign('signatureDefaultId', isset($defaultSignature['id']) ? $defaultSignature['id'] : ""); //// END SIGNATURES /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// //// EMAIL TEMPLATES $email_templates_arr = $this->getEmailTemplatesArray(); $this->smarty->assign('EMAIL_TEMPLATE_OPTIONS', get_select_options_with_id($email_templates_arr, '')); //// END EMAIL TEMPLATES /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// //// FOLDERS & TreeView $this->smarty->assign('groupUserOptions', $ie->getGroupsWithSelectOptions(array('' => $app_strings['LBL_EMAIL_CREATE_NEW']))); $tree = $this->getMailboxNodes(); // preloaded folder $preloadFolder = 'lazyLoadFolder = '; $focusFolderSerial = $current_user->getPreference('focusFolder', 'Emails'); if (!empty($focusFolderSerial)) { $focusFolder = unserialize($focusFolderSerial); //$focusFolder['ieId'], $focusFolder['folder'] $preloadFolder .= $json->encode($focusFolder) . ";"; } else { $preloadFolder .= "new Object();"; } //// END FOLDERS /////////////////////////////////////////////////////////////////////// $fullscreen = ''; if ($emailSettings['fullScreen'] == 1) { $fullscreen = 'SUGAR.ui.toggleHeader();'; } $out .= $this->smarty->fetch("modules/Emails/templates/_baseEmail.tpl"); $out .= $tree->generate_header(); $out .= $tree->generateNodesNoInit(true, 'email2treeinit'); $out .= <<<eoq \t\t\t<script type="text/javascript" language="javascript"> \t\t\t\t{$fullscreen} \t\t\t\tvar loader = new YAHOO.util.YUILoader({ \t\t\t\t require : ["layout", "element", "tabview", "menu", "cookie", "sugarwidgets"], \t\t\t\t loadOptional: true, \t\t\t\t filter: 'debug', \t\t\t\t skin: "", \t\t\t\t onSuccess: email2init, \t\t\t\t allowRollup: true, \t\t\t\t base: "include/javascript/yui/build/" \t\t\t\t}); \t\t\t\tloader.addModule({ \t\t\t\t name :"sugarwidgets", \t\t\t\t type : "js", \t\t\t\t fullpath: "include/javascript/sugarwidgets/SugarYUIWidgets.js", \t\t\t\t varName: "YAHOO.SUGAR", \t\t\t\t requires: ["datatable", "dragdrop", "treeview", "tabview"] \t\t\t\t}); \t\t\t\tloader.insert(); \t\t\t\t{$preloadFolder}; \t\t\t\t{$smtpOptions}; \t\t\t</script> eoq; return $out; }
public function testgetGroupsWithSelectOptions() { //unset and reconnect Db to resolve mysqli fetch exeception global $db; unset($db->database); $db->checkConnection(); $inboundEmail = new InboundEmail(); $inboundEmail->group_id = 1; $result = $inboundEmail->getGroupsWithSelectOptions(); $this->assertEquals('', $result); $expected = "\n<OPTION value='0'>1</OPTION>\n<OPTION selected value='1'>2</OPTION>\n<OPTION value='2'>3</OPTION>"; $result = $inboundEmail->getGroupsWithSelectOptions(array(1, 2, 3)); $this->assertEquals($expected, $result); //var_dump($result); }