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

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

funciona

File size: 3.2 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 _add_egw_account($mail,$dom,$pass) {
55
56                $res = true;
57                $domain = explode('.',$dom);
58                $size = count($domain);
59                if (  $size >= 3 && 
60                        $domain[$size-3] == "cta" &&
61                        $domain[$size-2] == "org" &&
62                        $domain[$size-1] == "ar" ) {
63
64                        $admincli= "/var/alternc/html/i/intranet/intranet.redcta.org.ar/wwws/stable/admin/admin-cli.php";
65                        $command= "--edit-user";                        // Command to be performed
66                       $adminuser = $GLOBALS["L_ADMINUSER_EGW"];
67                       $adminclave = $GLOBALS["L_ADMINCLAVE_EGW"];
68                        // $account - we use the email address which is extracted from the DB
69                        // $firstname - we use the left side of the email adress, which will be extracted from the database
70                        $lastname= "-";                                 // we have a generic lastname
71                        // $passwd will be generated with some magic
72                        // $email you know that, from the db
73                        $expires= "never";
74                        $canchangepw= "yes";
75                        $anonuser= "no";
76                        $primarygroup = $domain[$size-3];
77                        $secundarygroup = join(',', array_slice($domain,0,-3));
78                        $lastname = "-";
79                        $firstname = $mail;
80                        $email = $account = $mail ."@" .$dom;
81
82                        $go= $admincli ." " .$command ." " .$adminuser ."," .$adminclave .",\"" .$account ."\"," .$firstname ."," .$lastname ."," .$pass .",\"" .$email ."\"," .$expires ."," .$canchangepw ."," .$anonuser ."," .$primarygroup ;
83                       
84                        if (isset($secondarygroup)) {
85                        $go= $go ."," .$secondarygroup;
86                        }
87                        echo ($go);     
88                        // exit();
89                        $cod = exec($go);
90                        if ($cod)
91                        {
92                        die ($cod);
93                                $res = false;
94                        }       
95                }
96                return $res;
97
98        }       
99
100}
101
102
103
104?>
Note: See TracBrowser for help on using the repository browser.