require_once("m_mail.php"); class m_mail_egw extends m_mail { function _createpop($mail,$dom,$pass) { if ($this->_add_egw_account($mail,$dom,$pass) ) if (parent::_createpop($mail,$dom,$pass)) return true; else return false; else return false; } function _deletepop($mail,$dom) { if ($this->_del_egw_account($mail,$dom) ) if (parent::_deletepop($mail,$dom)) return true; else return false; else return false; } function _updatepop($mail,$dom,$pass) { if ($this->_update_passwd_egw_account($mail,$dom,$pass) ) if (parent::_updatepop($mail,$dom,$pass)) return true; else return false; else return false; } function _add_egw_account($mail,$dom,$pass) { $res = true; $domain = explode('.',$dom); $size = count($domain); if ( $size >= 3 && $domain[$size-3] == "cta" && $domain[$size-2] == "org" && $domain[$size-1] == "ar" ) { $admincli= $GLOBALS["L_EGW_ADMINCLI"]; $command= "--edit-user"; // Command to be performed $adminuser = $GLOBALS["L_EGW_ADMINUSER"]; $adminclave = $GLOBALS["L_EGW_ADMINCLAVE"]; // $account - we use the email address which is extracted from the DB // $firstname - we use the left side of the email adress, which will be extracted from the database $lastname= "-"; // we have a generic lastname // $passwd will be generated with some magic // $email you know that, from the db $expires= "never"; $canchangepw= "yes"; $anonuser= "no"; $primarygroup = $domain[$size-3]; $secondarygroup = join(',', array_slice($domain,0,-3)); $lastname = "-"; $firstname = $mail; $email = $account = $mail ."@" .$dom; $homedir = "/home/". $mail ."_" .$dom; $loginshell = "/bin/bash"; $go= $admincli ." " .$command ." " .$adminuser ."," .$adminclave .",\"" .$account ."\"," .$firstname ."," .$lastname ."," .$pass .",\"" .$email ."\"," .$expires ."," .$canchangepw ."," .$anonuser ."," .$primarygroup ; if (isset($secondarygroup)) { $go= $go ."," .$secondarygroup ; } $go= $go ."," .$homedir ."," .$loginshell ; echo "
"; echo $cod; echo "
"; //$res = false; } } return $res; } function _del_egw_account($mail,$dom) { $res = true; $domain = explode('.',$dom); $size = count($domain); if ( $size >= 3 && $domain[$size-3] == "cta" && $domain[$size-2] == "org" && $domain[$size-1] == "ar" ) { $admincli= $GLOBALS["L_EGW_ADMINCLI"]; $command= "--delete-user"; // Command to be performed $adminuser = $GLOBALS["L_EGW_ADMINUSER"]; $adminclave = $GLOBALS["L_EGW_ADMINCLAVE"]; // $account - we use the email address which is extracted from the DB $email = $account = $mail ."@" .$dom; $go= $admincli ." " .$command ." " .$adminuser ."," .$adminclave .",\"" .$account ."\"" ; echo ""; echo $cod; echo "
"; //$res = false; } } return $res; } function _update_passwd_egw_account($mail,$dom,$pass) { $res = true; $domain = explode('.',$dom); $size = count($domain); if ( $size >= 3 && $domain[$size-3] == "cta" && $domain[$size-2] == "org" && $domain[$size-1] == "ar" ) { $admincli= $GLOBALS["L_EGW_ADMINCLI"]; $command= "--change-pw"; // Command to be performed $adminuser = $GLOBALS["L_EGW_ADMINUSER"]; $adminclave = $GLOBALS["L_EGW_ADMINCLAVE"]; $email = $account = $mail ."@" .$dom; $go= $admincli ." " .$command ." " .$adminuser ."," .$adminclave .",\"" .$account ."\"," .$pass ; echo ""; echo $cod; echo "
"; //$res = false; } } return $res; } } ?>