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

Revision 7469, 1.2 KB checked in by alexandrecorreia, 12 years ago (diff)

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

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