Changeset 5954


Ignore:
Timestamp:
04/16/12 17:34:31 (12 years ago)
Author:
niltonneto
Message:

Ticket #2507 - Corrigido método getUserId(). Renomeado classe http_request.

Location:
sandbox/webservice/api
Files:
2 added
3 edited
1 moved

Legend:

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

    r5889 r5954  
    44 
    55class Catalog extends Expresso {         
    6         var $userPrefs; 
     6        var $searchCharactersNumber; 
    77        var $userId; 
    88 
    99        public function __construct(){ 
    10                 $this->userPrefs   = $this->getUserPreferences(); 
     10                $prefs = $GLOBALS['phpgw']->preferences->read(); 
     11                $this-> searchCharactersNumber = $prefs['expressoMail']['search_characters_number']; 
    1112        } 
    1213         
    1314        private function getUserId(){ 
    1415                $userProfile = $this->getUserProfile(); 
    15                 return $userProfile['account_id']; 
     16                return $userProfile['contactID']; 
    1617        } 
    1718         
     
    2930                                } 
    3031                                elseif($params['contactType'] == 2){ 
    31                                         if($this->userPrefs['search_characters_number'] <= strlen($search)) 
     32                                        if($this-> searchCharactersNumber <= strlen($search)) 
    3233                                                return $this->getGlobalContacts($search, $params['contactID']); 
    3334                                        else{ 
    34                                                 $this-> error = str_replace("%1",$this->userPrefs['search_characters_number'],"Your search argument must be longer than %1 characters."); 
     35                                                $this-> error = Errors::get(Errors::CATALOG_MIN_ARGUMENT_SEARCH); 
     36                                                $this-> error = str_replace("%1",$this-> searchCharactersNumber,$this->error); 
    3537                                                return $this->getResponse(); 
    3638                                        } 
  • sandbox/webservice/api/json-rpc/Expresso.php

    r5896 r5954  
    4949         
    5050        protected function isLoggedIn($params){ 
    51                 list($sessionid, $kp3) = explode(":", $params['auth']); 
    52                 if($GLOBALS['phpgw']->session->verify($sessionid, $kp3)){                                                                        
    53                         return true; 
     51                if($params['auth'] != null) { 
     52                        list($sessionid, $kp3) = explode(":", $params['auth']); 
     53                        if($GLOBALS['phpgw']->session->verify($sessionid, $kp3)){                                                                        
     54                                return true; 
     55                        } 
     56                        else{ 
     57                                $this-> error = Errors::get(Errors::LOGIN_AUTH_INVALID); 
     58                                return false; 
     59                        } 
    5460                } 
    5561                else{ 
    56                         $this-> error = "You are not logged in"; 
     62                        $this-> error = Errors::get(Errors::LOGIN_NOT_LOGGED_IN); 
    5763                        return false; 
    5864                }                
     
    6773                if(!$this-> isLoggedIn($params))  
    6874                {                                
    69                         if($params['auth'] != "")  
    70                         {        
    71                                 $this->error  = "Your auth is invalid"; 
    72                                  
    73                         } 
    74                         elseif($sessionid = $GLOBALS['phpgw']->session->create($params['user'], $params['password']))                                    
     75                        if($sessionid = $GLOBALS['phpgw']->session->create($params['user'], $params['password']))                                        
    7576                        { 
    7677                                $this->error  = null; 
     
    8283                        else 
    8384                        {                                
    84                                 $this-> error = $GLOBALS['phpgw']->session->reason; 
     85                                $this-> error = Errors::get($GLOBALS['phpgw']->session->cd_reason); 
    8586                        }                        
    8687                } 
  • sandbox/webservice/api/library/HttpRequest.php

    r5595 r5954  
    33* Access the HTTP Request  
    44*/   
    5 class http_request {   
     5class HttpRequest {   
    66   
    77    /** additional HTTP headers not prefixed with HTTP_ in $_SERVER superglobal */   
     
    1313    * @param Array Additional Headers to retrieve  
    1414    */   
    15     function http_request($add_headers = false) {   
     15    function HttpRequest($add_headers = false) {   
    1616       
    1717        $this->retrieve_headers($add_headers);   
  • sandbox/webservice/api/webservice.php

    r5687 r5954  
    11<?php 
    2 include_once("http_request.class.php"); 
    32 
    43$public_functions = array( 
     
    2221 
    2322include_once('../header.inc.php'); 
     23include_once("./library/HttpRequest.php"); 
     24include_once("./library/Errors.php"); 
    2425 
    2526// NO COOKIES!!!! 
     
    3839        if(empty($request)) { 
    3940                $request = array(); 
    40                 $http_request = new http_request(); 
     41                $http_request = new HttpRequest(); 
    4142                $content_type = $http_request->header('Content-Type'); 
    4243                $accept = $http_request->header('Accept'); 
Note: See TracChangeset for help on using the changeset viewer.