diff --git a/htdocs/admin.php b/htdocs/admin.php
index 574c35b..f2dfd7b 100644
--- a/htdocs/admin.php
+++ b/htdocs/admin.php
@@ -84,7 +84,6 @@ if (!empty($_POST['isactive']) && $server->isSuperAdmin()) {
-
";
} elseif ( (isset($_GET['viewonly'])) && ($_GET['viewonly']==2) ) {
?>
- Liste des alias/groupe de diffusion :
+ Liste des alias/groupe de diffusion :
+ ";
}
?>
-
-
diff --git a/htdocs/lib/auth.php b/htdocs/lib/auth.php
index f48a5ac..86a55b6 100644
--- a/htdocs/lib/auth.php
+++ b/htdocs/lib/auth.php
@@ -14,6 +14,9 @@ if (empty($_SESSION['login'])) {
if (!empty($_GET['account'])) {
$account = new LdapAccount($domain, Html::clean($_GET['account']));
}
+ if (!empty($_GET['alias'])) {
+ $alias = new LdapAlias($domain, Html::clean($_GET['alias']));
+ }
}
} catch (Exception $e) {
print ''.$e->getMessage().'
';
diff --git a/htdocs/lib/class.ldapalias.php b/htdocs/lib/class.ldapalias.php
new file mode 100644
index 0000000..55bfd43
--- /dev/null
+++ b/htdocs/lib/class.ldapalias.php
@@ -0,0 +1,42 @@
+conn = $domain->conn;
+ $this->domain = $domain->getName();
+
+ $this->name = $name;
+ if ($sr = @ldap_search($this->conn, "cn=".$name.",cn=".$this->domain.",".LDAP_BASE, "(ObjectClass=mailAlias)")) {
+ $objects = ldap_get_entries($this->conn, $sr);
+ $object = $objects[0];
+ $this->active = ($object['isactive'][0] == 'TRUE') ? true : false;
+ $this->aliases = array_filter($object['mailacceptinggeneralid'], "is_string");
+ $this->redirections = array_filter($object['maildrop'], "is_string");
+ } else {
+ throw new Exception("Cet alias n'existe pas !");
+ }
+ }
+
+ public function isActive() {
+ return $this->active;
+ }
+
+ public function getName() {
+ return $this->name;
+ }
+
+ public function getAliases() {
+ return preg_replace('/@'.$this->domain.'/', '', $this->aliases);
+ }
+
+ public function getRedirections() {
+ return $this->redirections;
+ }
+
+ public function __destruct() {
+ return true;
+ }
+}
diff --git a/htdocs/lib/class.ldapdomain.php b/htdocs/lib/class.ldapdomain.php
index ae9bafa..799e2b5 100644
--- a/htdocs/lib/class.ldapdomain.php
+++ b/htdocs/lib/class.ldapdomain.php
@@ -63,14 +63,17 @@ class LdapDomain extends LdapServer {
global $conf;
if (count($this->alias) == 0) {
if (! $conf['domaines']['onlyone']) {
- $rdn = ($conf['evoadmin']['version'] <= 2) ? "cn=" .$this->domain. "," .LDAP_BASE : "domain=" .$this->domain. "," .LDAP_BASE;
+ $rdn = ($conf['evoadmin']['version'] > 2) ? "cn=" .$this->domain. "," .LDAP_BASE : "domain=" .$this->domain. "," .LDAP_BASE;
} else {
$rdn = "ou=people," .LDAP_BASE;
}
$sr = ldap_search($this->conn, $rdn, "(objectClass=mailAlias)");
- $info = ldap_get_entries($this->conn, $sr);
- for ($i=0;$i<$info["count"];$i++) {
- array_push($this->alias,$info[$i]["cn"][0]);
+ $objects = ldap_get_entries($this->conn, $sr);
+ foreach($objects as $object) {
+ if(!empty($object["cn"][0])) {
+ $alias = new LdapAlias($this, $object["cn"][0]);
+ array_push($this->alias, $alias);
+ }
}
}
return $this->alias;
@@ -115,6 +118,21 @@ class LdapDomain extends LdapServer {
}
}
+ public function addAlias($name,$active=false,$mailaccept=array(),$maildrop=array()) {
+ $info["cn"] = $name;
+ $info["isActive"] = ($active) ? 'TRUE' : 'FALSE';
+ $info["objectclass"][0] = "mailAlias";
+ $info["mailacceptinggeneralid"] = $mailaccept;
+ $info["maildrop"] = array_filter($maildrop, function($value) {
+ return filter_var($value, FILTER_VALIDATE_EMAIL);
+ });
+
+ if (!@ldap_add($this->conn, "cn=".$name.",cn=".$this->domain.",".LDAP_BASE, $info)) {
+ $error = ldap_error($this->conn);
+ throw new Exception("Erreur dans l'ajout de l'alias : $error");
+ }
+ }
+
public function delAccount($uid) {
$dn = "uid=".$uid.",cn=".$this->domain.",".LDAP_BASE;
if ($sr = @ldap_search($this->conn, $dn, "(ObjectClass=mailAccount)")) {