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."); }
//// 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'])) { $ie = new InboundEmail(); if (false === $ie->savePersonalEmailAccount($return_id, $focus->user_name)) { header("Location: index.php?action=Error&module=Users&error_string=&ie_error=true&id=" . $return_id); die; // die here, else the header redirect below takes over. } } elseif (isset($_REQUEST['ie_id']) && !empty($_REQUEST['ie_id']) && empty($_REQUEST['server_url'])) { // user is deleting their I-E $ie = new InboundEmail();
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); echo $out; } else { die;