Ignore:
Timestamp:
05/12/11 11:52:50 (13 years ago)
Author:
afernandes
Message:

Ticket #1416 - Disponibilizado módulo de recursos para a comunidade

File:
1 edited

Legend:

Unmodified
Added
Removed
  • contrib/Dms/inc/inc.ClassUser.php

    r3526 r4362  
    4949} 
    5050 
     51 
     52 
     53 
     54                 
     55        function read_repository2($id) 
     56                { 
     57                         
     58                        $login=$GLOBALS['phpgw']->accounts->id2name($id); 
     59                                $ds = $GLOBALS['phpgw']->common->ldapConnect(); 
     60                                $user_context  = $GLOBALS['phpgw_info']['server']['ldap_context']; 
     61                                $group_context  = $GLOBALS['phpgw_info']['server']['ldap_context']; 
     62                                $justthese = array("gidnumber"); 
     63                                $sri = @ldap_search($ds, $group_context, ("(&(memberUid=" . $login.")(phpgwaccounttype=g))"), $justthese); 
     64                         
     65                                if(!$sri) 
     66                                return null; 
     67                                $allValues = ldap_get_entries($ds, $sri); 
     68 
     69                                 
     70                                while (list($null,$allVals) = @each($allValues)) 
     71                                { 
     72                                        settype($allVals,'array'); 
     73                                         
     74                                        if($data!=""){ 
     75                                                $data=$data.","; 
     76                                        } 
     77                                        $data=$data. $allVals['gidnumber'][0]; 
     78                                 
     79                                         
     80                                         
     81                                } 
     82                                 
     83                                //echo "<br>".$data; 
     84                                return $data; 
     85                } 
     86                 
     87 
     88function get_account_name($account_id,$valor) 
     89                { 
     90                //      $acct_type = $this->get_type($account_id); 
     91$acct_type ='u'; 
     92                        /* jakjr: using justthese with ldap_search */ 
     93                        //$justthese = array("cn","uid","givenname","sn","gecos"); 
     94 
     95                        /* search the dn for the given uid */ 
     96$ds = $GLOBALS['phpgw']->common->ldapConnect(); 
     97$user_context  = $GLOBALS['phpgw_info']['server']['ldap_context']; 
     98                         
     99$justthese = array("uidnumber",  "cn",  "mail","gecos","dn"); 
     100                        //      $sri = @ldap_search($this->ds, "ou=usuarios,ou=cnti,dc=gob,dc=ve", ("(&(sn=*)(mail=*@*)(structuralObjectClass=inetOrgPerson)(deliveryMode=virtual))"), $justthese); 
     101 
     102                        //if(($acct_type == 'g') && $this->group_context) 
     103                //      { 
     104                //              $sri = @ldap_search($this->ds, $this->group_context, '(gidnumber=' . (int)$account_id . ')', $justthese); 
     105                //      } 
     106                //      else 
     107                //      { 
     108                                $sri = @ldap_search($ds, $user_context, '(uidnumber=' . (int)$account_id . ')', $justthese); 
     109                        //} 
     110 
     111//echo $this->ds.",". $this->user_context.",". '(uidnumber=' . (int)$account_id . ')'.",". $justthese; 
     112                        if(!$sri) 
     113                                return False; 
     114                        $allValues = ldap_get_entries($ds, $sri); 
     115$retorna=""; 
     116                        if($acct_type =='g') 
     117                        { 
     118                                if($valor=='gecos') { 
     119                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['gecos'][0],'utf-8'); 
     120                                } 
     121                                if($valor=='uidnumber') { 
     122                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['uidnumber'][0],'utf-8'); 
     123                                } 
     124                                if($valor=='cn') { 
     125                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['cn'][0],'utf-8'); 
     126                                } 
     127 
     128                                if($valor=='mail') { 
     129                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['mail'][0],'utf-8'); 
     130                                } 
     131                                if($valor=='dn') { 
     132                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['dn'][0],'utf-8'); 
     133                                } 
     134                                 
     135                        } 
     136                        else 
     137                        { 
     138                                if($valor=='gecos') { 
     139                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['gecos'][0],'utf-8'); 
     140                                } 
     141                                if($valor=='uidnumber') { 
     142                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['uidnumber'][0],'utf-8'); 
     143                                } 
     144                                if($valor=='cn') { 
     145                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['cn'][0],'utf-8'); 
     146                                } 
     147 
     148                                if($valor=='mail') { 
     149                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['mail'][0],'utf-8'); 
     150                                } 
     151                                if($valor=='dn') { 
     152                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['dn'][0],'utf-8'); 
     153                                } 
     154                                 
     155 
     156 
     157 
     158                        } 
     159                        return $retorna; 
     160                } 
     161 
    51162function getUser($id) 
    52163{ 
     164//echo "llego"; 
    53165        $resArr["id"] = $id; 
    54         $resArr["login"] = phpgw_id2name($id); 
     166        $resArr["login"] =  phpgw_id2name($id);//get_account_name($id,'dn'); 
    55167        $resArr["fullName"] = phpgw_get_accname($id); 
    56168        $resArr["email"] = phpgw_get_accemail($id); 
     
    59171        $resArr["pwd"] = ''; 
    60172        $resArr["comment"] = ''; 
     173//      echo "hhh".$resArr["login"]."  ".$resArr["fullName"]."  ".$resArr["isAdmin"]; 
    61174        return new User($resArr["id"], $resArr["login"], $resArr["pwd"], $resArr["fullName"], $resArr["email"], $resArr["comment"], $resArr["isAdmin"]); 
    62175} 
     
    137250                $this->_isAdmin = $isAdmin; 
    138251        } 
     252         
     253         
     254        function add($id,$login,$fullName,$email,$isAdmin,$pwd,$comment) 
     255    { 
     256        $this->User = new User($id, $login, $pwd, $fullName, $email, $comment, $isAdmin); 
     257    } 
     258         
     259         function sortDataSet($s) 
     260    { 
     261        //Sort by the given parameter 
     262        switch($s) 
     263        { 
     264            case "fullName": 
     265                //Note use of array to reference member method of this object in callback 
     266                uasort($this->User,array($this,"cmpName")); 
     267                break; 
     268            
     269            case "login": 
     270                uasort($this->User,array($this,"cmpX")); 
     271                break; 
     272                
     273            case "id": 
     274                uasort($this->User,array($this,"cmpY")); 
     275                break;                
     276            
     277            case "added": 
     278            default: 
     279                //Re-sort array by original keys 
     280                ksort($this->User);        
     281        } 
     282    } 
     283 
     284    //Callback function for sorting by name 
     285    //$a and $b are dataItem objects 
     286    function cmpName($a,$b) 
     287    { 
     288        //Use sort() for simple alphabetical comparison 
     289        //Convert to lowercase to ensure consistent behaviour 
     290        $sortable = array(strtolower($a->_fullName),strtolower($b->_fullName)); 
     291        $sorted = $sortable; 
     292        sort($sorted);    
     293        
     294        //If the names have switched position, return -1. Otherwise, return 1. 
     295        return ($sorted[0] == $sortable[0]) ? -1 : 1; 
     296    } 
     297    
     298    //Callback function for sorting by x 
     299    //$a and $b are dataItem objects 
     300    function cmpX($a,$b) 
     301    { 
     302        //Use sort() for simple alphabetical comparison 
     303        //Convert to lowercase to ensure consistent behaviour 
     304        $sortable = array(strtolower($a->x),strtolower($b->x)); 
     305        $sorted = $sortable; 
     306        sort($sorted);    
     307        
     308        //If the names have switched position, return -1. Otherwise, return 1. 
     309        return ($sorted[0] == $sortable[0]) ? -1 : 1; 
     310    } 
     311    
     312    //Callback function for sorting by y 
     313    //$a and $b are dataItem objects 
     314    function cmpY($a,$b) 
     315    {        
     316        //If $a's y attribute >= $b's y attribute, return 1. Otherwise, return -1. 
     317        return ($a->y >= $b->y) ? 1 : -1; 
     318    }    
    139319 
    140320        function getID() { return $this->_id; } 
     
    339519        function isMemberOfGroup($group) 
    340520        { 
     521                //echo "es miembro de".$this."<br>"; 
    341522                return $group->isMember($this); 
    342523        } 
Note: See TracChangeset for help on using the changeset viewer.