source: sandbox/webservice/api/rest/mail/DelFolderResource.php @ 7470

Revision 7470, 1.5 KB checked in by alexandrecorreia, 11 years ago (diff)

Ticket #2507 - Ajustando os encodings dos parametros para caixa postal.

  • Property svn:executable set to *
Line 
1<?php
2
3class DelFolderResource extends MailAdapter {
4        public function post($request){
5                // to Receive POST Params (use $this->params)
6                parent::post($request);
7
8                if($this-> isLoggedIn())
9                {
10                        $params['del_past'] = $folder_id = mb_convert_encoding($this->getParam('folderID'),"UTF-8","ISO-8859-1");
11
12                        if(!$this->getImap()->folder_exists(mb_convert_encoding($folder_id, "UTF7-IMAP","UTF-8")))
13                                Errors::runException("MAIL_INVALID_FOLDER");
14
15                        $default_folders = array_keys($this->defaultFolders);
16                        if(in_array($folder_id, $default_folders))
17                                Errors::runException("MAIL_CANNOT_DEL_DEFAULT_FOLDER");
18
19                        $personal_folders = $this->getImap()->get_folders_list(array('noSharedFolders' => true, 'folderType' => 'personal'));
20                        if(!$personal_folders){
21                                return $this->getResponse();
22                        }
23                        foreach($personal_folders AS $personal_folder){
24                                if($personal_folder['folder_id'] == $folder_id && $personal_folder['folder_hasChildren'])
25                                        Errors::runException("MAIL_FOLDER_NOT_EMPTY");
26                        }
27
28                        if($this->getImap()->get_num_msgs(array('folder' => $folder_id)) > 0)
29                                Errors::runException("MAIL_FOLDER_NOT_EMPTY");
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.
32                        $this->imap = null;
33
34                        $result = $this->getImap()->delete_mailbox($params);
35                        if($result != 'Ok')
36                                Errors::runException("MAIL_FOLDER_NOT_DELETED");
37                }
38
39                $this->setResult(true);
40
41                //to Send Response (JSON RPC format)
42                return $this->getResponse();
43        }
44
45}
Note: See TracBrowser for help on using the repository browser.