Changeset 6274


Ignore:
Timestamp:
05/22/12 17:53:21 (12 years ago)
Author:
niltonneto
Message:

Ticket #2507 - Quando "contactID" for nulo, retornar a foto do usuário logado.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/webservice/api/rest/catalog/ContactPictureResource.php

    r6148 r6274  
    66                parent::post($request);  
    77                 
    8                 if($this-> isLoggedIn() && $this->getParam('contactID') != null)  
     8                if($this-> isLoggedIn())  
    99                {                                                                
    1010                        $contact = array(); 
     11                        $contactID = $this->getParam('contactID'); 
    1112                        // User Contact 
    12                         if($this->getParam('contactType') == 1){ 
    13                                 $query = 'select A.id_contact, A.photo from phpgw_cc_contact A where A.id_contact='.$this->getParam('contactID').' and A.id_owner='.$this -> getUserId(); 
     13                        if($this->getParam('contactType') == 1 && $contactID != null){ 
     14                                $query = 'select A.id_contact, A.photo from phpgw_cc_contact A where A.id_contact='.$contactID.' and A.id_owner='.$this -> getUserId(); 
    1415                                if (!$this->getDb()->query($query)) 
    1516                                        return false; 
     
    2627                        // Global Catalog 
    2728                        elseif($this->getParam('contactType') == 2){ 
    28                                 $photo = $this->getUserLdapPhoto(urldecode($this->getParam('contactID'))); 
     29                                if(!$contactID){ 
     30                                        $contactID = $GLOBALS['phpgw_info']['user']['account_dn']; 
     31                                } 
     32                                $photo = $this->getUserLdapPhoto(urldecode($contactID)); 
    2933                                $contact[] = array( 
    30                                                 'contactID'             => $this->getParam('contactID'), 
     34                                                'contactID'             => $contactID, 
    3135                                                'contactImagePicture'   => ($photo != null ? base64_encode($photo[0]) : "") 
    3236                                ); 
Note: See TracChangeset for help on using the changeset viewer.