forked from dtouzeau/artica
-
Notifications
You must be signed in to change notification settings - Fork 0
/
users.out-of-office.php
295 lines (223 loc) · 8.6 KB
/
users.out-of-office.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
<?php
include_once('ressources/class.templates.inc');
include_once('ressources/class.ldap.inc');
include_once('ressources/class.users.menus.inc');
include_once('ressources/class.user.inc');
$uid=$_SESSION["uid"];
if($uid==null){die('alert("Please logon");');}
if(isset($_GET["start-page"])){echo out_of_office_start();exit;}
if(isset($_GET["vacationActive"])){SaveVacation();exit;}
if(isset($_GET["vacationInfo"])){SavevacationInfo();exit;}
if(isset($_GET["start-message"])){echo out_of_office_message();exit;}
js();
function js(){
$uid=$_SESSION["uid"];
$tpl=new templates();
$title=$tpl->_ENGINE_parse_body('{OUT_OF_OFFICE}');
$vacationmsg=$tpl->_ENGINE_parse_body('{vacation_message}');
$page=CurrentPageName();
$html="
YAHOO.namespace(\"example.calendar\");
YAHOO.example.calendar.init = function() {
function Cal1eSelect(type,args,obj) {
var dates = args[0];
var date = dates[0];
var year = date[0], month = date[1], day = date[2];
var selectedDate=year+'-'+month+'-'+day;
document.getElementById('vacationStart').value=selectedDate;
}
function Cal2eSelect(type,args,obj) {
var dates = args[0];
var date = dates[0];
var year = date[0], month = date[1], day = date[2];
var selectedDate=year+'-'+month+'-'+day;
document.getElementById('vacationEnd').value=selectedDate;
}
YAHOO.example.calendar.cal1 = new YAHOO.widget.Calendar(\"cal1\",\"cal1Container\");
YAHOO.example.calendar.cal1.selectEvent.subscribe(Cal1eSelect, YAHOO.example.calendar.cal1, true);
YAHOO.example.calendar.cal1.render();
YAHOO.example.calendar.cal2 = new YAHOO.widget.Calendar(\"cal2\",\"cal2Container\");
YAHOO.example.calendar.cal2.selectEvent.subscribe(Cal2eSelect, YAHOO.example.calendar.cal2, true);
YAHOO.example.calendar.cal2.render();
}
function OutOfOfficeLoad(){
YahooWin3(650,'$page?start-page=yes','$uid: $title');
setTimeout(\"initCalcs()\",1500);
}
function initCalcs(){
YAHOO.util.Event.onDOMReady(YAHOO.example.calendar.init);
setTimeout(\"UpdateCalcs()\",500);
}
function UpdateCalcs(){
YAHOO.example.calendar.cal1.select(document.getElementById('vacationStart').value);
var selectedDates = YAHOO.example.calendar.cal1.getSelectedDates();
if (selectedDates.length > 0) {
var firstDate = selectedDates[0];
YAHOO.example.calendar.cal1.cfg.setProperty(\"pagedate\", (firstDate.getMonth()+1) + \"/\" + firstDate.getFullYear());
YAHOO.example.calendar.cal1.render();
}
YAHOO.example.calendar.cal2.select(document.getElementById('vacationEnd').value);
selectedDates = YAHOO.example.calendar.cal2.getSelectedDates();
if (selectedDates.length > 0) {
firstDate = selectedDates[0];
YAHOO.example.calendar.cal2.cfg.setProperty(\"pagedate\", (firstDate.getMonth()+1) + \"/\" + firstDate.getFullYear());
YAHOO.example.calendar.cal2.render();
}
}
var x_SaveOutOfOffice= function (obj) {
var results=obj.responseText;
if (results.length>0){
alert(results);
}
OutOfOfficeLoad();
}
function VacationMessage(){
YahooWin4(500,'$page?start-message=yes','$uid: $vacationmsg');
}
var x_SaveVacationInfo= function (obj) {
var results=obj.responseText;
if (results.length>0){
alert(results);
}
VacationMessage();
}
function SaveVacationInfo(){
var XHR = new XHRConnection();
XHR.appendData('vacationInfo',document.getElementById('vacationInfo').value);
document.getElementById('vacdiv').innerHTML='<center><img src=\"img/wait_verybig.gif\"></center>';
XHR.sendAndLoad('$page', 'GET',x_SaveVacationInfo);
}
function SaveOutOfOffice(){
var XHR = new XHRConnection();
XHR.appendData('vacationActive',document.getElementById('vacationActive').value);
XHR.appendData('vacationEnd',document.getElementById('vacationEnd').value);
XHR.appendData('vacationStart',document.getElementById('vacationStart').value);
document.getElementById('outofoff').innerHTML='<center><img src=\"img/wait_verybig.gif\"></center>';
XHR.sendAndLoad('$page', 'GET',x_SaveOutOfOffice);
}
OutOfOfficeLoad();
;
";
echo $html;
}
function out_of_office_start(){
$user=new user($_SESSION["uid"]);
if($user->vacationEnabled=="TRUE"){$vacation_active=1;}else{$vacation_active=0;}
$vacationStart=$user->vacationStart;
$vacationEnd=$user->vacationEnd;
$vacationStart_time=date('m/d/Y',$vacationStart);
$vacationEnd_time=date('m/d/Y',$vacationEnd);
$activate=Paragraphe_switch_img("{ENABLE_OUT_OF_OFFICE}","{ENABLE_OUT_OF_OFFICE_TEXT}","vacationActive",$vacation_active);
$activate=RoundedLightWhite($activate);
if($user->vacationActive=="TRUE"){$icon="ok24.png";$textActive="{enabled}";}else{$icon="danger24.png";$textActive="{disabled}";}
$status="
<table style='width:100%' class=table_form>
<tr>
<td colspan=2><strong style='font-size:16px'>{status}</strong></td>
<hr>
</tr>
<tr>
<td width=1%><img src='img/$icon'></td>
<td><strong style='width:12px'>$textActive</td>
</tr>
</table>";
$form_time="
<table style='width:100%'>
<tr>
<td align='left' style='border-bottom:1px solid #CCCCCC'><span style='font-size:14px;font-weight:bold;text-transform: capitalize;'>{from}:</span></td>
<td align='left' style='border-bottom:1px solid #CCCCCC'><span style='font-size:14px;font-weight:bold;text-transform: capitalize;'>{to}:</span></td>
</tr>
<tr>
<td align='center' style='padding-left:10px;padding-top:5px'><div id='cal1Container'><img src='img/wait.gif'></div></td>
<td align='center' style='padding-left:10px;padding-top:5px'><div id='cal2Container'><img src='img/wait.gif'></div></td>
</tr>
</table>
<input type='hidden' id='vacationStart' value='$vacationStart_time'>
<input type='hidden' id='vacationEnd' value='$vacationEnd_time'>
<hr>
<div style='text-align:right'><input type='button' value='{edit} »' OnClick=\"javascript:SaveOutOfOffice();\"></div>
";
$form_time=RoundedLightWhite($form_time);
$form="
<table style='width:100%'>
<tr>
<td valign='top'>$activate<br>$status
<hr>
<div style='text-align:right'><input type='button' value='{edit} »' OnClick=\"javascript:SaveOutOfOffice();\"></div></td>
<td valign='top'>$form_time</td>
</tr>
</table>
";
$html="
<H1>{OUT_OF_OFFICE}</H1>
<div style='float:right'><input type='button' value='{vacation_message}' OnClick=\"javascript:VacationMessage();\" ></div>
<p class=caption>{OUT_OF_OFFICE_TEXT}</p>
<div id='outofoff'>
$form
</div>
";
$tpl=new templates();
return $tpl->_ENGINE_parse_body($html);
//$timestamp = mktime(0, 0, 0, $month, $day, $year);
//current=time
}
function SaveVacation(){
$tpl=new templates();
$users=new user($_SESSION["uid"]);
if(preg_match('#(.+?)@(.+)#',$users->mail,$re)){
$alias="{$re[1]}@vacation.{$re[2]}";
}
if($_GET["vacationActive"]==1){
$users->vacationEnabled="TRUE";
$users->VacationCheck();
if(!$users->AddAliasesMailing($alias)){
echo $users->ldap_error;
exit;
}
}else{
$users->delete_AliasesMailing($alias);
if($users->VacationDisable()){
echo $tpl->_ENGINE_parse_body("{disable} {success}\n");
exit;
}
}
if(preg_match('#([0-9]+)-([0-9]+)-([0-9]+)#',$_GET["vacationStart"],$re)){
$timestamp = mktime(0, 0, 0, $re[2], $re[3], $re[1]);
$users->vacationStart=$timestamp;
}
if(preg_match('#([0-9]+)-([0-9]+)-([0-9]+)#',$_GET["vacationEnd"],$re)){
$timestamp = mktime(0, 0, 0, $re[2], $re[3], $re[1]);
$users->vacationEnd=$timestamp;
}
if($users->vacationEnd<$users->vacationStart){
die($tpl->_ENGINE_parse_body('{error_check_dates}'));
}
writelogs("vacationActive=\"$users->vacationActive\"..",__CLASS__.'/'.__FUNCTION__,__FILE__);
if(!$users->add_user()){echo $users->ldap_error;}
$users->VacationCheck();
}
function SavevacationInfo(){
$info=$_GET["vacationInfo"];
$users=new user($_SESSION["uid"]);
$users->vacationInfo=$info;
if(!$users->add_user()){echo $users->ldap_error;}
}
function out_of_office_message(){
$users=new user($_SESSION["uid"]);
$html="
<H1>{vacation_message}</H1>
<div id='vacdiv'>
<textarea
name='vacationInfo'
id='vacationInfo'
style='width:100%;padding:10px;height:250px;overflow:hidden;overflow-x: hidden;overflow-y: auto;font-family:\"Courier New\" Courier monospace;font-size:12px'>
$users->vacationInfo
</textarea>
<hr>
<div style='text-align:right'><input type='button' OnClick=\"javascript:SaveVacationInfo()\" value='{edit} »'></div>
</div>
";
$tpl=new templates();
return $tpl->_ENGINE_parse_body($html);
}
?>