} 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 if (isset($_REQUEST['server_url']) && !empty($_REQUEST['server_url'])) {
function getFromAccountsArray($ie) { global $current_user; global $app_strings; $ieAccountsFull = $ie->retrieveAllByGroupIdWithGroupAccounts($current_user->id); $ieAccountsFrom = array(); $oe = new OutboundEmail(); $system = $oe->getSystemMailerSettings(); $ret = $current_user->getUsersNameAndEmail(); $ret['name'] = from_html($ret['name']); $useMyAccountString = true; if (empty($ret['email'])) { $systemReturn = $current_user->getSystemDefaultNameAndEmail(); $ret['email'] = $systemReturn['email']; $ret['name'] = from_html($systemReturn['name']); $useMyAccountString = false; } // if $myAccountString = ''; if ($useMyAccountString) { $myAccountString = " - {$app_strings['LBL_MY_ACCOUNT']}"; } // if //Check to make sure that the user has set the associated inbound email account -> outbound account is active. $showFolders = unserialize(base64_decode($current_user->getPreference('showFolders', 'Emails'))); $sf = new SugarFolder(); $groupSubs = $sf->getSubscriptions($current_user); foreach ($ieAccountsFull as $k => $v) { $personalSelected = !empty($showFolders) && in_array($v->id, $showFolders); $allowOutboundGroupUsage = $v->get_stored_options('allow_outbound_group_usage', FALSE); $groupSelected = in_array($v->groupfolder_id, $groupSubs) && $allowOutboundGroupUsage; $selected = $personalSelected || $groupSelected; if (!$selected) { $GLOBALS['log']->debug("Inbound Email {$v->name}, not selected and will not be available for selection within compose UI."); continue; } $name = $v->get_stored_options('from_name'); $addr = $v->get_stored_options('from_addr'); if ($name != null && $addr != null) { $name = from_html($name); if (!$v->is_personal) { $ieAccountsFrom[] = array("value" => $v->id, "text" => "{$name} ({$addr}) - {$app_strings['LBL_EMAIL_UPPER_CASE_GROUP']}"); } else { $ieAccountsFrom[] = array("value" => $v->id, "text" => "{$name} ({$addr})"); } // else } // if } // foreach $userSystemOverride = $oe->getUsersMailerForSystemOverride($current_user->id); //Substitute in the users system override if its available. if ($userSystemOverride != null) { $system = $userSystemOverride; } if (!empty($system->mail_smtpserver)) { $admin = new Administration(); $admin->retrieveSettings(); //retrieve all admin settings. $ieAccountsFrom[] = array("value" => $system->id, "text" => "{$ret['name']} ({$ret['email']}){$myAccountString}"); } return $ieAccountsFrom; }
$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; $mail_smtptype = $userOverrideOE->mail_smtptype;
function testDuplicateSystemAccountForUser() { $oe = new OutboundEmail(); $userOverideAccont = $oe->createUserSystemOverrideAccount($this->_user->id, "TEST USER NAME", "TEST PASSWORD"); $this->userOverideAccont = $userOverideAccont; $retrievedOb = $oe->getUsersMailerForSystemOverride($this->_user->id); $this->assertEquals("TEST USER NAME", $retrievedOb->mail_smtpuser, "Could not duplicate systems outbound account for user"); $this->assertEquals($this->_user->id, $retrievedOb->user_id, "Could not duplicate systems outbound account for user"); $this->assertEquals("TEST PASSWORD", $retrievedOb->mail_smtppass, "Could not duplicate systems outbound account for user"); $this->assertEquals('system-override', $userOverideAccont->type, "Could not duplicate systems outbound account for user"); }
if ($k == "") { $sigs[$k] = $app_strings['LBL_NONE']; } else { if (is_array($v) && isset($v['name'])) { $sigs[$k] = $v['name']; } else { $sigs[$k] = $v; } } } $out['signatures'] = $sigs; $out['fromAccounts'] = $email->et->getFromAccountsArray($ie); $out['errorArray'] = array(); $oe = new OutboundEmail(); if ($oe->doesUserOverrideAccountRequireCredentials($current_user->id)) { $overideAccount = $oe->getUsersMailerForSystemOverride($current_user->id); //If the user override account has not been created yet, create it for the user. if ($overideAccount == null) { $overideAccount = $oe->createUserSystemOverrideAccount($current_user->id); } $out['errorArray'] = array($overideAccount->id => $app_strings['LBL_EMAIL_WARNING_MISSING_USER_CREDS']); } $ret = $json->encode($out); echo $ret; break; case "getSignature": $GLOBALS['log']->debug("********** EMAIL 2.0 - Asynchronous - at: getSignature"); if (isset($_REQUEST['id'])) { $signature = $current_user->getSignature($_REQUEST['id']); $signature['signature_html'] = from_html($signature['signature_html']); $out = $json->encode($signature);