- Timestamp:
- 11/01/12 10:35:51 (11 years ago)
- Location:
- sandbox/webservice/api
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/webservice/api/adapters/CalendarAdapter.php
r7465 r7489 19 19 } 20 20 21 protected function getEvents( $month, $year)21 protected function getEvents($month, $year) 22 22 { 23 23 $bo = CreateObject('calendar.bocalendar',1); -
sandbox/webservice/api/adapters/CatalogAdapter.php
r7465 r7489 93 93 $params = array ("search_for" => $search); 94 94 $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 } 111 119 } 112 }113 // Force ldap close114 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 else122 {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 } 125 133 } 126 134 } -
sandbox/webservice/api/rest/catalog/ContactsResource.php
r7463 r7489 61 61 } 62 62 } 63 64 63 $result = array ('contacts' => array_values($contacts)); 65 64 $this->setResult($result); -
sandbox/webservice/api/rest/mail/AddFolderResource.php
r7469 r7489 11 11 $parent_id = empty($parent_id) ? 'INBOX' : $parent_id; 12 12 $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"); 15 14 16 15 $all_folders = $this->getImap()->get_folders_list(); -
sandbox/webservice/api/rest/mail/DelFolderResource.php
r7470 r7489 8 8 if($this-> isLoggedIn()) 9 9 { 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"); 11 11 12 12 if(!$this->getImap()->folder_exists(mb_convert_encoding($folder_id, "UTF7-IMAP","UTF-8"))) … … 29 29 Errors::runException("MAIL_FOLDER_NOT_EMPTY"); 30 30 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. 32 32 $this->imap = null; 33 33 -
sandbox/webservice/api/rest/mail/MessagesResource.php
r7480 r7489 10 10 if($this-> isLoggedIn()) 11 11 { 12 $max_email_per_page = intval($this->getParam('resultsPerPage') ? $this->getParam('resultsPerPage') :13 $this->getImap()->prefs['max_email_per_page']);14 12 15 13 if($this->getParam('folderID') && $this->getParam('msgID') > 0) { … … 42 40 $params = array( 43 41 '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, 45 43 'sort_type' => "SORTDATE" 46 44 ); 47 45 48 46 $this->getImap()->prefs['preview_msg_subject'] = "1"; 47 error_log(serialize($params)); 49 48 $imap_msgs = $this->getImap()->search_msg($params); 50 49 51 if(!$imap_msgs){52 return $this->getResponse();53 }54 50 if($imap_msgs['num_msgs'] > 0) { 55 51 foreach($imap_msgs['data'] as $imap_msg) { 56 52 $msg = array(); 57 53 $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'); 59 55 $msg['msgDate'] = $imap_msg['udate']." 00:00"; 60 56 $msg['msgSubject'] = mb_convert_encoding($imap_msg['subject'],"UTF8", "ISO_8859-1"); … … 76 72 } 77 73 else{ 78 // TODO: Implementar a pesquisa de mensagens para vers ão 2.474 // TODO: Implementar a pesquisa de mensagens para verso 2.4 79 75 } 80 76 } 81 77 else{ 78 $max_email_per_page = intval($this->getParam('resultsPerPage') ? $this->getParam('resultsPerPage') : 79 $this->getImap()->prefs['max_email_per_page']); 80 82 81 $current_page = intval($this->getParam('page') ? $this->getParam('page') : 1); 83 82 … … 86 85 87 86 $this->getImap()->prefs['preview_msg_subject'] = "1"; 88 89 87 90 88 $imap_msgs = $this->getImap()-> get_range_msgs2( 91 89 array( "folder" => $this->getParam('folderID'), … … 99 97 return $this->getResponse(); 100 98 } 101 99 100 $folderID = mb_convert_encoding($this->getParam('folderID'), 'UTF-8','ISO-8859-1'); 101 102 102 foreach($imap_msgs as $i => $imap_msg) { 103 103 if(!is_int($i)) { 104 104 continue; 105 105 } 106 106 107 $msg = array(); 107 108 $msg['msgID'] = $imap_msg['msg_number']; 108 $msg['folderID'] = $imap_msgs['folder']; 109 $msg['folderID'] = $folderID; 110 109 111 $msg['msgDate'] = gmdate('d/m/Y H:i', $imap_msg['timestamp']); 110 112 $msg['msgFrom']['fullName'] = mb_convert_encoding($imap_msg['from']['name'],"UTF8", "ISO_8859-1"); … … 153 155 } 154 156 } 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 164 157 $result = array ( 165 158 'messages' => $all_msgs, 166 'numMessages' => $num_msgs,167 'numPages' => $num_pages,168 159 'timeZone' => $imap_msgs['offsetToGMT'] ? $imap_msgs['offsetToGMT'] : "", 169 160 'totalUnseen' => $imap_msgs['tot_unseen'] ? $imap_msgs['tot_unseen'] : "" -
sandbox/webservice/api/rest/mail/RenameFolderResource.php
r7469 r7489 8 8 if($this-> isLoggedIn()) 9 9 { 10 $old_id 10 $old_id = mb_convert_encoding($this->getParam('folderID'), "UTF-8", "ISO-8859-1"); 11 11 $new_name = mb_convert_encoding($this->getParam('folderName'), "UTF-8", "ISO-8859-1"); 12 12 13 if(!$this->getImap()->folder_exists( 13 if(!$this->getImap()->folder_exists(mb_convert_encoding($old_id, "UTF7-IMAP", "UTF-8"))) 14 14 Errors::runException("MAIL_INVALID_OLD_FOLDER"); 15 15 16 16 $default_folders = array_keys($this->defaultFolders); 17 17 if(in_array($old_id, $default_folders))
Note: See TracChangeset
for help on using the changeset viewer.