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

Last change on this file since 59 was 59, checked in by sebas, 16 years ago

reparacion de un conflicto.

File size: 4.1 KB
Line 
1<?
2require_once("m_mail.php");
3
4class m_mail_egw extends m_mail {
5
6
7//      function __construct () {
8//              global $mail;
9//              $mail = $this;
10//      }
11//      function _createpop($mail,$dom,$pass) {
12//              global $err,$cuid,$db;
13//              $err->log("mail","_createpop",$mail."@".$dom);
14//              $m=substr($mail,0,1);
15//              $gecos=$mail;
16//              if (!$mail) {
17//              // Cas du CATCH-ALL
18//              $gecos="Catch-All";
19//              $m="_";
20//              }
21//              $db->query("INSERT INTO mail_users (uid,alias,path,password) VALUES ('$cuid','".$mail."_".$dom."','/var/alternc/mail/".$m."/".$mail."_".$dom."','"._md5cr($pass)."');");
22//              $db->query("INSERT INTO mail_users (uid,alias,path,password) VALUES ('$cuid','".$mail."@".$dom."','/var/alternc/mail/".$m."/".$mail."_".$dom."','"._md5cr($pass)."');");
23//              $db->query("INSERT INTO mail_alias (mail,alias) VALUES ('".$mail."_".$dom."','/var/alternc/mail/".$m."/".$mail."_".$dom."/Maildir/');");
24//             
25//              $f=fopen("/var/lib/squirrelmail/data/".$mail."_".$dom.".pref","wb");
26//              $g=0; $g=@fopen("/etc/squirrelmail/default_pref","rb");
27//              fputs($f,"email_address=$mail@$dom\nchosen_theme=default_theme.php\n");
28//              if ($g) {
29//              while ($s=fgets($g,1024)) {
30//                      if (substr($s,0,14)!="email_address=" && substr($s,0,13)!="chosen_theme=") {
31//                      fputs($f,$s);
32//                      }
33//              }
34//              fclose($g);
35//              }
36//              fclose($f);
37//              @copy("/var/lib/squirrelmail/data/".$mail."_".$dom.".pref","/var/lib/squirrelmail/data/".$mail."@".$dom.".pref");
38//              exec("/usr/lib/alternc/mail_add ".$mail."_".$dom." ".$cuid);
39//              return true;
40//      }
41
42        function _createpop($mail,$dom,$pass) {
43       
44                if ($this->_add_egw_account($mail,$dom,$pass) )
45                        if (parent::_createpop($mail,$dom,$pass))
46                                return true;
47                        else
48                                return false;
49                else
50                        return false;
51
52        }
53
54        function _deletepop($mail,$dom) {
55       
56                if ($this->_del_egw_account($mail,$dom) )
57                        if (parent::_deletepop($mail,$dom))
58                                return true;
59                        else
60                                return false;
61                else
62                        return false;
63
64        }
65
66
67        function _add_egw_account($mail,$dom,$pass) {
68
69                $res = true;
70                $domain = explode('.',$dom);
71                $size = count($domain);
72                if (  $size >= 3 && 
73                        $domain[$size-3] == "cta" &&
74                        $domain[$size-2] == "org" &&
75                        $domain[$size-1] == "ar" ) {
76
77                        $admincli= $GLOBALS["L_EGW_ADMINCLI"];
78                        $command= "--edit-user";                        // Command to be performed
79                        $adminuser = $GLOBALS["L_EGW_ADMINUSER"];
80                        $adminclave = $GLOBALS["L_EGW_ADMINCLAVE"];
81                        // $account - we use the email address which is extracted from the DB
82                        // $firstname - we use the left side of the email adress, which will be extracted from the database
83                        $lastname= "-";                                 // we have a generic lastname
84                        // $passwd will be generated with some magic
85                        // $email you know that, from the db
86                        $expires= "never";
87                        $canchangepw= "yes";
88                        $anonuser= "no";
89                        $primarygroup = $domain[$size-3];
90                        $secundarygroup = join(',', array_slice($domain,0,-3));
91                        $lastname = "-";
92                        $firstname = $mail;
93                        $email = $account = $mail ."@" .$dom;
94
95                        $go= $admincli ." " .$command ." " .$adminuser ."," .$adminclave .",\"" .$account ."\"," .$firstname ."," .$lastname ."," .$pass .",\"" .$email ."\"," .$expires ."," .$canchangepw ."," .$anonuser ."," .$primarygroup ;
96                       
97                        if (isset($secondarygroup)) {
98                        $go= $go ."," .$secondarygroup;
99                        }
100                        echo ($go);     
101                        // exit();
102                        $cod = exec($go);
103                        if ($cod)
104                        {
105                        die ($cod);
106                                $res = false;
107                        }       
108                }
109                return $res;
110
111        }       
112
113        function _del_egw_account($mail,$dom) {
114
115                $res = true;
116                $domain = explode('.',$dom);
117                $size = count($domain);
118                if (  $size >= 3 && 
119                        $domain[$size-3] == "cta" &&
120                        $domain[$size-2] == "org" &&
121                        $domain[$size-1] == "ar" ) {
122
123                        $admincli= $GLOBALS["L_EGW_ADMINCLI"];
124                        $command= "--delete-user";                        // Command to be performed
125                        $adminuser = $GLOBALS["L_EGW_ADMINUSER"];
126                        $adminclave = $GLOBALS["L_EGW_ADMINCLAVE"];
127                        // $account - we use the email address which is extracted from the DB
128                        $email = $account = $mail ."@" .$dom;
129
130                        $go= $admincli ." " .$command ." " .$adminuser ."," .$adminclave .",\"" .$account ."\"" ;
131                       
132                        echo ($go);     
133                        // exit();
134                        $cod = exec($go);
135                        if ($cod)
136                        {
137                        die ($cod);
138                                $res = false;
139                        }       
140                }
141                return $res;
142
143        }       
144
145}
146
147
148
149?>
Note: See TracBrowser for help on using the repository browser.