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

Last change on this file since 199 was 199, checked in by sebas, 15 years ago

agregamos los parametros para el /home/ y login shell

File size: 4.1 KB
Line 
1<?
2require_once("m_mail.php");
3
4class m_mail_egw extends m_mail {
5
6        function _createpop($mail,$dom,$pass) {
7       
8                if ($this->_add_egw_account($mail,$dom,$pass) )
9                        if (parent::_createpop($mail,$dom,$pass))
10                                return true;
11                        else
12                                return false;
13                else
14                        return false;
15        }
16
17        function _deletepop($mail,$dom) {
18       
19                if ($this->_del_egw_account($mail,$dom) )
20                        if (parent::_deletepop($mail,$dom))
21                                return true;
22                        else
23                                return false;
24                else
25                        return false;
26        }
27
28        function _updatepop($mail,$dom,$pass) {
29       
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        }
38
39        function _add_egw_account($mail,$dom,$pass) {
40
41                $res = true;
42                $domain = explode('.',$dom);
43                $size = count($domain);
44                if (  $size >= 3 && 
45                        $domain[$size-3] == "cta" &&
46                        $domain[$size-2] == "org" &&
47                        $domain[$size-1] == "ar" ) {
48
49                        $admincli= $GLOBALS["L_EGW_ADMINCLI"];
50                        $command= "--edit-user";                        // Command to be performed
51                        $adminuser = $GLOBALS["L_EGW_ADMINUSER"];
52                        $adminclave = $GLOBALS["L_EGW_ADMINCLAVE"];
53                        // $account - we use the email address which is extracted from the DB
54                        // $firstname - we use the left side of the email adress, which will be extracted from the database
55                        $lastname= "-";                                 // we have a generic lastname
56                        // $passwd will be generated with some magic
57                        // $email you know that, from the db
58                        $expires= "never";
59                        $canchangepw= "yes";
60                        $anonuser= "no";
61                        $primarygroup = $domain[$size-3];
62                        $secondarygroup = join(',', array_slice($domain,0,-3));
63                        $lastname = "-";
64                        $firstname = $mail;
65                        $email = $account = $mail ."@" .$dom;
66                        $homedir = "/home/". $mail ."_" .$dom;
67                        $loginshell = "/bin/bash";
68
69                        $go= $admincli ." " .$command ." " .$adminuser ."," .$adminclave .",\"" .$account ."\"," .$firstname ."," .$lastname ."," .$pass .",\"" .$email ."\"," .$expires ."," .$canchangepw ."," .$anonuser ."," .$primarygroup ;
70                       
71                        //if (isset($secondarygroup)) {
72                        //$go= $go ."," .$secondarygroup ;
73                        //}
74
75                        $go= $go ."," .$homedir ."," .$loginshell ;
76
77                        echo "Usuario creado en el Intranet <br>";
78                        //echo $go;
79                        // exit();
80                        $cod = exec($go);
81                        if ($cod)
82                        {
83                         // die ($cod);
84                         echo $cod;
85                         //$res = false;
86                        }       
87                }
88                return $res;
89        }       
90
91        function _del_egw_account($mail,$dom) {
92
93                $res = true;
94                $domain = explode('.',$dom);
95                $size = count($domain);
96                if (  $size >= 3 && 
97                        $domain[$size-3] == "cta" &&
98                        $domain[$size-2] == "org" &&
99                        $domain[$size-1] == "ar" ) {
100
101                        $admincli= $GLOBALS["L_EGW_ADMINCLI"];
102                        $command= "--delete-user";                        // Command to be performed
103                        $adminuser = $GLOBALS["L_EGW_ADMINUSER"];
104                        $adminclave = $GLOBALS["L_EGW_ADMINCLAVE"];
105                        // $account - we use the email address which is extracted from the DB
106                        $email = $account = $mail ."@" .$dom;
107
108                        $go= $admincli ." " .$command ." " .$adminuser ."," .$adminclave .",\"" .$account ."\"" ;
109                       
110                        echo "Borre el usuario en el intranet tambien<br>";
111                        echo $go;
112                        // exit();
113                        $cod = exec($go);
114                        if ($cod)
115                        {
116                         // die ($cod);
117                         echo $cod;
118                         //$res = false;
119                        }       
120                }
121                return $res;
122        }       
123
124        function _update_passwd_egw_account($mail,$dom,$pass) {
125
126                $res = true;
127                $domain = explode('.',$dom);
128                $size = count($domain);
129                if (  $size >= 3 && 
130                        $domain[$size-3] == "cta" &&
131                        $domain[$size-2] == "org" &&
132                        $domain[$size-1] == "ar" ) {
133
134                        $admincli= $GLOBALS["L_EGW_ADMINCLI"];
135                        $command= "--edit-user";                        // Command to be performed
136                        $adminuser = $GLOBALS["L_EGW_ADMINUSER"];
137                        $adminclave = $GLOBALS["L_EGW_ADMINCLAVE"];
138                        $email = $account = $mail ."@" .$dom;
139
140                        $go= $admincli ." " .$command ." " .$adminuser ."," .$adminclave .",\"" .$account ."\",,," .$pass ;
141                       
142                        echo "Actualize la clave del usuario en la base ldap"; 
143                        // exit();
144                        $cod = exec($go);
145                        if ($cod)
146                        {
147                         // die ($cod);
148                         echo $cod;
149                         //$res = false;
150                        }       
151                }
152                return $res;
153        }       
154}
155
156?>
Note: See TracBrowser for help on using the repository browser.