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

Revision 6166, 1.1 KB checked in by asaikawa, 12 years ago (diff)

Ticket #2507 - Tratando erro de limite de pastas na adicao de pasta e correcao paliativa para problema na remocao

  • 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                        $all_folders = $this->getImap()->get_folders_list();
15                        if(!$all_folders){
16                                return $this->getResponse();
17                        }
18
19                        $max_folders = $this->getImap()->prefs['imap_max_folders'];
20                        if(count($all_folders) == $max_folders)
21                                Errors::runException("MAIL_FOLDER_LIMIT_REACHED");
22
23                        if(empty($new_name) || preg_match('/[\/\\\!\@\#\$\%\&\*\(\)]/', $new_name))
24                                Errors::runException("MAIL_INVALID_NEW_FOLDER_NAME");
25
26                        $new_id = $parent_id . $this->getImap()->imap_delimiter . $new_name;
27
28                        $params['newp'] = $new_id;
29
30                        $result = $this->getImap()->create_mailbox($params);
31                        if($result != 'Ok')
32                                Errors::runException("MAIL_FOLDER_NOT_ADDED");
33                }
34
35                $this->setResult(array('folderID' => $new_id));
36
37                //to Send Response (JSON RPC format)
38                return $this->getResponse();
39        }
40
41}
Note: See TracBrowser for help on using the repository browser.