Revision 7342,
1.5 KB
checked in by alexandrecorreia, 12 years ago
(diff) |
Ticket #3093 - Integrando API Rest(CELEPAR) com o ramo Trunk.
|
Rev | Line | |
---|
[7342] | 1 | <?php |
---|
| 2 | |
---|
| 3 | class 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 = $this->getParam('folderID'); |
---|
| 11 | |
---|
| 12 | if(!$this->getImap()->folder_exists($folder_id)) |
---|
| 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.