1 | <?php |
---|
2 | /**************************************************************************\ |
---|
3 | * eGroupWare - Calendar * |
---|
4 | * http://www.egroupware.org * |
---|
5 | * Based on Webcalendar by Craig Knudsen <cknudsen@radix.net> * |
---|
6 | * http://www.radix.net/~cknudsen * |
---|
7 | * Modified by Mark Peters <skeeter@phpgroupware.org> * |
---|
8 | * -------------------------------------------- * |
---|
9 | * This program is free software; you can redistribute it and/or modify it * |
---|
10 | * under the terms of the GNU General Public License as published by the * |
---|
11 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
12 | * option) any later version. * |
---|
13 | \**************************************************************************/ |
---|
14 | |
---|
15 | |
---|
16 | if (@$GLOBALS['phpgw_info']['flags']['included_classes']['socalendar__']) |
---|
17 | { |
---|
18 | return; |
---|
19 | } |
---|
20 | |
---|
21 | $GLOBALS['phpgw_info']['flags']['included_classes']['socalendar__'] = True; |
---|
22 | |
---|
23 | /* include(PHPGW_SERVER_ROOT.'/calendar/setup/setup.inc.php'); */ |
---|
24 | |
---|
25 | if(extension_loaded('mcal') == False) |
---|
26 | { |
---|
27 | define('MCAL_RECUR_NONE',0); |
---|
28 | define('MCAL_RECUR_DAILY',1); |
---|
29 | define('MCAL_RECUR_WEEKLY',2); |
---|
30 | define('MCAL_RECUR_MONTHLY_MDAY',3); |
---|
31 | define('MCAL_RECUR_MONTHLY_WDAY',4); |
---|
32 | define('MCAL_RECUR_YEARLY',5); |
---|
33 | |
---|
34 | define('MCAL_M_SUNDAY',1); |
---|
35 | define('MCAL_M_MONDAY',2); |
---|
36 | define('MCAL_M_TUESDAY',4); |
---|
37 | define('MCAL_M_WEDNESDAY',8); |
---|
38 | define('MCAL_M_THURSDAY',16); |
---|
39 | define('MCAL_M_FRIDAY',32); |
---|
40 | define('MCAL_M_SATURDAY',64); |
---|
41 | |
---|
42 | define('MCAL_M_WEEKDAYS',62); |
---|
43 | define('MCAL_M_WEEKEND',65); |
---|
44 | define('MCAL_M_ALLDAYS',127); |
---|
45 | } |
---|
46 | |
---|
47 | define('MSG_DELETED',0); |
---|
48 | define('MSG_MODIFIED',1); |
---|
49 | define('MSG_ADDED',2); |
---|
50 | define('MSG_REJECTED',3); |
---|
51 | define('MSG_TENTATIVE',4); |
---|
52 | define('MSG_ACCEPTED',5); |
---|
53 | define('MSG_ALARM',6); |
---|
54 | |
---|
55 | define('REJECTED',0); |
---|
56 | define('NO_RESPONSE',1); |
---|
57 | define('TENTATIVE',2); |
---|
58 | define('ACCEPTED',3); |
---|
59 | |
---|
60 | class socalendar__ |
---|
61 | { |
---|
62 | var $event; |
---|
63 | var $stream; |
---|
64 | var $user; |
---|
65 | var $users_status; |
---|
66 | var $debug = False; |
---|
67 | // var $debug = True; |
---|
68 | |
---|
69 | function socalendar__() |
---|
70 | { |
---|
71 | } |
---|
72 | |
---|
73 | function maketime($time) |
---|
74 | { |
---|
75 | return mktime($time['hour'],$time['min'],$time['sec'],$time['month'],$time['mday'],$time['year']); |
---|
76 | } |
---|
77 | |
---|
78 | function get_cached_event() |
---|
79 | { |
---|
80 | return $this->event; |
---|
81 | } |
---|
82 | |
---|
83 | function event_init() |
---|
84 | { |
---|
85 | $this->event = Array(); |
---|
86 | $this->add_attribute('owner',(int)$this->user); |
---|
87 | } |
---|
88 | |
---|
89 | function set_category($category='') |
---|
90 | { |
---|
91 | $this->add_attribute('category',$category); |
---|
92 | } |
---|
93 | |
---|
94 | function set_title($title='') |
---|
95 | { |
---|
96 | $this->add_attribute('title',$title); |
---|
97 | } |
---|
98 | |
---|
99 | function set_description($description='') |
---|
100 | { |
---|
101 | $this->add_attribute('description',$description); |
---|
102 | } |
---|
103 | |
---|
104 | function set_observations($observations='') |
---|
105 | { |
---|
106 | $this->add_attribute('observations',$observations); |
---|
107 | } |
---|
108 | |
---|
109 | function set_notifications_owner($notifications_owner='') |
---|
110 | { |
---|
111 | $this->add_attribute('notifications_owner',$notifications_owner); |
---|
112 | } |
---|
113 | |
---|
114 | function set_alter_by($alter_by='') |
---|
115 | { |
---|
116 | $this->add_attribute('alter_by',$alter_by); |
---|
117 | } |
---|
118 | |
---|
119 | function set_attachment($attachment='') |
---|
120 | { |
---|
121 | $this->add_attribute('attachment',$attachment); |
---|
122 | } |
---|
123 | |
---|
124 | function set_ex_participants($ex_participants='') |
---|
125 | { |
---|
126 | $this->add_attribute('ex_participants',$ex_participants); |
---|
127 | } |
---|
128 | |
---|
129 | function set_date($element,$year,$month,$day=0,$hour=0,$min=0,$sec=0) |
---|
130 | { |
---|
131 | $this->add_attribute($element,(int)$year,'year'); |
---|
132 | $this->add_attribute($element,(int)$month,'month'); |
---|
133 | $this->add_attribute($element,(int)$day,'mday'); |
---|
134 | $this->add_attribute($element,(int)$hour,'hour'); |
---|
135 | $this->add_attribute($element,(int)$min,'min'); |
---|
136 | $this->add_attribute($element,(int)$sec,'sec'); |
---|
137 | $this->add_attribute($element,0,'alarm'); |
---|
138 | } |
---|
139 | |
---|
140 | function set_start($year,$month,$day=0,$hour=0,$min=0,$sec=0) |
---|
141 | { |
---|
142 | $this->set_date('start',$year,$month,$day,$hour,$min,$sec); |
---|
143 | } |
---|
144 | |
---|
145 | function set_end($year,$month,$day=0,$hour=0,$min=0,$sec=0) |
---|
146 | { |
---|
147 | $this->set_date('end',$year,$month,$day,$hour,$min,$sec); |
---|
148 | } |
---|
149 | |
---|
150 | function set_alarm($alarm) |
---|
151 | { |
---|
152 | $this->add_attribute('alarm',(int)$alarm); |
---|
153 | } |
---|
154 | |
---|
155 | function set_class($class) |
---|
156 | { |
---|
157 | $this->add_attribute('public',$class); |
---|
158 | } |
---|
159 | |
---|
160 | function set_common_recur($year=0,$month=0,$day=0,$interval=0) |
---|
161 | { |
---|
162 | $this->add_attribute('recur_interval',(int)$interval); |
---|
163 | $this->set_date('recur_enddate',$year,$month,$day,0,0,0); |
---|
164 | $this->add_attribute('recur_data',0); |
---|
165 | } |
---|
166 | |
---|
167 | function set_recur_none() |
---|
168 | { |
---|
169 | $this->set_common_recur(0,0,0,0); |
---|
170 | $this->add_attribute('recur_type',MCAL_RECUR_NONE); |
---|
171 | } |
---|
172 | |
---|
173 | function set_recur_daily($year,$month,$day,$interval) |
---|
174 | { |
---|
175 | $this->set_common_recur((int)$year,(int)$month,(int)$day,$interval); |
---|
176 | $this->add_attribute('recur_type',MCAL_RECUR_DAILY); |
---|
177 | } |
---|
178 | |
---|
179 | function set_recur_weekly($year,$month,$day,$interval,$weekdays) |
---|
180 | { |
---|
181 | $this->set_common_recur((int)$year,(int)$month,(int)$day,$interval); |
---|
182 | $this->add_attribute('recur_type',MCAL_RECUR_WEEKLY); |
---|
183 | $this->add_attribute('recur_data',(int)$weekdays); |
---|
184 | } |
---|
185 | |
---|
186 | function set_recur_monthly_mday($year,$month,$day,$interval) |
---|
187 | { |
---|
188 | $this->set_common_recur((int)$year,(int)$month,(int)$day,$interval); |
---|
189 | $this->add_attribute('recur_type',MCAL_RECUR_MONTHLY_MDAY); |
---|
190 | } |
---|
191 | |
---|
192 | function set_recur_monthly_wday($year,$month,$day,$interval) |
---|
193 | { |
---|
194 | $this->set_common_recur((int)$year,(int)$month,(int)$day,$interval); |
---|
195 | $this->add_attribute('recur_type',MCAL_RECUR_MONTHLY_WDAY); |
---|
196 | } |
---|
197 | |
---|
198 | function set_recur_yearly($year,$month,$day,$interval) |
---|
199 | { |
---|
200 | $this->set_common_recur((int)$year,(int)$month,(int)$day,$interval); |
---|
201 | $this->add_attribute('recur_type',MCAL_RECUR_YEARLY); |
---|
202 | } |
---|
203 | |
---|
204 | function fetch_current_stream_event() |
---|
205 | { |
---|
206 | return $this->fetch_event($this->event['id']); |
---|
207 | } |
---|
208 | |
---|
209 | function add_attribute($attribute,$value,$element='**(**') |
---|
210 | { |
---|
211 | if(is_array($value)) |
---|
212 | { |
---|
213 | reset($value); |
---|
214 | } |
---|
215 | if($element!='**(**') |
---|
216 | { |
---|
217 | $this->event[$attribute][$element] = $value; |
---|
218 | } |
---|
219 | else |
---|
220 | { |
---|
221 | $this->event[$attribute] = $value; |
---|
222 | } |
---|
223 | } |
---|
224 | } |
---|