function loadAlias($aliasId) { $sql = 'SELECT' . ' alias_id,' . ' (username || \'@\' || domain) AS email,' . ' username,' . ' domain,' . ' destination,' . ' active' . ' FROM virtual_aliases' . ' JOIN virtual_domains USING(domain_id)' . ' WHERE alias_id = ?'; return db_getrow($sql, array($aliasId)); }
function getAutoReply($userId) { $sql = "SELECT begins, ends, message, active FROM autoreply WHERE user_id = ?"; $ret = db_getrow($sql, array($userId)); if ($ret["active"] == "t") { $ret["active"] = true; } else { $ret["active"] = false; } return $ret; }
$from = $argv[1]; $to = $argv[2]; $sql = "SELECT user_id, message"; $sql .= " FROM autoreply"; $sql .= " JOIN virtual_users USING(user_id)"; $sql .= " JOIN virtual_domains USING(domain_id)"; $sql .= " WHERE virtual_users.active = 't'"; $sql .= " AND autoreply.active = 't'"; $sql .= " AND begins <= now()"; $sql .= " AND (now() < ends"; $sql .= " OR ends IS NULL"; $sql .= " )"; $sql .= " AND (username || '@' || domain) = ?"; $params = array(); $params[] = $to; $row = db_getrow($sql, $params); $userId = $row['user_id']; $message = $row['message']; if ($message) { $sql = "SELECT timestamp"; $sql .= " FROM autoreply_log"; $sql .= " JOIN autoreply USING(user_id)"; $sql .= " WHERE active = 't'"; $sql .= " AND begins <= timestamp"; $sql .= " AND user_id = ?"; $sql .= " AND from_email = ?"; $params = array(); $params[] = $userId; $params[] = $from; $time = db_getval($sql, $params); if ($time) {