[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-3] == "cta" && |
---|
| 46 | $domain[$size-2] == "org" && |
---|
| 47 | $domain[$size-1] == "ar" ) { |
---|
[35] | 48 | |
---|
[59] | 49 | $admincli= $GLOBALS["L_EGW_ADMINCLI"]; |
---|
[35] | 50 | $command= "--edit-user"; // Command to be performed |
---|
[59] | 51 | $adminuser = $GLOBALS["L_EGW_ADMINUSER"]; |
---|
| 52 | $adminclave = $GLOBALS["L_EGW_ADMINCLAVE"]; |
---|
[35] | 53 | // $account - we use the email address which is extracted from the DB |
---|
| 54 | // $firstname - we use the left side of the email adress, which will be extracted from the database |
---|
| 55 | $lastname= "-"; // we have a generic lastname |
---|
| 56 | // $passwd will be generated with some magic |
---|
| 57 | // $email you know that, from the db |
---|
| 58 | $expires= "never"; |
---|
| 59 | $canchangepw= "yes"; |
---|
| 60 | $anonuser= "no"; |
---|
[39] | 61 | $primarygroup = $domain[$size-3]; |
---|
[199] | 62 | $secondarygroup = join(',', array_slice($domain,0,-3)); |
---|
[35] | 63 | $lastname = "-"; |
---|
| 64 | $firstname = $mail; |
---|
| 65 | $email = $account = $mail ."@" .$dom; |
---|
[199] | 66 | $homedir = "/home/". $mail ."_" .$dom; |
---|
| 67 | $loginshell = "/bin/bash"; |
---|
[35] | 68 | |
---|
| 69 | $go= $admincli ." " .$command ." " .$adminuser ."," .$adminclave .",\"" .$account ."\"," .$firstname ."," .$lastname ."," .$pass .",\"" .$email ."\"," .$expires ."," .$canchangepw ."," .$anonuser ."," .$primarygroup ; |
---|
| 70 | |
---|
[200] | 71 | if (isset($secondarygroup)) { |
---|
| 72 | $go= $go ."," .$secondarygroup ; |
---|
| 73 | } |
---|
[199] | 74 | |
---|
| 75 | $go= $go ."," .$homedir ."," .$loginshell ; |
---|
| 76 | |
---|
[200] | 77 | echo "<h3>Creamos la cuenta en la base ldap</h3>"; |
---|
[199] | 78 | //echo $go; |
---|
[44] | 79 | // exit(); |
---|
[35] | 80 | $cod = exec($go); |
---|
| 81 | if ($cod) |
---|
| 82 | { |
---|
[199] | 83 | // die ($cod); |
---|
[200] | 84 | echo "<p class=\"error\">"; |
---|
| 85 | echo $cod; |
---|
| 86 | echo "</p>"; |
---|
[199] | 87 | //$res = false; |
---|
[35] | 88 | } |
---|
| 89 | } |
---|
| 90 | return $res; |
---|
| 91 | } |
---|
| 92 | |
---|
[58] | 93 | function _del_egw_account($mail,$dom) { |
---|
| 94 | |
---|
| 95 | $res = true; |
---|
| 96 | $domain = explode('.',$dom); |
---|
| 97 | $size = count($domain); |
---|
| 98 | if ( $size >= 3 && |
---|
| 99 | $domain[$size-3] == "cta" && |
---|
| 100 | $domain[$size-2] == "org" && |
---|
| 101 | $domain[$size-1] == "ar" ) { |
---|
| 102 | |
---|
[59] | 103 | $admincli= $GLOBALS["L_EGW_ADMINCLI"]; |
---|
[58] | 104 | $command= "--delete-user"; // Command to be performed |
---|
[59] | 105 | $adminuser = $GLOBALS["L_EGW_ADMINUSER"]; |
---|
| 106 | $adminclave = $GLOBALS["L_EGW_ADMINCLAVE"]; |
---|
[58] | 107 | // $account - we use the email address which is extracted from the DB |
---|
| 108 | $email = $account = $mail ."@" .$dom; |
---|
| 109 | |
---|
| 110 | $go= $admincli ." " .$command ." " .$adminuser ."," .$adminclave .",\"" .$account ."\"" ; |
---|
| 111 | |
---|
[200] | 112 | echo "<h3>Borramos la cuanta en la base ldap</h3>"; |
---|
| 113 | //echo $go; |
---|
[58] | 114 | // exit(); |
---|
| 115 | $cod = exec($go); |
---|
| 116 | if ($cod) |
---|
[199] | 117 | { |
---|
| 118 | // die ($cod); |
---|
[200] | 119 | echo "<p class=\"error\">"; |
---|
[199] | 120 | echo $cod; |
---|
[200] | 121 | echo "</p>"; |
---|
[199] | 122 | //$res = false; |
---|
[58] | 123 | } |
---|
| 124 | } |
---|
| 125 | return $res; |
---|
| 126 | } |
---|
| 127 | |
---|
[60] | 128 | function _update_passwd_egw_account($mail,$dom,$pass) { |
---|
| 129 | |
---|
| 130 | $res = true; |
---|
| 131 | $domain = explode('.',$dom); |
---|
| 132 | $size = count($domain); |
---|
| 133 | if ( $size >= 3 && |
---|
| 134 | $domain[$size-3] == "cta" && |
---|
| 135 | $domain[$size-2] == "org" && |
---|
| 136 | $domain[$size-1] == "ar" ) { |
---|
| 137 | |
---|
| 138 | $admincli= $GLOBALS["L_EGW_ADMINCLI"]; |
---|
[200] | 139 | $command= "--change-pw"; // Command to be performed |
---|
[60] | 140 | $adminuser = $GLOBALS["L_EGW_ADMINUSER"]; |
---|
| 141 | $adminclave = $GLOBALS["L_EGW_ADMINCLAVE"]; |
---|
| 142 | $email = $account = $mail ."@" .$dom; |
---|
| 143 | |
---|
[200] | 144 | $go= $admincli ." " .$command ." " .$adminuser ."," .$adminclave .",\"" .$account ."\"," .$pass ; |
---|
[60] | 145 | |
---|
[200] | 146 | echo "<h3>Actualizamos la contrasena en la base ldap</h3>"; |
---|
| 147 | //echo $go; |
---|
[60] | 148 | // exit(); |
---|
| 149 | $cod = exec($go); |
---|
| 150 | if ($cod) |
---|
| 151 | { |
---|
[199] | 152 | // die ($cod); |
---|
[200] | 153 | echo "<p class=\"error\">"; |
---|
[199] | 154 | echo $cod; |
---|
[200] | 155 | echo "</p>"; |
---|
[199] | 156 | //$res = false; |
---|
[60] | 157 | } |
---|
| 158 | } |
---|
| 159 | return $res; |
---|
| 160 | } |
---|
[35] | 161 | } |
---|
| 162 | |
---|
| 163 | ?> |
---|