示例#1
0
function get_body(&$ss, $vardef)
{
    $modules = array();
    require_once 'modules/ModuleBuilder/parsers/relationships/DeployedRelationships.php';
    $relatableModules = array_keys(DeployedRelationships::findRelatableModules());
    foreach ($relatableModules as $module) {
        $modules[$module] = translate('LBL_MODULE_NAME', $module);
    }
    foreach (ACLController::disabledModuleList($modules, false, 'list') as $disabled_parent_type) {
        unset($modules[$disabled_parent_type]);
    }
    unset($modules[""]);
    unset($modules['Activities']);
    // cannot relate to Activities as only Activities' submodules have records; use a Flex Relate instead!
    // tyoung bug 18631 - reduce potential confusion when creating a relate custom field for Products - actually points to the Product Catalog, so label it that way in the drop down list
    if (isset($modules['ProductTemplates']) && $modules['ProductTemplates'] == 'Product') {
        $modules['ProductTemplates'] = translate('LBL_MODULE_NAME', 'ProductTemplates');
    }
    $ss->assign('modules', $modules);
    return $ss->fetch('modules/DynamicFields/templates/Fields/Forms/relate.tpl');
}
示例#2
0
 function getSearchViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex)
 {
     $form_name = 'search_form';
     if (isset($displayParams['formName'])) {
         $form_name = $displayParams['formName'];
     }
     $this->ss->assign('form_name', $form_name);
     $popup_request_data = array('call_back_function' => 'set_return', 'form_name' => $form_name, 'field_to_name_array' => array('id' => $vardef['id_name'], 'name' => $vardef['name']));
     global $app_list_strings;
     $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) {
         if ($disabled_parent_type != $focus->parent_type) {
             unset($parent_types[$disabled_parent_type]);
         }
     }
     $json = getJSONobj();
     $displayParams['popupData'] = '{literal}' . $json->encode($popup_request_data) . '{/literal}';
     $displayParams['disabled_parent_types'] = '<script>var disabledModules=' . $json->encode($disabled_parent_types) . ';</script>';
     $this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
     return $this->fetch('include/SugarFields/Fields/Parent/SearchView.tpl');
 }
