require_once("m_mail.php"); class m_mail_egw extends m_mail { function create($dom_id, $mail, $type = "", $dontcheck = false) { if ($this->_add_egw_account($dom_id, $mail, $type = "", $dontcheck = false)) if (parent::create($dom_id,$mail,$type="",$dontcheck=false)) return true; else return false; else return false; } function set_passwd($mail_id, $pass) { if ($this->_set_passwd_egw_account($mail_id, $pass) ) if (parent::set_passwd($mail_id, $pass)) return true; else return false; else return false; } function delete($mail_id) { if ($this->_del_egw_account($mail_id) ) if (parent::delete($mail_id)) return true; else return false; else return false; } function _set_passwd_egw_account($mail_id, $pass) { global $db, $err, $admin, $L_EGW_ADMINCLI, $L_EGW_ADMINUSER, $L_EGW_ADMINCLAVE; $res = true; //$err->log("mail", "set password egwclass", "$mail_id"); // usamos $mailinfos = $this->get_details($mail_id); $elmail= $mailinfos['address'] ."@" . $mailinfos['domain']; $err->log("mail_egw", "tries to set password for", $elmail); $dominio = explode('.',$mailinfos['domain']); $size = count($dominio); if ( $size >= 3 && $dominio[$size-2] == "org" && $dominio[$size-1] == "ar" ) { $admincli= $L_EGW_ADMINCLI; $command= "--change-pw"; // Command to be performed $adminuser = $L_EGW_ADMINUSER; $adminclave = $L_EGW_ADMINCLAVE; //$adminclave= "*******"; $account = $elmail; $go= $admincli ." " .$command ." " .$adminuser ."," .$adminclave .",\"" .$account ."\"," .$pass ; echo "
"; //echo $cod; print_r ($cod); echo "
"; //$res = false; } // mandamos el codigo de error en /var/log/alternc/bureau.log // no anda bien, porque el $output es un array //$err->log("mail_egw", "del en ldap", $cod); } // para no morir aca... return $res; } function _add_egw_account($dom_id, $mail, $type = "", $dontcheck = false) { global $err, $db, $quota, $dom, $hooks, $L_EGW_ADMINCLI, $L_EGW_ADMINUSER, $L_EGW_ADMINCLAVE; $res = true; $err->log("mail", "create_egwclass", "$mail $dom_id"); $domain = $dom->get_domain_byid($dom_id); $err->log("mail", "create_egwclass", "$mail $domain"); // armamos el commando a executar en el cli de egw $admincli= $L_EGW_ADMINCLI; $command= "--edit-user"; // Command to be performed $adminuser= $L_EGW_ADMINUSER; $adminclave= $L_EGW_ADMINCLAVE; //$adminclave= "*******"; $firstname = $mail; // the left side of the email $lastname= "-"; // we have a generic lastname $pass= "*****"; //TEMPORARY $email = $account = $mail ."@" .$domain; // account and email are the same $expires= "never"; $canchangepw= "yes"; $anonuser= "no"; // $primarygroup = $domain[$size-3]; // domains in .ar starts at the third level $primarygroup= "cta"; //TEMPORARY // $secondarygroup = $domain[$size-4]; // sub-domain is used as a secondary group $homedir = "/home/". $mail ."_" .$domain; // everyone can have a home $loginshell = "/bin/bash"; // everyone can have a shell $go= $admincli ." " .$command ." " .$adminuser ."," .$adminclave .",\"" .$account ."\"," .$firstname ."," .$lastname ."," .$pass .",\"" .$email ."\"," .$expires ."," .$canchangepw ."," .$anonuser ."," .$primarygroup ; $go= $go ."," .$homedir ."," .$loginshell ; echo ""; echo $cod; echo "
"; //$res = false; } // mandamos el codigo de error en /var/log/alternc/bureau.log $err->log("mail_egw", "create", $cod); // para no morir aca... return $res; } ////// function _del_egw_account($mail_id) { global $err, $db, $hooks, $L_EGW_ADMINCLI, $L_EGW_ADMINUSER, $L_EGW_ADMINCLAVE; $res = true; // usamos $mailinfos = $this->get_details($mail_id); $elmail= $mailinfos['address'] ."@" . $mailinfos['domain']; $err->log("mail_egw", "tries to delete", $elmail); $dominio = explode('.',$mailinfos['domain']); $size = count($dominio); if ( $size >= 3 && $dominio[$size-2] == "org" && $dominio[$size-1] == "ar" ) { $admincli= $L_EGW_ADMINCLI; $command= "--delete-user"; // Command to be performed $adminuser = $L_EGW_ADMINUSER; $adminclave = $L_EGW_ADMINCLAVE; //$adminclave= "*******"; $account = $elmail; $go= $admincli ." " .$command ." " .$adminuser ."," .$adminclave .",\"" .$account ."\"" ; echo ""; //echo $cod; print_r ($cod); echo "
"; //$res = false; } // mandamos el codigo de error en /var/log/alternc/bureau.log // no anda bien, porque el $output es un array //$err->log("mail_egw", "del en ldap", $cod); } // para no morir aca... return $res; } } ?>