[35] | 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) ) |
---|
[39] | 9 | if (parent::_createpop($mail,$dom,$pass)) |
---|
| 10 | return true; |
---|
[35] | 11 | else |
---|
| 12 | return false; |
---|
| 13 | else |
---|
| 14 | return false; |
---|
| 15 | } |
---|
| 16 | |
---|
[58] | 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 | |
---|
[60] | 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 | |
---|
[35] | 39 | function _add_egw_account($mail,$dom,$pass) { |
---|
| 40 | |
---|
| 41 | $res = true; |
---|
[39] | 42 | $domain = explode('.',$dom); |
---|
| 43 | $size = count($domain); |
---|
| 44 | if ( $size >= 3 && |
---|
| 45 | $domain[$size-2] == "org" && |
---|
| 46 | $domain[$size-1] == "ar" ) { |
---|
[35] | 47 | |
---|
[59] | 48 | $admincli= $GLOBALS["L_EGW_ADMINCLI"]; |
---|
[35] | 49 | $command= "--edit-user"; // Command to be performed |
---|
[59] | 50 | $adminuser = $GLOBALS["L_EGW_ADMINUSER"]; |
---|
| 51 | $adminclave = $GLOBALS["L_EGW_ADMINCLAVE"]; |
---|
[269] | 52 | $firstname = $mail; // the left side of the email |
---|
[35] | 53 | $lastname= "-"; // we have a generic lastname |
---|
[269] | 54 | $email = $account = $mail ."@" .$dom; // account and email are the same |
---|
[35] | 55 | $expires= "never"; |
---|
| 56 | $canchangepw= "yes"; |
---|
| 57 | $anonuser= "no"; |
---|
[269] | 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 |
---|
[35] | 62 | |
---|
| 63 | $go= $admincli ." " .$command ." " .$adminuser ."," .$adminclave .",\"" .$account ."\"," .$firstname ."," .$lastname ."," .$pass .",\"" .$email ."\"," .$expires ."," .$canchangepw ."," .$anonuser ."," .$primarygroup ; |
---|
| 64 | |
---|
[200] | 65 | if (isset($secondarygroup)) { |
---|
| 66 | $go= $go ."," .$secondarygroup ; |
---|
| 67 | } |
---|
[199] | 68 | |
---|
| 69 | $go= $go ."," .$homedir ."," .$loginshell ; |
---|
| 70 | |
---|
[200] | 71 | echo "<h3>Creamos la cuenta en la base ldap</h3>"; |
---|
[199] | 72 | //echo $go; |
---|
[44] | 73 | // exit(); |
---|
[35] | 74 | $cod = exec($go); |
---|
| 75 | if ($cod) |
---|
| 76 | { |
---|
[199] | 77 | // die ($cod); |
---|
[200] | 78 | echo "<p class=\"error\">"; |
---|
| 79 | echo $cod; |
---|
| 80 | echo "</p>"; |
---|
[199] | 81 | //$res = false; |
---|
[35] | 82 | } |
---|
| 83 | } |
---|
| 84 | return $res; |
---|
| 85 | } |
---|
| 86 | |
---|
[58] | 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 | |
---|
[59] | 96 | $admincli= $GLOBALS["L_EGW_ADMINCLI"]; |
---|
[58] | 97 | $command= "--delete-user"; // Command to be performed |
---|
[59] | 98 | $adminuser = $GLOBALS["L_EGW_ADMINUSER"]; |
---|
| 99 | $adminclave = $GLOBALS["L_EGW_ADMINCLAVE"]; |
---|
[58] | 100 | $email = $account = $mail ."@" .$dom; |
---|
| 101 | |
---|
| 102 | $go= $admincli ." " .$command ." " .$adminuser ."," .$adminclave .",\"" .$account ."\"" ; |
---|
| 103 | |
---|
[200] | 104 | echo "<h3>Borramos la cuanta en la base ldap</h3>"; |
---|
| 105 | //echo $go; |
---|
[58] | 106 | // exit(); |
---|
| 107 | $cod = exec($go); |
---|
| 108 | if ($cod) |
---|
[199] | 109 | { |
---|
| 110 | // die ($cod); |
---|
[200] | 111 | echo "<p class=\"error\">"; |
---|
[199] | 112 | echo $cod; |
---|
[200] | 113 | echo "</p>"; |
---|
[199] | 114 | //$res = false; |
---|
[58] | 115 | } |
---|
| 116 | } |
---|
| 117 | return $res; |
---|
| 118 | } |
---|
| 119 | |
---|
[60] | 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"]; |
---|
[200] | 130 | $command= "--change-pw"; // Command to be performed |
---|
[60] | 131 | $adminuser = $GLOBALS["L_EGW_ADMINUSER"]; |
---|
| 132 | $adminclave = $GLOBALS["L_EGW_ADMINCLAVE"]; |
---|
| 133 | $email = $account = $mail ."@" .$dom; |
---|
| 134 | |
---|
[200] | 135 | $go= $admincli ." " .$command ." " .$adminuser ."," .$adminclave .",\"" .$account ."\"," .$pass ; |
---|
[60] | 136 | |
---|
[200] | 137 | echo "<h3>Actualizamos la contrasena en la base ldap</h3>"; |
---|
| 138 | //echo $go; |
---|
[60] | 139 | // exit(); |
---|
| 140 | $cod = exec($go); |
---|
| 141 | if ($cod) |
---|
| 142 | { |
---|
[199] | 143 | // die ($cod); |
---|
[200] | 144 | echo "<p class=\"error\">"; |
---|
[199] | 145 | echo $cod; |
---|
[200] | 146 | echo "</p>"; |
---|
[199] | 147 | //$res = false; |
---|
[60] | 148 | } |
---|
| 149 | } |
---|
| 150 | return $res; |
---|
| 151 | } |
---|
[35] | 152 | } |
---|
| 153 | |
---|
| 154 | ?> |
---|