2 @define
('__POSTCALENDAR__', 'PostCalendar');
6 * PostCalendar::PostNuke Events Calendar Module
7 * Copyright (C) 2002 The PostCalendar Team
8 * http://postcalendar.tv
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * To read the license please read the docs/license.txt or visit
25 * http://www.gnu.org/copyleft/gpl.html
30 * Initializes a new install of PostCalendar
32 * This function will initialize a new installation of PostCalendar.
33 * It is accessed via the PostNuke Admin interface and should
34 * not be called directly.
36 * @return boolean true/false
38 * @author Roger Raymond <iansym@yahoo.com>
39 * @copyright The PostCalendar Team 2002
41 function postcalendar_init()
43 list($dbconn) = pnDBGetConn();
44 $pntable = pnDBGetTables();
45 $events_table = $pntable['postcalendar_events'];
46 $cat_table = $pntable['postcalendar_categories'];
48 // after reading some posts i've decided to adopt the new
49 // $pntable style which does not append table names.
50 // if you use joins in your SQL please remember this!
51 $sql = "CREATE TABLE $events_table (
52 pc_eid int(11) unsigned NOT NULL auto_increment,
53 pc_catid int(11) NOT NULL default '0',
54 pc_aid varchar(30) NOT NULL default '',
55 pc_title varchar(150) default '',
57 pc_hometext text default '',
58 pc_comments int(11) default '0',
59 pc_counter mediumint(8) unsigned default '0',
60 pc_topic int(3) NOT NULL default '1',
61 pc_informant varchar(20) NOT NULL default '',
62 pc_eventDate date NOT NULL default '0000-00-00',
63 pc_endDate date NOT NULL default '0000-00-00',
64 pc_duration bigint(20) NOT NULL default '0',
65 pc_recurrtype int(1) NOT NULL default '0',
66 pc_recurrspec text default '',
67 pc_recurrfreq int(3) NOT NULL default '0',
70 pc_alldayevent int(1) NOT NULL default '0',
71 pc_location text default '',
72 pc_conttel varchar(50) default '',
73 pc_contname varchar(50) default '',
74 pc_contemail varchar(255) default '',
75 pc_website varchar(255) default '',
76 pc_fee varchar(50) default '',
77 pc_eventstatus int(11) NOT NULL default '0',
78 pc_sharing int(11) NOT NULL default '0',
79 pc_language varchar(30) default '',
81 KEY basic_event (pc_catid,pc_aid,pc_eventDate,pc_endDate,pc_eventstatus,pc_sharing,pc_topic)
83 $dbconn->Execute($sql);
84 if ($dbconn->ErrorNo() != 0) {
85 pnSessionSetVar('errormsg', $dbconn->ErrorMsg());
89 // create the category table
90 $sql = "CREATE TABLE $cat_table (
91 pc_catid int(11) unsigned NOT NULL auto_increment,
92 pc_catname varchar(100) NOT NULL default 'Undefined',
93 pc_catcolor varchar(50) NOT NULL default '#EEEEEE',
94 pc_catdesc text default '',
95 PRIMARY KEY (pc_catid),
96 KEY basic_cat (pc_catname,pc_catcolor)
98 $dbconn->Execute($sql);
99 if ($dbconn->ErrorNo() != 0) {
100 pnSessionSetVar('errormsg', $dbconn->ErrorMsg());
104 // insert default category
105 $catid = $dbconn->GenID($cat_table);
106 $sql = "INSERT INTO $cat_table (pc_catid, pc_catname, pc_catcolor, pc_catdesc)
107 VALUES($catid,'Default','#EEEEEE','Default Category')";
108 $dbconn->Execute($sql);
109 if ($dbconn->ErrorNo() != 0) {
110 pnSessionSetVar('errormsg', $dbconn->ErrorMsg());
114 // PostCalendar Default Settings
115 pnModSetVar(__POSTCALENDAR__
, 'pcTime24Hours', '0');
116 pnModSetVar(__POSTCALENDAR__
, 'pcEventsOpenInNewWindow', '0');
117 pnModSetVar(__POSTCALENDAR__
, 'pcUseInternationalDates', '0');
118 pnModSetVar(__POSTCALENDAR__
, 'pcFirstDayOfWeek', '0');
119 pnModSetVar(__POSTCALENDAR__
, 'pcDayHighlightColor', '#EEEEEE');
120 pnModSetVar(__POSTCALENDAR__
, 'pcUsePopups', '1');
121 pnModSetVar(__POSTCALENDAR__
, 'pcDisplayTopics', '0');
122 pnModSetVar(__POSTCALENDAR__
, 'pcAllowDirectSubmit', '0');
123 pnModSetVar(__POSTCALENDAR__
, 'pcListHowManyEvents', '15');
124 pnModSetVar(__POSTCALENDAR__
, 'pcTimeIncrement', '15');
125 pnModSetVar(__POSTCALENDAR__
, 'pcAllowSiteWide', '0');
126 pnModSetVar(__POSTCALENDAR__
, 'pcAllowUserCalendar', '1');
127 pnModSetVar(__POSTCALENDAR__
, 'pcEventDateFormat', '%Y-%m-%d');
128 pnModSetVar(__POSTCALENDAR__
, 'pcTemplate', 'default');
129 pnModSetVar(__POSTCALENDAR__
, 'pcUseCache', '1');
130 pnModSetVar(__POSTCALENDAR__
, 'pcCacheLifetime', '3600');
131 pnModSetVar(__POSTCALENDAR__
, 'pcDefaultView', 'month');
132 pnModSetVar(__POSTCALENDAR__
, 'pcNotifyAdmin', '0');
133 pnModSetVar(__POSTCALENDAR__
, 'pcNotifyEmail', pnConfigGetVar('adminmail'));
138 * Upgrades an old install of PostCalendar
140 * This function is used to upgrade an old version
141 * of PostCalendar. It is accessed via the PostNuke
142 * Admin interface and should not be called directly.
144 * @return boolean true/false
145 * @param string $oldversion Version we're upgrading
147 * @author Roger Raymond <iansym@yahoo.com>
148 * @copyright The PostCalendar Team 2002
150 function postcalendar_upgrade($oldversion)
153 * Until PostNuke fixes the bugs
154 * with the module upgrade we are
155 * going to have to do it ourselves.
157 * Please do not use the Modules admin
158 * to upgrade PostCalendar. Use the
159 * link provided in the PostCalendar
162 $pcModInfo = pnModGetInfo(pnModGetIDFromName(__POSTCALENDAR__
));
163 $pcDir = pnVarPrepForOS($pcModInfo['directory']);
165 list($dbconn) = pnDBGetConn();
166 $pntable = pnDBGetTables();
167 $events_table = $pntable['postcalendar_events'];
168 $cat_table = $pntable['postcalendar_categories'];
170 switch ($oldversion) {
176 // we need the Date_Calc class
177 require_once("modules/$pcDir/pnincludes/Date/Calc.php");
179 // Update PostCalendar Variables
180 pnModSetVar(__POSTCALENDAR__
, 'pcTime24Hours', pnModGetVar(__POSTCALENDAR__
, 'time24hours'));
181 pnModSetVar(__POSTCALENDAR__
, 'pcEventsOpenInNewWindow', pnModGetVar(__POSTCALENDAR__
, 'eventsopeninnewwindow'));
182 pnModSetVar(__POSTCALENDAR__
, 'pcUseInternationalDates', pnModGetVar(__POSTCALENDAR__
, 'useinternationaldates'));
183 pnModSetVar(__POSTCALENDAR__
, 'pcFirstDayOfWeek', pnModGetVar(__POSTCALENDAR__
, 'firstdayofweek'));
184 pnModSetVar(__POSTCALENDAR__
, 'pcDayHighlightColor', pnModGetVar(__POSTCALENDAR__
, 'dayhighlightcolor'));
185 pnModSetVar(__POSTCALENDAR__
, 'pcUsePopups', pnModGetVar(__POSTCALENDAR__
, 'usepopups'));
186 pnModSetVar(__POSTCALENDAR__
, 'pcDisplayTopics', pnModGetVar(__POSTCALENDAR__
, 'displaytopics'));
187 pnModSetVar(__POSTCALENDAR__
, 'pcAllowDirectSubmit', '0');
188 pnModSetVar(__POSTCALENDAR__
, 'pcListHowManyEvents', pnModGetVar(__POSTCALENDAR__
, 'listhowmanyevents'));
189 pnModSetVar(__POSTCALENDAR__
, 'pcTimeIncrement', '15');
190 pnModSetVar(__POSTCALENDAR__
, 'pcAllowSiteWide', '0');
191 pnModSetVar(__POSTCALENDAR__
, 'pcAllowUserCalendar', '1');
192 pnModSetVar(__POSTCALENDAR__
, 'pcEventDateFormat', '%Y-%m-%d');
193 pnModSetVar(__POSTCALENDAR__
, 'pcTemplate', 'default');
194 pnModSetVar(__POSTCALENDAR__
, 'pcUseCache', '1');
195 pnModSetVar(__POSTCALENDAR__
, 'pcCacheLifetime', '3600');
196 pnModSetVar(__POSTCALENDAR__
, 'pcDefaultView', 'month');
197 pnModSetVar(__POSTCALENDAR__
, 'pcSafeMode', '0');
199 // alter the events table and change some old columns
200 $sql = "ALTER TABLE $events_table
201 ADD pc_catid int(11) default '0' NOT NULL,
202 ADD pc_duration bigint(20) default '0' NOT NULL,
203 ADD pc_sharing int(11) default '0' NOT NULL,
204 ADD pc_language varchar(30) default '',
205 CHANGE pc_eid pc_eid int(11) unsigned NOT NULL auto_increment,
206 CHANGE pc_location pc_location text,
207 CHANGE pc_conttel pc_conttel varchar(50),
208 CHANGE pc_contname pc_contname varchar(150),
209 CHANGE pc_contemail pc_contemail varchar(255),
210 CHANGE pc_website pc_website varchar(255),
211 CHANGE pc_fee pc_fee varchar(50),
212 CHANGE pc_recurrspec pc_recurrspec text default ''
215 $dbconn->Execute($sql);
216 if ($dbconn->ErrorNo() != 0) {
217 die('event table alter error : '.$dbconn->ErrorMsg());
221 // create the new categories table
222 $sql = "CREATE TABLE $cat_table (
223 pc_catid int(11) unsigned NOT NULL auto_increment,
224 pc_catname varchar(100) NOT NULL default 'Undefined',
225 pc_catcolor varchar(50) NOT NULL default '#EEEEEE',
226 pc_catdesc text default '',
227 PRIMARY KEY(pc_catid)
229 $dbconn->Execute($sql);
230 if ($dbconn->ErrorNo() != 0) {
231 die('cat table create error : '.$dbconn->ErrorMsg());
235 // insert the current hardcoded categories into the new categories table
236 $category1 = pnVarPrepForStore(pnModGetVar(__POSTCALENDAR__
, 'category1'));
237 $category2 = pnVarPrepForStore(pnModGetVar(__POSTCALENDAR__
, 'category2'));
238 $category3 = pnVarPrepForStore(pnModGetVar(__POSTCALENDAR__
, 'category3'));
239 $category4 = pnVarPrepForStore(pnModGetVar(__POSTCALENDAR__
, 'category4'));
240 $category5 = pnVarPrepForStore(pnModGetVar(__POSTCALENDAR__
, 'category5'));
243 "INSERT INTO $cat_table (pc_catid,pc_catname,pc_catcolor) VALUES ('1','$category1','#EEEEEE')",
244 "INSERT INTO $cat_table (pc_catid,pc_catname,pc_catcolor) VALUES ('2','$category2','#00ff00')",
245 "INSERT INTO $cat_table (pc_catid,pc_catname,pc_catcolor) VALUES ('3','$category3','#0000ff')",
246 "INSERT INTO $cat_table (pc_catid,pc_catname,pc_catcolor) VALUES ('4','$category4','#ffffff')",
247 "INSERT INTO $cat_table (pc_catid,pc_catname,pc_catcolor) VALUES ('5','$category5','#ffcc00')"
250 foreach ($inserts as $insert) {
251 $dbconn->Execute($insert);
252 if ($dbconn->ErrorNo() != 0) {
253 die('cat table insert error : '.$dbconn->ErrorMsg());
258 // update the current events to reflect the category system change
260 "UPDATE $events_table SET pc_catid = 1 WHERE pc_barcolor = 'r' ",
261 "UPDATE $events_table SET pc_catid = 2 WHERE pc_barcolor = 'g' ",
262 "UPDATE $events_table SET pc_catid = 3 WHERE pc_barcolor = 'b' ",
263 "UPDATE $events_table SET pc_catid = 4 WHERE pc_barcolor = 'w' ",
264 "UPDATE $events_table SET pc_catid = 5 WHERE pc_barcolor = 'y' "
267 foreach ($updates as $update) {
268 $dbconn->Execute($update);
269 if ($dbconn->ErrorNo() != 0) {
270 die('event table update error : '.$dbconn->ErrorMsg());
275 // alter the events table and drop the old barcolor column
276 $sql = "ALTER TABLE $events_table DROP pc_barcolor";
277 $dbconn->Execute($sql);
278 if ($dbconn->ErrorNo() != 0) {
279 die('cat table alter error : '.$dbconn->ErrorMsg());
283 // remove the old vars as they are no longer needed
284 pnModDelVar(__POSTCALENDAR__
, 'category1');
285 pnModDelVar(__POSTCALENDAR__
, 'category2');
286 pnModDelVar(__POSTCALENDAR__
, 'category3');
287 pnModDelVar(__POSTCALENDAR__
, 'category4');
288 pnModDelVar(__POSTCALENDAR__
, 'category5');
289 pnModDelVar(__POSTCALENDAR__
, 'time24hours');
290 pnModDelVar(__POSTCALENDAR__
, 'eventsopeninnewwindow');
291 pnModDelVar(__POSTCALENDAR__
, 'useinternationaldates');
292 pnModDelVar(__POSTCALENDAR__
, 'firstdayofweek');
293 pnModDelVar(__POSTCALENDAR__
, 'dayhighlightcolor');
294 pnModDelVar(__POSTCALENDAR__
, 'displaytopics');
295 pnModDelVar(__POSTCALENDAR__
, 'usepopups');
296 pnModDelVar(__POSTCALENDAR__
, 'listhowmanyevents');
297 pnModDelVar(__POSTCALENDAR__
, 'allowdirectsubmit');
298 pnModDelVar(__POSTCALENDAR__
, 'showeventsinyear');
300 //======================================================
301 // now, ideally, we will convert old events to the new
302 // style. this consists of reconfiguring the repeating
305 // we need to establish the current repeating
306 // conditions and convert them to the new system
307 //======================================================
308 // old repeating defines
309 //======================================================
310 @define
('_EVENT_NONE', -1);
311 @define
('_EVENT_DAILY', 0);
312 @define
('_EVENT_WEEKLY', 1);
313 @define
('_EVENT_MONTHLY', 2);
314 @define
('_EVENT_YEARLY', 3);
315 @define
('_RECUR_SAME_DAY', 0);
316 @define
('_RECUR_SAME_DATE', 1);
317 //======================================================
318 // new repeating defines
319 // $recurrspec['event_repeat']
320 //======================================================
321 @define
('NO_REPEAT', 0);
322 @define
('REPEAT', 1);
323 @define
('REPEAT_ON', 2);
324 @define
('REPEAT_DAYS', 3);
326 //======================================================
327 // $recurrspec['event_repeat_freq']
328 //======================================================
329 @define
('REPEAT_EVERY', 1);
330 @define
('REPEAT_EVERY_OTHER', 2);
331 @define
('REPEAT_EVERY_THIRD', 3);
332 @define
('REPEAT_EVERY_FOURTH', 4);
333 //======================================================
334 // $recurrspec['event_repeat_freq_type']
335 //======================================================
336 @define
('REPEAT_EVERY_DAY', 0);
337 @define
('REPEAT_EVERY_WEEK', 1);
338 @define
('REPEAT_EVERY_MONTH', 2);
339 @define
('REPEAT_EVERY_YEAR', 3);
340 //======================================================
341 // $recurrspec['event_repeat_on_num']
342 //======================================================
343 @define
('REPEAT_ON_1ST', 1);
344 @define
('REPEAT_ON_2ND', 2);
345 @define
('REPEAT_ON_3RD', 3);
346 @define
('REPEAT_ON_4TH', 4);
347 @define
('REPEAT_ON_LAST', 5);
348 //======================================================
349 // $recurrspec['event_repeat_on_day']
350 //======================================================
351 @define
('REPEAT_ON_SUN', 0);
352 @define
('REPEAT_ON_MON', 1);
353 @define
('REPEAT_ON_TUE', 2);
354 @define
('REPEAT_ON_WED', 3);
355 @define
('REPEAT_ON_THU', 4);
356 @define
('REPEAT_ON_FRI', 5);
357 @define
('REPEAT_ON_SAT', 6);
358 //======================================================
359 // $recurrspec['event_repeat_on_freq']
360 //======================================================
361 @define
('REPEAT_ON_MONTH', 1);
362 @define
('REPEAT_ON_2MONTH', 2);
363 @define
('REPEAT_ON_3MONTH', 3);
364 @define
('REPEAT_ON_4MONTH', 4);
365 @define
('REPEAT_ON_6MONTH', 6);
366 @define
('REPEAT_ON_YEAR', 12);
367 //======================================================
368 // Set Sharing Paramaters
369 //======================================================
370 @define
('SHARING_PRIVATE', 0);
371 @define
('SHARING_PUBLIC', 1);
372 @define
('SHARING_BUSY', 2);
373 @define
('SHARING_GLOBAL', 3);
374 //======================================================
375 // Here's some psuedo-code for the conversion
378 // $rtype = NO_REPEAT
379 // $rspec = 0 for all;
380 // $duration = endTime - startTime
384 // $rspec = REPEAT_EVERY|REPEAT_EVERY_DAY
385 // $duration = endTime - startTime
389 // $rspec = REPEAT_EVERY|REPEAT_EVERY_WEEK
390 // $duration = endTime - startTime
393 // if _RECUR_SAME_DAY
394 // $rtype = REPEAT_ON
395 // $rspec = REPEAT_ON_NUM|REPEAT_ON_DAY|REPEAT_ON_FREQ
396 // if _RECUR_SAME_DATE
398 // $rspec = REPEAT_EVERY|REPEAT_EVERY_MONTH
399 // $duration = endTime - startTime
402 // if _RECUR_SAME_DAY
403 // $rtype = REPEAT_ON
404 // $rspec = REPEAT_ON_NUM|REPEAT_ON_DAY|REPEAT_ON_FREQ
405 // if _RECUR_SAME_DATE
407 // $rspec = REPEAT_EVERY|REPEAT_EVERY_YEAR
408 // $duration = endTime - startTime
409 //======================================================
410 // attempt reconfiguration
411 //======================================================
412 $sql = "SELECT pc_eid, pc_eventDate, pc_startTime, pc_endTime, pc_recurrtype, pc_recurrfreq
414 $result = $dbconn->Execute($sql);
415 if ($dbconn->ErrorNo() != 0) {
416 die($dbconn->ErrorMsg());
420 if (!isset($result)) {
424 // grab the results and start the conversion
425 for (; !$result->EOF
; $result->MoveNext()) {
426 $recurrspec = array();
427 list($eid,$eventdate,$start,$end,$rtype,$rfreq) = $result->fields
;
429 if ($rtype == null) {
430 $rtype = _EVENT_NONE
;
435 $recurrtype = NO_REPEAT
;
436 $recurrspec['event_repeat_freq'] = 0;
437 $recurrspec['event_repeat_freq_type'] = 0;
438 $recurrspec['event_repeat_on_num'] = 0;
439 $recurrspec['event_repeat_on_day'] = 0;
440 $recurrspec['event_repeat_on_freq'] = 0;
444 $recurrtype = REPEAT
;
445 $recurrspec['event_repeat_freq'] = REPEAT_EVERY
;
446 $recurrspec['event_repeat_freq_type'] = REPEAT_EVERY_DAY
;
447 $recurrspec['event_repeat_on_num'] = 0;
448 $recurrspec['event_repeat_on_day'] = 0;
449 $recurrspec['event_repeat_on_freq'] = 0;
453 $recurrtype = REPEAT
;
454 $recurrspec['event_repeat_freq'] = REPEAT_EVERY
;
455 $recurrspec['event_repeat_freq_type'] = REPEAT_EVERY_WEEK
;
456 $recurrspec['event_repeat_on_num'] = 0;
457 $recurrspec['event_repeat_on_day'] = 0;
458 $recurrspec['event_repeat_on_freq'] = 0;
462 if ($rfreq == _RECUR_SAME_DATE
) {
463 $recurrtype = REPEAT
;
464 $recurrspec['event_repeat_freq'] = REPEAT_EVERY
;
465 $recurrspec['event_repeat_freq_type'] = REPEAT_EVERY_MONTH
;
466 $recurrspec['event_repeat_on_num'] = 0;
467 $recurrspec['event_repeat_on_day'] = 0;
468 $recurrspec['event_repeat_on_freq'] = 0;
469 } elseif ($rfreq == _RECUR_SAME_DAY
) {
470 $recurrtype = REPEAT_ON
;
471 list($y,$m,$d) = explode('-', $eventdate);
472 $recurrspec['event_repeat_freq'] = 0;
473 $recurrspec['event_repeat_freq_type'] = 0;
475 $edow = Date_Calc
::dayOfWeek($d, $m, $y);
476 // date of first event day of week
477 $firstDay = Date_Calc
::NWeekdayOfMonth(1, $edow, $m, $y, '%Y-%m-%d');
478 // find difference between 1st day and event day
479 list($y2,$m2,$d2) = explode('-', $firstDay);
480 $diff = Date_Calc
::dateDiff($d, $m, $y, $d2, $m2, $y2);
481 // assuming $diff is going to be a multiple of 7
486 if ($diff > REPEAT_ON_4TH
) {
487 $diff = REPEAT_ON_LAST
;
490 $recurrspec['event_repeat_on_num'] = $diff;
491 $recurrspec['event_repeat_on_day'] = $edow;
492 $recurrspec['event_repeat_on_freq'] = REPEAT_ON_MONTH
;
497 if ($rfreq == _RECUR_SAME_DATE
) {
498 $recurrtype = REPEAT
;
499 $recurrspec['event_repeat_freq'] = REPEAT_EVERY
;
500 $recurrspec['event_repeat_freq_type'] = REPEAT_EVERY_YEAR
;
501 $recurrspec['event_repeat_on_num'] = 0;
502 $recurrspec['event_repeat_on_day'] = 0;
503 $recurrspec['event_repeat_on_freq'] = 0;
504 } elseif ($rfreq == _RECUR_SAME_DAY
) {
505 $recurrtype = REPEAT_ON
;
506 list($y,$m,$d) = explode('-', $eventdate);
507 $recurrspec['event_repeat_freq'] = 0;
508 $recurrspec['event_repeat_freq_type'] = 0;
510 $edow = Date_Calc
::dayOfWeek($d, $m, $y);
511 // date of first event day of week
512 $firstDay = Date_Calc
::NWeekdayOfMonth(1, $edow, $m, $y, '%Y-%m-%d');
513 // find difference between 1st day and event day
514 list($y2,$m2,$d2) = explode('-', $firstDay);
515 $diff = Date_Calc
::dateDiff($d, $m, $y, $d2, $m2, $y2);
516 // assuming $diff is going to be a multiple of 7
521 if ($diff > REPEAT_ON_4TH
) {
522 $diff = REPEAT_ON_LAST
;
525 $recurrspec['event_repeat_on_num'] = $diff;
526 $recurrspec['event_repeat_on_day'] = $edow;
527 $recurrspec['event_repeat_on_freq'] = REPEAT_ON_YEAR
;
532 // ok, figure out the event's duration
533 list($sh,$sm,$ss) = explode(':', $start);
534 list($eh,$em,$es) = explode(':', $end);
535 $stime = mktime($sh, $sm, $ss, 1, 1, 1970);
536 // if the ending hour is less than the starting hour
537 // assume that the event spans to the next day
539 $etime = mktime($eh, $em, $es, 1, 2, 1970);
541 $etime = mktime($eh, $em, $es, 1, 1, 1970);
544 $duration = $etime - $stime;
545 // prep the vars for the sql statement
546 $eid = pnVarPrepForStore($eid);
547 $recurrtype = pnVarPrepForStore($recurrtype);
548 $recurrspec = pnVarPrepForStore(serialize($recurrspec));
549 // create our sql statement
550 $updatesql = "UPDATE $events_table SET
552 pc_recurrtype = $recurrtype,
553 pc_recurrspec = '$recurrspec',
554 pc_duration = $duration,
555 pc_sharing = ".SHARING_GLOBAL
."
556 WHERE pc_eid = $eid";
557 // execute our sql statement
558 $dbconn->Execute($updatesql);
559 if ($dbconn->ErrorNo() != 0) {
560 die($dbconn->ErrorMsg());
567 // all done, proceed with next upgrade step if available/necessary
568 return postcalendar_upgrade('3.1');
576 return postcalendar_upgrade('3.9.0');
583 pnModSetVar(__POSTCALENDAR__
, 'pcSafeMode', '0');
584 return postcalendar_upgrade('3.9.3');
590 $sql = "ALTER TABLE $events_table
591 ADD INDEX basic_event (pc_catid,pc_aid,pc_eventDate,pc_endDate,pc_eventstatus,pc_sharing,pc_topic)";
592 $dbconn->Execute($sql);
593 if ($dbconn->ErrorNo() != 0) {
594 die($dbconn->ErrorMsg());
599 $sql = "ALTER TABLE $cat_table
600 ADD INDEX basic_cat (pc_catname, pc_catcolor)";
601 $dbconn->Execute($sql);
602 if ($dbconn->ErrorNo() != 0) {
603 die($dbconn->ErrorMsg());
606 return postcalendar_upgrade('3.9.4');
613 return postcalendar_upgrade('3.9.8');
617 pnModDelVar(__POSTCALENDAR__
, 'pcSafeMode');
618 pnModSetVar(__POSTCALENDAR__
, 'pcNotifyAdmin', '0');
619 pnModSetVar(__POSTCALENDAR__
, 'pcNotifyEmail', pnConfigGetVar('adminmail'));
626 // if we get this far - load the userapi and clear the cache
627 if (!pnModAPILoad(__POSTCALENDAR__
, 'user')) {
631 $tpl =& new pcSmarty();
632 $tpl->clear_all_cache();
633 $tpl->clear_compiled_tpl();
638 * Deletes an install of PostCalendar
640 * This function removes PostCalendar from you
641 * PostNuke install and should be accessed via
642 * the PostNuke Admin interface
644 * @return boolean true/false
646 * @author Roger Raymond <iansym@yahoo.com>
647 * @copyright The PostCalendar Team 2002
649 function postcalendar_delete()
651 list($dbconn) = pnDBGetConn();
652 $pntable = pnDBGetTables();
653 $events_table = $pntable['postcalendar_events'];
654 $cat_table = $pntable['postcalendar_categories'];
655 $blocks_table = $pntable['blocks'];
656 $blocks_column =& $pntable['blocks_column'];
659 $modid = pnModGetIDFromName(__POSTCALENDAR__
);
661 // remove the PostCalendar events table
662 $sql = "DROP TABLE $events_table";
663 $dbconn->Execute($sql);
664 if ($dbconn->ErrorNo() != 0) {
665 pnSessionSetVar('errormsg', $dbconn->ErrorMsg());
669 // remove the PostCalendar categories table
670 $sql = "DROP TABLE $cat_table";
671 $dbconn->Execute($sql);
672 if ($dbconn->ErrorNo() != 0) {
673 pnSessionSetVar('errormsg', $dbconn->ErrorMsg());
677 // remove all the PostCalendar variables from the DB
678 pnModDelVar(__POSTCALENDAR__
, 'pcTime24Hours');
679 pnModDelVar(__POSTCALENDAR__
, 'pcEventsOpenInNewWindow');
680 pnModDelVar(__POSTCALENDAR__
, 'pcUseInternationalDates');
681 pnModDelVar(__POSTCALENDAR__
, 'pcFirstDayOfWeek');
682 pnModDelVar(__POSTCALENDAR__
, 'pcDayHighlightColor');
683 pnModDelVar(__POSTCALENDAR__
, 'pcUsePopups');
684 pnModDelVar(__POSTCALENDAR__
, 'pcDisplayTopics');
685 pnModDelVar(__POSTCALENDAR__
, 'pcAllowDirectSubmit');
686 pnModDelVar(__POSTCALENDAR__
, 'pcListHowManyEvents');
687 pnModDelVar(__POSTCALENDAR__
, 'pcTimeIncrement');
688 pnModDelVar(__POSTCALENDAR__
, 'pcAllowSiteWide');
689 pnModDelVar(__POSTCALENDAR__
, 'pcAllowUserCalendar');
690 pnModDelVar(__POSTCALENDAR__
, 'pcEventDateFormat');
691 pnModDelVar(__POSTCALENDAR__
, 'pcTemplate');
692 pnModDelVar(__POSTCALENDAR__
, 'pcUseCache');
693 pnModDelVar(__POSTCALENDAR__
, 'pcCacheLifetime');
694 pnModDelVar(__POSTCALENDAR__
, 'pcDefaultView');
695 pnModDelVar(__POSTCALENDAR__
, 'pcSafeMode');
696 pnModDelVar(__POSTCALENDAR__
, 'pcNotifyAdmin');
697 pnModDelVar(__POSTCALENDAR__
, 'pcNotifyEmail');
699 // remove any blocks associated with PostCalendar
700 // Seems the core does not clean up installed blocks so I will.
701 // I appologize for accessing core tables directly.
702 $sql = "DELETE FROM $blocks_table WHERE $blocks_column[mid] = '$modid'";
703 $dbconn->Execute($sql);
704 if ($dbconn->ErrorNo() != 0) {
705 pnSessionSetVar('errormsg', $dbconn->ErrorMsg());
709 // Deletion successful