source: sandbox/webservice/api/rest/mail/AddFolderResource.php @ 6165

Revision 6165, 854 bytes checked in by niltonneto, 12 years ago (diff)

Ticket #2507 - Refatorado e centralizado tratamento de Erros.

  • Property svn:executable set to *
Line 
1<?php
2
3class AddFolderResource 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                        $parent_id = $this->getParam('parentFolderID');
11                        $parent_id = empty($parent_id) ? 'INBOX' : $parent_id;
12                        $new_name  = $this->getParam('folderName');
13
14                        if(empty($new_name) || preg_match('/[\/\\\!\@\#\$\%\&\*\(\)]/', $new_name))
15                                Errors::runException("MAIL_INVALID_NEW_FOLDER_NAME");
16
17                        $new_id = $parent_id . $this->getImap()->imap_delimiter . $new_name;
18
19                        $params['newp'] = $new_id;
20
21                        $result = $this->getImap()->create_mailbox($params);
22                        if($result != 'Ok')
23                                Errors::runException("MAIL_FOLDER_NOT_ADDED");
24                }
25
26                $this->setResult(array('folderID' => $new_id));
27
28                //to Send Response (JSON RPC format)
29                return $this->getResponse();
30        }
31
32}
Note: See TracBrowser for help on using the repository browser.