} } 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']); } } } /////////////////////////////////////////////////////////////////////////// //// INBOUND EMAIL SAVES
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(); }
$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; $mail_smtptype = $userOverrideOE->mail_smtptype; } $sugar_smarty->assign("MAIL_SMTPUSER", $mail_smtpuser); $sugar_smarty->assign("MAIL_SMTPDISPLAY", $mail_smtpdisplay); $show_roles = !($focus->is_group == '1' || $focus->portal_only == '1'); $sugar_smarty->assign('SHOW_ROLES', $show_roles); // User Holidays subpanel on the advanced tab global $modules_exempt_from_availability_check; $modules_exempt_from_availability_check = array('Holidays' => 'Holidays');
function testIsUserAlloweedAccessToSystemOutboundEmail() { $oe = new OutboundEmail(); $GLOBALS['db']->query("DELETE FROM config WHERE category='notify' AND name='allow_default_outbound' "); $emptyTest = $oe->isAllowUserAccessToSystemDefaultOutbound(); $this->assertFalse($emptyTest, "User alloweed access to system outbound email account error"); $GLOBALS['db']->query("INSERT INTO config (category,name,value) VALUES ('notify','allow_default_outbound','2') "); $allowTest = $oe->isAllowUserAccessToSystemDefaultOutbound(); $this->assertTrue($allowTest, "User alloweed access to system outbound email account error"); $GLOBALS['db']->query("DELETE FROM config WHERE category='notify' AND name='allow_default_outbound' "); $emptyTest = $oe->isAllowUserAccessToSystemDefaultOutbound(); $this->assertFalse($emptyTest, "User alloweed access to system outbound email account error"); }
/** * 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(); if ($oe->isAllowUserAccessToSystemDefaultOutbound()) { $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 = Administration::getSettings(); //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; }