示例#3
0
function parse_list_modules(&$listArray)
{
    global $modListHeader;
    $returnArray = array();
    foreach ($listArray as $optionName => $optionVal) {
        if (array_key_exists($optionName, $modListHeader)) {
            $returnArray[$optionName] = $optionVal;
        }
        // special case for projects
        if (array_key_exists('Project', $modListHeader)) {
            $returnArray['ProjectTask'] = $listArray['ProjectTask'];
        }
    }
    $acldenied = ACLController::disabledModuleList($listArray, false);
    foreach ($acldenied as $denied) {
        unset($returnArray[$denied]);
    }
    asort($returnArray);
    return $returnArray;
}
示例#4
0
    /**
     * Add a parent selection popup window
     * @param displayname Name to display in the popup window
     * @param field_name name of the field
     */
    function addParent($displayname, $field)
    {
        global $app_strings, $app_list_strings;
        ///////////////////////////////////////
        ///
        /// SETUP POPUP
        $popup_request_data = array('call_back_function' => 'set_return', 'form_name' => 'MassUpdate', 'field_to_name_array' => array('id' => "parent_id", 'name' => "parent_name"));
        $json = getJSONobj();
        $encoded_popup_request_data = $json->encode($popup_request_data);
        $qsName = array('form' => 'MassUpdate', 'method' => 'query', 'modules' => array("Accounts"), 'group' => 'or', 'field_list' => array('name', 'id'), 'populate_list' => array("mass_parent_name", "mass_parent_id"), 'conditions' => array(array('name' => 'name', 'op' => 'like_custom', 'end' => '%', 'value' => '')), 'limit' => '30', 'no_match_text' => $app_strings['ERR_SQS_NO_MATCH']);
        $qsName = $json->encode($qsName);
        //
        ///////////////////////////////////////
        $change_parent_button = "<span class='id-ff'><button title='" . $app_strings['LBL_SELECT_BUTTON_TITLE'] . "' accessKey='" . $app_strings['LBL_SELECT_BUTTON_KEY'] . "'  type='button' class='button' value='" . $app_strings['LBL_SELECT_BUTTON_LABEL'] . "' name='button_parent_name' onclick='open_popup(document.MassUpdate.{$field['type_name']}.value, 600, 400, \"\", true, false, {$encoded_popup_request_data});'><img src='" . SugarThemeRegistry::current()->getImageURL('id-ff-select.png') . "'></button></span>";
        $parent_type = $field['parent_type'];
        $parent_types = $app_list_strings[$parent_type];
        $disabled_parent_types = ACLController::disabledModuleList($parent_types, false, 'list');
        foreach ($disabled_parent_types as $disabled_parent_type) {
            unset($parent_types[$disabled_parent_type]);
        }
        $types = get_select_options_with_id($parent_types, '');
        //BS Fix Bug 17110
        $pattern = "/\n<OPTION.*" . $app_strings['LBL_NONE'] . "<\\/OPTION>/";
        $types = preg_replace($pattern, "", $types);
        // End Fix
        $json = getJSONobj();
        $disabled_parent_types = $json->encode($disabled_parent_types);
        return <<<EOHTML
<td width="15%" scope="row">{$displayname} </td>
<td>
    <table width='100%' border='0' cellspacing='0' cellpadding='0'>
    <tr>
        <td valign='top'>
            <select name='{$field['type_name']}' id='mass_{$field['type_name']}'>
                {$types}
            </select>
        </td>
        <td valign='top'>
\t\t\t<input name='{$field['id_name']}' id='mass_{$field['id_name']}' type='hidden' value=''>
\t\t\t<input name='parent_name' id='mass_parent_name' class='sqsEnabled' autocomplete='off'
                type='text' value=''>
            {$change_parent_button}
        </td>
    </tr>
    </table>
</td>
<script type="text/javascript">
<!--
var disabledModules='{$disabled_parent_types}';
if(typeof sqs_objects == 'undefined'){
    var sqs_objects = new Array;
}
sqs_objects['MassUpdate_parent_name'] = {$qsName};
registerSingleSmartInputListener(document.getElementById('mass_parent_name'));
addToValidateBinaryDependency('MassUpdate', 'parent_name', 'alpha', false, '{$app_strings['ERR_SQS_NO_MATCH_FIELD']} {$app_strings['LBL_ASSIGNED_TO']}','parent_id');

document.getElementById('mass_{$field['type_name']}').onchange = function()
{
    document.MassUpdate.parent_name.value="";
    document.MassUpdate.parent_id.value="";

\tnew_module = document.forms["MassUpdate"].elements["parent_type"].value;

\tif(typeof(disabledModules[new_module]) != 'undefined') {
\t\tsqs_objects["MassUpdate_parent_name"]["disable"] = true;
\t\tdocument.forms["MassUpdate"].elements["parent_name"].readOnly = true;
\t} else {
\t\tsqs_objects["MassUpdate_parent_name"]["disable"] = false;
\t\tdocument.forms["MassUpdate"].elements["parent_name"].readOnly = false;
\t}
\tsqs_objects["MassUpdate_parent_name"]["modules"] = new Array(new_module);
    enableQS(false);

    checkParentType(document.MassUpdate.parent_type.value, document.MassUpdate.button_parent_name);
}
-->
</script>
EOHTML;
    }
