1<?php 2 3/** 4 +-----------------------------------------------------------------------+ 5 | This file is part of the Roundcube Webmail client | 6 | | 7 | Copyright (C) The Roundcube Dev Team | 8 | | 9 | Licensed under the GNU General Public License version 3 or | 10 | any later version with exceptions for skins & plugins. | 11 | See the README file for a full license statement. | 12 | | 13 | PURPOSE: | 14 | Handler for folder subscribe action | 15 +-----------------------------------------------------------------------+ 16 | Author: Thomas Bruederli <roundcube@gmail.com> | 17 | Author: Aleksander Machniak <alec@alec.pl> | 18 +-----------------------------------------------------------------------+ 19*/ 20 21class rcmail_action_settings_folder_subscribe extends rcmail_action 22{ 23 protected static $mode = self::MODE_AJAX; 24 25 /** 26 * Request handler. 27 * 28 * @param array $args Arguments from the previous step(s) 29 */ 30 public function run($args = []) 31 { 32 $rcmail = rcmail::get_instance(); 33 $storage = $rcmail->get_storage(); 34 $mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST, true); 35 36 if (strlen($mbox)) { 37 $result = $storage->subscribe([$mbox]); 38 39 // Handle virtual (non-existing) folders 40 if ( 41 !$result 42 && $storage->get_error_code() == -1 43 && $storage->get_response_code() == rcube_storage::TRYCREATE 44 ) { 45 $result = $storage->create_folder($mbox, true); 46 if ($result) { 47 // @TODO: remove 'virtual' class of folder's row 48 } 49 } 50 } 51 52 if (!empty($result)) { 53 // Handle subscription of protected folder (#1487656) 54 if ($rcmail->config->get('protect_default_folders') && $storage->is_special_folder($mbox)) { 55 $rcmail->output->command('disable_subscription', $mbox); 56 } 57 58 $rcmail->output->show_message('foldersubscribed', 'confirmation'); 59 } 60 else { 61 self::display_server_error('errorsaving'); 62 $rcmail->output->command('reset_subscription', $mbox, false); 63 } 64 65 $rcmail->output->send(); 66 } 67} 68