Fix alias deletion
This commit is contained in:
parent
76a18d5bc4
commit
64bc03f33e
|
@ -25,6 +25,15 @@ if (!empty($_POST['account'])) {
|
||||||
print '</form></div>';
|
print '</form></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($_POST['alias'])) {
|
||||||
|
$alias = Html::clean($_POST['alias']);
|
||||||
|
|
||||||
|
print '<div class="container"><form name="del "method="post" action="admin.php?domain='.$domain->getName().'&viewonly=2">';
|
||||||
|
print '<div class="alert alert-warning" role="alert">Voulez vous vraiment supprimer l\'alias '.$alias.' ?</div>';
|
||||||
|
print '<div class="alert alert-warning" role="alert"><button type="submit" name="delalias" value="'.$alias.'">Confirmer</button> / <a href="admin.php?domain='.$domain->getName().'&viewonly=2">Annuler</a></div>';
|
||||||
|
print '</form></div>';
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($_POST['delete'])) {
|
if (!empty($_POST['delete'])) {
|
||||||
$account = Html::clean($_POST['delete']);
|
$account = Html::clean($_POST['delete']);
|
||||||
print '<div class="container">';
|
print '<div class="container">';
|
||||||
|
@ -38,6 +47,19 @@ if (!empty($_POST['delete'])) {
|
||||||
print '</div>';
|
print '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($_POST['delalias'])) {
|
||||||
|
$alias = Html::clean($_POST['delalias']);
|
||||||
|
print '<div class="container">';
|
||||||
|
print '<div class="alert alert-warning" role="alert">Suppression de l\'alias '.$alias.' ...</div>';
|
||||||
|
try {
|
||||||
|
$domain->delAlias($alias);
|
||||||
|
print '<div class="alert alert-success" role="alert">Suppression effectué.</div>';
|
||||||
|
} catch (Exception $e) {
|
||||||
|
print '<div class="alert alert-danger" role="alert">'.$e->getMessage().'</div>';
|
||||||
|
}
|
||||||
|
print '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($_POST['isactive']) && $server->isSuperAdmin()) {
|
if (!empty($_POST['isactive']) && $server->isSuperAdmin()) {
|
||||||
$active = ($_POST['isactive'] == "TRUE") ? true : false;
|
$active = ($_POST['isactive'] == "TRUE") ? true : false;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -145,6 +145,19 @@ class LdapDomain extends LdapServer {
|
||||||
throw new Exception("Ce compte n'existe pas !");
|
throw new Exception("Ce compte n'existe pas !");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function delAlias($name) {
|
||||||
|
$dn = "cn=".$name.",cn=".$this->domain.",".LDAP_BASE;
|
||||||
|
if ($sr = @ldap_search($this->conn, $dn, "(ObjectClass=mailAlias)")) {
|
||||||
|
// Delete alias
|
||||||
|
if (!ldap_delete($this->conn, $dn)) {
|
||||||
|
$error = ldap_error($this->conn);
|
||||||
|
throw new Exception("Erreur dans la suppression de l'alias $name : $error");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Exception("Cet alias n'existe pas !");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function update($active=false) {
|
public function update($active=false) {
|
||||||
$info["isActive"] = ($active) ? 'TRUE' : 'FALSE';
|
$info["isActive"] = ($active) ? 'TRUE' : 'FALSE';
|
||||||
|
|
Loading…
Reference in a new issue