示例#5
0
	function fill_in_additional_detail_fields()
	{
		global $locale;
		parent::fill_in_additional_detail_fields();
		if (!empty($this->contact_id)) {
			$query  = "SELECT first_name, last_name FROM contacts ";
			$query .= "WHERE id='$this->contact_id' AND deleted=0";
			$result = $this->db->limitQuery($query,0,1,true," Error filling in additional detail fields: ");

			// Get the contact name.
			$row = $this->db->fetchByAssoc($result);
			$GLOBALS['log']->info("additional call fields $query");
			if($row != null)
			{
				$this->contact_name = $locale->getLocaleFormattedName($row['first_name'], $row['last_name'], '', '');
				$GLOBALS['log']->debug("Call($this->id): contact_name = $this->contact_name");
				$GLOBALS['log']->debug("Call($this->id): contact_id = $this->contact_id");
			}
		}
		if (!isset($this->duration_minutes)) {
			$this->duration_minutes = $this->minutes_value_default;
		}

        global $timedate;
        //setting default date and time
		if (is_null($this->date_start)) {
			$this->date_start = $timedate->now();
		}

		if (is_null($this->duration_hours))
			$this->duration_hours = "0";
		if (is_null($this->duration_minutes))
			$this->duration_minutes = "1";

		$this->fill_in_additional_parent_fields();

		global $app_list_strings;
		$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){
			if($disabled_parent_type != $this->parent_type){
				unset($parent_types[$disabled_parent_type]);
			}
		}

		$this->parent_type_options = get_select_options_with_id($parent_types, $this->parent_type);

		if (empty($this->reminder_time)) {
			$this->reminder_time = -1;
		}

		if ( empty($this->id) ) {
		    $reminder_t = $GLOBALS['current_user']->getPreference('reminder_time');
		    if ( isset($reminder_t) )
		        $this->reminder_time = $reminder_t;
		}
		$this->reminder_checked = $this->reminder_time == -1 ? false : true;

		if (empty($this->email_reminder_time)) {
			$this->email_reminder_time = -1;
		}
		if(empty($this->id)){
			$reminder_t = $GLOBALS['current_user']->getPreference('email_reminder_time');
			if(isset($reminder_t))
		    		$this->email_reminder_time = $reminder_t;
		}
		$this->email_reminder_checked = $this->email_reminder_time == -1 ? false : true;

		if (isset ($_REQUEST['parent_type']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'SubpanelEdits')) {
			$this->parent_type = $_REQUEST['parent_type'];
		} elseif (is_null($this->parent_type)) {
			$this->parent_type = $app_list_strings['record_type_default_key'];
		}
	}
