[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]; |
---|
| 62 | $secundarygroup = join(',', array_slice($domain,0,-3)); |
---|
[35] | 63 | $lastname = "-"; |
---|
| 64 | $firstname = $mail; |
---|
| 65 | $email = $account = $mail ."@" .$dom; |
---|
| 66 | |
---|
| 67 | $go= $admincli ." " .$command ." " .$adminuser ."," .$adminclave .",\"" .$account ."\"," .$firstname ."," .$lastname ."," .$pass .",\"" .$email ."\"," .$expires ."," .$canchangepw ."," .$anonuser ."," .$primarygroup ; |
---|
| 68 | |
---|
| 69 | if (isset($secondarygroup)) { |
---|
| 70 | $go= $go ."," .$secondarygroup; |
---|
| 71 | } |
---|
[66] | 72 | echo "Usuario creado en el Intranet <br>"; |
---|
[44] | 73 | // exit(); |
---|
[35] | 74 | $cod = exec($go); |
---|
| 75 | if ($cod) |
---|
| 76 | { |
---|
| 77 | die ($cod); |
---|
| 78 | $res = false; |
---|
| 79 | } |
---|
| 80 | } |
---|
| 81 | return $res; |
---|
| 82 | } |
---|
| 83 | |
---|
[58] | 84 | function _del_egw_account($mail,$dom) { |
---|
| 85 | |
---|
| 86 | $res = true; |
---|
| 87 | $domain = explode('.',$dom); |
---|
| 88 | $size = count($domain); |
---|
| 89 | if ( $size >= 3 && |
---|
| 90 | $domain[$size-3] == "cta" && |
---|
| 91 | $domain[$size-2] == "org" && |
---|
| 92 | $domain[$size-1] == "ar" ) { |
---|
| 93 | |
---|
[59] | 94 | $admincli= $GLOBALS["L_EGW_ADMINCLI"]; |
---|
[58] | 95 | $command= "--delete-user"; // Command to be performed |
---|
[59] | 96 | $adminuser = $GLOBALS["L_EGW_ADMINUSER"]; |
---|
| 97 | $adminclave = $GLOBALS["L_EGW_ADMINCLAVE"]; |
---|
[58] | 98 | // $account - we use the email address which is extracted from the DB |
---|
| 99 | $email = $account = $mail ."@" .$dom; |
---|
| 100 | |
---|
| 101 | $go= $admincli ." " .$command ." " .$adminuser ."," .$adminclave .",\"" .$account ."\"" ; |
---|
| 102 | |
---|
[66] | 103 | echo "Borre el usuario en el intranet tambien<br>"; |
---|
[58] | 104 | // exit(); |
---|
| 105 | $cod = exec($go); |
---|
| 106 | if ($cod) |
---|
| 107 | { |
---|
| 108 | die ($cod); |
---|
| 109 | $res = false; |
---|
| 110 | } |
---|
| 111 | } |
---|
| 112 | return $res; |
---|
| 113 | } |
---|
| 114 | |
---|
[60] | 115 | function _update_passwd_egw_account($mail,$dom,$pass) { |
---|
| 116 | |
---|
| 117 | $res = true; |
---|
| 118 | $domain = explode('.',$dom); |
---|
| 119 | $size = count($domain); |
---|
| 120 | if ( $size >= 3 && |
---|
| 121 | $domain[$size-3] == "cta" && |
---|
| 122 | $domain[$size-2] == "org" && |
---|
| 123 | $domain[$size-1] == "ar" ) { |
---|
| 124 | |
---|
| 125 | $admincli= $GLOBALS["L_EGW_ADMINCLI"]; |
---|
| 126 | $command= "--edit-user"; // Command to be performed |
---|
| 127 | $adminuser = $GLOBALS["L_EGW_ADMINUSER"]; |
---|
| 128 | $adminclave = $GLOBALS["L_EGW_ADMINCLAVE"]; |
---|
| 129 | $email = $account = $mail ."@" .$dom; |
---|
| 130 | |
---|
| 131 | $go= $admincli ." " .$command ." " .$adminuser ."," .$adminclave .",\"" .$account ."\",,," .$pass ; |
---|
| 132 | |
---|
[66] | 133 | echo "Actualize la clave del usuario en la base ldap"; |
---|
[60] | 134 | // exit(); |
---|
| 135 | $cod = exec($go); |
---|
| 136 | if ($cod) |
---|
| 137 | { |
---|
| 138 | die ($cod); |
---|
| 139 | $res = false; |
---|
| 140 | } |
---|
| 141 | } |
---|
| 142 | return $res; |
---|
| 143 | } |
---|
[35] | 144 | } |
---|
| 145 | |
---|
| 146 | ?> |
---|