Changeset 7489 for sandbox


Ignore:
Timestamp:
11/01/12 10:35:51 (11 years ago)
Author:
alexandrecorreia
Message:

Ticket #2507 - Emparelhando os codigos do servidor de produção com o sandbox.

Location:
sandbox/webservice/api
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • sandbox/webservice/api/adapters/CalendarAdapter.php

    r7465 r7489  
    1919        } 
    2020 
    21         protected function getEvents( $month, $year ) 
     21        protected function getEvents($month, $year) 
    2222        { 
    2323                $bo = CreateObject('calendar.bocalendar',1); 
  • sandbox/webservice/api/adapters/CatalogAdapter.php

    r7465 r7489  
    9393                $params = array ("search_for" => $search); 
    9494                $result = $this->getLdapCatalog()->quicksearch($params); 
    95                 // Reconnect for searching other attributes. 
    96                 $this->getLdapCatalog()->ldapConnect(true); 
    97                 foreach($result as $i => $row) { 
    98                         if(is_int($i)) { 
    99                                 $contacts[$i] = array( 
    100                                         'contactMails'  => array($result[$i]['mail']), 
    101                                         'contactPhones' => array($result[$i]['phone']), 
    102                                         'contactAlias' => "",                                    
    103                                         'contactFullName'       => ($result[$i]['cn'] != null ? mb_convert_encoding($row['cn'],"UTF8", "ISO_8859-1") : ""), 
    104                                         'contactBirthDate'      => "", 
    105                                         'contactNotes'          => "" 
    106                                 ); 
    107                                 // Buscar atributos faltantes.  
    108                                 $otherAttrs = $this->getUserLdapAttrs($result[$i]['mail']); 
    109                                 if(is_array($otherAttrs)) 
    110                                         $contacts[$i] = array_merge($otherAttrs, $contacts[$i]);                                 
     95                 
     96                if ( array_key_exists('error', $result)) 
     97                { 
     98                        Errors::runException("CATALOG_MANY_RESULTS"); 
     99                } 
     100                else 
     101                { 
     102                        // Reconnect for searching other attributes. 
     103                        $this->getLdapCatalog()->ldapConnect(true); 
     104                        foreach($result as $i => $row) { 
     105                                if(is_int($i)) { 
     106                                        $contacts[$i] = array( 
     107                                                'contactMails'  => array($result[$i]['mail']), 
     108                                                'contactPhones' => array($result[$i]['phone']), 
     109                                                'contactAlias' => "",                                    
     110                                                'contactFullName'       => ($result[$i]['cn'] != null ? mb_convert_encoding($row['cn'],"UTF8", "ISO_8859-1") : ""), 
     111                                                'contactBirthDate'      => "", 
     112                                                'contactNotes'          => "" 
     113                                        ); 
     114                                        // Buscar atributos faltantes.  
     115                                        $otherAttrs = $this->getUserLdapAttrs($result[$i]['mail']); 
     116                                        if(is_array($otherAttrs)) 
     117                                                $contacts[$i] = array_merge($otherAttrs, $contacts[$i]);                                 
     118                                } 
    111119                        } 
    112                 } 
    113                 // Force ldap close 
    114                 ldap_close($this->getLdapCatalog()->ds);                 
    115                 if( count($contacts) ) 
    116                 { 
    117                         $result = array ('contacts' => $contacts); 
    118                         $this->setResult($result); 
    119                         return $this->getResponse(); 
    120                 } 
    121                 else 
    122                 { 
    123                         Errors::runException("CATALOG_NO_RESULTS"); 
    124                 } 
     120                        // Force ldap close 
     121                        ldap_close($this->getLdapCatalog()->ds);                 
     122                        if( count($contacts) ) 
     123                        { 
     124                                $result = array ('contacts' => $contacts); 
     125                                $this->setResult($result); 
     126                                return $this->getResponse(); 
     127                        } 
     128                        else 
     129                        { 
     130                                Errors::runException("CATALOG_NO_RESULTS"); 
     131                        } 
     132                } 
    125133        } 
    126134} 
  • sandbox/webservice/api/rest/catalog/ContactsResource.php

    r7463 r7489  
    6161                                } 
    6262                        } 
    63                          
    6463                        $result = array ('contacts' => array_values($contacts)); 
    6564                        $this->setResult($result); 
  • sandbox/webservice/api/rest/mail/AddFolderResource.php

    r7469 r7489  
    1111                        $parent_id = empty($parent_id) ? 'INBOX' : $parent_id; 
    1212                        $new_name  = $this->getParam('folderName'); 
    13                         $new_name  = mb_convert_encoding($new_name, "UTF-8", "ISO-8859-1"); 
    14  
     13                        $new_name = mb_convert_encoding($new_name, "UTF-8", "ISO-8859-1"); 
    1514 
    1615                        $all_folders = $this->getImap()->get_folders_list(); 
  • sandbox/webservice/api/rest/mail/DelFolderResource.php

    r7470 r7489  
    88                if($this-> isLoggedIn()) 
    99                { 
    10                         $params['del_past'] = $folder_id = mb_convert_encoding($this->getParam('folderID'),"UTF-8","ISO-8859-1"); 
     10                        $params['del_past'] = $folder_id = mb_convert_encoding($this->getParam('folderID'), "UTF-8","ISO-8859-1"); 
    1111 
    1212                        if(!$this->getImap()->folder_exists(mb_convert_encoding($folder_id, "UTF7-IMAP","UTF-8"))) 
     
    2929                                Errors::runException("MAIL_FOLDER_NOT_EMPTY"); 
    3030 
    31                         // TODO: verificar o que ocorre com o objeto imap nas validações acima. Por algum motivo, recriando o objeto, o método delete_mailbox funciona, mas sem recriar, não funciona. 
     31                        // TODO: verificar o que ocorre com o objeto imap nas validações acima. Por algum motivo, recriando o objeto, o método delete_mailbox funciona, mas sem recriar, não funciona. 
    3232                        $this->imap = null; 
    3333 
  • sandbox/webservice/api/rest/mail/MessagesResource.php

    r7480 r7489  
    1010                if($this-> isLoggedIn())  
    1111                {                                        
    12                         $max_email_per_page = intval($this->getParam('resultsPerPage') ? $this->getParam('resultsPerPage') : 
    13                                         $this->getImap()->prefs['max_email_per_page']); 
    1412 
    1513                        if($this->getParam('folderID') && $this->getParam('msgID') > 0) { 
     
    4240                                        $params = array( 
    4341                                                        'condition' => implode(",",$condition),                                                  
    44                                                         'page'          => ($this->getParam('page') ? intval($this->getParam('page')) - 1 : 0), 
     42                                                        'page'          => (intval($this->getParam('page') ? $this->getParam('page') : "1"))-1, 
    4543                                                        'sort_type' => "SORTDATE" 
    4644                                                ); 
    4745 
    4846                                        $this->getImap()->prefs['preview_msg_subject'] = "1"; 
     47                                        error_log(serialize($params)); 
    4948                                        $imap_msgs = $this->getImap()->search_msg($params); 
    5049 
    51                                         if(!$imap_msgs){ 
    52                                                 return $this->getResponse(); 
    53                                         } 
    5450                                        if($imap_msgs['num_msgs'] > 0) { 
    5551                                                foreach($imap_msgs['data'] as $imap_msg) { 
    5652                                                        $msg = array(); 
    5753                                                        $msg['msgID'] = $imap_msg['uid']; 
    58                                                         $msg['folderID'] = $imap_msg['boxname']; 
     54                                                        $msg['folderID'] = mb_convert_encoding($imap_msg['boxname'],'UTF-8','ISO-8859-1'); 
    5955                                                        $msg['msgDate'] = $imap_msg['udate']." 00:00"; 
    6056                                                        $msg['msgSubject'] = mb_convert_encoding($imap_msg['subject'],"UTF8", "ISO_8859-1"); 
     
    7672                                } 
    7773                                else{ 
    78                                         // TODO: Implementar a pesquisa de mensagens para versão 2.4 
     74                                        // TODO: Implementar a pesquisa de mensagens para verso 2.4 
    7975                                } 
    8076                        } 
    8177                        else{ 
     78                                $max_email_per_page = intval($this->getParam('resultsPerPage') ? $this->getParam('resultsPerPage') : 
     79                                        $this->getImap()->prefs['max_email_per_page']); 
     80         
    8281                                $current_page = intval($this->getParam('page') ? $this->getParam('page') : 1); 
    8382         
     
    8685         
    8786                                $this->getImap()->prefs['preview_msg_subject'] = "1"; 
    88          
    89          
     87 
    9088                                $imap_msgs = $this->getImap()-> get_range_msgs2( 
    9189                                        array(  "folder"                        => $this->getParam('folderID'), 
     
    9997                                        return $this->getResponse(); 
    10098                                } 
    101          
     99 
     100                                $folderID = mb_convert_encoding($this->getParam('folderID'), 'UTF-8','ISO-8859-1'); 
     101 
    102102                                foreach($imap_msgs as $i => $imap_msg) { 
    103103                                        if(!is_int($i)) { 
    104104                                                continue; 
    105105                                        } 
     106                                         
    106107                                        $msg = array(); 
    107108                                        $msg['msgID'] = $imap_msg['msg_number']; 
    108                                         $msg['folderID'] =  $imap_msgs['folder']; 
     109                                        $msg['folderID'] = $folderID; 
     110 
    109111                                        $msg['msgDate'] = gmdate('d/m/Y H:i', $imap_msg['timestamp']); 
    110112                                        $msg['msgFrom']['fullName'] = mb_convert_encoding($imap_msg['from']['name'],"UTF8", "ISO_8859-1"); 
     
    153155                        } 
    154156                } 
    155                 $num_msgs  = 0; 
    156                 $num_pages = 1;          
    157                 $num_msgs = intval($imap_msgs['num_msgs']); 
    158                 if($num_msgs > $max_email_per_page) { 
    159                         $num_pages = $num_msgs / $max_email_per_page; 
    160                         if($num_pages > intval($num_pages)) 
    161                                 $num_pages = intval($num_pages) + 1; 
    162                 } 
    163                  
    164157                $result = array ( 
    165158                                'messages'        => $all_msgs, 
    166                                 'numMessages' => $num_msgs, 
    167                                 'numPages'        => $num_pages, 
    168159                                'timeZone'        => $imap_msgs['offsetToGMT'] ? $imap_msgs['offsetToGMT'] : "", 
    169160                                'totalUnseen' => $imap_msgs['tot_unseen'] ? $imap_msgs['tot_unseen'] : "" 
  • sandbox/webservice/api/rest/mail/RenameFolderResource.php

    r7469 r7489  
    88                if($this-> isLoggedIn()) 
    99                { 
    10                         $old_id   = mb_convert_encoding($this->getParam('folderID'), "UTF-8", "ISO-8859-1"); 
     10                        $old_id  = mb_convert_encoding($this->getParam('folderID'), "UTF-8", "ISO-8859-1"); 
    1111                        $new_name = mb_convert_encoding($this->getParam('folderName'), "UTF-8", "ISO-8859-1"); 
    1212 
    13                         if(!$this->getImap()->folder_exists( mb_convert_encoding($old_id, "UTF7-IMAP", "UTF-8"))) 
     13                        if(!$this->getImap()->folder_exists(mb_convert_encoding($old_id, "UTF7-IMAP", "UTF-8"))) 
    1414                                Errors::runException("MAIL_INVALID_OLD_FOLDER"); 
    15  
     15  
    1616                        $default_folders = array_keys($this->defaultFolders); 
    1717                        if(in_array($old_id, $default_folders)) 
Note: See TracChangeset for help on using the changeset viewer.