示例#6
0
 /**
  * Generate the config data needed for the Full Compose UI and the Quick Compose UI.  The set of config data
  * returned is the minimum set needed by the quick compose UI.
  *
  * @param String $type Drives which tinyMCE options will be included.
  */
 function _generateComposeConfigData($type = "email_compose_light")
 {
     global $app_list_strings, $current_user, $app_strings, $mod_strings, $current_language, $locale;
     //Link drop-downs
     $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]);
     }
     asort($parent_types);
     $linkBeans = json_encode(get_select_options_with_id($parent_types, ''));
     //TinyMCE Config
     require_once "include/SugarTinyMCE.php";
     $tiny = new SugarTinyMCE();
     $tinyConf = $tiny->getConfig($type);
     //Generate Language Packs
     $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";
         }
     }
     //Get the email mod strings but don't use the global variable as this may be overridden by
     //other modules when the quick create is rendered.
     $email_mod_strings = return_module_language($current_language, 'Emails');
     $modStrings = "var mod_strings = new Object();\n";
     foreach ($email_mod_strings as $k => $v) {
         $v = str_replace("'", "\\'", $v);
         $modStrings .= "mod_strings.{$k} = '{$v}';\n";
     }
     $lang .= "\n\n{$modStrings}\n";
     //Grab the Inboundemail language pack
     $ieModStrings = "var ie_mod_strings = new Object();\n";
     $ie_mod_strings = return_module_language($current_language, 'InboundEmail');
     foreach ($ie_mod_strings as $k => $v) {
         $v = str_replace("'", "\\'", $v);
         $ieModStrings .= "ie_mod_strings.{$k} = '{$v}';\n";
     }
     $lang .= "\n\n{$ieModStrings}\n";
     $this->smarty->assign('linkBeans', $linkBeans);
     $this->smarty->assign('linkBeansOptions', $parent_types);
     $this->smarty->assign('tinyMCE', $tinyConf);
     $this->smarty->assign('lang', $lang);
     $this->smarty->assign('app_strings', $app_strings);
     $this->smarty->assign('mod_strings', $email_mod_strings);
     $ie1 = new InboundEmail();
     //Signatures
     $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('signatureDefaultId', isset($defaultSignature['id']) ? $defaultSignature['id'] : "");
     //User Preferences
     $this->smarty->assign('userPrefs', json_encode($this->getUserPrefsJS()));
     //Get the users default outbound id
     $defaultOutID = $ie1->getUsersDefaultOutboundServerId($current_user);
     $this->smarty->assign('defaultOutID', $defaultOutID);
     //Character Set
     $charsets = json_encode($locale->getCharsetSelect());
     $this->smarty->assign('emailCharsets', $charsets);
     //Relateable List of People for address book search
     //#20776 jchi
     $peopleTables = array("users", "contacts", "leads", "prospects", "accounts");
     $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, ''));
 }
}
$xtpl->assign("TIME_FORMAT", '(' . $time_format . ')');
$xtpl->assign("USER_DATEFORMAT", '(' . $timedate->get_user_date_format() . ')');
$xtpl->assign("CALENDAR_DATEFORMAT", $timedate->get_cal_date_format());
if (empty($focus->assigned_user_id) && empty($focus->id)) {
    $focus->assigned_user_id = $current_user->id;
}
if (empty($focus->assigned_name) && empty($focus->id)) {
    $focus->assigned_user_name = $current_user->user_name;
}
$xtpl->assign("ASSIGNED_USER_OPTIONS", get_select_options_with_id(get_user_array(TRUE, "Active", $focus->assigned_user_id), $focus->assigned_user_id));
$xtpl->assign("ASSIGNED_USER_NAME", $focus->assigned_user_name);
$xtpl->assign("ASSIGNED_USER_ID", $focus->assigned_user_id);
$xtpl->assign("DURATION_HOURS", $focus->duration_hours);
$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) {
    if ($disabled_parent_type != $focus->parent_type) {
        unset($parent_types[$disabled_parent_type]);
    }
}
$xtpl->assign("TYPE_OPTIONS", get_select_options_with_id($parent_types, $focus->parent_type));
$xtpl->assign("STATUS_OPTIONS", get_select_options_with_id($app_list_strings['call_status_dom'], $focus->status));
$xtpl->assign("DIRECTION_OPTIONS", get_select_options_with_id($app_list_strings['call_direction_dom'], $focus->direction));
$xtpl->assign("DURATION_MINUTES_OPTIONS", get_select_options_with_id($focus->minutes_values, $focus->duration_minutes));
$reminder_time = $current_user->getPreference('reminder_time');
if (!empty($focus->reminder_time)) {
    $reminder_time = $focus->reminder_time;
}
$xtpl->assign("REMINDER_TIME_OPTIONS", get_select_options_with_id($app_list_strings['reminder_time_options'], $reminder_time));
if (empty($reminder_time)) {
示例#8
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;
    }
