source: trunk/alternc/patches/class/m_mail_egw.php @ 782

Last change on this file since 782 was 782, checked in by autocommit@…, 8 years ago

cambios majores para que anda con el ultimo alternc, todavia falta, hay una base

File size: 3.3 KB
RevLine 
[35]1<?
2require_once("m_mail.php");
3
4class m_mail_egw extends m_mail {
5
[782]6        function create($dom_id, $mail, $type = "", $dontcheck = false) {
7           if ($this->_add_egw_account($dom_id, $mail, $type = "", $dontcheck = false))
8                        if (parent::create($dom_id,$mail,$type="",$dontcheck=false))
[39]9                                return true;
[35]10                        else
11                                return false;
12                else
13                        return false;
14        }
15
[782]16        function delete($mail_id) {
[58]17       
[782]18                if ($this->_del_egw_account($mail_id) )
19                        if (parent::delete($mail_id))
[58]20                                return true;
21                        else
22                                return false;
23                else
24                        return false;
25        }
26
[782]27        function _add_egw_account($dom_id, $mail, $type = "", $dontcheck = false) {
28        global $err, $db, $quota, $dom, $hooks, $L_EGW_ADMINCLI, $L_EGW_ADMINUSER, $L_EGW_ADMINCLAVE;
29        $res = true;
30                $err->log("mail", "create_egwclass", "$mail $dom_id");
31        $domain = $dom->get_domain_byid($dom_id);
32                $err->log("mail", "create_egwclass", "$mail $domain");
[60]33
[35]34
[782]35        // armamos el commando a executar en el cli de egw
36        $admincli= $L_EGW_ADMINCLI;
37        $command= "--edit-user";              // Command to be performed
38        $adminuser= $L_EGW_ADMINUSER;
39        $adminclave= $L_EGW_ADMINCLAVE;
40        //$adminclave= "*******";
[35]41
[782]42        $firstname = $mail;                     // the left side of the email
43        $lastname= "-";                         // we have a generic lastname
44        $pass= "*****"; //TEMPORARY
45        $email = $account = $mail ."@" .$domain; // account and email are the same
46        $expires= "never";
47        $canchangepw= "yes";
48        $anonuser= "no";
49//      $primarygroup = $domain[$size-3];   // domains in .ar starts at the third level
50        $primarygroup= "cta"; //TEMPORARY
51//      $secondarygroup = $domain[$size-4]; // sub-domain is used as a secondary group
52        $homedir = "/home/". $mail ."_" .$domain; // everyone can have a home   
53        $loginshell = "/bin/bash";                // everyone can have a shell
[35]54
[782]55        $go= $admincli ." " .$command ." " .$adminuser ."," .$adminclave .",\"" .$account ."\"," .$firstname ."," .$lastname ."," .$pass .",\"" .$email ."\"," .$expires ."," .$canchangepw ."," .$anonuser ."," .$primarygroup ;
56       
57        $go= $go ."," .$homedir ."," .$loginshell ;
[199]58
[782]59        echo "<h3>Creamos la cuenta en la base ldap</h3>";
60//      echo "<h4>$go</h4>"; // LA CLAVE SALE... ACA
[199]61
[35]62                        $cod = exec($go);
63                        if ($cod)
64                        {
[199]65                         // die ($cod);
[200]66                         echo "<p class=\"error\">";
67                         echo $cod;
68                         echo "</p>";
[199]69                         //$res = false;
[35]70                        }       
71
[782]72        // mandamos el codigo de error en /var/log/alternc/bureau.log
73        $err->log("mail_egw", "create", $cod);
[58]74
75
[782]76        // para no morir aca...
77        return $res;
[58]78        }       
79
[782]80        function _del_egw_account($mail_id) {
81        global $err, $db, $hooks;
82                $err->log("mail", "delete_egwclass", $mail_id);
83        $res = true;
[60]84
[782]85        // desde el mail_id buscamos el dominio
86        $query="SELECT domaine FROM domaines
87                WHERE id=(SELECT domain_id FROM address where id=\"$mail_id\")";
88        $result_dominio=mysql_query($query);
[60]89
[782]90// print resultados...
91while($row = mysql_fetch_assoc($result_dominio)){
92foreach($row as $cname => $cvalue){print "$cname: $cvalue\t";}
93print "\r\n";
94}
95        // desde el mail_id buscamos la primera parte del mail
96        $query="SELECT address FROM address WHERE id=\"$mail_id\"";
97//      print "$query";
98        $result_mail=mysql_query($query);       
99// print resultados...
100while($row = mysql_fetch_assoc($result_mail)){
101foreach($row as $cname => $cvalue){print "$cname: $cvalue\t";}
102print "\r\n";
103}
[60]104
[782]105        // para no morir aca...
106        return $res;
[60]107        }       
[782]108
[35]109}
110
111?>
Note: See TracBrowser for help on using the repository browser.