Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add temporary email description #6001

Open
wants to merge 5 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions data/web/inc/functions.mailbox.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
$_data["validity"] = 8760;
}
$domain = $_data['domain'];
$description = $_data['description'];
$valid_domains[] = mailbox('get', 'mailbox_details', $username)['domain'];
$valid_alias_domains = user_get_alias_details($username)['alias_domains'];
if (!empty($valid_alias_domains)) {
Expand All @@ -62,10 +63,11 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
return false;
}
$validity = strtotime("+" . $_data["validity"] . " hour");
$stmt = $pdo->prepare("INSERT INTO `spamalias` (`address`, `goto`, `validity`) VALUES
(:address, :goto, :validity)");
$stmt = $pdo->prepare("INSERT INTO `spamalias` (`address`, `description`, `goto`, `validity`) VALUES
(:address, :description, :goto, :validity)");
$stmt->execute(array(
':address' => readable_random_string(rand(rand(3, 9), rand(3, 9))) . '.' . readable_random_string(rand(rand(3, 9), rand(3, 9))) . '@' . $domain,
':description' => $description,
':goto' => $username,
':validity' => $validity
));
Expand Down Expand Up @@ -4201,6 +4203,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
}
$stmt = $pdo->prepare("SELECT `address`,
`goto`,
`description`,
`validity`,
`created`,
`modified`
Expand Down
61 changes: 27 additions & 34 deletions data/web/inc/init_db.inc.php
marekfilip marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
function init_db_schema() {
function init_db_schema()
{
try {
global $pdo;

Expand Down Expand Up @@ -488,7 +489,7 @@ function init_db_schema() {
"quarantine_category" => "TINYINT(1) NOT NULL DEFAULT '1'",
"app_passwds" => "TINYINT(1) NOT NULL DEFAULT '1'",
"pw_reset" => "TINYINT(1) NOT NULL DEFAULT '1'",
),
),
"keys" => array(
"primary" => array(
"" => array("username")
Expand Down Expand Up @@ -527,6 +528,7 @@ function init_db_schema() {
"cols" => array(
"address" => "VARCHAR(255) NOT NULL",
"goto" => "TEXT NOT NULL",
"description" => "TEXT NOT NULL",
"created" => "DATETIME(0) NOT NULL DEFAULT NOW(0)",
"modified" => "DATETIME ON UPDATE CURRENT_TIMESTAMP",
"validity" => "INT(11)"
Expand Down Expand Up @@ -678,7 +680,7 @@ function init_db_schema() {
"mailbox_relayhost" => "TINYINT(1) NOT NULL DEFAULT '1'",
"domain_relayhost" => "TINYINT(1) NOT NULL DEFAULT '1'",
"domain_desc" => "TINYINT(1) NOT NULL DEFAULT '0'"
),
),
"keys" => array(
"primary" => array(
"" => array("username")
Expand Down Expand Up @@ -1151,7 +1153,7 @@ function init_db_schema() {
while ($row = array_shift($rows)) {
$pdo->query($row['FKEY_DROP']);
}
foreach($properties['cols'] as $column => $type) {
foreach ($properties['cols'] as $column => $type) {
$stmt = $pdo->query("SHOW COLUMNS FROM `" . $table . "` LIKE '" . $column . "'");
$num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));
if ($num_results == 0) {
Expand All @@ -1165,12 +1167,11 @@ function init_db_schema() {
}
}
$pdo->query("ALTER TABLE `" . $table . "` ADD `" . $column . "` " . $type);
}
else {
} else {
$pdo->query("ALTER TABLE `" . $table . "` MODIFY COLUMN `" . $column . "` " . $type);
}
}
foreach($properties['keys'] as $key_type => $key_content) {
foreach ($properties['keys'] as $key_type => $key_content) {
if (strtolower($key_type) == 'primary') {
foreach ($key_content as $key_values) {
$fields = "`" . implode("`, `", $key_values) . "`";
Expand Down Expand Up @@ -1227,18 +1228,18 @@ function init_db_schema() {
$keys_to_exist = array();
if (isset($properties['keys']['unique']) && is_array($properties['keys']['unique'])) {
foreach ($properties['keys']['unique'] as $key_name => $key_values) {
$keys_to_exist[] = $key_name;
$keys_to_exist[] = $key_name;
}
}
if (isset($properties['keys']['key']) && is_array($properties['keys']['key'])) {
foreach ($properties['keys']['key'] as $key_name => $key_values) {
$keys_to_exist[] = $key_name;
$keys_to_exist[] = $key_name;
}
}
// Index for foreign key must exist
if (isset($properties['keys']['fkey']) && is_array($properties['keys']['fkey'])) {
foreach ($properties['keys']['fkey'] as $key_name => $key_values) {
$keys_to_exist[] = $key_name;
$keys_to_exist[] = $key_name;
}
}
// Step 2: Drop all vanished indexes
Expand All @@ -1255,33 +1256,29 @@ function init_db_schema() {
$pdo->query("ALTER TABLE `" . $table . "` DROP PRIMARY KEY");
}
}
}
else {
} else {
// Create table if it is missing
$sql = "CREATE TABLE IF NOT EXISTS `" . $table . "` (";
foreach($properties['cols'] as $column => $type) {
foreach ($properties['cols'] as $column => $type) {
$sql .= "`" . $column . "` " . $type . ",";
}
foreach($properties['keys'] as $key_type => $key_content) {
foreach ($properties['keys'] as $key_type => $key_content) {
if (strtolower($key_type) == 'primary') {
foreach ($key_content as $key_values) {
$fields = "`" . implode("`, `", $key_values) . "`";
$sql .= "PRIMARY KEY (" . $fields . ")" . ",";
}
}
elseif (strtolower($key_type) == 'key') {
} elseif (strtolower($key_type) == 'key') {
foreach ($key_content as $key_name => $key_values) {
$fields = "`" . implode("`, `", $key_values) . "`";
$sql .= "KEY `" . $key_name . "` (" . $fields . ")" . ",";
}
}
elseif (strtolower($key_type) == 'unique') {
} elseif (strtolower($key_type) == 'unique') {
foreach ($key_content as $key_name => $key_values) {
$fields = "`" . implode("`, `", $key_values) . "`";
$sql .= "UNIQUE KEY `" . $key_name . "` (" . $fields . ")" . ",";
}
}
elseif (strtolower($key_type) == 'fkey') {
} elseif (strtolower($key_type) == 'fkey') {
foreach ($key_content as $key_name => $key_values) {
@list($table_ref, $field_ref) = explode('.', $key_values['ref']);
$sql .= "FOREIGN KEY `" . $key_name . "` (" . $key_values['col'] . ") REFERENCES `" . $table_ref . "` (`" . $field_ref . "`)
Expand All @@ -1295,7 +1292,6 @@ function init_db_schema() {
}
// Reset table attributes
$pdo->query("ALTER TABLE `" . $table . "` " . $properties['attr'] . ";");

}

// Recreate SQL views
Expand All @@ -1322,12 +1318,12 @@ function init_db_schema() {
$stmt = $pdo->query("SELECT NULL FROM `admin`");
$num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));
if ($num_results == 0) {
$pdo->query("INSERT INTO `admin` (`username`, `password`, `superadmin`, `created`, `modified`, `active`)
$pdo->query("INSERT INTO `admin` (`username`, `password`, `superadmin`, `created`, `modified`, `active`)
VALUES ('admin', '{SSHA256}K8eVJ6YsZbQCfuJvSUbaQRLr0HPLz5rC9IAp0PAFl0tmNDBkMDc0NDAyOTAxN2Rk', 1, NOW(), NOW(), 1)");
$pdo->query("INSERT INTO `domain_admins` (`username`, `domain`, `created`, `active`)
$pdo->query("INSERT INTO `domain_admins` (`username`, `domain`, `created`, `active`)
SELECT `username`, 'ALL', NOW(), 1 FROM `admin`
WHERE superadmin='1' AND `username` NOT IN (SELECT `username` FROM `domain_admins`);");
$pdo->query("DELETE FROM `admin` WHERE `username` NOT IN (SELECT `username` FROM `domain_admins`);");
$pdo->query("DELETE FROM `admin` WHERE `username` NOT IN (SELECT `username` FROM `domain_admins`);");
}
// Insert new DB schema version
$pdo->query("REPLACE INTO `versions` (`application`, `version`) VALUES ('db_schema', '" . $db_version . "');");
Expand Down Expand Up @@ -1355,7 +1351,7 @@ function init_db_schema() {
$pdo->query("UPDATE `mailbox` SET `attributes` = JSON_SET(`attributes`, '$.mailbox_format', \"maildir:\") WHERE JSON_VALUE(`attributes`, '$.mailbox_format') IS NULL;");
$pdo->query("UPDATE `mailbox` SET `attributes` = JSON_SET(`attributes`, '$.quarantine_notification', \"never\") WHERE JSON_VALUE(`attributes`, '$.quarantine_notification') IS NULL;");
$pdo->query("UPDATE `mailbox` SET `attributes` = JSON_SET(`attributes`, '$.quarantine_category', \"reject\") WHERE JSON_VALUE(`attributes`, '$.quarantine_category') IS NULL;");
foreach($tls_options as $tls_user => $tls_options) {
foreach ($tls_options as $tls_user => $tls_options) {
$stmt = $pdo->prepare("UPDATE `mailbox` SET `attributes` = JSON_SET(`attributes`, '$.tls_enforce_in', :tls_enforce_in),
`attributes` = JSON_SET(`attributes`, '$.tls_enforce_out', :tls_enforce_out)
WHERE `username` = :username");
Expand Down Expand Up @@ -1434,7 +1430,7 @@ function init_db_schema() {
":template" => $default_domain_template["template"]
));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
if (empty($row)){
if (empty($row)) {
$stmt = $pdo->prepare("INSERT INTO `templates` (`type`, `template`, `attributes`)
VALUES (:type, :template, :attributes)");
$stmt->execute(array(
Expand All @@ -1449,7 +1445,7 @@ function init_db_schema() {
":template" => $default_mailbox_template["template"]
));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
if (empty($row)){
if (empty($row)) {
$stmt = $pdo->prepare("INSERT INTO `templates` (`type`, `template`, `attributes`)
VALUES (:type, :template, :attributes)");
$stmt->execute(array(
Expand All @@ -1468,8 +1464,7 @@ function init_db_schema() {
'msg' => 'db_init_complete'
);
}
}
catch (PDOException $e) {
} catch (PDOException $e) {
if (php_sapi_name() == "cli") {
echo "DB initialization failed: " . print_r($e, true) . PHP_EOL;
} else {
Expand Down Expand Up @@ -1508,18 +1503,16 @@ function init_db_schema() {
SELECT `c_uid`, `domain`, `c_name`, `c_password`, `c_cn`, `mail`, `aliases`, `ad_aliases`, `ext_acl`, `kind`, `multiple_bookings` from sogo_view");
$stmt = $pdo->query("DELETE FROM _sogo_static_view WHERE `c_uid` NOT IN (SELECT `username` FROM `mailbox` WHERE `active` = '1');");
echo "Fixed _sogo_static_view" . PHP_EOL;
}
catch ( Exception $e ) {
} catch (Exception $e) {
// Dunno
}
}
try {
$m = new Memcached();
$m->addServer('memcached', 11211);
$m->flush();
echo "Cleaned up memcached". PHP_EOL;
}
catch ( Exception $e ) {
echo "Cleaned up memcached" . PHP_EOL;
} catch (Exception $e) {
// Dunno
}
init_db_schema();
Expand Down
8 changes: 8 additions & 0 deletions data/web/js/site/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,14 @@ jQuery(function($){
data: 'address',
defaultContent: ''
},
{
title: lang.description,
data: 'description',
defaultContent: '',
render: function (data, type) {
return escapeHtml(data);
}
},
{
title: lang.alias_valid_until,
data: 'validity',
Expand Down
3 changes: 2 additions & 1 deletion data/web/lang/lang.ca-es.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@
"client_configuration": "Guies de configuració per als clients de correu més habituals",
"create_syncjob": "Afegir treball de sincronitzaió",
"day": "Dia",
"description": "Descripció",
"direct_aliases": "Adreces àlies directes",
"direct_aliases_desc": "Els àlies directes sí que es veuen afectat per la configuració de l'usuari",
"eas_reset": "Fer un reset de la cache d'ActiveSync del dispositiu",
Expand Down Expand Up @@ -558,4 +559,4 @@
"week": "Setmana",
"weeks": "Setmanes"
}
}
}
3 changes: 2 additions & 1 deletion data/web/lang/lang.cs-cz.json
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,7 @@
"created_on": "Vytvoreno",
"daily": "Každý den",
"day": "den",
"description": "Popis",
"delete_ays": "Potvrďte odstranění.",
"direct_aliases": "Přímé aliasy",
"direct_aliases_desc": "Na přímé aliasy se uplatňuje filtr spamu a nastavení pravidel TLS",
Expand Down Expand Up @@ -1309,4 +1310,4 @@
"session_token": "Token formuláře není platný: Token mismatch",
"session_ua": "Token formuláře není platný: User-Agent validation error"
}
}
}
3 changes: 2 additions & 1 deletion data/web/lang/lang.da-dk.json
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,7 @@
"create_syncjob": "Opret nyt sync job",
"daily": "Dagligt",
"day": "dag",
"description": "Beskrivelse",
"delete_ays": "Bekræft venligst ønsket om sletning.",
"direct_aliases": "Direkte alias addresser",
"direct_aliases_desc": "Direkte alias-adresser påvirkes af spamfilter og TLS-politiske indstillinger.",
Expand Down Expand Up @@ -1091,4 +1092,4 @@
"first": "Først"
}
}
}
}
3 changes: 2 additions & 1 deletion data/web/lang/lang.de-de.json
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,7 @@
"created_on": "Erstellt am",
"daily": "Täglich",
"day": "Tag",
"description": "Beschreibung",
"delete_ays": "Soll der Löschvorgang wirklich ausgeführt werden?",
"direct_aliases": "Direkte Alias-Adressen",
"direct_aliases_desc": "Nur direkte Alias-Adressen werden für benutzerdefinierte Einstellungen berücksichtigt.",
Expand Down Expand Up @@ -1338,4 +1339,4 @@
"hour": "Nachrichten / Stunde",
"day": "Nachrichten / Tag"
}
}
}
3 changes: 2 additions & 1 deletion data/web/lang/lang.en-gb.json
Original file line number Diff line number Diff line change
Expand Up @@ -1192,6 +1192,7 @@
"created_on": "Created on",
"daily": "Daily",
"day": "day",
"description": "Description",
"delete_ays": "Please confirm the deletion process.",
"direct_aliases": "Direct alias addresses",
"direct_aliases_desc": "Direct alias addresses are affected by spam filter and TLS policy settings.",
Expand Down Expand Up @@ -1338,4 +1339,4 @@
"session_token": "Form token invalid: Token mismatch",
"session_ua": "Form token invalid: User-Agent validation error"
}
}
}
3 changes: 2 additions & 1 deletion data/web/lang/lang.es-es.json
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,7 @@
"create_syncjob": "Crear nuevo trabajo de sincronización",
"daily": "Cada día",
"day": "Día",
"description": "Descripción",
"direct_aliases": "Alias directos",
"direct_aliases_desc": "Los alias directos se ven afectadas por el filtro de correo no deseado y la configuración de la política TLS del usuario.",
"eas_reset": "Resetear el caché ActiveSync",
Expand Down Expand Up @@ -778,4 +779,4 @@
"fuzzy_learn_error": "Error aprendiendo hash: %s",
"ip_invalid": "IP inválida omitida: %s"
}
}
}
3 changes: 2 additions & 1 deletion data/web/lang/lang.fi-fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,7 @@
"create_syncjob": "Luo uusi synkronointi työ",
"daily": "Päivittäin",
"day": "Päivä",
"description": "Kuvaus",
"direct_aliases": "Suorat alias osoitteet",
"direct_aliases_desc": "Roska posti suodatus-ja TLS-käytäntö asetukset vaikuttavat suora aliaksen osoitteisiin.",
"eas_reset": "Tyhjennä ActiveSync-laitteen väli muisti",
Expand Down Expand Up @@ -908,4 +909,4 @@
"last": "Edellinen"
}
}
}
}
3 changes: 2 additions & 1 deletion data/web/lang/lang.fr-fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,7 @@
"create_syncjob": "Créer une tâche de synchronisation",
"daily": "Quotidien",
"day": "jour",
"description": "Description",
"delete_ays": "Veuillez confirmer le processus de suppression.",
"direct_aliases": "Adresses alias directes",
"direct_aliases_desc": "Les adresses d’alias directes sont affectées par le filtre anti-spam et les paramètres de politique TLS.",
Expand Down Expand Up @@ -1267,4 +1268,4 @@
"ratelimit": {
"disabled": "Désactivé"
}
}
}
3 changes: 2 additions & 1 deletion data/web/lang/lang.hu-hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@
"create_syncjob": "Új szinkronizációs művelet létrehozása",
"daily": "Napi",
"day": "nap",
"description": "Leírás",
"delete_ays": "Erősítse meg a törlést.",
"direct_aliases": "Közvetlen alias címek",
"eas_reset": "ActiveSync eszköz gyorsítótár ürítése",
Expand Down Expand Up @@ -591,4 +592,4 @@
"app_name": "Alkalmazás neve",
"app_passwd_protocols": "Engedélyezett protokollok az alkalmazás jelszavához"
}
}
}
3 changes: 2 additions & 1 deletion data/web/lang/lang.it-it.json
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,7 @@
"created_on": "Creato il",
"daily": "Giornaliero",
"day": "giorno",
"description": "Descrizione",
"delete_ays": "Please confirm the deletion process.",
"direct_aliases": "Direct alias addresses",
"direct_aliases_desc": "Direct alias addresses are affected by spam filter and TLS policy settings.",
Expand Down Expand Up @@ -1308,4 +1309,4 @@
},
"decimal": "."
}
}
}
Loading