1 | <? |
---|
2 | require_once("m_mail.php"); |
---|
3 | |
---|
4 | class 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 "<h3>Creamos la cuenta en la base ldap</h3>"; |
---|
78 | //echo $go; |
---|
79 | // exit(); |
---|
80 | $cod = exec($go); |
---|
81 | if ($cod) |
---|
82 | { |
---|
83 | // die ($cod); |
---|
84 | echo "<p class=\"error\">"; |
---|
85 | echo $cod; |
---|
86 | echo "</p>"; |
---|
87 | //$res = false; |
---|
88 | } |
---|
89 | } |
---|
90 | return $res; |
---|
91 | } |
---|
92 | |
---|
93 | function _del_egw_account($mail,$dom) { |
---|
94 | |
---|
95 | $res = true; |
---|
96 | $domain = explode('.',$dom); |
---|
97 | $size = count($domain); |
---|
98 | if ( $size >= 3 && |
---|
99 | $domain[$size-3] == "cta" && |
---|
100 | $domain[$size-2] == "org" && |
---|
101 | $domain[$size-1] == "ar" ) { |
---|
102 | |
---|
103 | $admincli= $GLOBALS["L_EGW_ADMINCLI"]; |
---|
104 | $command= "--delete-user"; // Command to be performed |
---|
105 | $adminuser = $GLOBALS["L_EGW_ADMINUSER"]; |
---|
106 | $adminclave = $GLOBALS["L_EGW_ADMINCLAVE"]; |
---|
107 | // $account - we use the email address which is extracted from the DB |
---|
108 | $email = $account = $mail ."@" .$dom; |
---|
109 | |
---|
110 | $go= $admincli ." " .$command ." " .$adminuser ."," .$adminclave .",\"" .$account ."\"" ; |
---|
111 | |
---|
112 | echo "<h3>Borramos la cuanta en la base ldap</h3>"; |
---|
113 | //echo $go; |
---|
114 | // exit(); |
---|
115 | $cod = exec($go); |
---|
116 | if ($cod) |
---|
117 | { |
---|
118 | // die ($cod); |
---|
119 | echo "<p class=\"error\">"; |
---|
120 | echo $cod; |
---|
121 | echo "</p>"; |
---|
122 | //$res = false; |
---|
123 | } |
---|
124 | } |
---|
125 | return $res; |
---|
126 | } |
---|
127 | |
---|
128 | function _update_passwd_egw_account($mail,$dom,$pass) { |
---|
129 | |
---|
130 | $res = true; |
---|
131 | $domain = explode('.',$dom); |
---|
132 | $size = count($domain); |
---|
133 | if ( $size >= 3 && |
---|
134 | $domain[$size-3] == "cta" && |
---|
135 | $domain[$size-2] == "org" && |
---|
136 | $domain[$size-1] == "ar" ) { |
---|
137 | |
---|
138 | $admincli= $GLOBALS["L_EGW_ADMINCLI"]; |
---|
139 | $command= "--change-pw"; // Command to be performed |
---|
140 | $adminuser = $GLOBALS["L_EGW_ADMINUSER"]; |
---|
141 | $adminclave = $GLOBALS["L_EGW_ADMINCLAVE"]; |
---|
142 | $email = $account = $mail ."@" .$dom; |
---|
143 | |
---|
144 | $go= $admincli ." " .$command ." " .$adminuser ."," .$adminclave .",\"" .$account ."\"," .$pass ; |
---|
145 | |
---|
146 | echo "<h3>Actualizamos la contrasena en la base ldap</h3>"; |
---|
147 | //echo $go; |
---|
148 | // exit(); |
---|
149 | $cod = exec($go); |
---|
150 | if ($cod) |
---|
151 | { |
---|
152 | // die ($cod); |
---|
153 | echo "<p class=\"error\">"; |
---|
154 | echo $cod; |
---|
155 | echo "</p>"; |
---|
156 | //$res = false; |
---|
157 | } |
---|
158 | } |
---|
159 | return $res; |
---|
160 | } |
---|
161 | } |
---|
162 | |
---|
163 | ?> |
---|