* @version 1.9 * @license GPL * @link https://sourceforge.net/projects/rcubevacation/ * @todo See README.TXT */ // Load required dependencies require 'lib/vacationdriver.class.php'; require 'lib/dotforward.class.php'; require 'lib/vacationfactory.class.php'; require 'lib/VacationConfig.class.php'; class vacation extends rcube_plugin { public $task = 'settings'; private $v = ""; private $inicfg = ""; private $enableVacationTab = true; private $vcObject; public function init() { $this->add_texts('localization/', array('vacation')); $this->load_config(); $this->inicfg = $this->readIniConfig(); // Don't proceed if the current host does not support vacation if (!$this->enableVacationTab) { return false; } $this->v = VacationDriverFactory::Create($this->inicfg['driver']); $this->v->setIniConfig($this->inicfg); $this->register_action('plugin.vacation', array($this, 'vacation_init')); $this->register_action('plugin.vacation-save', array($this, 'vacation_save')); $this->register_handler('plugin.vacation_form', array($this, 'vacation_form')); // The vacation_aliases method is defined in vacationdriver.class.php so use $this->v here $this->register_action('plugin.vacation_aliases', array($this->v, 'vacation_aliases')); $this->include_script('vacation.js'); $this->include_stylesheet($this->local_skin_path().'/vacation.css'); $this->rcmail = rcmail::get_instance(); $this->user = $this->rcmail->user; $this->identity = $this->user->get_identity(); // forward settings are shared by ftp,sshftp and setuid driver. $this->v->setDotForwardConfig($this->inicfg['driver'],$this->vcObject->getDotForwardCfg()); } public function vacation_init() { $this->add_texts('localization/', array('vacation')); $rcmail = rcmail::get_instance(); $rcmail->output->set_pagetitle($this->gettext('autoresponder')); //Load template $rcmail->output->send('vacation.vacation'); } public function vacation_save() { $rcmail = rcmail::get_instance(); // Initialize the driver $this->v->init(); if ($this->v->save()) { // $this->v->getActionText() Dummy for now $rcmail->output->show_message($this->gettext("success_changed"), 'confirmation'); } else { $rcmail->output->show_message($this->gettext("failed"), 'error'); } $this->vacation_init(); } // Parse config.ini and get configuration for current host private function readIniConfig() { $this->vcObject = new VacationConfig(); $this->vcObject->setCurrentHost($_SESSION['imap_host']); $config = $this->vcObject->getCurrentConfig(); if (false !== ($errorStr = $this->vcObject->hasError())) { raise_error(array('code' => 601, 'type' => 'php', 'file' => __FILE__, 'message' => sprintf("Vacation plugin: %s", $errorStr)), true, true); } $this->enableVacationTab = $this->vcObject->hasVacationEnabled(); return $config; } public function vacation_form() { $rcmail = rcmail::get_instance(); // Initialize the driver $this->v->init(); $settings = $this->v->_get(); // Load default body & subject if present. if (empty($settings['subject']) && $defaults = $this->v->loadDefaults()) { $settings['subject'] = $defaults['subject']; $settings['body'] = $defaults['body']; } $rcmail->output->set_env('product_name', $rcmail->config->get('product_name')); // return the complete edit form as table $out = '
\n"; $rcmail->output->add_gui_object('vacationform', 'vacation-form'); return $out; } } ?>