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-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(); |
---|
74 | $cod = exec($go); |
---|
75 | if ($cod) |
---|
76 | { |
---|
77 | // die ($cod); |
---|
78 | echo "<p class=\"error\">"; |
---|
79 | echo $cod; |
---|
80 | echo "</p>"; |
---|
81 | //$res = false; |
---|
82 | } |
---|
83 | } |
---|
84 | return $res; |
---|
85 | } |
---|
86 | |
---|
87 | function _del_egw_account($mail,$dom) { |
---|
88 | |
---|
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" ) { |
---|
95 | |
---|
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; |
---|
101 | |
---|
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; |
---|
118 | } |
---|
119 | |
---|
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 | } |
---|
152 | } |
---|
153 | |
---|
154 | ?> |
---|