示例#9
0
 function fill_in_additional_detail_fields()
 {
     global $locale;
     // Fill in the assigned_user_name
     $this->assigned_user_name = get_assigned_user_name($this->assigned_user_id);
     if (!empty($this->contact_id)) {
         $query = "SELECT first_name, last_name FROM contacts ";
         $query .= "WHERE id='{$this->contact_id}' AND deleted=0";
         $result = $this->db->limitQuery($query, 0, 1, true, " Error filling in additional detail fields: ");
         // Get the contact name.
         $row = $this->db->fetchByAssoc($result);
         $GLOBALS['log']->info("additional call fields {$query}");
         if ($row != null) {
             $this->contact_name = $locale->getLocaleFormattedName($row['first_name'], $row['last_name'], '', '');
             $GLOBALS['log']->debug("Call({$this->id}): contact_name = {$this->contact_name}");
             $GLOBALS['log']->debug("Call({$this->id}): contact_id = {$this->contact_id}");
         }
     }
     $this->created_by_name = get_assigned_user_name($this->created_by);
     $this->modified_by_name = get_assigned_user_name($this->modified_user_id);
     $this->fill_in_additional_parent_fields();
     if (!isset($this->time_hour_start)) {
         $this->time_start_hour = intval(substr($this->time_start, 0, 2));
     }
     //if-else
     if (isset($this->time_minute_start)) {
         $time_start_minutes = $this->time_minute_start;
     } else {
         $time_start_minutes = substr($this->time_start, 3, 5);
         if ($time_start_minutes > 0 && $time_start_minutes < 15) {
             $time_start_minutes = "15";
         } else {
             if ($time_start_minutes > 15 && $time_start_minutes < 30) {
                 $time_start_minutes = "30";
             } else {
                 if ($time_start_minutes > 30 && $time_start_minutes < 45) {
                     $time_start_minutes = "45";
                 } else {
                     if ($time_start_minutes > 45) {
                         $this->time_start_hour += 1;
                         $time_start_minutes = "00";
                     }
                 }
             }
         }
         //if-else
     }
     //if-else
     if (isset($this->time_hour_start)) {
         $time_start_hour = $this->time_hour_start;
     } else {
         $time_start_hour = intval(substr($this->time_start, 0, 2));
     }
     global $timedate;
     $this->time_meridiem = $timedate->AMPMMenu('', $this->time_start, 'onchange="SugarWidgetScheduler.update_time();"');
     $hours_arr = array();
     $num_of_hours = 13;
     $start_at = 1;
     if (empty($time_meridiem)) {
         $num_of_hours = 24;
         $start_at = 0;
     }
     //if
     for ($i = $start_at; $i < $num_of_hours; $i++) {
         $i = $i . "";
         if (strlen($i) == 1) {
             $i = "0" . $i;
         }
         $hours_arr[$i] = $i;
     }
     //for
     if (!isset($this->duration_minutes)) {
         $this->duration_minutes = $this->minutes_value_default;
     }
     //setting default date and time
     if (is_null($this->date_start)) {
         $this->date_start = $timedate->now();
     }
     if (is_null($this->time_start)) {
         $this->time_start = $timedate->to_display_time(TimeDate::getInstance()->nowDb(), true);
     }
     if (is_null($this->duration_hours)) {
         $this->duration_hours = "0";
     }
     if (is_null($this->duration_minutes)) {
         $this->duration_minutes = "1";
     }
     if (empty($this->id) && !empty($_REQUEST['date_start'])) {
         $this->date_start = $_REQUEST['date_start'];
     }
     if (!empty($this->date_start)) {
         $start = SugarDateTime::createFromFormat($GLOBALS['timedate']->get_date_time_format(), $this->date_start);
         if (!empty($start)) {
             if (!empty($this->duration_hours) || !empty($this->duration_minutes)) {
                 $this->date_end = $start->modify("+{$this->duration_hours} Hours +{$this->duration_minutes} Minutes")->format($GLOBALS['timedate']->get_date_time_format());
             }
         } else {
             $GLOBALS['log']->fatal("Meeting::save: Bad date {$this->date_start} for format " . $GLOBALS['timedate']->get_date_time_format());
         }
     }
     global $app_list_strings;
     $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) {
         if ($disabled_parent_type != $this->parent_type) {
             unset($parent_types[$disabled_parent_type]);
         }
     }
     $this->parent_type_options = get_select_options_with_id($parent_types, $this->parent_type);
     if (empty($this->reminder_time)) {
         $this->reminder_time = -1;
     }
     if (empty($this->id)) {
         $reminder_t = $GLOBALS['current_user']->getPreference('reminder_time');
         if (isset($reminder_t)) {
             $this->reminder_time = $reminder_t;
         }
     }
     $this->reminder_checked = $this->reminder_time == -1 ? false : true;
     if (empty($this->email_reminder_time)) {
         $this->email_reminder_time = -1;
     }
     if (empty($this->id)) {
         $reminder_t = $GLOBALS['current_user']->getPreference('email_reminder_time');
         if (isset($reminder_t)) {
             $this->email_reminder_time = $reminder_t;
         }
     }
     $this->email_reminder_checked = $this->email_reminder_time == -1 ? false : true;
     if (isset($_REQUEST['parent_type'])) {
         $this->parent_type = $_REQUEST['parent_type'];
     } elseif (is_null($this->parent_type)) {
         $this->parent_type = $app_list_strings['record_type_default_key'];
     }
 }
