/[smecontribs]/rpms/smeserver-vacation/contribs9/smeserver-vacation-1.1-auto_enable_disable_vacation.patch
ViewVC logotype

Contents of /rpms/smeserver-vacation/contribs9/smeserver-vacation-1.1-auto_enable_disable_vacation.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Fri Sep 4 21:38:24 2015 UTC (9 years, 1 month ago) by stephdl
Branch: MAIN
CVS Tags: smeserver-vacation-1_1-7_el6_sme
* Fri Sep 4 2015 stephane de Labrusse <stephdl@de-labrusse.fr> 1.1-7.sme
- code done by Mats Schuh <m.schuh@neckargeo.net>
- Allow automated enabling and disabling of user vacations on given dates [SME: 7555]
- Above functionality provided by additional db accounts entries and a cron script

1 diff -urN smeserver-vacation-1.1.old/root/etc/cron.d/vacation smeserver-vacation-1.1/root/etc/cron.d/vacation
2 --- smeserver-vacation-1.1.old/root/etc/cron.d/vacation 1970-01-01 01:00:00.000000000 +0100
3 +++ smeserver-vacation-1.1/root/etc/cron.d/vacation 2015-09-04 18:19:50.007131821 +0200
4 @@ -0,0 +1,4 @@
5 +# Check each user account if a vacation message should be enabled
6 +# or disabled based on the given From/To vacation dates
7 +# Do it shortly after midnight on every day
8 +0 01 * * * root /sbin/e-smith/vacation/check_vacation_dates.sh
9 diff -urN smeserver-vacation-1.1.old/root/etc/e-smith/locale/de/etc/e-smith/web/functions/uservacations smeserver-vacation-1.1/root/etc/e-smith/locale/de/etc/e-smith/web/functions/uservacations
10 --- smeserver-vacation-1.1.old/root/etc/e-smith/locale/de/etc/e-smith/web/functions/uservacations 2015-09-04 10:53:45.506912186 +0200
11 +++ smeserver-vacation-1.1/root/etc/e-smith/locale/de/etc/e-smith/web/functions/uservacations 2015-09-04 20:05:53.405096692 +0200
12 @@ -21,7 +21,39 @@
13 </entry>
14 <entry>
15 <base>MODIFY_DESCRIPTION</base>
16 - <trans><![CDATA[ <p> Enter a vacation message here. You can use "$SUBJECT" anywhere in the text to be replaced with the subject line from the email that activated the auto-reply. </p> <p> This message must be composed of two parts separated by a blank line. The first will be integrated into the headings of the email reply, you must thus ensure you leave at least a blank line before typing your message. </p> <p> The primary domain is added to the address automatically, or you can insert a virtual domain. To change the vacation message back to the default type "reset". </p> ]]></trans>
17 + <trans><![CDATA[
18 + <p>
19 + Geben Sie hier eine Abwesenheitsnachricht an. Sie können die Variable "$SUBJECT" an beliebiger Stelle im Nachrichtentext einfügen. An dieser Stelle wird in der generierten Abwsenheitsnachricht der Betreff derjenigen empfangenen Nachricht erscheinen, welche die automatische Abwesenheitsnachricht ausgelöst hat.
20 + </p>
21 + <p>
22 + Der Text der Abwesenheitsnachricht sollte aus zwei Teilen bestehen, die voneinander durch eine Leerzeile getrennt sind.
23 + Der obere Teil wird in den Header der generierten Abwesenheitsnachricht eingefügt.
24 + Vor dem eigentlichen Inhalt der Abwesenheitsnachricht muss also auf jeden Fall eine Leerzeile stehen.
25 + </p>
26 + <p>
27 + Die primäre Domain wird der Absenderadresse automatisch hinzugefügt. Sie können aber im "From:"-Header auch eine virtuelle Domäne verwenden.
28 + Um die Abwesenheitsnachricht auf den Standardtext zurückzusetzen geben Sie bitte "reset" ein.
29 + </p>
30 + <p>
31 + Sie können zusätzlich die entsprechenden Felder ausfüllen, um das Versenden der Abwesenheitsnachricht
32 + für diesen Benutzer-Account zum jeweiligen Datum automatisch zu aktivieren und zu deaktivieren.
33 + </p>
34 + <p>
35 + Bitte verwenden Sie dafür das Format JJJJMMTT (vierstellige Jahreszahl, zweistellige Monatszahl, zweistellige Tageszahl)
36 + und beachten Sie, dass die Sie in die beiden Felder nicht das gleiche Datum eintragen dürfen.
37 + </p>
38 + <p>
39 + Wenn Sie diese Funktionalität verwenden möchten dann belassen Sie den Eintrag "Abwesenheitsnotiz aktivieren" auf "Nein"; die Aktivierung erfolgt dann automatisch am gewünschten Datum.
40 + </p>
41 + ]]></trans>
42 + </entry>
43 + <entry>
44 + <base>VACATION_FROM</base>
45 + <trans>Abwesenheitsnotiz aktivieren am (JJJJMMTT)</trans>
46 + </entry>
47 + <entry>
48 + <base>VACATION_TO</base>
49 + <trans>Abwesenheitsnotiz deaktivieren am (JJJJMMTT)</trans>
50 </entry>
51 <entry>
52 <base>MESSAGE</base>
53 @@ -29,7 +61,7 @@
54 </entry>
55 <entry>
56 <base>VACATION_STATUS</base>
57 - <trans>Abwesenheitsnotiz aktivieren</trans>
58 + <trans>Abwesenheitsnotiz aktiviert</trans>
59 </entry>
60 <entry>
61 <base>FROM</base>
62 diff -urN smeserver-vacation-1.1.old/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/uservacations smeserver-vacation-1.1/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/uservacations
63 --- smeserver-vacation-1.1.old/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/uservacations 2015-09-04 10:53:45.507912125 +0200
64 +++ smeserver-vacation-1.1/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/uservacations 2015-09-04 19:35:46.599092069 +0200
65 @@ -42,10 +42,28 @@
66 "From: user@primary.domain" with "From: user@virtual.domain").
67 To change the vacation message back to the default type "reset".
68 </p>
69 + <p>
70 + You can also fill out the "Enable vacation on" and "Disable vacation on" fields in order to
71 + automatically enable and disable sending of the vacation message for this user account on the given dates.
72 + </p>
73 + <p>
74 + The format used is YYYYMMDD (four digit year, two digit month, two digit day)
75 + and the dates in the two fields must not be the same.
76 + If you want to use this functionality, leave the "Enable vacation messages" setting at "No" - it will be automatically activated based on the date given.
77 + </p>
78 + </p>
79 ]]>
80 </trans>
81 </entry>
82 <entry>
83 + <base>VACATION_FROM</base>
84 + <trans>Enable vacation on (YYYYMMDD)</trans>
85 + </entry>
86 + <entry>
87 + <base>VACATION_TO</base>
88 + <trans>Disable vacation on (YYYYMMDD)</trans>
89 + </entry>
90 + <entry>
91 <base>MESSAGE</base>
92 <trans>Vacation message</trans>
93 </entry>
94 diff -urN smeserver-vacation-1.1.old/root/etc/e-smith/web/functions/uservacations smeserver-vacation-1.1/root/etc/e-smith/web/functions/uservacations
95 --- smeserver-vacation-1.1.old/root/etc/e-smith/web/functions/uservacations 2015-09-04 10:53:45.503912372 +0200
96 +++ smeserver-vacation-1.1/root/etc/e-smith/web/functions/uservacations 2015-09-04 18:12:18.853099056 +0200
97 @@ -54,6 +54,14 @@
98 <field type="literal" id="FullName">
99 <label>USER_NAME</label>
100 </field>
101 +
102 + <field type="text" id="EmailVacationFrom">
103 + <label>VACATION_FROM</label>
104 + </field>
105 +
106 + <field type="text" id="EmailVacationTo">
107 + <label>VACATION_TO</label>
108 + </field>
109
110 <subroutine src="get_vacation_text()" />
111
112 diff -urN smeserver-vacation-1.1.old/root/sbin/e-smith/vacation/check_vacation_dates.sh smeserver-vacation-1.1/root/sbin/e-smith/vacation/check_vacation_dates.sh
113 --- smeserver-vacation-1.1.old/root/sbin/e-smith/vacation/check_vacation_dates.sh 1970-01-01 01:00:00.000000000 +0100
114 +++ smeserver-vacation-1.1/root/sbin/e-smith/vacation/check_vacation_dates.sh 2015-09-04 18:39:09.929079461 +0200
115 @@ -0,0 +1,37 @@
116 +#!/bin/bash
117 +CURRENT_DATE=`date +%Y%m%d`
118 +
119 +echo "Checking vacation changes on $CURRENT_DATE"
120 +
121 +# iterate over users
122 +for key in `db accounts keys`
123 +do
124 + if [ `db accounts gettype $key` == "user" ]
125 + then
126 + # check for EmailVacationProperty
127 + if [ -z `db accounts getprop $key EmailVacation` ]
128 + then
129 + echo "$key never went on vacation before."
130 +
131 + # if both fields are empty or contain the same value, do nothing
132 + elif [ `db accounts getprop $key EmailVacationFrom` == `db accounts getprop $key EmailVacationTo` ]
133 + then
134 + echo "Both fields empty or same date, not changing anything for $key"
135 + # db accounts setprop $key EmailVacation no
136 +
137 + elif [ `db accounts getprop $key EmailVacationFrom` == $CURRENT_DATE ]
138 + then
139 + echo "Happy holidays, $key"
140 + db accounts setprop $key EmailVacation yes
141 +
142 + elif [ `db accounts getprop $key EmailVacationTo` == $CURRENT_DATE ]
143 + then
144 + echo "Back to work, $key"
145 + db accounts setprop $key EmailVacation no
146 +
147 + else
148 + echo "Nothing to do for $key"
149 +
150 + fi
151 + fi
152 +done
153 diff -urN smeserver-vacation-1.1.old/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/uservacations.pm smeserver-vacation-1.1/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/uservacations.pm
154 --- smeserver-vacation-1.1.old/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/uservacations.pm 2015-09-04 10:53:45.503912372 +0200
155 +++ smeserver-vacation-1.1/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/uservacations.pm 2015-09-04 11:47:21.004897212 +0200
156 @@ -85,6 +85,8 @@
157 {
158 # make it clearer which uses have vacation
159 my $EmailVacation = $user->prop('EmailVacation') || '';
160 + my $EmailVacationFrom = $user->prop('EmailVacationFrom') || '';
161 + my $EmailVacationTo = $user->prop('EmailVacationTo') || '';
162 my $status = $user->prop('EmailVacation') || '';
163 if ($status eq 'yes') { $status = 'YES'; } else { $status = ''; }
164
165 @@ -94,6 +96,8 @@
166 $user->prop('LastName'),
167 status => $self->localise($status),
168 EmailVacation => $EmailVacation,
169 + EmailVacationFrom => $EmailVacationFrom,
170 + EmailVacationTo => $EmailVacationTo,
171 Modify => $self->localise('MODIFY'),
172 }
173 }
174 @@ -115,6 +119,8 @@
175 "User=" . $row->{User},
176 "FullName=" . $row->{FullName},
177 "EmailVacation=" . $row->{EmailVacation},
178 + "EmailVacationFrom=" . $row->{EmailVacationFrom},
179 + "EmailVacationTo=" . $row->{EmailVacationTo},
180 "wherenext=VACATION_PAGE_MODIFY");
181 }
182
183 @@ -177,6 +183,8 @@
184 my $user = $q->param('User');
185
186 my $EmailVacation = $q->param('EmailVacation');
187 + my $EmailVacationFrom = $q->param('EmailVacationFrom');
188 + my $EmailVacationTo = $q->param('EmailVacationTo');
189 my $new_message = $q->param('new_message');
190 my $vfile = "/home/e-smith/files/users/$user/.vacation.msg";
191
192 @@ -228,6 +236,8 @@
193 "/home/e-smith/files/users/$user/.vacation.msg");
194
195 $adb->set_prop($user, 'EmailVacation', $EmailVacation);
196 + $adb->set_prop($user, 'EmailVacationFrom', $EmailVacationFrom);
197 + $adb->set_prop($user, 'EmailVacationTo', $EmailVacationTo);
198
199 #the first is more correct but is slower
200 #system ("/sbin/e-smith/signal-event", "email-update", $user) == 0
201 @@ -260,6 +270,16 @@
202 return $adb->get_prop($PanelUser, "EmailVacation");
203 }
204
205 +sub get_vacation_date_from
206 +{
207 + return $adb->get_prop($PanelUser, "EmailVacationFrom");
208 +}
209 +
210 +sub get_vacation_date_to
211 +{
212 + return $adb->get_prop($PanelUser, "EmailVacationTo");
213 +}
214 +
215 # this formats the text to display on screen
216 sub userpanel_get_vacation_text
217 {
218

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed