Changeset 3234 for branches/2.2


Ignore:
Timestamp:
09/13/10 16:21:28 (14 years ago)
Author:
niltonneto
Message:

Ticket #566 - Implementado bloqueio ao editar dados pessoais, conforme ACL.

Location:
branches/2.2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/phpgwapi/inc/class.accounts_ldap.inc.php

    r1904 r3234  
    6363                        { 
    6464                                /* jakjr: using justthese with ldap_search */ 
    65                                 $justthese = array("uidnumber", "gidnumber", "uid", "cn", "givenname", "sn", "mail", "phpgwaccountstatus", "phpgwaccountexpires", "phpgwaccounttype", "phpgwlastpasswdchange","phpgwagreeterm","telephonenumber"); 
     65                                $justthese = array("uidnumber", "gidnumber", "uid", "cn", "givenname", "sn", "mail", "phpgwaccountstatus", "phpgwaccountexpires", "phpgwaccounttype", "phpgwlastpasswdchange","phpgwagreeterm","telephonenumber","mobile"); 
    6666                                $sri = @ldap_search($this->ds, $this->user_context, ("(&(uidnumber=" . (int)$this->account_id.")(phpgwaccounttype=u))"), $justthese); 
    6767                        } 
     
    9090                                } 
    9191                                $this->data['telephonenumber']   = $allValues[0]['telephonenumber'][0]; 
     92                                $this->data['mobile']   = $allValues[0]['mobile'][0]; 
    9293                                /* jakjr: this is not used for expressoLivre */ 
    9394                                /* 
  • branches/2.2/preferences/changepersonaldata.php

    r1225 r3234  
    3838        )); 
    3939 
    40         $GLOBALS['phpgw']->template->set_var('lang_commercial_telephonenumber',lang('Commercial Telephone number')); 
     40        $GLOBALS['phpgw']->template->set_var('lang_commercial_telephonenumber',lang('%1 telephone number',lang('Commercial'))); 
    4141        $GLOBALS['phpgw']->template->set_var('lang_ps_commercial_telephonenumber', 
    4242        lang('Observation') . ': ' . lang('This telephone number will apear in searches for your name, and it will be visible for all ExpressoLivre Users') . '.'); 
     43        $GLOBALS['phpgw']->template->set_var('lang_mobile_telephonenumber',lang('%1 telephone number',lang('Mobile'))); 
    4344        $GLOBALS['phpgw']->template->set_var('lang_change',lang('Change')); 
    4445        $GLOBALS['phpgw']->template->set_var('lang_cancel',lang('Cancel')); 
     
    4748        /* Get telephone number from ldap or from post */ 
    4849        $ldap_conn = $GLOBALS['phpgw']->common->ldapConnect(); 
    49         $result = ldap_search($ldap_conn, $GLOBALS['phpgw_info']['server']['ldap_context'], 'uid='.$GLOBALS['phpgw_info']['user']['account_lid'], array('telephonenumber')); 
     50        $result = ldap_search($ldap_conn, $GLOBALS['phpgw_info']['server']['ldap_context'], 'uid='.$GLOBALS['phpgw_info']['user']['account_lid'], array('telephonenumber','mobile')); 
    5051        $entrie = ldap_get_entries($ldap_conn, $result); 
    51         $GLOBALS['phpgw']->template->set_var('telephonenumber',$_POST['telephonenumber'] ? $_POST['telephonenumber'] : $entrie[0]['telephonenumber'][0]); 
     52 
     53        /* BEGIN ACL Check for Personal Data Fields.*/ 
     54        $disabledTelephoneNumber = false; 
     55        $disabledMobile = false; 
     56          
     57        if ($GLOBALS['phpgw']->acl->check('blockpersonaldata',1)) { 
     58                $disabledTelephoneNumber = '"disabled=true"'; 
     59        } 
     60        if ($GLOBALS['phpgw']->acl->check('blockpersonaldata',2)) { 
     61                $disabledMobile = '"disabled=true"'; 
     62        } 
     63        /* END ACL Check for Personal Data Fields.*/ 
     64         
     65        $GLOBALS['phpgw']->template->set_var('telephonenumber',($_POST['telephonenumber'] ? $_POST['telephonenumber'] : $entrie[0]['telephonenumber'][0]).$disabledTelephoneNumber); 
     66        $GLOBALS['phpgw']->template->set_var('mobile',($_POST['mobile'] ? $_POST['mobile'] : $entrie[0]['mobile'][0]).$disabledMobile); 
     67 
    5268        ldap_close($ldap_conn); 
    5369 
     
    5975        if ($_POST['change']) 
    6076        { 
    61                 if ($_POST['telephonenumber'] != $GLOBALS['phpgw_info']['user']['telephonenumber']) 
     77                if ($_POST['telephonenumber'] != $GLOBALS['phpgw_info']['user']['telephonenumber'] || $_POST['mobile'] != $GLOBALS['phpgw_info']['user']['mobile']) 
    6278                { 
    6379                        $pattern = '/\([0-9]{2,3}\)[0-9]{4}-[0-9]{4}$/'; 
    6480                        if ((strlen($_POST['telephonenumber']) != 0) && (!preg_match($pattern, $_POST['telephonenumber']))) 
    6581                        { 
    66                                 $errors[] = lang('Format of telephone number is invalid.'); 
     82                                $errors[] = lang('Format of %1 telephone number is invalid.', lang("Commercial")); 
    6783                        } 
    68                         else 
     84                        if ((strlen($_POST['mobile']) != 0) && (!preg_match($pattern, $_POST['mobile']))) 
     85                        { 
     86                                $errors[] = lang('Format of %1 telephone number is invalid.', lang("Mobile")); 
     87                        } 
     88                        if(!is_array($errors)) 
    6989                        { 
    7090                                // Use LDAP Replication mode, if available 
     
    84104                                } 
    85105                                 
    86                                 if ($GLOBALS['phpgw_info']['user']['telephonenumber']) 
    87                                 { 
     106                                if(!$disabledTelephoneNumber && ($_POST['telephonenumber'] != $GLOBALS['phpgw_info']['user']['telephonenumber'])) { 
    88107                                        if (strlen($_POST['telephonenumber']) == 0) { 
    89108                                                $info['telephonenumber'] = $GLOBALS['phpgw_info']['user']['telephonenumber']; 
    90109                                                $result = @ldap_mod_del($ldap_conn, $GLOBALS['phpgw_info']['user']['account_dn'], $info); 
    91110                                        } 
     111                                        elseif(strlen($GLOBALS['phpgw_info']['user']['telephonenumber']) == 0) { 
     112                                                $info['telephonenumber'] = $_POST['telephonenumber']; 
     113                                                $result = @ldap_mod_add($ldap_conn, $GLOBALS['phpgw_info']['user']['account_dn'], $info); 
     114                                        }                                        
    92115                                        else { 
    93116                                                $info['telephonenumber'] = $_POST['telephonenumber']; 
    94117                                                $result = @ldap_mod_replace($ldap_conn, $GLOBALS['phpgw_info']['user']['account_dn'], $info); 
    95118                                        } 
     119                                        unset($info['telephonenumber']); 
    96120                                } 
    97                                 else 
    98                                 { 
    99                                         $info['telephonenumber'] = $_POST['telephonenumber']; 
    100                                         $result = @ldap_mod_add($ldap_conn, $GLOBALS['phpgw_info']['user']['account_dn'], $info); 
     121                                if (!$disabledMobile && ($_POST['mobile'] != $GLOBALS['phpgw_info']['user']['mobile'])) { 
     122                                        if (strlen($_POST['mobile']) == 0) { 
     123                                                $info['mobile'] = $GLOBALS['phpgw_info']['user']['mobile']; 
     124                                                $result = @ldap_mod_del($ldap_conn, $GLOBALS['phpgw_info']['user']['account_dn'], $info); 
     125                                        } 
     126                                        elseif(strlen($GLOBALS['phpgw_info']['user']['mobile']) == 0) { 
     127                                                $info['mobile'] = $_POST['mobile']; 
     128                                                $result = @ldap_mod_add($ldap_conn, $GLOBALS['phpgw_info']['user']['account_dn'], $info); 
     129                                        } 
     130                                        else { 
     131                                                $info['mobile'] = $_POST['mobile']; 
     132                                                $result = @ldap_mod_replace($ldap_conn, $GLOBALS['phpgw_info']['user']['account_dn'], $info); 
     133                                        } 
    101134                                } 
     135                                ldap_close($ldap_conn);  
    102136                        } 
    103137                         
  • branches/2.2/preferences/templates/default/changepersonaldata.tpl

    r1132 r3234  
    1818        </td> 
    1919     </tr> 
     20     <tr><td colspan=2 height="20px"></td></tr> 
     21     <tr> 
     22       <td> 
     23        {lang_mobile_telephonenumber}: 
     24       </td> 
     25       <td> 
     26        <input type="input" autocomplete="off" name="mobile" size=12 value="{mobile}" maxlength="13" onkeyUp="FormatTelephoneNumber(event, this);">&nbsp;(xx)xxxx-xxxx 
     27       </td> 
     28     </tr> 
    2029     <tr> 
    2130       <td colspan="3"> 
Note: See TracChangeset for help on using the changeset viewer.