Changeset 7859 for sandbox


Ignore:
Timestamp:
02/05/13 17:22:09 (11 years ago)
Author:
alexandrecorreia
Message:

Ticket #2507 - Correções dos retornos, padronização das variáveis

Location:
sandbox/webservice/api/rest
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • sandbox/webservice/api/rest/admin/CreateUserResource.php

    r7813 r7859  
    132132                                } 
    133133 
    134                                 $this->setResult( array( "result" => true ) ); 
     134                                $this->setResult( array( "createUser" => true ) ); 
    135135                        } 
    136136                        else 
  • sandbox/webservice/api/rest/admin/DeleteUserResource.php

    r7814 r7859  
    4242                                } 
    4343 
    44                                 $this->setResult( array( "result" => true ) ); 
     44                                $this->setResult( array( "deleteUser" => true ) ); 
    4545                        } 
    4646                        else 
  • sandbox/webservice/api/rest/admin/EditUserResource.php

    r7814 r7859  
    4343                                        $return['accountDescription']   = $fields['corporative_information_description']; 
    4444                                         
    45                                         $this->setResult( array( "result" => $return )); 
     45                                        $this->setResult( array( "editUser" => $return )); 
    4646                                } 
    4747                                else 
  • sandbox/webservice/api/rest/admin/RenameUserResource.php

    r7813 r7859  
    6666 
    6767 
    68                                 $this->setResult( array( "result" => true ) ); 
     68                                $this->setResult( array( "renameUser" => true ) ); 
    6969                        } 
    7070                        else 
  • sandbox/webservice/api/rest/admin/SearchUserResource.php

    r7813 r7859  
    2828                                $list = $this->listUsers( $searchUser ); 
    2929 
     30                                $user = array(); 
     31 
     32                                foreach( $list as $_u ) 
     33                                { 
     34                                        $user['accountId']              = $_u['account_id']; 
     35                                        $user['accountLid']             = $_u['account_lid']; 
     36                                        $user['accountCn']              = $_u['account_cn']; 
     37                                        $user['accountMail']    = $_u['account_mail']; 
     38                                } 
     39 
    3040                                if( count($list) > 0 ) 
    3141                                { 
    32                                         $this->setResult( array( "result" => $list ) ); 
     42                                        $this->setResult( array( "searchUser" => $user ) ); 
    3343                                } 
    3444                                else 
  • sandbox/webservice/api/rest/catalog/ContactsResource.php

    r7489 r7859  
    1212                                $search = trim($this->getParam('search')); 
    1313                                $search = ($search ? mb_convert_encoding($search,"ISO_8859-1", "UTF8") : ""); 
    14                                  
     14                                $contactID = $this->getParam('contactID'); 
     15 
     16                                $search_string = "%$search%"; 
     17 
     18                                $arr_params = array(); 
     19 
    1520                                if($this->getParam('contactType') == 1) { 
    16                                         if($search != "") { 
    17                                                 $query_contact = "(A.alias ilike '%$search%' or A.names_ordered ilike '%$search%' or C.connection_value ilike '%$search%') and"; 
     21                                        if($search != "") {      
     22                                                $arr_params[] = $search_string; 
     23                                                $arr_params[] = $search_string; 
     24                                                $arr_params[] = $search_string; 
     25                                                $query_contact = "(A.alias ilike ? or A.names_ordered ilike ? or C.connection_value ilike ?) and"; 
    1826                                        } 
    1927                                        elseif($this->getParam('contactID') > 0){ 
    20                                                 $query_contact = 'A.id_contact='.$this->getParam('contactID').' and'; 
     28                                                $arr_params[] = $contactID; 
     29                                                $query_contact = "A.id_contact = ? and "; 
    2130                                        } 
    2231                                } 
    2332                                elseif($this->getParam('contactType') == 2){ 
    2433                                        if($this-> getMinArgumentSearch() <= strlen($search)) 
    25                                                 return $this->getGlobalContacts($search, $this->getParam('contactID')); 
     34                                                return $this->getGlobalContacts($search, $contactID ); 
    2635                                        else{ 
    2736                                                Errors::runException("CATALOG_MIN_ARGUMENT_SEARCH", $this-> getMinArgumentSearch()); 
     
    2938                                } 
    3039                        } 
     40 
     41                        //ADICIONA O ID_OWNER  
     42                        $arr_params[] = $this->getUserId(); 
    3143                 
    32                         $query = 'select B.id_typeof_contact_connection, A.photo, A.id_contact, A.alias, A.given_names, A.family_names, A.names_ordered, A.birthdate, A.notes, C.connection_value from phpgw_cc_contact A, '. 
    33                                         'phpgw_cc_contact_conns B, phpgw_cc_connections C where A.id_contact = B.id_contact and B.id_connection = C.id_connection '. 
    34                                         ' and '.$query_contact.' A.id_owner='.$this -> getUserId().' group by '. 
    35                                         ' B.id_typeof_contact_connection, A.photo, A.id_contact, A.alias, A.given_names, A.family_names,A.names_ordered,A.birthdate, A.notes,C.connection_value order by lower(A.names_ordered)'; 
    36                  
    37                         if (!$this->getDb()->query($query)) 
    38                                 return false; 
    39                  
     44                        $query = 'select  
     45                                                  B.id_typeof_contact_connection,  
     46                                                  A.photo,  
     47                                                  A.id_contact,  
     48                                                  A.alias,  
     49                                                  A.given_names,  
     50                                                  A.family_names,  
     51                                                  A.names_ordered,  
     52                                                  A.birthdate,  
     53                                                  A.notes,  
     54                                                  C.connection_value  
     55                                                from  
     56                                                        phpgw_cc_contact A,  
     57                                                        phpgw_cc_contact_conns B,  
     58                                                        phpgw_cc_connections C  
     59                                                where  
     60                                                        A.id_contact = B.id_contact and  
     61                                                        B.id_connection = C.id_connection and  
     62                                                        '.$query_contact.'  
     63                                                        A.id_owner = ? 
     64                                        group by  
     65                                                B.id_typeof_contact_connection,  
     66                                                A.photo,  
     67                                                A.id_contact,  
     68                                                A.alias,  
     69                                                A.given_names, 
     70                                                A.family_names, 
     71                                                A.names_ordered, 
     72                                                A.birthdate, 
     73                                                A.notes, 
     74                                                C.connection_value       
     75                                        order by  
     76                                                lower(A.names_ordered)'; 
     77 
     78                        $resQuery = $this->getDb()->Link_ID->query($query,$arr_params); 
     79 
    4080                        $contacts = array(); 
    41                         while($this->getDb()->next_record()) { 
    42                                 $row = $this->getDb()->row(); 
     81                        while($row = $resQuery->fetchRow()) { 
     82 
    4383                                $id = $row['id_contact']; 
    4484                                $contactType = ($row['id_typeof_contact_connection'] == 2 ? 'contactPhones' : 'contactMails'); 
    45                  
     85 
    4686                                if($contacts[$id] != null){ 
    4787                                        $contacts[$id][$contactType][] = $row['connection_value']; 
     
    61101                                } 
    62102                        } 
    63                         $result = array ('contacts' => array_values($contacts)); 
     103 
     104                        $result = array ( 'contacts' => array_values($contacts)); 
    64105                        $this->setResult($result); 
    65106                } 
  • sandbox/webservice/api/rest/dispatch.php

    r7855 r7859  
    11<?php 
    22 
    3 define('API_DIRECTORY','/var/www/expresso/api/rest', True); 
     3define('API_DIRECTORY','/var/www/expresso_22/api/rest', True); 
    44 
    55// load libraries 
Note: See TracChangeset for help on using the changeset viewer.