/
app_calendar.class.php
685 lines (609 loc) · 19.2 KB
/
app_calendar.class.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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
<?php
/**
* Calendar
*
* App_calendar
*
* @package project
* @author Serge J. <jey@tut.by>
* @copyright http://www.atmatic.eu/ (c)
* @version 0.1 (wizard, 17:05:45 [May 07, 2012])
*/
Define('DEF_REPEAT_TYPE_OPTIONS', '1=Yearly|2=Monthly|3=Weekly|4=Daily'); // options for 'REPEAT_TYPE'
//
//
class app_calendar extends module {
/**
* app_calendar
*
* Module class constructor
*
* @access private
*/
function app_calendar() {
$this->name="app_calendar";
$this->title="<#LANG_APP_CALENDAR#>";
$this->module_category="<#LANG_SECTION_APPLICATIONS#>";
$this->checkInstalled();
}
/**
* saveParams
*
* Saving module parameters
*
* @access public
*/
function saveParams($data=0) {
$p=array();
if (IsSet($this->id)) {
$p["id"]=$this->id;
}
if (IsSet($this->view_mode)) {
$p["view_mode"]=$this->view_mode;
}
if (IsSet($this->edit_mode)) {
$p["edit_mode"]=$this->edit_mode;
}
if (IsSet($this->data_source)) {
$p["data_source"]=$this->data_source;
}
if (IsSet($this->tab)) {
$p["tab"]=$this->tab;
}
return parent::saveParams($p);
}
/**
* getParams
*
* Getting module parameters from query string
*
* @access public
*/
function getParams() {
global $id;
global $mode;
global $view_mode;
global $edit_mode;
global $data_source;
global $tab;
if (isset($id)) {
$this->id=$id;
}
if (isset($mode)) {
$this->mode=$mode;
}
if (isset($view_mode)) {
$this->view_mode=$view_mode;
}
if (isset($edit_mode)) {
$this->edit_mode=$edit_mode;
}
if (isset($data_source)) {
$this->data_source=$data_source;
}
if (isset($tab)) {
$this->tab=$tab;
}
}
/**
* Run
*
* Description
*
* @access public
*/
function run() {
global $session;
$out=array();
if ($this->action=='admin') {
$this->admin($out);
} else {
$this->usual($out);
}
$this->checkSettings();
if (IsSet($this->owner->action)) {
$out['PARENT_ACTION']=$this->owner->action;
}
if (IsSet($this->owner->name)) {
$out['PARENT_NAME']=$this->owner->name;
}
$out['VIEW_MODE']=$this->view_mode;
$out['EDIT_MODE']=$this->edit_mode;
$out['MODE']=$this->mode;
$out['ACTION']=$this->action;
$out['DATA_SOURCE']=$this->data_source;
$out['TAB']=$this->tab;
if ($this->single_rec) {
$out['SINGLE_REC']=1;
}
$this->data=$out;
$p=new parser(DIR_TEMPLATES.$this->name."/".$this->name.".html", $this->data, $this);
$this->result=$p->result;
}
/**
* Title
*
* Description
*
* @access public
*/
function checkSettings() {
$settings=array(
array(
'NAME'=>'APP_CALENDAR_SOONLIMIT',
'TITLE'=>'Days to show in "soon" section',
'TYPE'=>'text',
'DEFAULT'=>'6'
),
array(
'NAME'=>'APP_CALENDAR_SHOWDONE',
'TITLE'=>'Show recently done items',
'TYPE'=>'yesno',
'DEFAULT'=>'1'
)
);
foreach($settings as $k=>$v) {
$rec=SQLSelectOne("SELECT ID FROM settings WHERE NAME='".$v['NAME']."'");
if (!$rec['ID']) {
$rec['NAME']=$v['NAME'];
$rec['VALUE']=$v['DEFAULT'];
$rec['DEFAULTVALUE']=$v['DEFAULT'];
$rec['TITLE']=$v['TITLE'];
$rec['TYPE']=$v['TYPE'];
$rec['ID']=SQLInsert('settings', $rec);
Define('SETTINGS_'.$rec['NAME'], $v['DEFAULT']);
}
}
}
/**
* BackEnd
*
* Module backend
*
* @access public
*/
function admin(&$out) {
if (isset($this->data_source) && !$_GET['data_source'] && !$_POST['data_source']) {
$out['SET_DATASOURCE']=1;
}
if ($this->data_source=='calendar_events' || $this->data_source=='') {
if ($this->view_mode=='' || $this->view_mode=='search_calendar_events') {
$this->search_calendar_events($out);
}
if ($this->view_mode=='edit_calendar_events') {
// $this->edit_calendar_events($out, $this->id);
$this->usual_edit($out, $this->id);
}
if ($this->view_mode=='delete_calendar_events') {
$this->delete_calendar_events($this->id);
$this->redirect("?data_source=calendar_events");
}
if ($this->view_mode=='delete_all_task') {
$this->delete_all_task();
$this->redirect("?data_source=calendar_events");
}
if ($this->view_mode=='delete_all_past_events') {
$this->delete_all_past_events();
$this->redirect("?data_source=calendar_events");
}
}
if (isset($this->data_source) && !$_GET['data_source'] && !$_POST['data_source']) {
$out['SET_DATASOURCE']=1;
}
if ($this->data_source=='calendar_categories') {
if ($this->view_mode=='' || $this->view_mode=='search_calendar_categories') {
$this->search_calendar_categories($out);
}
if ($this->view_mode=='edit_calendar_categories') {
$this->edit_calendar_categories($out, $this->id);
}
if ($this->view_mode=='delete_calendar_categories') {
$this->delete_calendar_categories($this->id);
$this->redirect("?data_source=calendar_categories");
}
}
}
/**
* FrontEnd
*
* Module frontend
*
* @access public
*/
function usual(&$out) {
if ($this->view_mode=='edit') {
$this->usual_edit($out);
}
if ($this->view_mode=='') {
if ($this->mode=='is_done') {
global $id;
$this->task_done($id);
$this->redirect("?");
}
if ($this->mode=='reset_done') {
global $id;
$rec=SQLSelectOne("SELECT * FROM calendar_events WHERE ID='".(int)$id."'");
$rec['IS_DONE']=0;
SQLUpdate('calendar_events', $rec);
$this->redirect("?");
}
$events_today_temp=SQLSelect("SELECT calendar_events.*,calendar_categories.ICON FROM calendar_events left join calendar_categories on calendar_events.calendar_category_id=calendar_categories.id WHERE TO_DAYS(DUE)=TO_DAYS(NOW()) AND IS_REPEATING!=1 AND IS_TASK=0 ORDER BY IS_TASK DESC");
if ($events_today_temp) {
foreach($events_today_temp as $k=>$v) {
$events_today[]=$v;
//$calendar_categories[$k1]['EVENTS_TODAY'][]=$v;
}
}
$tasks_today=SQLSelect("SELECT calendar_events.*,calendar_categories.ICON FROM calendar_events left join calendar_categories on calendar_events.calendar_category_id=calendar_categories.id WHERE TO_DAYS(DUE)=TO_DAYS(NOW()) AND IS_DONE=0 AND IS_TASK=1 ORDER BY IS_TASK DESC");
if ($tasks_today) {
foreach($tasks_today as $k=>$v) {
$events_today[]=$v;
//$calendar_categories[$k1]['EVENTS_TODAY'][]=$v;
}
}
$events_early_today=SQLSelect("SELECT calendar_events.*,calendar_categories.ICON FROM calendar_events left join calendar_categories on calendar_events.calendar_category_id=calendar_categories.id WHERE TO_DAYS(DATE(CONCAT_WS('-', DATE_FORMAT(NOW(), '%Y'), DATE_FORMAT(DUE, '%m'), DATE_FORMAT(DUE, '%d'))))=TO_DAYS(NOW()) AND IS_REPEATING=1 AND REPEAT_TYPE=1 AND IS_TASK=0 ORDER BY IS_TASK DESC");
if ($events_early_today) {
foreach($events_early_today as $k=>$v) {
$events_today[]=$v;
//$calendar_categories[$k1]['EVENTS_TODAY'][]=$v;
}
}
$events_monthly_today=SQLSelect("SELECT calendar_events.*,calendar_categories.ICON FROM calendar_events left join calendar_categories on calendar_events.calendar_category_id=calendar_categories.id WHERE TO_DAYS(DATE(CONCAT_WS('-', DATE_FORMAT(NOW(), '%Y'), DATE_FORMAT(NOW(), '%m'), DATE_FORMAT(DUE, '%d'))))=TO_DAYS(NOW()) AND IS_REPEATING=1 AND REPEAT_TYPE=2 AND IS_TASK=0 ORDER BY IS_TASK DESC");
if ($events_monthly_today) {
foreach($events_monthly_today as $k=>$v) {
$events_today[]=$v;
//$calendar_categories[$k1]['EVENTS_TODAY'][]=$v;
}
}
$events_weekly_today=SQLSelect("SELECT calendar_events.*,calendar_categories.ICON FROM calendar_events left join calendar_categories on calendar_events.calendar_category_id=calendar_categories.id WHERE DATE_FORMAT(DUE, '%w')=DATE_FORMAT(NOW(), '%w') AND IS_REPEATING=1 AND REPEAT_TYPE=3 AND IS_TASK=0 ORDER BY IS_TASK DESC");
if ($events_weekly_today) {
foreach($events_weekly_today as $k=>$v) {
$events_today[]=$v;
//$calendar_categories[$k1]['EVENTS_TODAY'][]=$v;
}
}
if ($events_today) {
$out['EVENTS_TODAY']=$events_today;
}
$daymorph=Array('дней','день','дня','дня','дня','дней','дней','дней','дней','дней');
$calendar_categories=SQLSelect("SELECT ID,TITLE,ICON FROM calendar_categories ORDER BY PRIORITY DESC");
$calendar_categories[]=array('ID'=>0,'TITLE'=>'Без категории');
foreach($calendar_categories as $k1=>$v1) {
$events_past=SQLSelect("SELECT *, (TO_DAYS(DUE)-TO_DAYS(NOW())) as AGE FROM calendar_events WHERE TO_DAYS(DUE)<TO_DAYS(NOW()) AND IS_TASK=1 AND IS_DONE=0 and CALENDAR_CATEGORY_ID=" . $v1['ID'] . " ORDER BY IS_TASK DESC, AGE");
if ($events_past) {
foreach($events_past as $k=>$v) {
$days=abs($v['AGE']);
$days=$daymorph[$days-floor($days/10)*10];
$v['DAYS']=$days;
$calendar_categories[$k1]['EVENTS_PAST'][]=$v;
}
$out['EVENTS_PAST']=$events_past;
}
$how_soon=SETTINGS_APP_CALENDAR_SOONLIMIT;
$events_soon=SQLSelect("SELECT *, (TO_DAYS(DUE)-TO_DAYS(NOW())) as AGE FROM calendar_events WHERE IS_TASK=0 AND (TO_DAYS(DUE)>TO_DAYS(NOW()) AND (TO_DAYS(DUE)-TO_DAYS(NOW())<=".(int)$how_soon.")) and CALENDAR_CATEGORY_ID=" . $v1['ID'] . " ORDER BY AGE");
$tasks_soon=SQLSelect("SELECT *, (TO_DAYS(DUE)-TO_DAYS(NOW())) as AGE FROM calendar_events WHERE IS_TASK=1 AND IS_DONE=0 AND (TO_DAYS(DUE)>TO_DAYS(NOW()) OR (IS_NODATE=1)) and CALENDAR_CATEGORY_ID=" . $v1['ID'] . " ORDER BY AGE");
if ($tasks_soon) {
foreach($tasks_soon as $k=>$v) {
$events_soon[]=$v;
}
}
$events_early_soon=SQLSelect("SELECT *, TO_DAYS(DATE(CONCAT_WS('-', DATE_FORMAT(NOW(), '%Y'), DATE_FORMAT(DUE, '%m'), DATE_FORMAT(DUE, '%d'))))-TO_DAYS(NOW()) as AGE FROM calendar_events WHERE (TO_DAYS(DATE(CONCAT_WS('-', DATE_FORMAT(NOW(), '%Y'), DATE_FORMAT(DUE, '%m'), DATE_FORMAT(DUE, '%d'))))>TO_DAYS(NOW())) AND (TO_DAYS(DATE(CONCAT_WS('-', DATE_FORMAT(NOW(), '%Y'), DATE_FORMAT(DUE, '%m'), DATE_FORMAT(DUE, '%d'))))-TO_DAYS(NOW())<=".(int)$how_soon.") AND IS_REPEATING=1 AND REPEAT_TYPE=1 AND IS_TASK=0 and CALENDAR_CATEGORY_ID=" . $v1['ID'] . " ORDER BY DUE");
if ($events_early_soon) {
foreach($events_early_soon as $k=>$v) {
$events_soon[]=$v;
}
}
$events_monthly_soon=SQLSelect("SELECT * FROM calendar_events WHERE (TO_DAYS(DATE(CONCAT_WS('-', DATE_FORMAT(NOW(), '%Y'), DATE_FORMAT(NOW(), '%m'), DATE_FORMAT(DUE, '%d'))))>TO_DAYS(NOW())) AND (TO_DAYS(DATE(CONCAT_WS('-', DATE_FORMAT(NOW(), '%Y'), DATE_FORMAT(DUE, '%m'), DATE_FORMAT(DUE, '%d'))))-TO_DAYS(NOW())<=".(int)$how_soon.") AND IS_REPEATING=1 AND REPEAT_TYPE=2 AND IS_TASK=0 and CALENDAR_CATEGORY_ID=" . $v1['ID'] . " ORDER BY DUE");
if ($events_monthly_soon) {
foreach($events_monthly_soon as $k=>$v) {
$events_soon[]=$v;
}
}
if ($events_soon) {
//$new_events=array();
foreach($events_soon as $ev) {
if (!$seen[$ev['ID']]) {
//$new_events[]=$ev;
if ($ev['AGE']) {
$days=abs($ev['AGE']);
$days=$daymorph[$days-floor($days/10)*10];
$ev['DAYS']=$days;
}
$calendar_categories[$k1]['EVENTS_SOON'][]=$ev;
}
$seen[$ev['ID']]=1;
}
// $out['EVENTS_SOON']=$new_events;
}
$events_pastpPan=SQLSelect("SELECT *, (TO_DAYS(DUE)-TO_DAYS(NOW())) as AGE FROM calendar_events WHERE (TO_DAYS(DUE)>TO_DAYS(NOW()) AND (TO_DAYS(DUE)-TO_DAYS(NOW())<='3') AND IS_DONE='0') ORDER BY AGE");
if ($events_pastpPan) {
$out['EVENTS_PASTPLAN']=$events_pastpPan;
}
if (empty($calendar_categories[$k1]['EVENTS_PAST']) and empty($calendar_categories[$k1]['EVENTS_SOON']) and empty ($calendar_categories[$k1]['RECENTLY_DONE'])) {
$calendar_categories[$k1]['REC_COUNT']=0;
} else {
$calendar_categories[$k1]['REC_COUNT']=1;
}
}
$out['CALENDAR_CATEGORIES']=$calendar_categories;
if (SETTINGS_APP_CALENDAR_SHOWDONE=='1') {
$recently_done=SQLSelect("SELECT * FROM calendar_events WHERE IS_TASK=1 AND (IS_DONE=1 OR IS_REPEATING=1) AND TO_DAYS(NOW())-TO_DAYS(DONE_WHEN)<=1") ;
if ($recently_done) {
$out['RECENTLY_DONE']=$recently_done;
}
}
}
}
/**
* Title
*
* Description
*
* @access public
*/
function usual_edit(&$out) {
global $title;
global $id;
if ($id) {
$rec=SQLSelectOne("SELECT * FROM calendar_events WHERE ID='".(int)$id."'");
if ($this->mode=='delete') {
SQLExec("DELETE FROM calendar_events WHERE ID='".(int)$rec['ID']."'");
$this->redirect("?");
}
} else {
$out['TITLE']=$title;
$out['DUE']=date('Y-m-d');
if ($out['TITLE']) {
$others=SQLSelect("SELECT ID, TITLE, IS_DONE FROM calendar_events WHERE TITLE LIKE '%".DBSafe($out['TITLE'])."%' ORDER BY ID DESC");
if ($others) {
$out['OTHERS']=$others;
}
}
}
if ($this->mode=='update') {
$ok=1;
global $is_task;
global $notes;
$rec['TITLE']=$title;
if (!$rec['TITLE']) {
$ok=0;
$out['ERR_TITLE']=1;
}
$rec['IS_TASK']=(int)$is_task;
$rec['NOTES']=$notes;
global $due;
$rec['DUE']=$due;
if (!$rec['DUE']) {
$rec['DUE']=date('Y-m-d');
}
global $is_repeating;
$rec['IS_REPEATING']=(int)$is_repeating;
global $is_repeating_after;
$rec['IS_REPEATING_AFTER']=(int)$is_repeating_after;
global $repeat_in;
$rec['REPEAT_IN']=(int)$repeat_in;
global $repeat_type;
$rec['REPEAT_TYPE']=(int)$repeat_type;
global $is_done;
if ($is_done && !$rec['IS_DONE']) {
$marked_done=1;
}
$rec['IS_DONE']=(int)$is_done;
global $is_nodate;
$rec['IS_NODATE']=(int)$rec['IS_NODATE'];
global $user_id;
$rec['USER_ID']=(int)$user_id;
global $location_id;
$rec['LOCATION_ID']=(int)$location_id;
global $calendar_category_id;
$rec['CALENDAR_CATEGORY_ID']=(int)$calendar_category_id;
global $done_script_id;
$rec['DONE_SCRIPT_ID']=(int)$done_script_id;
if ($ok) {
if ($rec['ID']) {
SQLUpdate('calendar_events', $rec);
} else {
$rec['ADDED']=date('Y-m-d H:i:s');
$rec['ID']=SQLInsert('calendar_events', $rec);
}
if ($marked_done) {
$this->task_done($rec['ID']);
}
$this->redirect("?");
}
}
outHash($rec, $out);
$out['USERS']=SQLSelect("SELECT * FROM users ORDER BY NAME");
$out['LOCATIONS']=SQLSelect("SELECT * FROM gpslocations ORDER BY TITLE");
$out['SCRIPTS']=SQLSelect("SELECT ID, TITLE FROM scripts ORDER BY TITLE");
$out['CALENDAR_CATEGORIES']=SQLSelect("SELECT ID, TITLE from calendar_categories ORDER BY TITLE");
}
/**
* Title
*
* Description
*
* @access public
*/
function task_done($id) {
//DebMes("Task $id is DONE! Congratulations!!!");
$rec=SQLSelectOne("SELECT * FROM calendar_events WHERE ID='".(int)$id."'");
$rec['DONE_WHEN']=date('Y-m-d H:i:s');
$rec['IS_DONE']=1;
$tmp=explode('-', $rec['DUE']);
$due_time=mktime(1, 1, 1, $tmp[1], $tmp[2], $tmp[0]);
if ($rec['IS_REPEATING']) {
$rec['IS_DONE']=0;
if ($rec['REPEAT_TYPE']==1) {
// yearly task
$due_time_next_year=mktime(1, 1, 1, $tmp[1], $tmp[2], $tmp[0]+1);
$rec['DUE']=date('Y-m-d', $due_time_next_year);
} elseif ($rec['REPEAT_TYPE']==2) {
// monthly task
$time_next_month=$due_time+31*24*60*60;
$due_time_next_month=mktime(1, 1, 1, date('m', $time_next_month), $tmp[2], date('Y', $time_next_month));
$rec['DUE']=date('Y-m-d', $due_time_next_month);
} elseif ($rec['REPEAT_TYPE']==3) {
// weekly task
$due_time_next_week=$due_time+7*24*60*60;
$rec['DUE']=date('Y-m-d', $due_time_next_week);
} elseif ($rec['REPEAT_TYPE']==9) {
// custom repeat task
if ($rec['IS_REPEATING_AFTER']) {
$rec['DUE']=date('Y-m-d', time()+$rec['REPEAT_IN']*24*60*60);
} else {
$rec['DUE']=date('Y-m-d', $due_time+$rec['REPEAT_IN']*24*60*60);
}
}
}
$rec['LOG']=date('Y-m-d H:i:s').' Task marked DONE'."\n".$rec['LOG'];
SQLUpdate('calendar_events', $rec);
if ($rec['DONE_SCRIPT_ID']) {
runScript($rec['DONE_SCRIPT_ID'], $rec);
}
}
/**
* calendar_events search
*
* @access public
*/
function search_calendar_events(&$out) {
require(DIR_MODULES.$this->name.'/calendar_events_search.inc.php');
}
/**
* calendar_events edit/add
*
* @access public
*/
function edit_calendar_events(&$out, $id) {
require(DIR_MODULES.$this->name.'/calendar_events_edit.inc.php');
}
/**
* calendar_events delete record
*
* @access public
*/
function delete_calendar_events($id) {
$rec=SQLSelectOne("SELECT * FROM calendar_events WHERE ID='$id'");
// some action for related tables
SQLExec("DELETE FROM calendar_events WHERE ID='".$rec['ID']."'");
}
/**
* calendar_events delete all task
*
* @access public
*/
function delete_all_task() {
SQLExec("DELETE FROM calendar_events WHERE IS_TASK=1 and IS_DONE=1 and (TO_DAYS(NOW())-TO_DAYS(DONE_WHEN))>1");
}
/**
* calendar_events delete all past events
*
* @access public
*/
function delete_all_past_events() {
SQLExec("DELETE FROM calendar_events WHERE IS_TASK=0 and IS_REPEATING=0 and (TO_DAYS(NOW())-TO_DAYS(DUE))>1");
}
/**
* calendar_categories search
*
* @access public
*/
function search_calendar_categories(&$out) {
require(DIR_MODULES.$this->name.'/calendar_categories_search.inc.php');
}
/**
* calendar_categories edit/add
*
* @access public
*/
function edit_calendar_categories(&$out, $id) {
require(DIR_MODULES.$this->name.'/calendar_categories_edit.inc.php');
}
/**
* calendar_categories delete record
*
* @access public
*/
function delete_calendar_categories($id) {
$rec=SQLSelectOne("SELECT * FROM calendar_categories WHERE ID='$id'");
// some action for related tables
@unlink(ROOT.'./cms/calendar/'.$rec['ICON']);
SQLExec("DELETE FROM calendar_categories WHERE ID='".$rec['ID']."'");
}
/**
* Install
*
* Module installation routine
*
* @access private
*/
function install($data='') {
@umask(0);
if (!Is_Dir(ROOT."./cms/calendar")) {
mkdir(ROOT."./cms/calendar", 0777);
}
parent::install();
}
/**
* Uninstall
*
* Module uninstall routine
*
* @access public
*/
function uninstall() {
SQLExec('DROP TABLE IF EXISTS calendar_events');
SQLExec('DROP TABLE IF EXISTS calendar_categories');
parent::uninstall();
}
/**
* dbInstall
*
* Database installation routine
*
* @access private
*/
function dbInstall($data) {
/*
calendar_events - Events
calendar_categories - Categories
*/
$data = <<<EOD
calendar_events: ID int(10) unsigned NOT NULL auto_increment
calendar_events: TITLE varchar(255) NOT NULL DEFAULT ''
calendar_events: SYSTEM varchar(255) NOT NULL DEFAULT ''
calendar_events: NOTES text
calendar_events: DUE date
calendar_events: ADDED datetime
calendar_events: DONE_WHEN datetime
calendar_events: IS_TASK int(3) NOT NULL DEFAULT '0'
calendar_events: IS_DONE int(3) NOT NULL DEFAULT '0'
calendar_events: IS_NODATE int(3) NOT NULL DEFAULT '0'
calendar_events: IS_REPEATING int(3) NOT NULL DEFAULT '0'
calendar_events: REPEAT_TYPE int(3) NOT NULL DEFAULT '0'
calendar_events: WEEK_DAYS varchar(255) NOT NULL DEFAULT ''
calendar_events: IS_REPEATING_AFTER int(3) NOT NULL DEFAULT '0'
calendar_events: REPEAT_IN int(10) NOT NULL DEFAULT '0'
calendar_events: USER_ID int(10) NOT NULL DEFAULT '0'
calendar_events: LOCATION_ID int(10) NOT NULL DEFAULT '0'
calendar_events: CALENDAR_CATEGORY_ID int(10) NOT NULL DEFAULT '0'
calendar_events: DONE_SCRIPT_ID int(10) NOT NULL DEFAULT '0'
calendar_events: DONE_CODE text
calendar_events: LOG text
calendar_categories: ID int(10) unsigned NOT NULL auto_increment
calendar_categories: TITLE varchar(255) NOT NULL DEFAULT ''
calendar_categories: ACTIVE int(255) NOT NULL DEFAULT '0'
calendar_categories: PRIORITY int(10) NOT NULL DEFAULT '0'
calendar_categories: ICON varchar(70) NOT NULL DEFAULT ''
EOD;
parent::dbInstall($data);
}
// --------------------------------------------------------------------
}
/*
*
* TW9kdWxlIGNyZWF0ZWQgTWF5IDA3LCAyMDEyIHVzaW5nIFNlcmdlIEouIHdpemFyZCAoQWN0aXZlVW5pdCBJbmMgd3d3LmFjdGl2ZXVuaXQuY29tKQ==
*
*/
?>