[RCU] Vacation responder issue

omar.crea at thyme.it omar.crea at thyme.it
Wed Feb 18 15:37:51 CET 2009

Hi all, 
I want to add a vacation responder (i.e. the possibility to save a string 
to my db representing the text to display when the user set the
on) to my Roundcube installation. 
I find some examples of vacation plugins on the forum, but they are 
not as I want it: I need a plugin that uses only Roundcube and read/write 
the text message of the responder from/to a db. (while the other responders

use cPanel or COM or others...)

I tried to implement the plugin basing my code on the changepasswd plugin

The problem is that using this code I cannot show the current value of the
responder text on the browser page, while I'm able to change it in the db. 

Here is what I tried to write:

--- File program/steps/settings/vacationresp.inc --- (new)
$OUTPUT->add_handler('vacationresp', 'rcmail_vacationresp_form');
// $OUTPUT->include_script('vacationresp.js');

function rcmail_vacationresp_form($attrib) {
    list($form_start, $form_end) = get_form_tags($attrib,
    // return the complete edit form as table
    $out = $form_start;
    $table = new html_table(array('cols' => 2));

    if (!isset($no_override['curvacation']))
        $field_id = 'rcmfd_curvac';
        //$input_curvac = new html_textarea(array('name' => '_curvacation',
'id' => $field_id));
        $input_curvac = new html_textarea(array('name' => '_curvacation',
'id' => $field_id, 'size' => 40));

        $table->add('title', html::label($field_id,
        //$table->add(null, $input_curvac->show());
        $table->add(null, $input_curvac->show('_vacation'));
        // $table->add(null, $input_curvac->show($show_vacation));
    $out .= $table->show($attrib);
    $out .= $form_end;

    return $out;

--- File program/steps/settings/save_vacationresp.inc --- (new)

$old_vac = $_POST['_curvacation'];
$sql_select = str_replace(array('%u'), 
$sql_update = str_replace(array('%u', '%o'), 
                array($_SESSION['username'], $old_vac),
$user_db = new rcube_mdb2($vacationresp_config['db_dsnw'],
$vacationresp_config['db_dsnr'], $vacationresp_config['db_persistent']);

if ($err_str = $user_db->is_error()) {
    'code' => 603,
    'type' => 'db',
    'message' => $err_str), FALSE, TRUE);

if ($user_db->num_rows() == 1) {
    $updated = false;
    $updated = $user_db->query($sql_update);

    if ($updated) {
        $OUTPUT->show_message('vacationchanged', 'confirmation');
    else {
        $OUTPUT->show_message('vacationfailed', 'error');
else {
    $OUTPUT->show_message('vacationfailed', 'error');

--- File program/js/app.js --- (modified)
      case 'settings':
        this.enable_command('preferences', 'identities', 'save', 'folders',
'changepasswd', 'vacationresp', true);

        if (this.env_action='vacationresp')
          this.enable_command('save_vacationresp', true);

      case 'vacationresp':

      case 'save_vacationresp':

--- File program/plugins/vacationresp/config.inc.php --- (new)
$vacationresp_config = array();
$vacationresp_config['db_dsnw'] =
$vacationresp_config['db_dsnr'] = ''; 
$vacationresp_config['db_persistent'] = FALSE;
$vacationresp_config['sql_select'] = "SELECT username FROM users WHERE
username = '%u';";
$vacationresp_config['sql_update'] = "UPDATE users SET vacation = '%o'
WHERE username = '%u';";

--- File program/plugins/vacationresp/vacationresp.php
class vacationresp extends rcube_plugin
    function init()
        // preperation for Plugin API
        // not used yet

--- File skins/default/templates/vacationresp.html --- (new)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml">
<title><roundcube:object name="pagetitle" /></title>
<roundcube:include file="/includes/links.html" />
<link rel="stylesheet" type="text/css" href="/settings.css" />
<script type="text/javascript" src="/functions.js"></script>
<body onload="rcube_init_settings_tabs()">
<roundcube:include file="/includes/taskbar.html" />
<roundcube:include file="/includes/header.html" />
<roundcube:include file="/includes/settingstabs.html" />
<div id="userprefs-box">
<div id="userprefs-title"><roundcube:label name="vacation" /></div>
<div style="padding:15px 0 15px 15px">
<roundcube:object name="vacationresp" />
<div style="clear:left"></div>    
<p id="listbuttons"><roundcube:button command="save_vacationresp"
type="input" class="button mainaction" label="save" /></p>    

--- File skins/default/includes/settingstabs.html --- (modified)
<span id="settingstabvacationresp" class="tablink"><roundcube:button
command="vacationresp" type="link" label="vacation" title="vacationresp"
class="tablink" /></span>

Someone knows how to pass the current vacation text value to the showed
Thanks in advance. 

List info: http://lists.roundcube.net/users/

More information about the users mailing list