/** * Retrieves the mailer for a user if they have overriden the username * and password for the default system account. * * @param String $user_id */ function getUsersMailerForSystemOverride($user_id) { $query = "SELECT id FROM outbound_email WHERE user_id = '{$user_id}' AND type = 'system-override' ORDER BY name"; $rs = $this->db->query($query); $row = $this->db->fetchByAssoc($rs); if (!empty($row['id'])) { $oe = new OutboundEmail(); $oe->retrieve($row['id']); return $oe; } else { return null; } }
$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) { if ($k == 'stored_options') {
function testSystemAccountMailSettingsChangedNoUserAccessToUsername() { //User not alloweed to access system email username/password $GLOBALS['db']->query("DELETE FROM config WHERE category='notify' AND name='allow_default_outbound' "); $newSystemPort = 864; $newSystemServer = "system.imap.com"; $userID = create_guid(); $ob = new OutboundEmail(); $ob->id = $userID; $ob->new_with_id = TRUE; $ob->name = 'Sugar Test 2'; $ob->type = 'system-override'; $ob->user_id = $this->_user->id; $ob->mail_sendtype = "SMTP"; $ob->mail_smtpuser = "******"; $ob->mail_smtppass = "******"; $ob->save(); $this->ob = $ob; $system = $ob->getSystemMailerSettings(); $system->new_with_id = FALSE; $system->mail_smtpport = $newSystemPort; $system->mail_smtpserver = $newSystemServer; $system->saveSystem(); $obRetrieved = new OutboundEmail(); $obRetrieved->retrieve($userID); $this->assertEquals($newSystemPort, $obRetrieved->mail_smtpport, "Could not update users system-override accounts after system save."); $this->assertEquals($newSystemServer, $obRetrieved->mail_smtpserver, "Could not update users system-override accounts after system save."); $this->assertEquals("Test User", $obRetrieved->mail_smtpuser, "Could not update users system-override accounts after system save."); $this->assertEquals("User Pass", $obRetrieved->mail_smtppass, "Could not update users system-override accounts after system save."); }
$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(); $oe->id = $_REQUEST['mail_id']; $oe->name = $_REQUEST['mail_name'];