示例#10
0
 function fill_in_additional_detail_fields()
 {
     parent::fill_in_additional_detail_fields();
     $query = "SELECT c.first_name, c.last_name, c.phone_work, c.id FROM contacts  c, calls_contacts  c_c ";
     $query .= "WHERE c_c.contact_id=c.id AND c_c.call_id='{$this->id}' AND c_c.deleted=0 AND c.deleted=0";
     $result = $this->db->limitQuery($query, 0, 1, true, " Error filling in additional detail fields: ");
     // Get the id and the name.
     $row = array();
     $row = $this->db->fetchByAssoc($result);
     $GLOBALS['log']->info("additional call fields {$query}");
     if ($row != null) {
         $this->contact_name = return_name($row, 'first_name', 'last_name');
         $this->contact_phone = $row['phone_work'];
         $this->contact_id = $row['id'];
         $GLOBALS['log']->debug("Call({$this->id}): contact_name = {$this->contact_name}");
         $GLOBALS['log']->debug("Call({$this->id}): contact_phone = {$this->contact_phone}");
         $GLOBALS['log']->debug("Call({$this->id}): contact_id = {$this->contact_id}");
     } else {
         $this->contact_name = '';
         $this->contact_phone = '';
         $this->contact_id = '';
         $GLOBALS['log']->debug("Call({$this->id}): contact_name = {$this->contact_name}");
         $GLOBALS['log']->debug("Call({$this->id}): contact_phone = {$this->contact_phone}");
         $GLOBALS['log']->debug("Call({$this->id}): contact_id = {$this->contact_id}");
     }
     if (!isset($this->duration_minutes)) {
         $this->duration_minutes = $this->minutes_value_default;
     }
     global $timedate;
     //setting default date and time
     if (is_null($this->date_start)) {
         $this->date_start = $timedate->to_display_date_time(gmdate($GLOBALS['timedate']->get_db_date_time_format()));
     }
     if (is_null($this->duration_hours)) {
         $this->duration_hours = "0";
     }
     if (is_null($this->duration_minutes)) {
         $this->duration_minutes = "1";
     }
     $this->fill_in_additional_parent_fields();
     global $app_list_strings;
     $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) {
         if ($disabled_parent_type != $this->parent_type) {
             unset($parent_types[$disabled_parent_type]);
         }
     }
     $this->parent_type_options = get_select_options_with_id($parent_types, $this->parent_type);
     if (empty($this->reminder_time)) {
         $this->reminder_time = -1;
     }
     $this->reminder_checked = $this->reminder_time == -1 ? false : true;
     if (isset($_REQUEST['parent_type'])) {
         $this->parent_type = $_REQUEST['parent_type'];
     } elseif (is_null($this->parent_type)) {
         $this->parent_type = $app_list_strings['record_type_default_key'];
     }
 }
 function fill_in_additional_detail_fields()
 {
     // Fill in the assigned_user_name
     $this->assigned_user_name = get_assigned_user_name($this->assigned_user_id);
     $query = "SELECT contacts.first_name, contacts.last_name, contacts.phone_work, contacts.id , contacts.assigned_user_id contact_name_owner FROM contacts, meetings_contacts ";
     $query .= " WHERE meetings_contacts.contact_id=contacts.id AND meetings_contacts.meeting_id='{$this->id}' AND meetings_contacts.deleted=0 AND contacts.deleted=0";
     $result = $this->db->limitQuery($query, 0, 1, true, " Error filling in additional detail fields: ");
     // Get the id and the name.
     $row = $this->db->fetchByAssoc($result);
     $GLOBALS['log']->info($row);
     if ($row != null) {
         $this->contact_name = return_name($row, 'first_name', 'last_name');
         $this->contact_phone = $row['phone_work'];
         $this->contact_id = $row['id'];
         $this->contact_name_owner = $row['contact_name_owner'];
         $GLOBALS['log']->debug("Call({$this->id}): contact_name = {$this->contact_name}");
         $GLOBALS['log']->debug("Call({$this->id}): contact_phone = {$this->contact_phone}");
         $GLOBALS['log']->debug("Call({$this->id}): contact_id = {$this->contact_id}");
     } else {
         $this->contact_name = '';
         $this->contact_phone = '';
         $this->contact_id = '';
         $GLOBALS['log']->debug("Call({$this->id}): contact_name = {$this->contact_name}");
         $GLOBALS['log']->debug("Call({$this->id}): contact_phone = {$this->contact_phone}");
         $GLOBALS['log']->debug("Call({$this->id}): contact_id = {$this->contact_id}");
     }
     $this->created_by_name = get_assigned_user_name($this->created_by);
     $this->modified_by_name = get_assigned_user_name($this->modified_user_id);
     $this->fill_in_additional_parent_fields();
     if (!isset($this->time_hour_start)) {
         $this->time_start_hour = intval(substr($this->time_start, 0, 2));
     }
     //if-else
     if (isset($this->time_minute_start)) {
         $time_start_minutes = $this->time_minute_start;
     } else {
         $time_start_minutes = substr($this->time_start, 3, 5);
         if ($time_start_minutes > 0 && $time_start_minutes < 15) {
             $time_start_minutes = "15";
         } else {
             if ($time_start_minutes > 15 && $time_start_minutes < 30) {
                 $time_start_minutes = "30";
             } else {
                 if ($time_start_minutes > 30 && $time_start_minutes < 45) {
                     $time_start_minutes = "45";
                 } else {
                     if ($time_start_minutes > 45) {
                         $this->time_start_hour += 1;
                         $time_start_minutes = "00";
                     }
                 }
             }
         }
         //if-else
     }
     //if-else
     if (isset($this->time_hour_start)) {
         $time_start_hour = $this->time_hour_start;
     } else {
         $time_start_hour = intval(substr($this->time_start, 0, 2));
     }
     global $timedate;
     $this->time_meridiem = $timedate->AMPMMenu('', $this->time_start, 'onchange="SugarWidgetScheduler.update_time();"');
     $hours_arr = array();
     $num_of_hours = 13;
     $start_at = 1;
     if (empty($time_meridiem)) {
         $num_of_hours = 24;
         $start_at = 0;
     }
     //if
     for ($i = $start_at; $i < $num_of_hours; $i++) {
         $i = $i . "";
         if (strlen($i) == 1) {
             $i = "0" . $i;
         }
         $hours_arr[$i] = $i;
     }
     //for
     if (!isset($this->duration_minutes)) {
         $this->duration_minutes = $this->minutes_value_default;
     }
     //setting default date and time
     if (is_null($this->date_start)) {
         $this->date_start = $timedate->to_display_date_time(gmdate($GLOBALS['timedate']->get_db_date_time_format()));
     }
     if (is_null($this->time_start)) {
         $this->time_start = $timedate->to_display_time(gmdate($GLOBALS['timedate']->get_db_date_time_format()), true);
     }
     if (is_null($this->duration_hours)) {
         $this->duration_hours = "0";
     }
     if (is_null($this->duration_minutes)) {
         $this->duration_minutes = "1";
     }
     global $current_user;
     $reminder_t = $current_user->getPreference('reminder_time');
     if (!empty($this->reminder_time)) {
         $reminder_t = $this->reminder_time;
     }
     global $app_list_strings;
     $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) {
         if ($disabled_parent_type != $this->parent_type) {
             unset($parent_types[$disabled_parent_type]);
         }
     }
     $this->parent_type_options = get_select_options_with_id($parent_types, $this->parent_type);
     if (empty($this->reminder_time)) {
         $this->reminder_time = -1;
     }
     $this->reminder_checked = $this->reminder_time == -1 ? false : true;
     if (isset($_REQUEST['parent_type'])) {
         $this->parent_type = $_REQUEST['parent_type'];
     } elseif (is_null($this->parent_type)) {
         $this->parent_type = $app_list_strings['record_type_default_key'];
     }
 }
 function fill_in_additional_detail_fields()
 {
     global $app_list_strings;
     global $locale;
     global $current_user;
     // Fill in the assigned_user_name
     $this->assigned_user_name = get_assigned_user_name($this->assigned_user_id);
     $this->created_by_name = get_assigned_user_name($this->created_by);
     $this->modified_by_name = get_assigned_user_name($this->modified_user_id);
     //Fill parent field
     $this->fill_in_additional_parent_fields();
     global $timedate;
     //preset due_date time based on priority default setting
     if (is_null($this->date_start)) {
         $this->date_start = $timedate->now();
     }
     if (is_null($this->date_due)) {
         $default_priority = $app_list_strings['oqc_dropdowns_default']['oqc_priority_default_key'];
         // There is bug in some PHP versions that gives wrong relative weekday date; so we did some workaround here
         switch ($default_priority) {
             case 'Low':
                 $period = 7;
                 $now = $timedate->getNow();
                 while ($period > 0) {
                     $weekday = date('l', $now->modify("+1 day")->getTimestamp());
                     if ($weekday != 'Sunday' && $weekday != 'Monday') {
                         $period = $period - 1;
                     }
                 }
                 $this->date_due = $timedate->asUser($now);
                 break;
             case 'Medium':
                 $period = 3;
                 $now = $timedate->getNow();
                 while ($period > 0) {
                     $weekday = date('l', $now->modify("+1 day")->getTimestamp());
                     if ($weekday != 'Sunday' && $weekday != 'Monday') {
                         $period = $period - 1;
                     }
                 }
                 $this->date_due = $timedate->asUser($now);
                 //	$GLOBALS['log']->error("Date Due is ".$this->date_due . ' Timedate is '. $timedate->now());
                 break;
             case 'High':
                 $period = 1;
                 $now = $timedate->getNow();
                 while ($period > 0) {
                     $weekday = date('l', $now->modify("+1 day")->getTimestamp());
                     if ($weekday != 'Sunday' && $weekday != 'Monday') {
                         $period = $period - 1;
                     }
                 }
                 $this->date_due = $timedate->asUser($now);
                 break;
         }
     }
     $parent_types = $app_list_strings['oqc_parent_type_display_list'];
     $disabled_parent_types = ACLController::disabledModuleList($parent_types, false, 'list');
     foreach ($disabled_parent_types as $disabled_parent_type) {
         if ($disabled_parent_type != $this->parent_type) {
             unset($parent_types[$disabled_parent_type]);
         }
     }
     $this->parent_type_options = get_select_options_with_id($parent_types, $this->parent_type);
     if (isset($_REQUEST['parent_type'])) {
         $this->parent_type = $_REQUEST['parent_type'];
     } elseif (is_null($this->parent_type)) {
         $this->parent_type = $app_list_strings['oqc_dropdowns_default']['oqc_parent_type_default_key'];
     }
 }