示例#1
0
    /**
     * 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">&nbsp;
					</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">&nbsp;
					</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;
    }
示例#2
0
     $GLOBALS['log']->debug("********** EMAIL 2.0 - Asynchronous - at: saveListViewSortOrder");
     $email->et->saveListViewSortOrder($_REQUEST['ieId'], $_REQUEST['focusFolder'], $_REQUEST['sortBy'], $_REQUEST['reverse']);
     break;
     ////    END FOLDER ACTIONS
     ///////////////////////////////////////////////////////////////////////////
     ///////////////////////////////////////////////////////////////////////////
     ////    INBOUND EMAIL ACCOUNTS
 ////    END FOLDER ACTIONS
 ///////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////
 ////    INBOUND EMAIL ACCOUNTS
 case "retrieveAllOutbound":
     $GLOBALS['log']->debug("********** EMAIL 2.0 - Asynchronous - at: retrieveAllOutbound");
     global $current_user;
     $oe = new OutboundEmail();
     $outbounds = $oe->getUserMailers($current_user);
     $results = array('outbound_account_list' => $outbounds, 'count' => count($outbounds));
     $out = $json->encode($results, false);
     echo $out;
     break;
 case "editOutbound":
     $GLOBALS['log']->debug("********** EMAIL 2.0 - Asynchronous - at: editOutbound");
     if (isset($_REQUEST['outbound_email']) && !empty($_REQUEST['outbound_email'])) {
         $oe = new OutboundEmail();
         $oe->retrieve($_REQUEST['outbound_email']);
         $ret = array();
         foreach ($oe->field_defs as $def) {
             $ret[$def] = $oe->{$def};
         }
         $ret['mail_smtppass'] = '';
         // don't send back the password