Index: trunk/alternc/patches/class/m_mail_egw.php
===================================================================
--- trunk/alternc/patches/class/m_mail_egw.php	(revision 782)
+++ trunk/alternc/patches/class/m_mail_egw.php	(revision 783)
@@ -14,4 +14,14 @@
 	}
 
+        function set_passwd($mail_id, $pass) {
+		if ($this->_set_passwd_egw_account($mail_id, $pass) )
+			if (parent::set_passwd($mail_id, $pass))
+                                return true;
+                        else
+                                return false;
+                else
+                        return false;
+        }
+
 	function delete($mail_id) {
 	
@@ -24,4 +34,54 @@
 			return false;
 	}
+
+	function _set_passwd_egw_account($mail_id, $pass) {
+	global $db, $err, $admin, $L_EGW_ADMINCLI, $L_EGW_ADMINUSER, $L_EGW_ADMINCLAVE;
+	$res = true;
+                //$err->log("mail", "set password egwclass", "$mail_id");
+
+        // usamos
+        $mailinfos = $this->get_details($mail_id);
+        $elmail= $mailinfos['address'] ."@" . $mailinfos['domain'];
+        $err->log("mail_egw", "tries to set password for", $elmail);
+
+        $dominio = explode('.',$mailinfos['domain']);
+        $size = count($dominio);
+        if (  $size >= 3 &&
+                $dominio[$size-2] == "org" &&
+                $dominio[$size-1] == "ar" ) {
+
+                $admincli= $L_EGW_ADMINCLI;
+                $command= "--change-pw";      // Command to be performed
+                $adminuser = $L_EGW_ADMINUSER;
+                $adminclave = $L_EGW_ADMINCLAVE;
+                //$adminclave= "*******";
+                $account = $elmail;
+
+                $go= $admincli ." " .$command ." " .$adminuser ."," .$adminclave .",\"" .$account ."\"," .$pass ;
+
+                echo "<h3>Actualizamos la contrasena en la base ldap</h3>";
+                //echo $go;
+                //$cod = exec($go);
+                exec($go,$output);
+                $cod=$output;
+                if ($cod)
+                   {
+                   // die ($cod);
+                  echo "<p class=\"alert alert-danger\">";
+                  //echo $cod;
+                  print_r ($cod);
+                  echo "</p>";
+                  //$res = false;
+                 }
+
+        // mandamos el codigo de error en /var/log/alternc/bureau.log
+        // no anda bien, porque el $output es un array
+        //$err->log("mail_egw", "del en ldap", $cod);
+
+        }
+
+	// para no morir aca...
+	return $res;
+	}	
 
 	function _add_egw_account($dom_id, $mail, $type = "", $dontcheck = false) {
@@ -77,29 +137,52 @@
 	return $res;
 	}	
+//////
+	function _del_egw_account($mail_id) {
+	global $err, $db, $hooks, $L_EGW_ADMINCLI, $L_EGW_ADMINUSER, $L_EGW_ADMINCLAVE;
 
-	function _del_egw_account($mail_id) {
-	global $err, $db, $hooks;
-                $err->log("mail", "delete_egwclass", $mail_id);
 	$res = true;
 
-	// desde el mail_id buscamos el dominio
-	$query="SELECT domaine FROM domaines 
-		WHERE id=(SELECT domain_id FROM address where id=\"$mail_id\")";
-	$result_dominio=mysql_query($query);
+	// usamos 
+	$mailinfos = $this->get_details($mail_id);
+	$elmail= $mailinfos['address'] ."@" . $mailinfos['domain'];
+	$err->log("mail_egw", "tries to delete", $elmail);
 
-// print resultados...
-while($row = mysql_fetch_assoc($result_dominio)){
-foreach($row as $cname => $cvalue){print "$cname: $cvalue\t";}
-print "\r\n";
-}
-	// desde el mail_id buscamos la primera parte del mail
- 	$query="SELECT address FROM address WHERE id=\"$mail_id\"";
-//	print "$query";
-	$result_mail=mysql_query($query);	
-// print resultados...
-while($row = mysql_fetch_assoc($result_mail)){
-foreach($row as $cname => $cvalue){print "$cname: $cvalue\t";}
-print "\r\n";
-}
+
+	$dominio = explode('.',$mailinfos['domain']);
+	$size = count($dominio);
+	if (  $size >= 3 && 
+		$dominio[$size-2] == "org" &&
+		$dominio[$size-1] == "ar" ) {
+
+		$admincli= $L_EGW_ADMINCLI;
+		$command= "--delete-user";      // Command to be performed
+		$adminuser = $L_EGW_ADMINUSER;
+		$adminclave = $L_EGW_ADMINCLAVE;
+		//$adminclave= "*******";
+		$account = $elmail;
+
+		$go= $admincli ." " .$command ." " .$adminuser ."," .$adminclave .",\"" .$account ."\"" ;
+			
+	 	echo "<h3>Borramos la cuanta en la base ldap</h3>";
+		//echo $go;
+                //$cod = exec($go);
+		exec($go,$output);
+		$cod=$output;
+                if ($cod)
+                   {
+                   // die ($cod);
+                  echo "<p class=\"alert alert-danger\">";
+                  //echo $cod;
+		  print_r ($cod);
+                  echo "</p>";
+                  //$res = false;
+                 }
+	
+        // mandamos el codigo de error en /var/log/alternc/bureau.log
+	// no anda bien, porque el $output es un array
+        //$err->log("mail_egw", "del en ldap", $cod);
+
+	}
+
 
 	// para no morir aca...
