protected function setupEmailSettings() { global $current_user, $app_list_strings; $this->ss->assign("MAIL_SENDTYPE", get_select_options_with_id($app_list_strings['notifymail_sendtype'], $this->bean->getPreference('mail_sendtype'))); /////////////////////////////////////////////////////////////////////////////// //// EMAIL OPTIONS // We need to turn off the requiredness of emails if it is a group or portal user if ($this->usertype == 'GROUP' || $this->usertype == 'PORTAL_ONLY') { global $dictionary; $dictionary['User']['fields']['email1']['required'] = false; } // hack to disable email field being required if it shouldn't be required if ($this->ss->get_template_vars("REQUIRED_EMAIL_ADDRESS") == '0') { $GLOBALS['dictionary']['User']['fields']['email1']['required'] = false; } $this->ss->assign("NEW_EMAIL", '<span id="email_span">' . getEmailAddressWidget($this->bean, "email1", $this->bean->email1, $this->viewType) . '</span>'); // hack to undo that previous hack if ($this->ss->get_template_vars("REQUIRED_EMAIL_ADDRESS") == '0') { $GLOBALS['dictionary']['User']['fields']['email1']['required'] = true; } $raw_email_link_type = $this->bean->getPreference('email_link_type'); $mailerPreferenceStatus = OutboundEmailConfigurationPeer::getMailConfigurationStatusForUser($current_user); $options = $app_list_strings['dom_email_link_type']; if ($this->viewType == 'EditView') { if ($mailerPreferenceStatus === OutboundEmailConfigurationPeer::STATUS_INVALID_SYSTEM_CONFIG) { $raw_email_link_type = 'mailto'; } $this->ss->assign('EMAIL_LINK_TYPE', get_select_options_with_id($options, $raw_email_link_type)); } else { $this->ss->assign('EMAIL_LINK_TYPE', $options[$raw_email_link_type]); } ///// END EMAIL OPTIONS /////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////// /// Handle email account selections for users ///////////////////////////////////////////// $hide_if_can_use_default = true; $disableSugarClient = false; if (!($this->usertype == 'GROUP' || $this->usertype == 'PORTAL_ONLY')) { // email smtp $systemOutboundEmail = new OutboundEmail(); $systemOutboundEmail = $systemOutboundEmail->getSystemMailerSettings(); $mail_smtpserver = $systemOutboundEmail->mail_smtpserver; $mail_smtptype = $systemOutboundEmail->mail_smtptype; $mail_smtpport = $systemOutboundEmail->mail_smtpport; $mail_smtpssl = $systemOutboundEmail->mail_smtpssl; $mail_smtpuser = ""; $mail_smtppass = ""; $mail_smtpdisplay = $systemOutboundEmail->mail_smtpdisplay; $mail_smtpauth_req = true; $mail_haspass = empty($systemOutboundEmail->mail_smtppass) ? 0 : 1; if (!$systemOutboundEmail->isAllowUserAccessToSystemDefaultOutbound()) { $mail_smtpauth_req = $systemOutboundEmail->mail_smtpauth_req; $userOverrideOE = $systemOutboundEmail->getUsersMailerForSystemOverride($this->bean->id); if ($userOverrideOE != null) { $mail_smtpuser = $userOverrideOE->mail_smtpuser; $mail_smtppass = $userOverrideOE->mail_smtppass; $mail_haspass = empty($userOverrideOE->mail_smtppass) ? 0 : 1; } if (!$mail_smtpauth_req && (empty($systemOutboundEmail->mail_smtpserver) || empty($systemOutboundEmail->mail_smtpuser) || empty($systemOutboundEmail->mail_smtppass))) { $hide_if_can_use_default = true; } else { $hide_if_can_use_default = false; } } $this->ss->assign("mail_smtpdisplay", $mail_smtpdisplay); $this->ss->assign("mail_smtpserver", $mail_smtpserver); $this->ss->assign("mail_smtpuser", $mail_smtpuser); $this->ss->assign("mail_smtppass", ""); $this->ss->assign("mail_haspass", $mail_haspass); $this->ss->assign("mail_smtpauth_req", $mail_smtpauth_req); $this->ss->assign('MAIL_SMTPPORT', $mail_smtpport); $this->ss->assign('MAIL_SMTPSSL', $mail_smtpssl); } if ($mailerPreferenceStatus === OutboundEmailConfigurationPeer::STATUS_INVALID_SYSTEM_CONFIG) { $disableSugarClient = true; $hide_if_can_use_default = true; //to hide the username/password fields } $this->ss->assign('DISABLE_SUGAR_CLIENT', $disableSugarClient); $this->ss->assign('HIDE_IF_CAN_USE_DEFAULT_OUTBOUND', $hide_if_can_use_default); }