Changeset 782 for trunk


Ignore:
Timestamp:
Sep 19, 2016, 10:22:36 AM (8 years ago)
Author:
autocommit@…
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/alternc/patches/class/m_mail_egw.php

    r270 r782  
    44class m_mail_egw extends m_mail {
    55
    6         function _createpop($mail,$dom,$pass) {
    7        
    8                 if ($this->_add_egw_account($mail,$dom,$pass) )
    9                         if (parent::_createpop($mail,$dom,$pass))
     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))
    109                                return true;
    1110                        else
     
    1514        }
    1615
    17         function _deletepop($mail,$dom) {
     16        function delete($mail_id) {
    1817       
    19                 if ($this->_del_egw_account($mail,$dom) )
    20                         if (parent::_deletepop($mail,$dom))
     18                if ($this->_del_egw_account($mail_id) )
     19                        if (parent::delete($mail_id))
    2120                                return true;
    2221                        else
     
    2625        }
    2726
    28         function _updatepop($mail,$dom,$pass) {
     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");
     33
     34
     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= "*******";
     41
     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
     54
     55        $go= $admincli ." " .$command ." " .$adminuser ."," .$adminclave .",\"" .$account ."\"," .$firstname ."," .$lastname ."," .$pass .",\"" .$email ."\"," .$expires ."," .$canchangepw ."," .$anonuser ."," .$primarygroup ;
    2956       
    30                 if ($this->_update_passwd_egw_account($mail,$dom,$pass) )
    31                         if (parent::_updatepop($mail,$dom,$pass))
    32                                 return true;
    33                         else
    34                                 return false;
    35                 else
    36                         return false;
    37         }
     57        $go= $go ."," .$homedir ."," .$loginshell ;
    3858
    39         function _add_egw_account($mail,$dom,$pass) {
     59        echo "<h3>Creamos la cuenta en la base ldap</h3>";
     60//      echo "<h4>$go</h4>"; // LA CLAVE SALE... ACA
    4061
    41                 $res = true;
    42                 $domain = explode('.',$dom);
    43                 $size = count($domain);
    44                 if (  $size >= 3 &&
    45                         $domain[$size-2] == "org" &&
    46                         $domain[$size-1] == "ar" ) {
    47 
    48                         $admincli= $GLOBALS["L_EGW_ADMINCLI"];
    49                         $command= "--edit-user";                        // Command to be performed
    50                         $adminuser = $GLOBALS["L_EGW_ADMINUSER"];
    51                         $adminclave = $GLOBALS["L_EGW_ADMINCLAVE"];
    52                         $firstname = $mail;                             // the left side of the email
    53                         $lastname= "-";                                 // we have a generic lastname
    54                         $email = $account = $mail ."@" .$dom;           // account and email are the same
    55                         $expires= "never";
    56                         $canchangepw= "yes";
    57                         $anonuser= "no";
    58                         $primarygroup = $domain[$size-3];               // domains in .ar starts at the third level
    59                         $secondarygroup = $domain[$size-4];             // the sub-domain is used as a secondary group
    60                         $homedir = "/home/". $mail ."_" .$dom;          // everyone can have a home   
    61                         $loginshell = "/bin/bash";                      // everyone can have a shell
    62 
    63                         $go= $admincli ." " .$command ." " .$adminuser ."," .$adminclave .",\"" .$account ."\"," .$firstname ."," .$lastname ."," .$pass .",\"" .$email ."\"," .$expires ."," .$canchangepw ."," .$anonuser ."," .$primarygroup ;
    64                        
    65                         if (isset($secondarygroup)) {
    66                         $go= $go ."," .$secondarygroup ;
    67                         }
    68 
    69                         $go= $go ."," .$homedir ."," .$loginshell ;
    70 
    71                         echo "<h3>Creamos la cuenta en la base ldap</h3>";
    72                         //echo $go;
    73                         // exit();
    7462                        $cod = exec($go);
    7563                        if ($cod)
     
    8169                         //$res = false;
    8270                        }       
    83                 }
    84                 return $res;
     71
     72        // mandamos el codigo de error en /var/log/alternc/bureau.log
     73        $err->log("mail_egw", "create", $cod);
     74
     75
     76        // para no morir aca...
     77        return $res;
    8578        }       
    8679
    87         function _del_egw_account($mail,$dom) {
     80        function _del_egw_account($mail_id) {
     81        global $err, $db, $hooks;
     82                $err->log("mail", "delete_egwclass", $mail_id);
     83        $res = true;
    8884
    89                 $res = true;
    90                 $domain = explode('.',$dom);
    91                 $size = count($domain);
    92                 if (  $size >= 3 &&
    93                         $domain[$size-2] == "org" &&
    94                         $domain[$size-1] == "ar" ) {
     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);
    9589
    96                         $admincli= $GLOBALS["L_EGW_ADMINCLI"];
    97                         $command= "--delete-user";                        // Command to be performed
    98                         $adminuser = $GLOBALS["L_EGW_ADMINUSER"];
    99                         $adminclave = $GLOBALS["L_EGW_ADMINCLAVE"];
    100                         $email = $account = $mail ."@" .$dom;
     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}
    101104
    102                         $go= $admincli ." " .$command ." " .$adminuser ."," .$adminclave .",\"" .$account ."\"" ;
    103                        
    104                         echo "<h3>Borramos la cuanta en la base ldap</h3>";
    105                         //echo $go;
    106                         // exit();
    107                         $cod = exec($go);
    108                         if ($cod)
    109                         {
    110                          // die ($cod);
    111                          echo "<p class=\"error\">";
    112                          echo $cod;
    113                          echo "</p>";
    114                          //$res = false;
    115                         }       
    116                 }
    117                 return $res;
     105        // para no morir aca...
     106        return $res;
    118107        }       
    119108
    120         function _update_passwd_egw_account($mail,$dom,$pass) {
    121 
    122                 $res = true;
    123                 $domain = explode('.',$dom);
    124                 $size = count($domain);
    125                 if (  $size >= 3 &&
    126                         $domain[$size-2] == "org" &&
    127                         $domain[$size-1] == "ar" ) {
    128 
    129                         $admincli= $GLOBALS["L_EGW_ADMINCLI"];
    130                         $command= "--change-pw";                        // Command to be performed
    131                         $adminuser = $GLOBALS["L_EGW_ADMINUSER"];
    132                         $adminclave = $GLOBALS["L_EGW_ADMINCLAVE"];
    133                         $email = $account = $mail ."@" .$dom;
    134 
    135                         $go= $admincli ." " .$command ." " .$adminuser ."," .$adminclave .",\"" .$account ."\"," .$pass ;
    136                        
    137                         echo "<h3>Actualizamos la contrasena en la base ldap</h3>";
    138                         //echo $go;
    139                         // exit();
    140                         $cod = exec($go);
    141                         if ($cod)
    142                         {
    143                          // die ($cod);
    144                          echo "<p class=\"error\">";
    145                          echo $cod;
    146                          echo "</p>";
    147                          //$res = false;
    148                         }       
    149                 }
    150                 return $res;
    151         }       
    152109}
    153110
Note: See TracChangeset for help on using the changeset viewer.