[2] | 1 | <?php |
---|
| 2 | /***************************************************************************\ |
---|
| 3 | * eGroupWare - Contacts Center * |
---|
| 4 | * http://www.egroupware.org * |
---|
| 5 | * Written by: * |
---|
| 6 | * - Raphael Derosso Pereira <raphaelpereira@users.sourceforge.net> * |
---|
| 7 | * sponsored by Thyamad - http://www.thyamad.com |
---|
| 8 | * ------------------------------------------------------------------------- * |
---|
| 9 | * This program is free software; you can redistribute it and/or modify it * |
---|
| 10 | * under the terms of the GNU General Public License as published by the * |
---|
| 11 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
| 12 | * option) any later version. * |
---|
| 13 | \***************************************************************************/ |
---|
| 14 | |
---|
| 15 | /* |
---|
| 16 | Set a global flag to indicate this file was found by admin/config.php. |
---|
| 17 | config.php will unset it after parsing the form values. |
---|
| 18 | */ |
---|
| 19 | $GLOBALS['phpgw_info']['server']['found_validation_hook'] = True; |
---|
| 20 | |
---|
| 21 | /* Check all settings to validate input. Name must be 'final_validation' */ |
---|
[4504] | 22 | function final_validation(&$value='') |
---|
[2] | 23 | { |
---|
| 24 | $error = false; |
---|
| 25 | |
---|
[4508] | 26 | /* if($value['cc_global_source0'] == 'ldap') |
---|
| 27 | { |
---|
| 28 | if (!$value['cc_ldap_host0']) |
---|
| 29 | { |
---|
| 30 | $error[] = '<br>LDAP host must be set!'; |
---|
| 31 | } |
---|
| 32 | |
---|
| 33 | if(!$value['cc_ldap_context0']) |
---|
| 34 | { |
---|
| 35 | $error[] = '<br>There must be a Context'; |
---|
| 36 | } |
---|
[4504] | 37 | |
---|
[4508] | 38 | if(!$value['cc_ldap_browse_dn0']) |
---|
| 39 | { |
---|
| 40 | $error[] = '<br>The Browse Account must be set'; |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | if ($value['cc_ldap_pw0'] != $_POST['cc_ldap_pw0']) |
---|
| 44 | { |
---|
| 45 | $error[] = '<br>Invalid LDAP Password!'; |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | } */ |
---|
| 49 | |
---|
| 50 | /* Check if the password field is blank, then discard changes */ |
---|
[4504] | 51 | foreach ($value as $attr_name => $attr_value) { |
---|
| 52 | if ($attr_value == '') { |
---|
| 53 | $v = explode("_", $attr_name); |
---|
| 54 | $nums[] = $v[3]; |
---|
[2] | 55 | } |
---|
[4504] | 56 | } |
---|
| 57 | |
---|
| 58 | foreach ($nums as $num) { |
---|
| 59 | //Deleta toda a tupla que contem o atributo vazio |
---|
[4508] | 60 | foreach ($value as $attr_name_x => $attr_value_x) { |
---|
[4504] | 61 | if (strpos($attr_name_x, $num) !== false) { |
---|
| 62 | if (strpos($attr_name_x, 'cc_attribute_name') !== false) |
---|
[4508] | 63 | //$error[] = "<br/>" . lang("Could not find the LDAP attribute pointed by") . " " . $attr_value_x; |
---|
[4504] | 64 | |
---|
| 65 | unset($value[$attr_name_x]); |
---|
| 66 | |
---|
| 67 | } |
---|
[2] | 68 | } |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | if ($error) |
---|
| 72 | { |
---|
| 73 | $GLOBALS['config_error'] = implode("\n", $error); |
---|
| 74 | } |
---|
| 75 | } |
---|
[4500] | 76 | |
---|
| 77 | |
---|
| 78 | /* |
---|
| 79 | * @function cc_allow_details |
---|
[4504] | 80 | * @abstract Recebe o valor do checkbox e força a saída para TRUE ou FALSE |
---|
[4500] | 81 | * @author Prognus software livre - http://www.prognus.com.br | prognus@prognus.com.br |
---|
| 82 | * @param $value |
---|
| 83 | */ |
---|
| 84 | function cc_allow_details(&$value) { |
---|
| 85 | if ($value == 'details') { |
---|
| 86 | $value = "true"; |
---|
| 87 | } else { |
---|
| 88 | $value = "false"; |
---|
| 89 | } |
---|
| 90 | } |
---|
[4504] | 91 | |
---|
| 92 | |
---|
| 93 | |
---|
| 94 | /* |
---|
| 95 | * @function cc_attribute_ldapname |
---|
| 96 | * @abstract valida campo "Correspondente LDAP" se é um campo ldap válido |
---|
| 97 | * @author Prognus Software Livre - http://www.prognus.com.br | prognus@prognus.com.br |
---|
| 98 | * @param $value |
---|
| 99 | */ |
---|
| 100 | function cc_attribute_ldapname(&$value) { |
---|
[4508] | 101 | /* |
---|
| 102 | //Retirada a validação dos campos correspondentes no LDAP. |
---|
[4504] | 103 | $ldap = CreateObject('contactcenter.bo_ldap_manager'); |
---|
| 104 | $ds = $GLOBALS['phpgw']->common->ldapConnect($ldap->srcs[1]['host'], $ldap->srcs[1]['acc'], $ldap->srcs[1]['pw'], true); |
---|
| 105 | $dn=$ldap->srcs[1]['dn']; |
---|
| 106 | $justThese = array('uid', 'cn', $value); |
---|
| 107 | $sr = ldap_search($ds, $dn, "($value=*)", $justThese, 0, 1); |
---|
| 108 | $info = ldap_get_entries($ds, $sr); |
---|
| 109 | |
---|
| 110 | if (!$info) |
---|
| 111 | $value = ""; |
---|
| 112 | ldap_close($ds); |
---|
[4508] | 113 | */ |
---|
[4504] | 114 | } |
---|
[2] | 115 | ?> |
---|