Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vacation activation/end date support #26

Open
nerijus opened this issue Oct 1, 2014 · 4 comments
Open

vacation activation/end date support #26

nerijus opened this issue Oct 1, 2014 · 4 comments

Comments

@nerijus
Copy link

nerijus commented Oct 1, 2014

postfixadmin-2.91 supports "ability to choose activation date, end date and reply interval for vacation message". Does rc-vacation plugin support it?

@wpoely86
Copy link
Contributor

wpoely86 commented Oct 2, 2014

@nerijus Have you looked at contrib/postfix-schema.sql ?

@nerijus
Copy link
Author

nerijus commented Oct 2, 2014

I've looked now and made a diff against the latest pfadmin schema:

--- postfix-schema.sql  2014-10-02 13:19:11.476977392 +0300
+++ vacation.sql    2014-10-02 13:18:54.478977096 +0300
@@ -1,11 +1,13 @@
 CREATE TABLE IF NOT EXISTS `vacation` (
   `email` varchar(255) NOT NULL,
   `subject` varchar(255) CHARACTER SET utf8 NOT NULL,
   `body` text CHARACTER SET utf8 NOT NULL,
+  `activefrom` timestamp NOT NULL DEFAULT '1999-12-31 22:00:00',
+  `activeuntil` timestamp NOT NULL DEFAULT '1999-12-31 22:00:00',
   `cache` text NOT NULL,
   `domain` varchar(255) NOT NULL,
+  `interval_time` int(11) NOT NULL DEFAULT '0',
   `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
-  `active` tinyint(1) NOT NULL DEFAULT '1',
-  PRIMARY KEY (`email`),
-  KEY `email` (`email`)
+  `modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  `active` tinyint(1) NOT NULL DEFAULT '1'
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Postfix Admin - Virtual Vacation';

Is it possible to add support for modifying activefrom and activeuntil?

@nightah
Copy link

nightah commented Mar 15, 2016

The values are generated in php as Unix time, however Postfix requires them in 'YYYY-MM-DD HH:MM:SS' format.

Below the write query is converted to the required format for Postfix to store and action.
The read query needs to be converted back to Unix time so when you are interacting with the jquery calendar you get the stored time (if it exists) as opposed to a time of '01-01-1970' in the widget.

Change the following sections in your config.inc.php:

// read data queries
$rcmail_config['vacation_sql_read'] =
// MySQL
array(
"SELECT
subject AS vacation_subject,
body AS vacation_message,
active AS vacation_enable,
UNIX_TIMESTAMP(activefrom) AS vacation_start,
UNIX_TIMESTAMP(activeuntil) AS vacation_end
FROM vacation
WHERE email=%username AND domain=%email_domain;"
);

// write data queries
$rcmail_config['vacation_sql_write'] =
// MySQL
array(
"DELETE FROM vacation WHERE email=%email AND domain=%email_domain;",
"INSERT INTO vacation (email,domain,subject,body,created,active,activefrom,activeuntil)
VALUES (%email,%email_domain,%vacation_subject,%vacation_message,NOW(),%vacation_enable,FROM_UNIXTIME(%vacation_start, '%Y-%m-%d 00:00:00'),FROM_UNIXTIME(%vacation_end, '%Y-%m-%d 23:59:59'));",

@nightah nightah mentioned this issue Mar 15, 2016
@nerijus
Copy link
Author

nerijus commented Feb 22, 2021

Thank you, it worked after I added 'cache' field which is a leftover from 2.2 (see https://sourceforge.net/p/postfixadmin/bugs/345/).
The diff looks like this:

-                       activefrom AS vacation_start,
-                       activeuntil AS vacation_end
+                       UNIX_TIMESTAMP(activefrom) AS vacation_start,
+                       UNIX_TIMESTAMP(activeuntil) AS vacation_end

                        "DELETE FROM vacation WHERE email=%email AND domain=%email_domain;",
-                       "INSERT INTO vacation (email,domain,subject,body,created,active,activefrom,activeuntil)
-                               VALUES (%email,%email_domain,%vacation_subject,%vacation_message,NOW(),%vacation_enable,%vacation_start,%vacation_end);",
+                       "INSERT INTO vacation (email,domain,subject,body,created,active,activefrom,activeuntil,cache)
+                               VALUES (%email,%email_domain,%vacation_subject,%vacation_message,NOW(),%vacation_enable,FROM_UNIXTIME(%vacation_start, '%Y-%m-%d 00:00:00'),FROM_UNIXTIME(%vacation_end, '%Y-%m-%d 23:59:59'),'');",

                        "DELETE from vacation_notification WHERE on_vacation=%email;",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants