1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
|
<?php
//
// Main panel
//
function drawAdminTools_Aliases($domain){
global $adm_login;
global $adm_pass;
global $edit_domain;
global $edit_mailbox;
global $addrlink;
global $pro_mysql_pop_table;
global $pro_mysql_mailaliasgroup_table;
checkLoginPassAndDomain($adm_login,$adm_pass,$domain["name"]);
$out = "";
$dsc = array(
"title" => _("List of your mail groups") ,
"new_item_title" => _("Create New Mail Group") ,
"new_item_link" => _("Create Mail Group") ,
"edit_item_title" => _("Edit Mail Group") ,
"table_name" => $pro_mysql_mailaliasgroup_table,
"action" => "aliasgroup",
"forward" => array("adm_login","adm_pass","addrlink"),
"id_fld" => "autoinc",
"list_fld_show" => "id",
"max_item" => $domain["max_email"],
"num_item_txt" => _("Number of active mailboxes:"),
"create_item_callback" => "emailAliasesCreateCallback",
"delete_item_callback" => "emailAliasesDeleteCallback",
"edit_item_callback" => "emailAliasesEditCallback",
"order_by" => "id",
"where_list" => array(
"domain_parent" => $domain["name"]),
"cols" => array(
"autoinc" => array(
"type" => "id",
"display" => "no",
"legend" => _("Login:") ),
"id" => array(
"type" => "text",
"check" => "dtc_login_or_email",
"disable_edit" => "yes",
"happen" => "@".$domain["name"],
"legend" => _("Email:") ),
"delivery_group" => array(
"type" => "textarea",
"check" => "mail_alias_group",
"legend" => _("Delivery Group:") ,
"cols" => "40",
"rows" => "7")
),
"check_unique" => array( "id"),
"check_unique_msg" => _("Email address is already in use.")
);
$list_items = dtcListItemsEdit($dsc);
// We have to query again, in case something has changed
$q = "SELECT id FROM $pro_mysql_mailaliasgroup_table WHERE domain_parent='".$domain["name"]."';";
$r = mysql_query($q)or die ("Cannot query $q line: ".__LINE__." file ".__FILE__." sql said:" .mysql_error());
$n = mysql_num_rows($r);
$out .= $list_items;
$out .= helpLink("PmWiki/Email-Accounts");
return $out;
}
///////////////////
// Few callbacks //
///////////////////
function emailAliasesEditCallback ($id){
global $pro_mysql_pop_table;
global $pro_mysql_mailaliasgroup_table;
$q = "SELECT * FROM $pro_mysql_mailaliasgroup_table WHERE autoinc='$id';";
$r = mysql_query($q)or die ("Cannot query $q line: ".__LINE__." file ".__FILE__." sql said:" .mysql_error());
$n = mysql_num_rows($r);
if($n != 1){
die("Cannot find created email line ".__LINE__." file ".__FILE__);
}
$a = mysql_fetch_array($r);
$q = "UPDATE $pro_mysql_mailaliasgroup_table SET delivery_group='".trim($_REQUEST['delivery_group'])."' WHERE autoinc='$id';";
$r = mysql_query($q)or die ("Cannot query $q line: ".__LINE__." file ".__FILE__." sql said:" .mysql_error());
//writeDotQmailFile($a["id"],$a["mbox_host"]);
triggerMXListUpdate();
updateUsingCron("gen_qmail='yes', qmail_newu='yes'");
return "";
}
function emailAliasesCreateCallback ($id){
global $pro_mysql_list_table;
global $conf_dtc_system_uid;
global $conf_dtc_system_gid;
global $adm_login;
global $edit_domain;
global $pro_mysql_mailaliasgroup_table;
global $pro_mysql_pop_table;
$q = "SELECT * FROM $pro_mysql_mailaliasgroup_table WHERE autoinc='$id';";
$r = mysql_query($q)or die ("Cannot query $q line: ".__LINE__." file ".__FILE__." sql said:" .mysql_error());
$n = mysql_num_rows($r);
if($n != 1){
die("Cannot find created email line ".__LINE__." file ".__FILE__);
}
$a = mysql_fetch_array($r);
$test_query = "SELECT * FROM $pro_mysql_list_table WHERE name='".$a["id"]."' AND domain='$edit_domain'";
$test_result = mysql_query ($test_query) or die("Cannot execute query \"$test_query\" line ".__LINE__." file ".__FILE__. " sql said ".mysql_error());
$testnum_rows = mysql_num_rows($test_result);
if($testnum_rows >= 1){
$q = "DELETE FROM $pro_mysql_mailaliasgroup_table WHERE autoinc='$id';";
$r = mysql_query($q) or die ("Cannot query $q line: ".__LINE__." file ".__FILE__." sql said:" .mysql_error());
return "<font color=\"red\">Error: Email address already exists with this name!</font><br />";
}
$test_query = "SELECT * FROM $pro_mysql_pop_table WHERE id='".$a["id"]."' AND mbox_host='$edit_domain'";
$test_result = mysql_query ($test_query) or die("Cannot execute query \"$test_query\" line ".__LINE__." file ".__FILE__. " sql said ".mysql_error());
$testnum_rows = mysql_num_rows($test_result);
if($testnum_rows >= 1){
$q = "DELETE FROM $pro_mysql_mailaliasgroup_table WHERE autoinc='$id';";
$r = mysql_query($q) or die ("Cannot query $q line: ".__LINE__." file ".__FILE__." sql said:" .mysql_error());
return "<font color=\"red\">Error: Email address already exists with this name!</font><br />";
}
triggerMXListUpdate();
updateUsingCron("gen_qmail='yes', qmail_newu='yes'");
return "";
}
function emailAliasesDeleteCallback ($id){
global $pro_mysql_mailaliasgroup_table;
triggerMXListUpdate();
updateUsingCron("gen_qmail='yes', qmail_newu='yes'");
$q = "DELETE FROM $pro_mysql_mailaliasgroup_table WHERE autoinc='$id';";
$r = mysql_query($q)or die ("Cannot query $q line: ".__LINE__." file ".__FILE__." sql said:" .mysql_error());
if($r != true ){
die("Cannot find created email line ".__LINE__." file ".__FILE__);
}
triggerMXListUpdate();
updateUsingCron("gen_qmail='yes', qmail_newu='yes'");
return "";
}
?>
|