Changeset 5889


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

Ticket #2507 - Implementado métodos getUserProfile() e getUserPreferences().

Location:
sandbox/webservice/api/json-rpc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sandbox/webservice/api/json-rpc/Catalog.php

    r5722 r5889  
    44 
    55class Catalog extends Expresso {         
     6        var $userPrefs; 
     7        var $userId; 
     8 
     9        public function __construct(){ 
     10                $this->userPrefs   = $this->getUserPreferences(); 
     11        } 
     12         
     13        private function getUserId(){ 
     14                $userProfile = $this->getUserProfile(); 
     15                return $userProfile['account_id']; 
     16        } 
    617         
    718        public function getUserContacts($params){ 
     
    920                        $search = ""; 
    1021                        if($params) { 
    11                                  
    1222                                $search = trim($params['search']); 
    13                                 if($params['contactID'] > 0){ 
    14                                         $query_contact = 'A.id_contact='.$params['contactID'].' and'; 
    15                                 } 
    16                                 elseif($search != "") { 
     23                                if($search != "") { 
    1724                                        $search = mb_convert_encoding($search,"ISO_8859-1", "UTF8"); 
    1825                                } 
    1926                                 
    20                                 if(($search || $params['contactID']) && $params['contactType'] == 2){ 
    21                                         return $this->getGlobalContacts($search, $params['contactID']);                                  
     27                                if($params['contactID'] > 0 && $params['contactType'] == 1){ 
     28                                        $query_contact = 'A.id_contact='.$params['contactID'].' and'; 
     29                                } 
     30                                elseif($params['contactType'] == 2){ 
     31                                        if($this->userPrefs['search_characters_number'] <= strlen($search)) 
     32                                                return $this->getGlobalContacts($search, $params['contactID']); 
     33                                        else{ 
     34                                                $this-> error = str_replace("%1",$this->userPrefs['search_characters_number'],"Your search argument must be longer than %1 characters."); 
     35                                                return $this->getResponse(); 
     36                                        } 
    2237                                } 
    2338                        } 
  • sandbox/webservice/api/json-rpc/Expresso.php

    r5714 r5889  
    2525        }        
    2626                 
    27         protected function getUserId(){ 
    28                 return $GLOBALS['phpgw_info']['user']['account_id']; 
     27        protected function getUserProfile(){ 
     28                return array( 
     29                        'account_id'            => $GLOBALS['phpgw_info']['user']['account_id'], 
     30                        'email'                         => $GLOBALS['phpgw_info']['user']['email'], 
     31                        'telephonenumber'       => $GLOBALS['phpgw_info']['user']['telephonenumber'], 
     32                        'fullname'                      => $GLOBALS['phpgw_info']['user']['fullname'] 
     33                ); 
     34        } 
     35 
     36        protected function getUserPreferences(){ 
     37                $prefs = $GLOBALS['phpgw']->preferences->read(); 
     38                return array( 
     39                                "search_characters_number"  => $prefs['expressoMail']['search_characters_number'], 
     40                                "search_result_number"          => $prefs['expressoMail']['search_result_number'], 
     41                                "save_deleted_msg"                      => $prefs['expressoMail']['save_deleted_msg'], 
     42                                "max_email_per_page"            => $prefs['expressoMail']['max_email_per_page'], 
     43                                "delete_trash_messages_after_n_days" => $prefs['expressoMail']['delete_trash_messages_after_n_days'], 
     44                                "save_in_folder"                        => $prefs['expressoMail']['save_in_folder'] 
     45                                ); 
    2946        } 
    3047         
     
    7188                        { 
    7289                                $this->error  = null; 
    73                                 $this->result = array('auth' =>  $sessionid.":".$GLOBALS['phpgw']->session->kp3); 
     90                                $this->result = array( 
     91                                                'auth'                  => $sessionid.":".$GLOBALS['phpgw']->session->kp3, 
     92                                                'profile'               => $this->getUserProfile(), 
     93                                                'preferences'   => $this->getUserPreferences() 
     94                                        ); 
    7495                        } 
    7596                        else 
Note: See TracChangeset for help on using the changeset viewer.