function testGetAssoicatedInboundAccountForOutboundAccounts() { global $current_user; $ob = new OutboundEmail(); $ob->id = $this->outbound_id; $results = $ob->getAssociatedInboundAccounts($current_user); $this->assertEquals($this->ib->id, $results[0], "Could not retrieve the inbound mail accounts for an outbound account"); $obEmpty = new OutboundEmail(); $obEmpty->id = uniqid(); $empty_results = $obEmpty->getAssociatedInboundAccounts($current_user); $this->assertEquals(0, count($empty_results), "Outbound email account returned for unspecified/empty inbound mail account."); }
/** * Sole constructor */ function SugarPHPMailer() { global $locale; global $current_user; global $sugar_config; $admin = new Administration(); $admin->retrieveSettings(); if (isset($admin->settings['disclosure_enable']) && !empty($admin->settings['disclosure_enable'])) { $this->disclosureEnabled = true; $this->disclosureText = $admin->settings['disclosure_text']; } $this->oe = new OutboundEmail(); $this->oe->getUserMailerSettings($current_user); $this->SetLanguage('en', 'vendor/phpmailer/phpmailer/language/'); $this->PluginDir = 'custom/include/phpmailer/'; $this->Mailer = 'smtp'; // cn: i18n $this->CharSet = $locale->getPrecedentPreference('default_email_charset'); $this->Encoding = 'quoted-printable'; $this->IsHTML(false); // default to plain-text email $this->Hostname = $sugar_config['host_name']; $this->WordWrap = 996; // cn: gmail fix $this->protocol = $this->oe->mail_smtpssl == 1 ? "ssl://" : $this->protocol; }
/** * @dataProvider getFields * @param string $field */ public function testFieldsEncoding($field) { // testing insert $ob = new OutboundEmail(); $ob->type = 'test'; $ob->id = create_guid(); $ob->new_with_id = true; $ob->name = 'Test ' . $ob->id; $ob->user_id = '1'; $ob->{$field} = mt_rand() . " test \\ 'test' " . mt_rand(); $ob->save(); // testing update $ob->new_with_id = false; $ob->name = 'Update ' . $ob->id; $ob->user_id = '1'; $ob->{$field} = mt_rand() . " test2 \\ 'test2' " . mt_rand(); $ob->save(); }
/** * Determines if a user needs to set their user name/password for their system * override account. * * @param unknown_type $user_id * @return unknown */ function doesUserOverrideAccountRequireCredentials($user_id) { $userCredentialsReq = FALSE; $sys = new OutboundEmail(); $ob = $sys->getSystemMailerSettings(); //Dirties '$this' //If auth for system account is disabled or user can use system outbound account return false. if ($ob->mail_smtpauth_req == 0 || $this->isAllowUserAccessToSystemDefaultOutbound() || $this->mail_sendtype == 'sendmail') { return $userCredentialsReq; } $userOverideAccount = $this->getUsersMailerForSystemOverride($user_id); if ($userOverideAccount == null || empty($userOverideAccount->mail_smtpuser) || empty($userOverideAccount->mail_smtppass)) { $userCredentialsReq = TRUE; } return $userCredentialsReq; }
function action_Save() { require_once 'include/OutboundEmail/OutboundEmail.php'; require_once 'modules/Configurator/Configurator.php'; $configurator = new Configurator(); global $sugar_config; global $current_user; if (!is_admin($current_user) && !is_admin_for_module($GLOBALS['current_user'], 'Emails') && !is_admin_for_module($GLOBALS['current_user'], 'Campaigns')) { sugar_die("Unauthorized access to administration."); } //Do not allow users to spoof for sendmail if the config flag is not set. if (!isset($sugar_config['allow_sendmail_outbound']) || !$sugar_config['allow_sendmail_outbound']) { $_REQUEST['mail_sendtype'] = "SMTP"; } // save Outbound settings #Bug 20033 Ensure data for Outbound email exists before trying to update the system mailer. if (isset($_REQUEST['mail_sendtype']) && empty($_REQUEST['campaignConfig'])) { $oe = new OutboundEmail(); $oe->populateFromPost(); $oe->saveSystem(); } $focus = new Administration(); if (isset($_POST['tracking_entities_location_type'])) { if ($_POST['tracking_entities_location_type'] != '2') { unset($_POST['tracking_entities_location']); unset($_POST['tracking_entities_location_type']); } } // cn: handle mail_smtpauth_req checkbox on/off (removing double reference in the form itself if (!isset($_POST['mail_smtpauth_req'])) { $_POST['mail_smtpauth_req'] = 0; if (empty($_POST['campaignConfig'])) { $_POST['notify_allow_default_outbound'] = 0; // If smtp auth is disabled ensure outbound is disabled. } } if (!empty($_POST['notify_allow_default_outbound'])) { $oe = new OutboundEmail(); if (!$oe->isAllowUserAccessToSystemDefaultOutbound()) { $oe->removeUserOverrideAccounts(); } } $focus->saveConfig(); // save User defaults for emails $configurator->config['email_default_delete_attachments'] = isset($_REQUEST['email_default_delete_attachments']) ? true : false; /////////////////////////////////////////////////////////////////////////////// //// SECURITY $security = array(); if (isset($_REQUEST['applet'])) { $security['applet'] = 'applet'; } if (isset($_REQUEST['base'])) { $security['base'] = 'base'; } if (isset($_REQUEST['embed'])) { $security['embed'] = 'embed'; } if (isset($_REQUEST['form'])) { $security['form'] = 'form'; } if (isset($_REQUEST['frame'])) { $security['frame'] = 'frame'; } if (isset($_REQUEST['frameset'])) { $security['frameset'] = 'frameset'; } if (isset($_REQUEST['iframe'])) { $security['iframe'] = 'iframe'; } if (isset($_REQUEST['import'])) { $security['import'] = '\\?import'; } if (isset($_REQUEST['layer'])) { $security['layer'] = 'layer'; } if (isset($_REQUEST['link'])) { $security['link'] = 'link'; } if (isset($_REQUEST['object'])) { $security['object'] = 'object'; } if (isset($_REQUEST['style'])) { $security['style'] = 'style'; } if (isset($_REQUEST['xmp'])) { $security['xmp'] = 'xmp'; } $security['script'] = 'script'; $configurator->config['email_xss'] = base64_encode(serialize($security)); //// SECURITY /////////////////////////////////////////////////////////////////////////////// ksort($sugar_config); $configurator->handleOverride(); }
function testIsUserAuthRequiredForOverrideAccount() { $oe = new OutboundEmail(); $GLOBALS['db']->query("DELETE FROM config WHERE category='notify' AND name='allow_default_outbound' "); $system = $oe->getSystemMailerSettings(); //System does not require auth, no user overide account. $system->mail_smtpauth_req = 0; $system->save(FALSE); $notRequired = $oe->doesUserOverrideAccountRequireCredentials($this->_user->id); $this->assertFalse($notRequired, "Test failed for determining if user auth required."); //System does require auth, no user overide account. $system->mail_smtpauth_req = 1; $system->save(FALSE); $notRequired = $oe->doesUserOverrideAccountRequireCredentials($this->_user->id); $this->assertTrue($notRequired, "Test failed for determining if user auth required."); //System requires auth and users alloweed to use sys defaults. $GLOBALS['db']->query("INSERT INTO config (category,name,value) VALUES ('notify','allow_default_outbound','2') "); $notRequired = $oe->doesUserOverrideAccountRequireCredentials($this->_user->id); $this->assertFalse($notRequired, "Test failed for determining if user auth required."); //System requires auth but user details are empty and users are not alloweed to use system details.. $GLOBALS['db']->query("DELETE FROM config WHERE category='notify' AND name='allow_default_outbound' "); $userOverideAccont = $oe->createUserSystemOverrideAccount($this->_user->id, "", ""); $this->userOverideAccont = $userOverideAccont; $notRequired = $oe->doesUserOverrideAccountRequireCredentials($this->_user->id); $this->assertTrue($notRequired, "Test failed for determining if user auth required."); //User has provided all credentials. $this->userOverideAccont->mail_smtpuser = "******"; $this->userOverideAccont->mail_smtppass = "******"; $this->userOverideAccont->new_with_id = FALSE; $this->userOverideAccont->save(); $notRequired = $oe->doesUserOverrideAccountRequireCredentials($this->_user->id); $this->assertFalse($notRequired, "Test failed for determining if user auth required."); }
function action_Save() { require_once 'include/OutboundEmail/OutboundEmail.php'; require_once 'modules/Configurator/Configurator.php'; $configurator = new Configurator(); global $sugar_config; global $current_user, $mod_strings; if (!is_admin($current_user) && !is_admin_for_module($GLOBALS['current_user'], 'Emails') && !is_admin_for_module($GLOBALS['current_user'], 'Campaigns')) { sugar_die($mod_strings['LBL_UNAUTH_ACCESS']); } //Do not allow users to spoof for sendmail if the config flag is not set. if (!isset($sugar_config['allow_sendmail_outbound']) || !$sugar_config['allow_sendmail_outbound']) { $_REQUEST['mail_sendtype'] = "SMTP"; } // save Outbound settings #Bug 20033 Ensure data for Outbound email exists before trying to update the system mailer. if (isset($_REQUEST['mail_sendtype']) && empty($_REQUEST['campaignConfig'])) { $oe = new OutboundEmail(); $oe->populateFromPost(); $oe->saveSystem(); } $focus = BeanFactory::getBean('Administration'); if (isset($_POST['tracking_entities_location_type'])) { if ($_POST['tracking_entities_location_type'] != '2') { unset($_POST['tracking_entities_location']); unset($_POST['tracking_entities_location_type']); } } // cn: handle mail_smtpauth_req checkbox on/off (removing double reference in the form itself if (!isset($_POST['mail_smtpauth_req'])) { $_POST['mail_smtpauth_req'] = 0; if (empty($_POST['campaignConfig'])) { $_POST['notify_allow_default_outbound'] = 0; // If smtp auth is disabled ensure outbound is disabled. } } $focus->saveConfig(); // mark user metadata changed so the user preferences get refreshed // (user preferences contain email client preference) $mm = MetadataManager::getManager(); $mm->setUserMetadataHasChanged($current_user); // save User defaults for emails $configurator->config['email_default_delete_attachments'] = isset($_REQUEST['email_default_delete_attachments']) ? true : false; /////////////////////////////////////////////////////////////////////////////// //// SECURITY $security = array(); if (isset($_REQUEST['applet'])) { $security['applet'] = 'applet'; } if (isset($_REQUEST['base'])) { $security['base'] = 'base'; } if (isset($_REQUEST['embed'])) { $security['embed'] = 'embed'; } if (isset($_REQUEST['form'])) { $security['form'] = 'form'; } if (isset($_REQUEST['frame'])) { $security['frame'] = 'frame'; } if (isset($_REQUEST['frameset'])) { $security['frameset'] = 'frameset'; } if (isset($_REQUEST['iframe'])) { $security['iframe'] = 'iframe'; } if (isset($_REQUEST['import'])) { $security['import'] = '\\?import'; } if (isset($_REQUEST['layer'])) { $security['layer'] = 'layer'; } if (isset($_REQUEST['link'])) { $security['link'] = 'link'; } if (isset($_REQUEST['object'])) { $security['object'] = 'object'; } if (isset($_REQUEST['style'])) { $security['style'] = 'style'; } if (isset($_REQUEST['xmp'])) { $security['xmp'] = 'xmp'; } $security['script'] = 'script'; $configurator->config['email_xss'] = base64_encode(serialize($security)); //// SECURITY /////////////////////////////////////////////////////////////////////////////// ksort($sugar_config); $configurator->handleOverride(); }
* In accordance with Section 7(b) of the GNU General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * SugarCRM" logo. If the display of the logo is not reasonably feasible for * technical reasons, the Appropriate Legal Notices must display the words * "Powered by SugarCRM". ********************************************************************************/ /********************************************************************************* * Description: TODO: To be written. * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. ********************************************************************************/ require_once 'include/OutboundEmail/OutboundEmail.php'; // save Outbound (SMTP/Sendmail) settings #Bug 20033 Ensure data for Outbound email exists before trying to update the system mailer. if (isset($_REQUEST['mail_sendtype'])) { $oe = new OutboundEmail(); $oe->populateFromPost(); $oe->saveSystem(); } $focus = new Administration(); if (isset($_POST['tracking_entities_location_type'])) { if ($_POST['tracking_entities_location_type'] != '2') { unset($_POST['tracking_entities_location']); unset($_POST['tracking_entities_location_type']); } } // cn: handle mail_smtpauth_req checkbox on/off (removing double reference in the form itself if (!isset($_POST['mail_smtpauth_req'])) { $_POST['mail_smtpauth_req'] = 0; } $focus->saveConfig();
if (isset($_POST['page']) && $_POST['page'] == 'Change') { header("Location: index.php?action=ChangePassword&module=Users&record=" . $_POST['record'] . "&error_password=" . urlencode($focus->error_string)); exit; } } else { if ($newUser) { $new_pwd = '3'; } else { $new_pwd = '1'; } } } /////////////////////////////////////////////////////////////////////////// //// OUTBOUND EMAIL SAVES /////////////////////////////////////////////////////////////////////////// $sysOutboundAccunt = new OutboundEmail(); //If a user is not alloweed to use the default system outbound account then they will be //saving their own username/password for the system account if (!$sysOutboundAccunt->isAllowUserAccessToSystemDefaultOutbound()) { $userOverrideOE = $sysOutboundAccunt->getUsersMailerForSystemOverride($focus->id); if ($userOverrideOE != null) { //User is alloweed to clear username and pass so no need to check for blanks. $userOverrideOE->mail_smtpuser = $_REQUEST['mail_smtpuser']; $userOverrideOE->mail_smtppass = $_REQUEST['mail_smtppass']; $userOverrideOE->save(); } else { //If a user name and password for the mail account is set, create the users override account. if (!(empty($_REQUEST['mail_smtpuser']) || empty($_REQUEST['mail_smtppass']))) { $sysOutboundAccunt->createUserSystemOverrideAccount($focus->id, $_REQUEST['mail_smtpuser'], $_REQUEST['mail_smtppass']); } }
/** * Saves Personal Inbox settings for Users * @param string userId ID of user to assign all emails for this account * @param strings userName Name of account, for Sugar purposes * @param bool forceSave Default true. Flag to save errored settings. * @return boolean true on success, false on fail */ function savePersonalEmailAccount($userId = '', $userName = '', $forceSave = true) { if (!empty($userId)) { $groupId = $userId; } elseif (isset($_REQUEST['group_id']) && !empty($_REQUEST['group_id'])) { $groupId = $_REQUEST['group_id']; } else { return false; } $accountExists = false; if (isset($_REQUEST['ie_id']) && !empty($_REQUEST['ie_id'])) { $this->retrieve($_REQUEST['ie_id']); $accountExists = true; } $ie_name = $_REQUEST['ie_name']; $this->is_personal = 1; $this->name = $ie_name; $this->group_id = $groupId; $this->status = $_REQUEST['ie_status']; $this->server_url = $_REQUEST['server_url']; $this->email_user = $_REQUEST['email_user']; $this->email_password = $_REQUEST['email_password']; $this->port = $_REQUEST['port']; $this->protocol = $_REQUEST['protocol']; if ($this->protocol == "pop3") { $_REQUEST['mailbox'] = "INBOX"; } $this->mailbox = $_REQUEST['mailbox']; $this->mailbox_type = 'pick'; // forcing this if (isset($_REQUEST['ssl']) && $_REQUEST['ssl'] == 1) { $useSsl = true; } else { $useSsl = false; } $this->service = '::::::::::'; if ($forceSave) { $id = $this->save(); // saving here to prevent user from having to re-enter all the info in case of error $this->retrieve($id); } $this->protocol = $_REQUEST['protocol']; // need to set this again since we safe the "service" string to empty explode values $opts = $this->getSessionConnectionString($this->server_url, $this->email_user, $this->port, $this->protocol); if (empty($opts)) { $opts = $this->findOptimumSettings($useSsl); } $delimiter = $this->getSessionInboundDelimiterString($this->server_url, $this->email_user, $this->port, $this->protocol); if (isset($opts['serial']) && !empty($opts['serial'])) { $this->service = $opts['serial']; if (isset($_REQUEST['mark_read']) && $_REQUEST['mark_read'] == 1) { $this->delete_seen = 0; } else { $this->delete_seen = 1; } // handle stored_options serialization if (isset($_REQUEST['only_since']) && $_REQUEST['only_since'] == 1) { $onlySince = true; } else { $onlySince = false; } $focusUser = new User(); $focusUser->retrieve($groupId); $mailerId = isset($_REQUEST['outbound_email']) ? $_REQUEST['outbound_email'] : ""; $oe = new OutboundEmail(); $oe->getSystemMailerSettings($focusUser, $mailerId); $stored_options = array(); $stored_options['from_name'] = $_REQUEST['from_name']; $stored_options['from_addr'] = $_REQUEST['from_addr']; if (!$this->isPop3Protocol()) { $stored_options['trashFolder'] = isset($_REQUEST['trashFolder']) ? $_REQUEST['trashFolder'] : ""; $stored_options['sentFolder'] = isset($_REQUEST['sentFolder']) ? $_REQUEST['sentFolder'] : ""; } // if $stored_options['only_since'] = $onlySince; $stored_options['filter_domain'] = ''; $storedOptions['folderDelimiter'] = $delimiter; $stored_options['outbound_email'] = isset($_REQUEST['outbound_email']) ? $_REQUEST['outbound_email'] : $oe->id; $this->stored_options = base64_encode(serialize($stored_options)); $this->save(); return true; } else { // could not find opts, no save $GLOBALS['log']->debug('-----> InboundEmail could not find optimums for User: ' . $ie_name); return false; } }
} $focus = new Administration(); if (isset($_POST['tracking_entities_location_type'])) { if ($_POST['tracking_entities_location_type'] != '2') { unset($_POST['tracking_entities_location']); unset($_POST['tracking_entities_location_type']); } } // cn: handle mail_smtpauth_req checkbox on/off (removing double reference in the form itself if (!isset($_POST['mail_smtpauth_req'])) { $_POST['mail_smtpauth_req'] = 0; $_POST['notify_allow_default_outbound'] = 0; //If smtp auth is disabled ensure outbound is disabled. } if (!empty($_POST['notify_allow_default_outbound'])) { $oe = new OutboundEmail(); if (!$oe->isAllowUserAccessToSystemDefaultOutbound()) { $oe->removeUserOverrideAccounts(); } } $focus->saveConfig(); // save User defaults for emails $sugar_config['email_default_delete_attachments'] = isset($_REQUEST['email_default_delete_attachments']) ? true : false; /////////////////////////////////////////////////////////////////////////////// //// SECURITY $security = array(); if (isset($_REQUEST['applet'])) { $security['applet'] = 'applet'; } if (isset($_REQUEST['base'])) { $security['base'] = 'base';
$oe = new OutboundEmail(); $oe->retrieve($_REQUEST['outbound_email']); $ret = array(); foreach ($oe->field_defs as $def) { $ret[$def] = $oe->{$def}; } $out = $json->encode($ret, true); echo $out; } else { echo "NOOP"; } break; case "deleteOutbound": $GLOBALS['log']->debug("********** EMAIL 2.0 - Asynchronous - at: deleteOutbound"); if (isset($_REQUEST['outbound_email']) && !empty($_REQUEST['outbound_email'])) { $oe = new OutboundEmail(); global $current_user; $oe->retrieve($_REQUEST['outbound_email']); $oe->delete(); $ret = array(); $count = 0; $outbounds = $oe->getUserMailers($current_user); $out = $json->encode($outbounds, true); echo $out; } else { echo "NOOP"; } break; case "saveOutbound": $GLOBALS['log']->debug("********** EMAIL 2.0 - Asynchronous - at: saveOutbound"); $oe = new OutboundEmail();
/** * Created by iluxovi4 - Убирайте везде эту подпись * Protected by SugarTalk.ru greshdrtju ======= */ function sendSugarPHPMail($tos, $subject, $body, $attach = "", $nameToSend = "", $assigned_user_id, $type) { require_once 'include/SugarPHPMailer.php'; require_once 'modules/Administration/Administration.php'; global $current_user; $mail = new SugarPHPMailer(); $admin = new Administration(); $admin->retrieveSettings(); $user = new User(); if ($type == 'Realty') { $user_id = $assigned_user_id; $user->retrieve($user_id); $oe = new OutboundEmail(); $userSettings = $oe->getUserMailerSettings($user); if ($admin->settings['mail_sendtype'] == "SMTP") { $mail->Host = $admin->settings['mail_smtpserver']; $mail->Port = $admin->settings['mail_smtpport']; if ($admin->settings['mail_smtpauth_req']) { $mail->SMTPAuth = TRUE; $mail->Username = $admin->settings['mail_smtpuser']; $mail->Password = $admin->settings['mail_smtppass']; } $mail->Mailer = "smtp"; $mail->SMTPKeepAlive = true; } else { $mail->mailer = 'sendmail'; } $mail->IsSMTP(); // send via SMTP if ($admin->settings['mail_smtpssl'] == '2') { $mail->SMTPSecure = "tls"; } elseif ($admin->settings['mail_smtpssl'] == '1') { $mail->SMTPSecure = "ssl"; } //$mail->Body = $body."<br/> <b style='color: red;'><strong> Важно! </strong> Ответ присылайте на почту: </b>".$userSettings->mail_smtpuser; $mail->Body = $body; $mail->From = $admin->settings['notify_fromaddress']; } elseif ($type == 'Contacts' or $type == 'Accounts') { $user_id = $assigned_user_id; $user->retrieve($user_id); $oe = new OutboundEmail(); $userSettings = $oe->getUserMailerSettings($user); if ($userSettings->mail_sendtype == "SMTP") { $mail->Host = $admin->settings['mail_smtpserver']; $mail->Port = $admin->settings['mail_smtpport']; if ($userSettings->mail_smtpauth_req) { $mail->SMTPAuth = TRUE; $mail->Username = $userSettings->mail_smtpuser; $mail->Password = $userSettings->mail_smtppass; } $mail->Mailer = "smtp"; $mail->SMTPKeepAlive = true; } else { $mail->mailer = 'sendmail'; } $mail->IsSMTP(); // send via SMTP if ($admin->settings['mail_smtpssl'] == '2') { $mail->SMTPSecure = "tls"; } elseif ($admin->settings['mail_smtpssl'] == '1') { $mail->SMTPSecure = "ssl"; } $mail->Body = $body; $mail->From = $user->email1; } //$user->retrieve(); $mail->CharSet = 'UTF-8'; $mail->FromName = $admin->settings['notify_fromname']; $mail->ContentType = "text/html"; //"text/plain" $mail->IsHTML(true); $mail->Subject = $subject; $mail->AddAttachment($attach, $nameToSend); foreach ($tos as $name => $address) { $mail->AddAddress("{$address}", "{$name}"); } if (!$mail->send()) { $GLOBALS['log']->info("sendSugarPHPMail - Mailer error: " . $mail->ErrorInfo); return false; } else { return true; } }
/** * If `mail_smtpserver` setting is missing on system mailer settings, a * notification is created and assigned to system user. */ function handleMissingSmtpServerSettingsNotifications() { require_once 'include/OutboundEmail/OutboundEmail.php'; $oe = new OutboundEmail(); $settings = $oe->getSystemMailerSettings(); if (!empty($settings->mail_smtpserver)) { return; } $user = \BeanFactory::getBean('Users'); $user->getSystemUser(); if (empty($user)) { return; } $app_strings = return_application_language($GLOBALS['current_language']); $emailSettingsUrl = sprintf('<a href="#bwc/index.php?module=EmailMan&action=config">%s</a>', $app_strings['LBL_MISSING_SMPT_SERVER_SETTINGS_NOTIFICATION_LINK_TEXT']); $description = str_replace('{{emailSettingsUrl}}', $emailSettingsUrl, $app_strings['TPL_MISSING_SMPT_SERVER_SETTINGS_NOTIFICATION_DESCRIPTION']); $notification = \BeanFactory::getBean('Notifications'); $notification->name = $app_strings['LBL_MISSING_SMPT_SERVER_SETTINGS_NOTIFICATION_SUBJECT']; $notification->description = $description; $notification->severity = 'warning'; $notification->assigned_user_id = $user->id; $notification->save(); }
function saveConfig() { // outbound email settings $oe = new OutboundEmail(); foreach ($_POST as $key => $val) { $prefix = $this->get_config_prefix($key); if (in_array($prefix[0], $this->config_categories)) { if (is_array($val)) { $val = implode(",", $val); } $this->saveSetting($prefix[0], $prefix[1], $val); } if (strpos($key, "mail_") !== false) { if (in_array($key, $oe->field_defs)) { $oe->{$key} = $val; } } } //saving outbound email from here is probably redundant, adding a check to make sure //smtpserver name is set. if (!empty($oe->mail_smtpserver)) { $oe->saveSystem(); } $this->retrieveSettings(false, true); }
/** * This function will return all the accounts this user has access to based on the * match of the emailId passed in as a parameter * * @param unknown_type $ie * @return unknown */ function getFromAllAccountsArray($ie, $ret) { global $current_user; global $app_strings; $ret['fromAccounts'] = array(); if (!isset($ret['to']) && !empty($ret['from'])) { $ret['fromAccounts']['status'] = false; return $ret; } $ieAccountsFull = $ie->retrieveAllByGroupIdWithGroupAccounts($current_user->id); $foundInPersonalAccounts = false; $foundInGroupAccounts = false; $foundInSystemAccounts = false; //$toArray = array(); if ($ret['type'] == "draft") { $toArray = explode(",", $ret['from']); } else { $toArray = $ie->email->email2ParseAddressesForAddressesOnly($ret['to']); } // else foreach ($ieAccountsFull as $k => $v) { $storedOptions = unserialize(base64_decode($v->stored_options)); if (array_search_insensitive($storedOptions['from_addr'], $toArray)) { if ($v->is_personal) { $foundInPersonalAccounts = true; break; } else { $foundInGroupAccounts = true; } // else } // if } // foreach $oe = new OutboundEmail(); $system = $oe->getSystemMailerSettings(); $return = $current_user->getUsersNameAndEmail(); $return['name'] = from_html($return['name']); $useMyAccountString = true; if (empty($return['email'])) { $systemReturn = $current_user->getSystemDefaultNameAndEmail(); $return['email'] = $systemReturn['email']; $return['name'] = from_html($systemReturn['name']); $useMyAccountString = false; } // if $myAccountString = ''; if ($useMyAccountString) { $myAccountString = " - {$app_strings['LBL_MY_ACCOUNT']}"; } // if if (!empty($system->id)) { $admin = new Administration(); $admin->retrieveSettings(); //retrieve all admin settings. if (in_array(trim($return['email']), $toArray)) { $foundInSystemAccounts = true; } // if } // if if (!$foundInPersonalAccounts && !$foundInGroupAccounts && !$foundInSystemAccounts) { $ret['fromAccounts']['status'] = false; return $ret; } // if $ieAccountsFrom = array(); foreach ($ieAccountsFull as $k => $v) { $storedOptions = unserialize(base64_decode($v->stored_options)); $storedOptionsName = from_html($storedOptions['from_name']); $selected = false; if (array_search_insensitive($storedOptions['from_addr'], $toArray)) { //if ($ret['to'] == $storedOptions['from_addr']) { $selected = true; } // if if ($foundInPersonalAccounts) { if ($v->is_personal) { $ieAccountsFrom[] = array("value" => $v->id, "selected" => $selected, "text" => "{$storedOptionsName} ({$storedOptions['from_addr']})"); } // if } else { $ieAccountsFrom[] = array("value" => $v->id, "selected" => $selected, "text" => "{$storedOptionsName} ({$storedOptions['from_addr']}) - {$app_strings['LBL_EMAIL_UPPER_CASE_GROUP']}"); } // else } // foreach if (!empty($system->id)) { if (!$foundInPersonalAccounts && !$foundInGroupAccounts && $foundInSystemAccounts) { $ieAccountsFrom[] = array("value" => $system->id, "selected" => true, "text" => "{$return['name']} ({$return['email']}){$myAccountString}"); } else { $ieAccountsFrom[] = array("value" => $system->id, "text" => "{$return['name']} ({$return['email']}){$myAccountString}"); } // else } // if $ret['fromAccounts']['status'] = $foundInPersonalAccounts || $foundInGroupAccounts || $foundInSystemAccounts ? true : false; $ret['fromAccounts']['data'] = $ieAccountsFrom; return $ret; }
} $ie->{$k} = $retService; } if (isset($ie->{$k})) { $ret[$k] = $ie->{$k}; } } $out = $json->encode($ret); echo $out; } //If the user is saving the username/password then we need to update the outbound account. $outboundMailUser = isset($_REQUEST['mail_smtpuser']) ? $_REQUEST['mail_smtpuser'] : ""; $outboundMailPass = isset($_REQUEST['mail_smtppass']) ? $_REQUEST['mail_smtppass'] : ""; $outboundMailId = isset($_REQUEST['outbound_email']) ? $_REQUEST['outbound_email'] : ""; if (!empty($outboundMailUser) && !empty($outboundMailPass) && !empty($outboundMailId)) { $oe = new OutboundEmail(); $oe->retrieve($outboundMailId); $oe->mail_smtpuser = $outboundMailUser; $oe->mail_smtppass = $outboundMailPass; $oe->save(); } } else { echo "NOOP"; } break; case "getIeAccount": $GLOBALS['log']->debug("********** EMAIL 2.0 - Asynchronous - at: getIeAccount"); $ie->retrieve($_REQUEST['ieId']); if ($ie->group_id == $current_user->id) { $ret = array(); foreach ($ie->field_defs as $k => $v) {
/** * Get the users default IE account id * * @param User $user * @return string */ function getUsersDefaultOutboundServerId($user) { $id = $user->getPreference($this->keyForUsersDefaultIEAccount, 'Emails', $user); //If no preference has been set, grab the default system id. if (empty($id)) { $oe = new OutboundEmail(); $system = $oe->getSystemMailerSettings(); $id = empty($system->id) ? '' : $system->id; } return $id; }
if (isset($user_subpanel_tabs)) { $sugar_smarty->assign("SUBPANEL_TABS", $user_subpanel_tabs ? 'checked' : ''); } else { $sugar_smarty->assign("SUBPANEL_TABS", $GLOBALS['sugar_config']['default_subpanel_tabs'] ? 'checked' : ''); } // Email Options $sugar_smarty->assign("EMAIL_OPTIONS", $focus->emailAddress->getEmailAddressWidgetDetailView($focus)); $email_link_type = $focus->getPreference('email_link_type'); if (!empty($email_link_type)) { $sugar_smarty->assign('EMAIL_LINK_TYPE', $app_list_strings['dom_email_link_type'][$focus->getPreference('email_link_type')]); } if ($focus->getPreference('email_link_type') == 'sugar') { $sugar_smarty->assign('SHOW_SMTP_SETTINGS', true); } //Handle outbound email templates $oe = new OutboundEmail(); $userOverrideOE = $oe->getUsersMailerForSystemOverride($focus->id); $mail_smtpuser = ""; $mail_smtpserver = ""; if ($userOverrideOE == null) { $systemOE = $oe->getSystemMailerSettings(); $mail_smtpdisplay = $systemOE->mail_smtpdisplay; $mail_smtpserver = $systemOE->mail_smtpserver; $mail_smtptype = $systemOE->mail_smtptype; if ($oe->isAllowUserAccessToSystemDefaultOutbound()) { $mail_smtpuser = $systemOE->mail_smtpuser; } } else { $mail_smtpdisplay = $userOverrideOE->mail_smtpdisplay; $mail_smtpuser = $userOverrideOE->mail_smtpuser; $mail_smtpserver = $userOverrideOE->mail_smtpserver;