Revision 7489,
1.2 KB
checked in by alexandrecorreia, 12 years ago
(diff) |
Ticket #2507 - Emparelhando os codigos do servidor de produção com o sandbox.
|
-
Property svn:executable set to
*
|
Rev | Line | |
---|
[6155] | 1 | <?php |
---|
| 2 | |
---|
| 3 | class 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'); |
---|
[7489] | 13 | $new_name = mb_convert_encoding($new_name, "UTF-8", "ISO-8859-1"); |
---|
[6155] | 14 | |
---|
[6166] | 15 | $all_folders = $this->getImap()->get_folders_list(); |
---|
| 16 | if(!$all_folders){ |
---|
| 17 | return $this->getResponse(); |
---|
| 18 | } |
---|
| 19 | |
---|
| 20 | $max_folders = $this->getImap()->prefs['imap_max_folders']; |
---|
| 21 | if(count($all_folders) == $max_folders) |
---|
| 22 | Errors::runException("MAIL_FOLDER_LIMIT_REACHED"); |
---|
| 23 | |
---|
[6155] | 24 | if(empty($new_name) || preg_match('/[\/\\\!\@\#\$\%\&\*\(\)]/', $new_name)) |
---|
[6165] | 25 | Errors::runException("MAIL_INVALID_NEW_FOLDER_NAME"); |
---|
[6155] | 26 | |
---|
| 27 | $new_id = $parent_id . $this->getImap()->imap_delimiter . $new_name; |
---|
| 28 | |
---|
| 29 | $params['newp'] = $new_id; |
---|
| 30 | |
---|
| 31 | $result = $this->getImap()->create_mailbox($params); |
---|
| 32 | if($result != 'Ok') |
---|
[6165] | 33 | Errors::runException("MAIL_FOLDER_NOT_ADDED"); |
---|
[6155] | 34 | } |
---|
| 35 | |
---|
| 36 | $this->setResult(array('folderID' => $new_id)); |
---|
| 37 | |
---|
| 38 | //to Send Response (JSON RPC format) |
---|
| 39 | return $this->getResponse(); |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.