| [ Index ] |
krapohl.info |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * $Id: common.api.php,v 1.5 2004/08/19 19:17:44 larsneo Exp $ 4 * 5 * PostCalendar::PostNuke Events Calendar Module 6 * Copyright (C) 2002 The PostCalendar Team 7 * http://postcalendar.tv 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * 23 * To read the license please read the docs/license.txt or visit 24 * http://www.gnu.org/copyleft/gpl.html 25 * 26 */ 27 28 //================================================================= 29 // define constants used to make the code more readable 30 //================================================================= 31 define('_IS_SUNDAY', 0); 32 define('_IS_MONDAY', 1); 33 define('_IS_SATURDAY', 6); 34 define('_AM_VAL', 1); 35 define('_PM_VAL', 2); 36 define('_ACTION_DELETE', 4); 37 define('_ACTION_EDIT', 2); 38 define('_EVENT_APPROVED', 1); 39 define('_EVENT_QUEUED', 0); 40 define('_EVENT_HIDDEN', -1); 41 // $event_repeat 42 define('NO_REPEAT', 0); 43 define('REPEAT', 1); 44 define('REPEAT_ON', 2); 45 // $event_repeat_freq 46 define('REPEAT_EVERY', 1); 47 define('REPEAT_EVERY_OTHER', 2); 48 define('REPEAT_EVERY_THIRD', 3); 49 define('REPEAT_EVERY_FOURTH', 4); 50 // $event_repeat_freq_type 51 define('REPEAT_EVERY_DAY', 0); 52 define('REPEAT_EVERY_WEEK', 1); 53 define('REPEAT_EVERY_MONTH', 2); 54 define('REPEAT_EVERY_YEAR', 3); 55 // $event_repeat_on_num 56 define('REPEAT_ON_1ST', 1); 57 define('REPEAT_ON_2ND', 2); 58 define('REPEAT_ON_3RD', 3); 59 define('REPEAT_ON_4TH', 4); 60 define('REPEAT_ON_LAST', 5); 61 // $event_repeat_on_day 62 define('REPEAT_ON_SUN', 0); 63 define('REPEAT_ON_MON', 1); 64 define('REPEAT_ON_TUE', 2); 65 define('REPEAT_ON_WED', 3); 66 define('REPEAT_ON_THU', 4); 67 define('REPEAT_ON_FRI', 5); 68 define('REPEAT_ON_SAT', 6); 69 // $event_repeat_on_freq 70 define('REPEAT_ON_MONTH', 1); 71 define('REPEAT_ON_2MONTH', 2); 72 define('REPEAT_ON_3MONTH', 3); 73 define('REPEAT_ON_4MONTH', 4); 74 define('REPEAT_ON_6MONTH', 6); 75 define('REPEAT_ON_YEAR', 12); 76 // event sharing values 77 define('SHARING_PRIVATE', 0); 78 define('SHARING_PUBLIC', 1); 79 define('SHARING_BUSY', 2); 80 define('SHARING_GLOBAL', 3); 81 // admin defines 82 define('_ADMIN_ACTION_APPROVE', 0); 83 define('_ADMIN_ACTION_HIDE', 1); 84 define('_ADMIN_ACTION_EDIT', 2); 85 define('_ADMIN_ACTION_VIEW', 3); 86 define('_ADMIN_ACTION_DELETE', 4); 87 //================================================================= 88 // Get the global PostCalendar config settings 89 // This will save us a lot of time and DB queries later 90 //================================================================= 91 define('_SETTING_USE_POPUPS', pnModGetVar(__POSTCALENDAR__,'pcUsePopups')); 92 define('_SETTING_USE_INT_DATES', pnModGetVar(__POSTCALENDAR__,'pcUseInternationalDates')); 93 define('_SETTING_OPEN_NEW_WINDOW', pnModGetVar(__POSTCALENDAR__,'pcEventsOpenInNewWindow')); 94 define('_SETTING_DAY_HICOLOR', pnModGetVar(__POSTCALENDAR__,'pcDayHighlightColor')); 95 define('_SETTING_FIRST_DAY_WEEK', pnModGetVar(__POSTCALENDAR__,'pcFirstDayOfWeek')); 96 define('_SETTING_DATE_FORMAT', pnModGetVar(__POSTCALENDAR__,'pcEventDateFormat')); 97 define('_SETTING_TIME_24HOUR', pnModGetVar(__POSTCALENDAR__,'pcTime24Hours')); 98 define('_SETTING_DIRECT_SUBMIT', pnModGetVar(__POSTCALENDAR__,'pcAllowDirectSubmit')); 99 define('_SETTING_DISPLAY_TOPICS', pnModGetVar(__POSTCALENDAR__,'pcDisplayTopics')); 100 define('_SETTING_ALLOW_GLOBAL', pnModGetVar(__POSTCALENDAR__,'pcAllowSiteWide')); 101 define('_SETTING_ALLOW_USER_CAL', pnModGetVar(__POSTCALENDAR__,'pcAllowUserCalendar')); 102 define('_SETTING_TIME_INCREMENT', pnModGetVar(__POSTCALENDAR__,'pcTimeIncrement')); 103 define('_SETTING_HOW_MANY_EVENTS', pnModGetVar(__POSTCALENDAR__,'pcListHowManyEvents')); 104 define('_SETTING_TEMPLATE', pnModGetVar(__POSTCALENDAR__,'pcTemplate')); 105 define('_SETTING_EVENTS_IN_YEAR', pnModGetVar(__POSTCALENDAR__,'pcShowEventsInYear')); 106 define('_SETTING_USE_CACHE', pnModGetVar(__POSTCALENDAR__,'pcUseCache')); 107 define('_SETTING_CACHE_LIFETIME', pnModGetVar(__POSTCALENDAR__,'pcCacheLifetime')); 108 define('_SETTING_DEFAULT_VIEW', pnModGetVar(__POSTCALENDAR__,'pcDefaultView')); 109 define('_SETTING_SAFE_MODE', pnModGetVar(__POSTCALENDAR__,'pcSafeMode')); 110 define('_SETTING_NOTIFY_ADMIN', pnModGetVar(__POSTCALENDAR__,'pcNotifyAdmin')); 111 define('_SETTING_NOTIFY_EMAIL', pnModGetVar(__POSTCALENDAR__,'pcNotifyEmail')); 112 //================================================================= 113 // Make checking basic permissions easier 114 //================================================================= 115 define('PC_ACCESS_ADMIN', pnSecAuthAction(0, 'PostCalendar::', 'null::null', ACCESS_ADMIN)); 116 define('PC_ACCESS_DELETE', pnSecAuthAction(0, 'PostCalendar::', 'null::null', ACCESS_DELETE)); 117 define('PC_ACCESS_ADD', pnSecAuthAction(0, 'PostCalendar::', 'null::null', ACCESS_ADD)); 118 define('PC_ACCESS_EDIT', pnSecAuthAction(0, 'PostCalendar::', 'null::null', ACCESS_EDIT)); 119 define('PC_ACCESS_MODERATE', pnSecAuthAction(0, 'PostCalendar::', 'null::null', ACCESS_MODERATE)); 120 define('PC_ACCESS_COMMENT', pnSecAuthAction(0, 'PostCalendar::', 'null::null', ACCESS_COMMENT)); 121 define('PC_ACCESS_READ', pnSecAuthAction(0, 'PostCalendar::', 'null::null', ACCESS_READ)); 122 define('PC_ACCESS_OVERVIEW', pnSecAuthAction(0, 'PostCalendar::', 'null::null', ACCESS_OVERVIEW)); 123 define('PC_ACCESS_NONE', pnSecAuthAction(0, 'PostCalendar::', 'null::null', ACCESS_NONE)); 124 //========================================================================= 125 // Require and Setup utility classes and functions 126 //========================================================================= 127 define('DATE_CALC_BEGIN_WEEKDAY', _SETTING_FIRST_DAY_WEEK); 128 require_once("modules/$pcDir/pnincludes/Date/Calc.php"); 129 //========================================================================= 130 // grab the global language file 131 //========================================================================= 132 $userlang = pnUserGetLang(); 133 if(file_exists("modules/$pcDir/pnlang/$userlang/global.php")) { 134 require_once("modules/$pcDir/pnlang/$userlang/global.php"); 135 } else { 136 require_once("modules/$pcDir/pnlang/eng/global.php"); 137 } 138 unset($userlang); 139 //========================================================================= 140 // Setup Smarty defines 141 //========================================================================= 142 if(!class_exists('Smarty')) { 143 define('_PC_SMARTY_LOADED',true); 144 define('SMARTY_DIR',"modules/$pcDir/pnincludes/Smarty/"); 145 require_once(SMARTY_DIR.'/Smarty.class.php'); 146 } 147 require_once("modules/$pcDir/pcSmarty.class.php"); 148 //========================================================================= 149 // utility functions for postcalendar 150 //========================================================================= 151 function pcDebugVar($in) 152 { 153 echo '<pre>'; 154 if(is_array($in)) print_r($in); 155 else echo $in; 156 echo '</pre>'; 157 } 158 function &pcVarPrepForDisplay($s) { 159 $s = nl2br(pnVarPrepForDisplay(postcalendar_removeScriptTags($s))); 160 $s = preg_replace('/&(#)?([0-9a-z]+);/i','&\\1\\2;',$s); 161 return $s; 162 } 163 function &pcVarPrepHTMLDisplay($s) { 164 return pnVarPrepHTMLDisplay(postcalendar_removeScriptTags($s)); 165 } 166 function pcGetTopicName($topicid) 167 { 168 list($dbconn) = pnDBGetConn(); 169 $pntable = pnDBGetTables(); 170 171 $topics_table = $pntable['topics']; 172 $topics_column = &$pntable['topics_column']; 173 $sql = "SELECT $topics_column[topicname] 174 FROM $topics_table 175 WHERE $topics_column[topicid] = '".(int)pnVarPrepForStore($topicid)."'"; 176 $result = $dbconn->Execute($sql); 177 if($result === false) return ''; 178 else return $result->fields[0]; 179 } 180 function &postcalendar_makeValidURL($s) 181 { 182 if(empty($s)) return ''; 183 if(!preg_match('|^http[s]?:\/\/|i',$s)) { 184 $s = 'http://'.$s; 185 } 186 return $s; 187 } 188 function postcalendar_removeScriptTags($in) 189 { 190 return preg_replace("/<script.*?>(.*?)<\/script>/","",$in); 191 } 192 function &postcalendar_getDate($format='%Y%m%d') 193 { 194 list($Date,$jumpday,$jumpmonth,$jumpyear) = pnVarCleanFromInput('Date','jumpday','jumpmonth','jumpyear'); 195 if(!isset($Date)) { 196 // if we still don't have a date then calculate it 197 $time = time(); 198 if (pnUserLoggedIn()) { 199 $time += (pnUserGetVar('timezone_offset') - pnConfigGetVar('timezone_offset')) * 3600; 200 } 201 // check the jump menu 202 if(!isset($jumpday)) $jumpday = strftime('%d',$time); 203 if(!isset($jumpmonth)) $jumpmonth = strftime('%m',$time); 204 if(!isset($jumpyear)) $jumpyear = strftime('%Y',$time); 205 // create the correct date string 206 $Date = (int) "$jumpyear$jumpmonth$jumpday"; 207 } 208 $y = substr($Date,0,4); 209 $m = substr($Date,4,2); 210 $d = substr($Date,6,2); 211 return strftime($format,mktime(0,0,0,$m,$d,$y)); 212 } 213 214 function &postcalendar_today($format='%Y%m%d') 215 { 216 $time = time(); 217 if (pnUserLoggedIn()) { 218 $time += (pnUserGetVar('timezone_offset') - pnConfigGetVar('timezone_offset')) * 3600; 219 } 220 return strftime($format,$time); 221 } 222 223 /** 224 * postcalendar_adminapi_pageSetup() 225 * 226 * sets up any necessary javascript for the page 227 * @return string javascript to insert into the page 228 */ 229 function postcalendar_adminapi_pageSetup() { return postcalendar_userapi_pageSetup(); } 230 /** 231 * postcalendar_userapi_pageSetup() 232 * 233 * sets up any necessary javascript for the page 234 * @return string javascript to insert into the page 235 */ 236 function postcalendar_userapi_pageSetup() 237 { 238 $output = ''; 239 // load the DHTML JavaScript code and insert it into the page 240 if(_SETTING_USE_POPUPS) { $output .= postcalendar_userapi_loadPopups(); } 241 // insert the js popup code into the page (find better code) 242 if(_SETTING_OPEN_NEW_WINDOW) { $output .= postcalendar_userapi_jsPopup(); } 243 return $output; 244 } 245 /** 246 * postcalendar_userapi_jsPopup 247 * Creates the necessary javascript code for a popup window 248 */ 249 function postcalendar_userapi_jsPopup() 250 { if(defined('_POSTCALENDAR_JSPOPUPS_LOADED')) { 251 // only put the script on the page once 252 return false; 253 } 254 define('_POSTCALENDAR_JSPOPUPS_LOADED',true); 255 256 // build the correct link 257 $js_link = "'index.php?module=".__POSTCALENDAR__."&type=user&func=view&viewtype=details&eid='+eid+'&Date='+date+'&popup=1'"; 258 $js_window_options = 'toolbar=no,' 259 . 'location=no,' 260 . 'directories=no,' 261 . 'status=no,' 262 . 'menubar=no,' 263 . 'scrollbars=yes,' 264 . 'resizable=no,' 265 . 'width=600,' 266 . 'height=300'; 267 268 $output = <<<EOF 269 270 <script type="text/javascript" language="JavaScript"> 271 <!-- 272 function opencal(eid,date) { 273 window.name='csCalendar'; 274 w = window.open($js_link,'PostCalendarEvents','$js_window_options'); 275 } 276 // --> 277 </script> 278 279 EOF; 280 return $output; 281 } 282 283 /** 284 * postcalendar_userapi_loadPopups 285 * Creates the necessary javascript code for mouseover dHTML popups 286 */ 287 function postcalendar_userapi_loadPopups() 288 { if(defined('_POSTCALENDAR_LOADPOPUPS_LOADED')) { 289 // only put the script on the page once 290 return false; 291 } 292 define('_POSTCALENDAR_LOADPOPUPS_LOADED',true); 293 294 // get the theme globals :: is there a better way to do this? 295 global $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $bgcolor5; 296 global $textcolor1, $textcolor2; 297 298 // lets get the module's information 299 $modinfo = pnModGetInfo(pnModGetIDFromName(__POSTCALENDAR__)); 300 $pcDir = pnVarPrepForOS($modinfo['directory']); 301 unset($modinfo); 302 $capicon = ''; 303 $close = _PC_OL_CLOSE; 304 305 $output = <<<EOF 306 307 <script type="text/javascript" language="JavaScript"> 308 <!-- overLIB configuration --> 309 ol_fgcolor = "$bgcolor1"; 310 ol_bgcolor = "$bgcolor2"; 311 ol_textcolor = "$textcolor2"; 312 ol_capcolor = "$textcolor2"; 313 ol_closecolor = "$textcolor2"; 314 ol_textfont = "Verdana,Arial,Helvetica"; 315 ol_captionfont = "Verdana,Arial,Helvetica"; 316 ol_captionsize = 2; 317 ol_textsize = 2; 318 ol_border = 2; 319 ol_width = 350; 320 ol_offsetx = 10; 321 ol_offsety = 10; 322 ol_sticky = 0; 323 ol_close = "$close"; 324 ol_closeclick = 0; 325 ol_autostatus = 2; 326 ol_snapx = 0; 327 ol_snapy = 0; 328 ol_fixx = -1; 329 ol_fixy = -1; 330 ol_background = ""; 331 ol_fgbackground = ""; 332 ol_bgbackground = ""; 333 ol_padxl = 1; 334 ol_padxr = 1; 335 ol_padyt = 1; 336 ol_padyb = 1; 337 ol_capicon = "$capicon"; 338 ol_hauto = 1; 339 ol_vauto = 1; 340 </script> 341 <div id="overDiv" style="position:absolute; top:0px; left:0px; visibility:hidden; z-index:1000;"></div> 342 <script type="text/javascript" language="JavaScript" src="modules/$pcDir/pnincludes/overlib_mini.js"> 343 <!-- overLIB (c) Erik Bosrup --> 344 </script> 345 346 EOF; 347 return $output; 348 } 349 350 /** 351 * postcalendar_adminapi_getmonthname() 352 * 353 * Returns the month name translated for the user's current language 354 * 355 * @param array $args['Date'] number of month to return 356 * @return string month name in user's language 357 */ 358 function postcalendar_adminapi_getmonthname($args) { return postcalendar_userapi_getmonthname($args); } 359 /** 360 * postcalendar_userapi_getmonthname() 361 * 362 * Returns the month name translated for the user's current language 363 * 364 * @param array $args['Date'] date to return month name of 365 * @return string month name in user's language 366 */ 367 function postcalendar_userapi_getmonthname($args) 368 { 369 extract($args); unset($args); 370 if(!isset($Date)) { return false; } 371 $month_name = array('01' => _CALJAN, '02' => _CALFEB, '03' => _CALMAR, 372 '04' => _CALAPR, '05' => _CALMAY, '06' => _CALJUN, 373 '07' => _CALJUL, '08' => _CALAUG, '09' => _CALSEP, 374 '10' => _CALOCT, '11' => _CALNOV, '12' => _CALDEC); 375 return $month_name[date('m',$Date)]; 376 } 377 /** 378 * Returns an array of form data for FormSelectMultiple 379 */ 380 function postcalendar_adminapi_buildTimeSelect($args) { return postcalendar_userapi_buildTimeSelect($args); } 381 function postcalendar_userapi_buildTimeSelect($args) 382 { 383 $inc = _SETTING_TIME_INCREMENT; 384 extract($args); unset($args); 385 $output = array('h'=>array(),'m'=>array()); 386 if((bool)_SETTING_TIME_24HOUR) { 387 $start=0; $end=23; 388 } else { 389 $start=1; $end=12; 390 $hselected = $hselected > 12 ? $hselected-=12 : $hselected; 391 } 392 393 for($c=0,$h=$start; $h<=$end; $h++,$c++) { 394 $hour = sprintf('%02d',$h); 395 $output['h'][$c]['id'] = pnVarPrepForStore($h); 396 $output['h'][$c]['selected'] = $hselected == $hour; 397 $output['h'][$c]['name'] = pnVarPrepForDisplay($hour); 398 } 399 400 for($c=0,$m=0; $m<=(60-$inc);$m+=$inc,$c++) { 401 $min = sprintf('%02d',$m); 402 $output['m'][$c]['id'] = pnVarPrepForStore($m); 403 $output['m'][$c]['selected'] = $mselected == $min; 404 $output['m'][$c]['name'] = pnVarPrepForDisplay($min); 405 } 406 return $output; 407 } 408 /** 409 * Returns an array of form data for FormSelectMultiple 410 */ 411 function postcalendar_adminapi_buildMonthSelect($args) { return postcalendar_userapi_buildMonthSelect($args); } 412 function postcalendar_userapi_buildMonthSelect($args) 413 { 414 extract($args); unset($args); 415 if(!isset($pc_month)) { $pc_month = Date_Calc::getMonth(); } 416 // create the return object to be inserted into the form 417 $output = array(); 418 if(!isset($selected)) $selected = ''; 419 for ($c=0,$i=1;$i<=12;$i++,$c++) { 420 if ($selected) { $sel = $selected == $i ? true : false; } 421 elseif ($i == $pc_month) { $sel = true; } 422 else { $sel = false; } 423 $output[$c]['id'] = sprintf('%02d',$i); 424 $output[$c]['selected'] = $sel; 425 $output[$c]['name'] = postcalendar_userapi_getmonthname(array('Date'=>mktime(0,0,0,$i,15))); 426 } 427 return $output; 428 } 429 430 /** 431 * Returns an array of form data for FormSelectMultiple 432 */ 433 function postcalendar_adminapi_buildDaySelect($args) { return postcalendar_userapi_buildDaySelect($args); } 434 function postcalendar_userapi_buildDaySelect($args) 435 { 436 extract($args); unset($args); 437 if(!isset($pc_day)) { $pc_day = Date_Calc::getDay(); } 438 // create the return object to be inserted into the form 439 $output = array(); 440 if(!isset($selected)) $selected = ''; 441 for($c=0,$i=1; $i<=31; $i++,$c++) { 442 if ($selected) { $sel = $selected == $i ? true : false; } 443 elseif ($i == $pc_day) { $sel = true; } 444 else { $sel = false; } 445 $output[$c]['id'] = sprintf('%02d',$i); 446 $output[$c]['selected'] = $sel; 447 $output[$c]['name'] = sprintf('%02d',$i); 448 } 449 return $output; 450 } 451 452 /** 453 * Returns an array of form data for FormSelectMultiple 454 */ 455 function postcalendar_adminapi_buildYearSelect($args) { return postcalendar_userapi_buildYearSelect($args); } 456 function postcalendar_userapi_buildYearSelect($args) 457 { 458 extract($args); unset($args); 459 if(!isset($pc_year)) { $pc_year = date('Y'); } 460 // create the return object to be inserted into the form 461 $output = array(); 462 // we want the list to contain 10 years before today and 30 years after 463 // maybe this will eventually become a user defined value 464 $pc_start_year = date('Y') - 10; 465 $pc_end_year = date('Y') + 30; 466 if(!isset($selected)) $selected = ''; 467 for($c=0,$i=$pc_start_year; $i<=$pc_end_year; $i++,$c++) { 468 if ($selected) { $sel = $selected == $i ? true : false; } 469 elseif ($i == $pc_year) { $sel = true; } 470 else { $sel = false; } 471 $output[$c]['id'] = sprintf('%04d',$i); 472 $output[$c]['selected'] = $sel; 473 $output[$c]['name'] = sprintf('%04d',$i); 474 } 475 return $output; 476 } 477 478 function &postcalendar_adminapi_getCategories() { return postcalendar_userapi_getCategories(); } 479 function &postcalendar_userapi_getCategories() 480 { 481 list($dbconn) = pnDBGetConn(); 482 $pntable = pnDBGetTables(); 483 $cat_table = $pntable['postcalendar_categories']; 484 $sql = "SELECT pc_catid,pc_catname,pc_catcolor,pc_catdesc 485 FROM $cat_table 486 ORDER BY pc_catname"; 487 $result = $dbconn->Execute($sql); 488 489 if($dbconn->ErrorNo() != 0) { return array(); } 490 if(!isset($result)) { return array(); } 491 492 $categories = array(); 493 for($i=0; !$result->EOF; $result->MoveNext()) { 494 list($catid,$catname,$catcolor,$catdesc) = $result->fields; 495 // check the category's permissions 496 if (!pnSecAuthAction(0,'PostCalendar::Category',"$catname::$catid",ACCESS_OVERVIEW)) { 497 continue; 498 } 499 $categories[$i]['id'] = $catid; 500 $categories[$i]['name'] = $catname; 501 $categories[$i]['color'] = $catcolor; 502 $categories[$i++]['desc'] = $catdesc; 503 } 504 $result->Close(); 505 return $categories; 506 } 507 508 function &postcalendar_adminapi_getTopics() { return postcalendar_userapi_getTopics(); } 509 function &postcalendar_userapi_getTopics() 510 { 511 list($dbconn) = pnDBGetConn(); 512 $pntable = pnDBGetTables(); 513 $topics_table = $pntable['topics']; 514 $topics_column = &$pntable['topics_column']; 515 $sql = "SELECT $topics_column[topicid], $topics_column[topictext], $topics_column[topicname] 516 FROM $topics_table 517 ORDER BY $topics_column[topictext]"; 518 $topiclist = $dbconn->Execute($sql); 519 if($dbconn->ErrorNo() != 0) { 520 return false; 521 } 522 $data = array(); 523 $i=0; 524 for(;!$topiclist->EOF;$topiclist->MoveNext()) { 525 // check topic permissions 526 if(pnSecAuthAction(0,'PostCalendar::Topic',$topiclist->fields[2].'::'.$topiclist->fields[0],ACCESS_OVERVIEW)) { 527 list($data[$i]['id'], $data[$i]['text'], $data[$i++]['name']) = $topiclist->fields; 528 } 529 } 530 $topiclist->Close(); 531 return $data; 532 } 533 534 /** 535 * postcalendar_adminapi_submitEvent() 536 * submit an event 537 * @param $args array of event data 538 * @return bool true on success : false on failure; 539 */ 540 function postcalendar_adminapi_submitEvent($args) { return postcalendar_userapi_submitEvent($args); } 541 /** 542 * postcalendar_userapi_submitEvent() 543 * submit an event 544 * @param $args array of event data 545 * @return bool true on success : false on failure; 546 */ 547 function postcalendar_userapi_submitEvent($args) 548 { 549 extract($args); unset($args); 550 551 list($dbconn) = pnDBGetConn(); 552 $pntable = pnDBGetTables(); 553 554 // determine if the event is to be published immediately or not 555 if( (bool) _SETTING_DIRECT_SUBMIT || 556 (bool) PC_ACCESS_ADMIN || 557 ($event_sharing != SHARING_GLOBAL) ) { 558 $event_status = _EVENT_APPROVED; 559 } else { 560 $event_status = _EVENT_QUEUED; 561 } 562 563 // set up some vars for the insert statement 564 $startDate = $event_startyear.'-'.$event_startmonth.'-'.$event_startday; 565 if($event_endtype == 1) { 566 $endDate = $event_endyear.'-'.$event_endmonth.'-'.$event_endday; 567 } else { 568 $endDate = '0000-00-00'; 569 } 570 571 if(!isset($event_allday)) $event_allday = 0; 572 if((bool)_SETTING_TIME_24HOUR) { 573 $startTime = $event_starttimeh.':'.$event_starttimem.':00'; 574 } else { 575 if($event_startampm == _AM_VAL) { 576 $event_starttimeh = $event_starttimeh == 12 ? '00' : $event_starttimeh; 577 } else { 578 $event_starttimeh = $event_starttimeh != 12 ? $event_starttimeh+=12 : $event_starttimeh; 579 } 580 $startTime = sprintf('%02d',$event_starttimeh).':'.sprintf('%02d',$event_starttimem).':00'; 581 } 582 583 // get rid of variables we no longer need to save memory 584 unset($event_startyear,$event_startmonth,$event_startday,$event_endyear,$event_endmonth, 585 $event_endday,$event_starttimeh,$event_starttimem); 586 587 /* causes problem when admin edits user's calendar 588 if(pnUserLoggedIn()) { 589 $event_userid = pnUserGetVar('uid'); 590 } else { 591 $event_userid = 0; 592 } 593 */ 594 595 /* 596 DW (me <-at-> denniswarnr dot net) 03-26-2004 597 Changed code so that admins can edit users' appointments 598 */ 599 if(pnUserLoggedIn()) { 600 // Checks to see if this is a new event or not 601 if ($pc_event_id != ""){ 602 // Since this is not a new event, we go 603 // to database to see who owns it 604 $sql = "SELECT pc_aid 605 FROM $pntable[postcalendar_events] 606 WHERE pc_eid = '".(int)pnVarPrepForStore($pc_event_id)."'"; 607 608 $result = $dbconn->Execute($sql); 609 $event_userid_from_db = $result->fields[0]; 610 611 $current_user_id = pnUserGetVar('uid'); 612 613 // If the current user editing the event 614 // is the one that owns it 615 if ($event_userid_from_db == $current_user_id){ 616 $event_userid = $current_user_id; 617 // Else change the id to the user that owns the event 618 // which we get from the database 619 } else { 620 $event_userid = $event_userid_from_db; 621 } 622 } else { 623 $event_userid = pnUserGetVar('uid'); 624 } 625 } else { 626 $event_userid = 0; 627 } 628 /* end of DW changes */ 629 630 if($pc_html_or_text == 'html') { 631 $event_desc = ':html:'.$event_desc; 632 } else { 633 $event_desc = ':text:'.$event_desc; 634 } 635 636 list($event_subject,$event_desc,$event_topic,$startDate,$endDate, 637 $event_repeat,$startTime,$event_allday,$event_category, 638 $event_location_info,$event_conttel,$event_contname, 639 $event_contemail,$event_website,$event_fee,$event_status, 640 $event_recurrspec,$event_duration,$event_sharing,$event_userid, 641 $pc_event_id) = @pnVarPrepForStore($event_subject,$event_desc,$event_topic,$startDate,$endDate, 642 $event_repeat,$startTime,$event_allday,$event_category, 643 $event_location_info,$event_conttel,$event_contname, 644 $event_contemail,$event_website,$event_fee,$event_status, 645 $event_recurrspec,$event_duration,$event_sharing,$event_userid, 646 $pc_event_id); 647 648 if(!isset($is_update)) { $is_update = false; } 649 if($is_update) { 650 $sql = "UPDATE $pntable[postcalendar_events] 651 SET pc_title = '$event_subject', 652 pc_hometext = '$event_desc', 653 pc_topic = '$event_topic', 654 pc_eventDate = '$startDate', 655 pc_endDate = '$endDate', 656 pc_recurrtype = '$event_repeat', 657 pc_startTime = '$startTime', 658 pc_alldayevent = '$event_allday', 659 pc_catid = '$event_category', 660 pc_location = '$event_location_info', 661 pc_conttel = '$event_conttel', 662 pc_contname = '$event_contname', 663 pc_contemail = '$event_contemail', 664 pc_website = '$event_website', 665 pc_fee = '$event_fee', 666 pc_eventstatus = '$event_status', 667 pc_recurrspec = '$event_recurrspec', 668 pc_duration = '$event_duration', 669 pc_sharing = '$event_sharing', 670 pc_aid = '$event_userid' 671 WHERE pc_eid = '$pc_event_id'"; 672 } else { 673 $pc_event_id = $dbconn->GenId($pntable['postcalendar_events']); 674 $sql = "INSERT INTO $pntable[postcalendar_events] ( 675 pc_eid, 676 pc_title, 677 pc_time, 678 pc_hometext, 679 pc_topic, 680 pc_informant, 681 pc_eventDate, 682 pc_endDate, 683 pc_recurrtype, 684 pc_startTime, 685 pc_alldayevent, 686 pc_catid, 687 pc_location, 688 pc_conttel, 689 pc_contname, 690 pc_contemail, 691 pc_website, 692 pc_fee, 693 pc_eventstatus, 694 pc_recurrspec, 695 pc_duration, 696 pc_sharing, 697 pc_aid) 698 VALUES ( 699 '$pc_event_id', 700 '$event_subject', 701 NOW(), 702 '$event_desc', 703 '$event_topic', 704 '$uname', 705 '$startDate', 706 '$endDate', 707 '$event_repeat', 708 '$startTime', 709 '$event_allday', 710 '$event_category', 711 '$event_location_info', 712 '$event_conttel', 713 '$event_contname', 714 '$event_contemail', 715 '$event_website', 716 '$event_fee', 717 '$event_status', 718 '$event_recurrspec', 719 '$event_duration', 720 '$event_sharing', 721 '$event_userid' 722 )"; 723 } 724 $result = $dbconn->Execute($sql); 725 if($result === false) { 726 return false; 727 } else { 728 if((bool)$is_update) { 729 $eid = $pc_event_id; 730 } else { 731 $eid = $dbconn->PO_Insert_ID($pntable['postcalendar_events'],'pc_eid'); 732 } 733 pc_notify($eid,$is_update); 734 return true; 735 } 736 } 737 738 function pc_notify($eid,$is_update) 739 { 740 if(!(bool)_SETTING_NOTIFY_ADMIN) { return true; } 741 742 $subject = _PC_NOTIFY_SUBJECT; 743 744 if((bool)$is_update) { 745 $message = _PC_NOTIFY_UPDATE_MSG; 746 } else { 747 $message = _PC_NOTIFY_NEW_MSG; 748 } 749 750 $modinfo = pnModGetInfo(pnModGetIDFromName(__POSTCALENDAR__)); 751 $modversion = pnVarPrepForOS($modinfo['version']); 752 unset($modinfo); 753 754 $message .= pnModURL(__POSTCALENDAR__,'admin','adminevents',array('pc_event_id'=>$eid,'action'=>_ADMIN_ACTION_VIEW)); 755 $message .= "\n\n\n\n"; 756 $message .= "----\n"; 757 $message .= "PostCalendar $modversion\n"; 758 $message .= "http://www.postcalendar.tv"; 759 760 mail(_SETTING_NOTIFY_EMAIL,$subject,$message, 761 "From: " . _SETTING_NOTIFY_EMAIL . "\r\n" 762 ."X-Mailer: PHP/" . phpversion() . "\r\n" 763 ."X-Mailer: PostCalendar/$modversion" ); 764 765 return true; 766 } 767 768 /** 769 * postcalendar_adminapi_buildSubmitForm() 770 * create event submit form 771 */ 772 function postcalendar_adminapi_buildSubmitForm($args) { return postcalendar_userapi_buildSubmitForm($args,true); } 773 /** 774 * postcalendar_userapi_buildSubmitForm() 775 * create event submit form 776 */ 777 function postcalendar_userapi_buildSubmitForm($args,$admin=false) 778 { 779 if(!PC_ACCESS_ADD) { return _POSTCALENDARNOAUTH; } 780 extract($args); unset($args); 781 782 $output =& new pnHTML(); 783 $output->SetInputMode(_PNH_VERBATIMINPUT); 784 // set up Smarty 785 $tpl =& new pcSmarty(); 786 $tpl->caching = false; 787 788 $template_name = pnModGetVar(__POSTCALENDAR__,'pcTemplate'); 789 if(!isset($template_name)) { 790 $template_name ='default'; 791 } 792 793 //================================================================= 794 // Setup the correct config file path for the templates 795 //================================================================= 796 $modinfo = pnModGetInfo(pnModGetIDFromName(__POSTCALENDAR__)); 797 $modir = pnVarPrepForOS($modinfo['directory']); 798 $modname = $modinfo['displayname']; 799 $all_categories =& pnModAPIFunc(__POSTCALENDAR__,'user','getCategories'); 800 unset($modinfo); 801 $tpl->config_dir = "modules/$modir/pntemplates/$template_name/config/"; 802 //================================================================= 803 // PARSE MAIN 804 //================================================================= 805 $tpl->assign_by_ref('TPL_NAME',$template_name); 806 $tpl->assign('FUNCTION',pnVarCleanFromInput('func')); 807 $tpl->assign_by_ref('ModuleName', $modname); 808 $tpl->assign_by_ref('ModuleDirectory', $modir); 809 $tpl->assign_by_ref('category',$all_categories); 810 $tpl->assign('NewEventHeader', _PC_NEW_EVENT_HEADER); 811 $tpl->assign('EventTitle', _PC_EVENT_TITLE); 812 $tpl->assign('Required', _PC_REQUIRED); 813 $tpl->assign('DateTimeTitle', _PC_DATE_TIME); 814 $tpl->assign('AlldayEventTitle', _PC_ALLDAY_EVENT); 815 $tpl->assign('TimedEventTitle', _PC_TIMED_EVENT); 816 $tpl->assign('TimedDurationTitle', _PC_TIMED_DURATION); 817 $tpl->assign('TimedDurationHoursTitle', _PC_TIMED_DURATION_HOURS); 818 $tpl->assign('TimedDurationMinutesTitle',_PC_TIMED_DURATION_MINUTES); 819 $tpl->assign('EventDescTitle', _PC_EVENT_DESC); 820 821 //================================================================= 822 // PARSE INPUT_EVENT_TITLE 823 //================================================================= 824 $tpl->assign('InputEventTitle', 'event_subject'); 825 $tpl->assign('ValueEventTitle', pnVarPrepForDisplay($event_subject)); 826 827 //================================================================= 828 // PARSE SELECT_DATE_TIME 829 //================================================================= 830 $output->SetOutputMode(_PNH_RETURNOUTPUT); 831 if(_SETTING_USE_INT_DATES) { 832 $sel_data = pnModAPIFunc(__POSTCALENDAR__,'user','buildDaySelect',array('pc_day'=>$day,'selected'=>$event_startday)); 833 $formdata = $output->FormSelectMultiple('event_startday', $sel_data); 834 $sel_data = pnModAPIFunc(__POSTCALENDAR__,'user','buildMonthSelect',array('pc_month'=>$month,'selected'=>$event_startmonth)); 835 $formdata .= $output->FormSelectMultiple('event_startmonth', $sel_data); 836 } else { 837 $sel_data = pnModAPIFunc(__POSTCALENDAR__,'user','buildMonthSelect',array('pc_month'=>$month,'selected'=>$event_startmonth)); 838 $formdata = $output->FormSelectMultiple('event_startmonth', $sel_data); 839 $sel_data = pnModAPIFunc(__POSTCALENDAR__,'user','buildDaySelect',array('pc_day'=>$day,'selected'=>$event_startday)); 840 $formdata .= $output->FormSelectMultiple('event_startday', $sel_data); 841 } 842 $sel_data = pnModAPIFunc(__POSTCALENDAR__,'user','buildYearSelect',array('pc_year'=>$year,'selected'=>$event_startyear)); 843 $formdata .= $output->FormSelectMultiple('event_startyear', $sel_data); 844 $output->SetOutputMode(_PNH_KEEPOUTPUT); 845 $tpl->assign('SelectDateTime', $formdata); 846 $tpl->assign('InputAllday', 'event_allday'); 847 $tpl->assign('ValueAllday', '1'); 848 $tpl->assign('SelectedAllday', $event_allday==1 ? 'checked':''); 849 $tpl->assign('InputTimed', 'event_allday'); 850 $tpl->assign('ValueTimed', '0'); 851 $tpl->assign('SelectedTimed', $event_allday==0 ? 'checked':''); 852 853 //================================================================= 854 // PARSE SELECT_END_DATE_TIME 855 //================================================================= 856 $output->SetOutputMode(_PNH_RETURNOUTPUT); 857 if(_SETTING_USE_INT_DATES) { 858 $sel_data = pnModAPIFunc(__POSTCALENDAR__,'user','buildDaySelect',array('pc_day'=>$day,'selected'=>$event_endday)); 859 $formdata = $output->FormSelectMultiple('event_endday', $sel_data); 860 $sel_data = pnModAPIFunc(__POSTCALENDAR__,'user','buildMonthSelect',array('pc_month'=>$month,'selected'=>$event_endmonth)); 861 $formdata .= $output->FormSelectMultiple('event_endmonth', $sel_data); 862 } else { 863 $sel_data = pnModAPIFunc(__POSTCALENDAR__,'user','buildMonthSelect',array('pc_month'=>$month,'selected'=>$event_endmonth)); 864 $formdata = $output->FormSelectMultiple('event_endmonth', $sel_data); 865 $sel_data = pnModAPIFunc(__POSTCALENDAR__,'user','buildDaySelect',array('pc_day'=>$day,'selected'=>$event_endday)); 866 $formdata .= $output->FormSelectMultiple('event_endday', $sel_data); 867 } 868 $sel_data = pnModAPIFunc(__POSTCALENDAR__,'user','buildYearSelect',array('pc_year'=>$year,'selected'=>$event_endyear)); 869 $formdata .= $output->FormSelectMultiple('event_endyear', $sel_data); 870 $output->SetOutputMode(_PNH_KEEPOUTPUT); 871 $tpl->assign('SelectEndDate', $formdata); 872 873 //================================================================= 874 // PARSE SELECT_TIMED_EVENT 875 //================================================================= 876 $stimes = pnModAPIFunc(__POSTCALENDAR__,'user','buildTimeSelect',array('hselected'=>$event_starttimeh,'mselected'=>$event_starttimem)); 877 878 $output->SetOutputMode(_PNH_RETURNOUTPUT); 879 $timed_hours = $output->FormSelectMultiple('event_starttimeh', $stimes['h']); 880 $timed_minutes = $output->FormSelectMultiple('event_starttimem', $stimes['m']); 881 if(!_SETTING_TIME_24HOUR) { 882 $ampm = array(); 883 $ampm[0]['id'] = pnVarPrepForStore(_AM_VAL); 884 $ampm[0]['selected'] = $event_startampm == _AM_VAL; 885 $ampm[0]['name'] = pnVarPrepForDisplay(_PC_AM); 886 $ampm[1]['id'] = pnVarPrepForStore(_PM_VAL); 887 $ampm[1]['selected'] = $event_startampm == _PM_VAL; 888 $ampm[1]['name'] = pnVarPrepForDisplay(_PC_PM); 889 $timed_ampm = $output->FormSelectMultiple('event_startampm', $ampm); 890 } else { 891 $timed_ampm = ''; 892 } 893 $output->SetOutputMode(_PNH_KEEPOUTPUT); 894 895 $tpl->assign('SelectTimedHours', $timed_hours); 896 $tpl->assign('SelectTimedMinutes', $timed_minutes); 897 $tpl->assign('SelectTimedAMPM', $timed_ampm); 898 899 //================================================================= 900 // PARSE SELECT_DURATION 901 //================================================================= 902 for($i=0; $i<=24; $i+=1) { 903 $TimedDurationHours[$i] = array('value'=>$i, 904 'selected'=>($event_dur_hours==$i ? 'selected':''), 905 'name'=>sprintf('%02d',$i)); 906 } 907 $tpl->assign('TimedDurationHours',$TimedDurationHours); 908 $tpl->assign('InputTimedDurationHours', 'event_dur_hours'); 909 910 for($i=0; $i<60; $i+=_SETTING_TIME_INCREMENT) { 911 $TimedDurationMinutes[$i] = array('value'=>$i, 912 'selected'=>($event_dur_minutes==$i ? 'selected':''), 913 'name'=>sprintf('%02d',$i)); 914 } 915 $tpl->assign('TimedDurationMinutes',$TimedDurationMinutes); 916 $tpl->assign('InputTimedDurationMinutes', 'event_dur_minutes'); 917 918 //================================================================= 919 // PARSE INPUT_EVENT_DESC 920 //================================================================= 921 $tpl->assign('InputEventDesc', 'event_desc'); 922 if(empty($pc_html_or_text)) { 923 $display_type = substr($event_desc,0,6); 924 if($display_type == ':text:') { 925 $pc_html_or_text = 'text'; 926 $event_desc = substr($event_desc,6); 927 } elseif($display_type == ':html:') { 928 $pc_html_or_text = 'html'; 929 $event_desc = substr($event_desc,6); 930 } else { 931 $pc_html_or_text = 'text'; 932 } 933 unset($display_type); 934 } 935 $tpl->assign('ValueEventDesc', pnVarPrepForDisplay($event_desc)); 936 937 $eventHTMLorText = "<select name=\"pc_html_or_text\">"; 938 if($pc_html_or_text == 'text') { 939 $eventHTMLorText .= "<option value=\"text\" selected=\"selected\">"._PC_SUBMIT_TEXT."</option>"; 940 } else { 941 $eventHTMLorText .= "<option value=\"text\">"._PC_SUBMIT_TEXT."</option>"; 942 } 943 if($pc_html_or_text == 'html') { 944 $eventHTMLorText .= "<option value=\"html\" selected=\"selected\">"._PC_SUBMIT_HTML."</option>"; 945 } else { 946 $eventHTMLorText .= "<option value=\"html\">"._PC_SUBMIT_HTML."</option>"; 947 } 948 $eventHTMLorText .= "</select>"; 949 $tpl->assign('EventHTMLorText',$eventHTMLorText); 950 //================================================================= 951 // PARSE select_event_topic_block 952 //================================================================= 953 $tpl->assign('displayTopics',_SETTING_DISPLAY_TOPICS); 954 if((bool)_SETTING_DISPLAY_TOPICS) { 955 $a_topics =& postcalendar_userapi_getTopics(); 956 $topics = array(); 957 foreach($a_topics as $topic) { 958 array_push($topics,array('value'=>$topic['id'], 959 'selected'=>($topic['id']==$event_topic ? 'selected':''), 960 'name'=>$topic['text'])); 961 } 962 unset($a_topics); 963 // only show this if we have topics to show 964 if(count($topics) > 0) { 965 $tpl->assign('topics',$topics); 966 $tpl->assign('EventTopicTitle', _PC_EVENT_TOPIC); 967 $tpl->assign('InputEventTopic', 'event_topic'); 968 } 969 } 970 971 //================================================================= 972 // PARSE select_event_type_block 973 //================================================================= 974 $categories = array(); 975 foreach($all_categories as $category) { 976 array_push($categories,array('value'=>$category['id'], 977 'selected'=>($category['id']==$event_category ? 'selected' : ''), 978 'name'=>$category['name'], 979 'color'=>$category['color'], 980 'desc'=>$category['desc'])); 981 } 982 // only show this if we have categories to show 983 // you should ALWAYS have at least one valid category 984 if(count($categories) > 0) { 985 $tpl->assign('categories',$categories); 986 $tpl->assign('EventCategoriesTitle', _PC_EVENT_CATEGORY); 987 $tpl->assign('InputEventCategory', 'event_category'); 988 } 989 //================================================================= 990 // PARSE event_sharing_block 991 //================================================================= 992 $data = array(); 993 if(_SETTING_ALLOW_USER_CAL) { 994 array_push($data,array(SHARING_PRIVATE,_PC_SHARE_PRIVATE)); 995 array_push($data,array(SHARING_PUBLIC,_PC_SHARE_PUBLIC)); 996 array_push($data,array(SHARING_BUSY,_PC_SHARE_SHOWBUSY)); 997 } 998 if(pnSecAuthAction(0,'PostCalendar::', '::', ACCESS_ADMIN) || _SETTING_ALLOW_GLOBAL || !_SETTING_ALLOW_USER_CAL) { 999 array_push($data,array(SHARING_GLOBAL,_PC_SHARE_GLOBAL)); 1000 } 1001 $sharing = array(); 1002 foreach($data as $cell) { 1003 array_push($sharing,array('value'=>$cell[0], 1004 'selected'=>((int) $event_sharing == $cell[0] ? 'selected' : ''), 1005 'name'=>$cell[1])); 1006 } 1007 $tpl->assign('sharing',$sharing); 1008 $tpl->assign('EventSharingTitle', _PC_SHARING); 1009 $tpl->assign('InputEventSharing','event_sharing'); 1010 //================================================================= 1011 // location information 1012 //================================================================= 1013 $tpl->assign('EventLocationTitle', _PC_EVENT_LOCATION); 1014 $tpl->assign('InputLocation', 'event_location'); 1015 $tpl->assign('ValueLocation', pnVarPrepForDisplay($event_location)); 1016 $tpl->assign('EventStreetTitle', _PC_EVENT_STREET); 1017 $tpl->assign('InputStreet1', 'event_street1'); 1018 $tpl->assign('ValueStreet1', pnVarPrepForDisplay($event_street1)); 1019 $tpl->assign('InputStreet2', 'event_street2'); 1020 $tpl->assign('ValueStreet2', pnVarPrepForDisplay($event_street2)); 1021 $tpl->assign('EventCityTitle', _PC_EVENT_CITY); 1022 $tpl->assign('InputCity', 'event_city'); 1023 $tpl->assign('ValueCity', pnVarPrepForDisplay($event_city)); 1024 $tpl->assign('EventStateTitle', _PC_EVENT_STATE); 1025 $tpl->assign('InputState', 'event_state'); 1026 $tpl->assign('ValueState', pnVarPrepForDisplay($event_state)); 1027 $tpl->assign('EventPostalTitle', _PC_EVENT_POSTAL); 1028 $tpl->assign('InputPostal', 'event_postal'); 1029 $tpl->assign('ValuePostal', pnVarPrepForDisplay($event_postal)); 1030 //================================================================= 1031 // contact information 1032 //================================================================= 1033 $tpl->assign('EventContactTitle', _PC_EVENT_CONTACT); 1034 $tpl->assign('InputContact', 'event_contname'); 1035 $tpl->assign('ValueContact', pnVarPrepForDisplay($event_contname)); 1036 $tpl->assign('EventPhoneTitle', _PC_EVENT_PHONE); 1037 $tpl->assign('InputPhone', 'event_conttel'); 1038 $tpl->assign('ValuePhone', pnVarPrepForDisplay($event_conttel)); 1039 $tpl->assign('EventEmailTitle', _PC_EVENT_EMAIL); 1040 $tpl->assign('InputEmail', 'event_contemail'); 1041 $tpl->assign('ValueEmail', pnVarPrepForDisplay($event_contemail)); 1042 $tpl->assign('EventWebsiteTitle', _PC_EVENT_WEBSITE); 1043 $tpl->assign('InputWebsite', 'event_website'); 1044 $tpl->assign('ValueWebsite', pnVarPrepForDisplay($event_website)); 1045 $tpl->assign('EventFeeTitle', _PC_EVENT_FEE); 1046 $tpl->assign('InputFee', 'event_fee'); 1047 $tpl->assign('ValueFee', pnVarPrepForDisplay($event_fee)); 1048 //================================================================= 1049 // Repeating Information 1050 //================================================================= 1051 $tpl->assign('RepeatingHeader', _PC_REPEATING_HEADER); 1052 $tpl->assign('NoRepeatTitle', _PC_NO_REPEAT); 1053 $tpl->assign('RepeatTitle', _PC_REPEAT); 1054 $tpl->assign('RepeatOnTitle', _PC_REPEAT_ON); 1055 $tpl->assign('OfTheMonthTitle', _PC_OF_THE_MONTH); 1056 $tpl->assign('EndDateTitle', _PC_END_DATE); 1057 $tpl->assign('NoEndDateTitle', _PC_NO_END); 1058 $tpl->assign('InputNoRepeat', 'event_repeat'); 1059 $tpl->assign('ValueNoRepeat', '0'); 1060 $tpl->assign('SelectedNoRepeat', (int) $event_repeat==0 ? 'checked':''); 1061 $tpl->assign('InputRepeat', 'event_repeat'); 1062 $tpl->assign('ValueRepeat', '1'); 1063 $tpl->assign('SelectedRepeat', (int) $event_repeat==1 ? 'checked':''); 1064 1065 unset($in); 1066 $in = array(_PC_EVERY,_PC_EVERY_OTHER,_PC_EVERY_THIRD,_PC_EVERY_FOURTH); 1067 $keys = array(REPEAT_EVERY,REPEAT_EVERY_OTHER,REPEAT_EVERY_THIRD,REPEAT_EVERY_FOURTH); 1068 $repeat_freq = array(); 1069 foreach($in as $k=>$v) { 1070 array_push($repeat_freq,array('value'=>$keys[$k], 1071 'selected'=>($keys[$k]==$event_repeat_freq?'selected':''), 1072 'name'=>$v)); 1073 } 1074 $tpl->assign('InputRepeatFreq','event_repeat_freq'); 1075 if(empty($event_repeat_freq) || $event_repeat_freq < 1) $event_repeat_freq = 1; 1076 $tpl->assign('InputRepeatFreqVal',$event_repeat_freq); 1077 $tpl->assign('repeat_freq',$repeat_freq); 1078 1079 unset($in); 1080 $in = array(_PC_EVERY_DAY,_PC_EVERY_WEEK,_PC_EVERY_MONTH,_PC_EVERY_YEAR); 1081 $keys = array(REPEAT_EVERY_DAY,REPEAT_EVERY_WEEK,REPEAT_EVERY_MONTH,REPEAT_EVERY_YEAR); 1082 $repeat_freq_type = array(); 1083 foreach($in as $k=>$v) { 1084 array_push($repeat_freq_type,array('value'=>$keys[$k], 1085 'selected'=>($keys[$k]==$event_repeat_freq_type?'selected':''), 1086 'name'=>$v)); 1087 } 1088 $tpl->assign('InputRepeatFreqType','event_repeat_freq_type'); 1089 $tpl->assign('repeat_freq_type',$repeat_freq_type); 1090 1091 $tpl->assign('InputRepeatOn', 'event_repeat'); 1092 $tpl->assign('ValueRepeatOn', '2'); 1093 $tpl->assign('SelectedRepeatOn', (int) $event_repeat==2 ? 'checked':''); 1094 1095 unset($in); 1096 $in = array(_PC_EVERY_1ST,_PC_EVERY_2ND,_PC_EVERY_3RD,_PC_EVERY_4TH,_PC_EVERY_LAST); 1097 $keys = array(REPEAT_ON_1ST,REPEAT_ON_2ND,REPEAT_ON_3RD,REPEAT_ON_4TH,REPEAT_ON_LAST); 1098 $repeat_on_num = array(); 1099 foreach($in as $k=>$v) { 1100 array_push($repeat_on_num,array('value'=>$keys[$k], 1101 'selected'=>($keys[$k]==$event_repeat_on_num?'selected':''), 1102 'name'=>$v)); 1103 } 1104 $tpl->assign('InputRepeatOnNum', 'event_repeat_on_num'); 1105 $tpl->assign('repeat_on_num',$repeat_on_num); 1106 1107 unset($in); 1108 $in = array(_PC_EVERY_SUN,_PC_EVERY_MON,_PC_EVERY_TUE,_PC_EVERY_WED,_PC_EVERY_THU,_PC_EVERY_FRI,_PC_EVERY_SAT); 1109 $keys = array(REPEAT_ON_SUN,REPEAT_ON_MON,REPEAT_ON_TUE,REPEAT_ON_WED,REPEAT_ON_THU,REPEAT_ON_FRI,REPEAT_ON_SAT); 1110 $repeat_on_day = array(); 1111 foreach($in as $k=>$v) { 1112 array_push($repeat_on_day,array('value'=>$keys[$k], 1113 'selected'=>($keys[$k]==$event_repeat_on_day ? 'selected' : ''), 1114 'name'=>$v)); 1115 } 1116 $tpl->assign('InputRepeatOnDay', 'event_repeat_on_day'); 1117 $tpl->assign('repeat_on_day',$repeat_on_day); 1118 1119 unset($in); 1120 $in = array(_PC_OF_EVERY_MONTH,_PC_OF_EVERY_2MONTH,_PC_OF_EVERY_3MONTH,_PC_OF_EVERY_4MONTH,_PC_OF_EVERY_6MONTH,_PC_OF_EVERY_YEAR); 1121 $keys = array(REPEAT_ON_MONTH,REPEAT_ON_2MONTH,REPEAT_ON_3MONTH,REPEAT_ON_4MONTH,REPEAT_ON_6MONTH,REPEAT_ON_YEAR); 1122 $repeat_on_freq = array(); 1123 foreach($in as $k=>$v) { 1124 array_push($repeat_on_freq,array('value'=>$keys[$k], 1125 'selected'=>($keys[$k] == $event_repeat_on_freq ? 'selected' : ''), 1126 'name'=>$v)); 1127 } 1128 $tpl->assign('InputRepeatOnFreq', 'event_repeat_on_freq'); 1129 if(empty($event_repeat_on_freq) || $event_repeat_on_freq < 1) $event_repeat_on_freq = 1; 1130 $tpl->assign('InputRepeatOnFreqVal', $event_repeat_on_freq); 1131 $tpl->assign('repeat_on_freq',$repeat_on_freq); 1132 $tpl->assign('MonthsTitle',_PC_MONTHS); 1133 1134 //================================================================= 1135 // PARSE INPUT_END_DATE 1136 //================================================================= 1137 $tpl->assign('InputEndOn', 'event_endtype'); 1138 $tpl->assign('ValueEndOn', '1'); 1139 $tpl->assign('SelectedEndOn', (int) $event_endtype==1 ? 'checked':''); 1140 //================================================================= 1141 // PARSE INPUT_NO_END 1142 //================================================================= 1143 $tpl->assign('InputNoEnd', 'event_endtype'); 1144 $tpl->assign('ValueNoEnd', '0'); 1145 $tpl->assign('SelectedNoEnd', (int) $event_endtype==0 ? 'checked':''); 1146 1147 $output->SetOutputMode(_PNH_RETURNOUTPUT); 1148 $authkey = $output->FormHidden('authid',pnSecGenAuthKey()); 1149 $output->SetOutputMode(_PNH_KEEPOUTPUT); 1150 1151 $form_hidden = "<input type=\"hidden\" name=\"is_update\" value=\"$is_update\" />"; 1152 $form_hidden .= "<input type=\"hidden\" name=\"pc_event_id\" value=\"$pc_event_id\" />"; 1153 if(isset($data_loaded)) { 1154 $form_hidden .= "<input type=\"hidden\" name=\"data_loaded\" value=\"$data_loaded\" />"; 1155 $tpl->assign('FormHidden',$form_hidden); 1156 } 1157 $form_submit = '<select name="form_action"> 1158 <option value="preview">'._PC_EVENT_PREVIEW.'</option> 1159 <option value="commit">'._PC_EVENT_SUBMIT.'</option> 1160 </select>'.$authkey.'<input type="submit" name="submit" value="go">' ; 1161 $tpl->assign('FormSubmit',$form_submit); 1162 1163 // do not cache this page 1164 if($admin) { 1165 $output->Text($tpl->fetch($template_name.'/admin/submit.html')); 1166 } else { 1167 $output->Text($tpl->fetch($template_name.'/user/submit.html')); 1168 } 1169 $output->Text(postcalendar_footer()); 1170 return $output->GetOutput(); 1171 } 1172 1173 function &postcalendar_userapi_pcGetEventDetails($eid) 1174 { 1175 1176 if(!isset($eid)) { 1177 return false; 1178 } 1179 list($dbconn) = pnDBGetConn(); 1180 $pntable = pnDBGetTables(); 1181 1182 // link to the events tables 1183 $table = $pntable['postcalendar_events']; 1184 $cattable = $pntable['postcalendar_categories']; 1185 1186 $sql = "SELECT DISTINCT e.pc_eid, 1187 e.pc_informant, 1188 e.pc_catid, 1189 e.pc_title, 1190 e.pc_time, 1191 e.pc_hometext, 1192 e.pc_eventDate, 1193 e.pc_duration, 1194 e.pc_endDate, 1195 e.pc_startTime, 1196 e.pc_recurrtype, 1197 e.pc_recurrfreq, 1198 e.pc_recurrspec, 1199 e.pc_topic, 1200 e.pc_alldayevent, 1201 e.pc_location, 1202 e.pc_conttel, 1203 e.pc_contname, 1204 e.pc_contemail, 1205 e.pc_website, 1206 e.pc_fee, 1207 e.pc_sharing, 1208 c.pc_catcolor, 1209 c.pc_catname, 1210 c.pc_catdesc 1211 FROM $table e, $cattable c 1212 WHERE e.pc_eid = '".pnVarPrepForStore($eid)."' AND c.pc_catid = e.pc_catid"; 1213 1214 $result = $dbconn->Execute($sql); 1215 if($dbconn->ErrorNo() != 0) { 1216 die ($dbconn->ErrorMsg()); 1217 } 1218 $event = array(); 1219 if(!isset($result)) { 1220 return $event; 1221 } 1222 list($event['eid'], $event['uname'], $event['catid'], 1223 $event['title'], $event['time'], $event['hometext'], 1224 $event['eventDate'], $event['duration'], $event['endDate'], 1225 $event['startTime'], $event['recurrtype'], $event['recurrfreq'], 1226 $event['recurrspec'], $event['topic'], $event['alldayevent'], 1227 $event['location'], $event['conttel'], $event['contname'], 1228 $event['contemail'], $event['website'], $event['fee'], $event['sharing'], 1229 $event['catcolor'], $event['catname'], $event['catdesc']) = $result->fields; 1230 // there has to be a more intelligent way to do this 1231 @list($event['duration_hours'],$dmin) = @explode('.',($event['duration']/60/60)); 1232 $event['duration_minutes'] = substr(sprintf('%.2f','.' . 60*($dmin/100)),2,2); 1233 //'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 1234 $result->Close(); 1235 1236 $userid = pnUserGetVar('uid'); 1237 1238 // get the user id of event's author 1239 $users = pnUserGetAll(); 1240 foreach($users as $user) { 1241 if($user['uname'] == $event['uname']) { 1242 $cuserid = $user['uid']; 1243 break; 1244 } 1245 } 1246 unset($users); 1247 1248 // is this a public event to be shown as busy? 1249 if($event['sharing'] == SHARING_PRIVATE && $cuserid != $userid) { 1250 // they are not supposed to see this 1251 return false; 1252 } elseif($event['sharing'] == SHARING_BUSY && $cuserid != $userid) { 1253 // make it not display any information 1254 $event['title'] = _USER_BUSY_TITLE; 1255 $event['hometext'] = _USER_BUSY_MESSAGE; 1256 $event['location'] = ''; 1257 $event['conttel'] = ''; 1258 $event['contname'] = ''; 1259 $event['contemail'] = ''; 1260 $event['website'] = ''; 1261 $event['fee'] = ''; 1262 } else { 1263 $event['title'] = $event['title']; 1264 $event['hometext'] = $event['hometext']; 1265 $event['location'] = $event['location']; 1266 $event['conttel'] = $event['conttel']; 1267 $event['contname'] = $event['contname']; 1268 $event['contemail'] = $event['contemail']; 1269 $event['website'] = $event['website']; 1270 $event['fee'] = $event['fee']; 1271 } 1272 $event['desc'] = $event['hometext']; 1273 $event['website'] = $event['website']; 1274 return $event; 1275 } 1276 1277 /** 1278 * postcalendar_userapi_eventDetail 1279 * Creates the detailed event display and outputs html. 1280 * Accepts an array of key/value pairs 1281 * @param int $eid the id of the event to display 1282 * @return string html output 1283 * @access public 1284 */ 1285 function postcalendar_adminapi_eventDetail($args) { return postcalendar_userapi_eventDetail($args,true); } 1286 function postcalendar_userapi_eventDetail($args,$admin=false) 1287 { 1288 if(!(bool)PC_ACCESS_READ) { return _POSTCALENDARNOAUTH; } 1289 // get the theme globals :: is there a better way to do this? 1290 pnThemeLoad(pnUserGetTheme()); 1291 global $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $bgcolor5; 1292 global $textcolor1, $textcolor2; 1293 $popup = pnVarCleanFromInput('popup'); 1294 extract($args); unset($args); 1295 if(!isset($cacheid)) $cacheid = null; 1296 if(!isset($eid)) { 1297 return false; 1298 } 1299 if(!isset($nopop)) { 1300 $nopop = false; 1301 } 1302 $uid = pnUserGetVar('uid'); 1303 //================================================================= 1304 // Find out what Template we're using 1305 //================================================================= 1306 $template_name = _SETTING_TEMPLATE; 1307 if(!isset($template_name)) { 1308 $template_name = 'default'; 1309 } 1310 //================================================================= 1311 // Setup Smarty Template Engine 1312 //================================================================= 1313 $tpl =& new pcSmarty(); 1314 1315 if($admin) { 1316 $template = $template_name.'/admin/details.html'; 1317 $args['cacheid'] = ''; 1318 $print=0; 1319 $Date =& postcalendar_getDate(); 1320 $tpl->caching = false; 1321 } else { 1322 $template = $template_name.'/user/details.html'; 1323 } 1324 1325 if(!$tpl->is_cached($template,$cacheid)) { 1326 // let's get the DB information 1327 list($dbconn) = pnDBGetConn(); 1328 $pntable = pnDBGetTables(); 1329 // get the event's information 1330 $event =& postcalendar_userapi_pcGetEventDetails($eid); 1331 // if the above is false, it's a private event for another user 1332 // we should not diplay this - so we just exit gracefully 1333 if($event === false) { return false; } 1334 //================================================================= 1335 // get event's topic information 1336 //================================================================= 1337 $topics_table = $pntable['topics']; 1338 $topics_column = $pntable['topics_column']; 1339 $topicsql = "SELECT $topics_column[topictext],$topics_column[topicimage] 1340 FROM $topics_table 1341 WHERE $topics_column[topicid] = $event[topic] 1342 LIMIT 1"; 1343 $topic_result = $dbconn->Execute($topicsql); 1344 list($event['topictext'],$event['topicimg']) = $topic_result->fields; 1345 $location = unserialize($event['location']); 1346 $event['location'] = $location['event_location']; 1347 $event['street1'] = $location['event_street1']; 1348 $event['street2'] = $location['event_street2']; 1349 $event['city'] = $location['event_city']; 1350 $event['state'] = $location['event_state']; 1351 $event['postal'] = $location['event_postal']; 1352 $event['date'] = str_replace('-','',$Date); 1353 //================================================================= 1354 // populate the template 1355 //================================================================= 1356 if(!empty($event['location']) || !empty($event['street1']) || 1357 !empty($event['street2']) || !empty($event['city']) || 1358 !empty($event['state']) || !empty($event['postal'])) { 1359 $tpl->assign('LOCATION_INFO',true); 1360 } else { 1361 $tpl->assign('LOCATION_INFO',false); 1362 } 1363 if(!empty($event['contname']) || !empty($event['contemail']) || 1364 !empty($event['conttel']) || !empty($event['website'])) { 1365 $tpl->assign('CONTACT_INFO',true); 1366 } else { 1367 $tpl->assign('CONTACT_INFO',false); 1368 } 1369 $display_type = substr($event['hometext'],0,6); 1370 if($display_type == ':text:') { 1371 $prepFunction = 'pcVarPrepForDisplay'; 1372 $event['hometext'] = substr($event['hometext'],6); 1373 } elseif($display_type == ':html:') { 1374 $prepFunction = 'pcVarPrepHTMLDisplay'; 1375 $event['hometext'] = substr($event['hometext'],6); 1376 } else { 1377 $prepFunction = 'pcVarPrepHTMLDisplay'; 1378 } 1379 unset($display_type); 1380 // prep the vars for output 1381 $event['title'] =& $prepFunction($event['title']); 1382 $event['hometext'] =& $prepFunction($event['hometext']); 1383 $event['desc'] =& $event['hometext']; 1384 $event['conttel'] =& $prepFunction($event['conttel']); 1385 $event['contname'] =& $prepFunction($event['contname']); 1386 $event['contemail'] =& $prepFunction($event['contemail']); 1387 $event['website'] =& $prepFunction(postcalendar_makeValidURL($event['website'])); 1388 $event['fee'] =& $prepFunction($event['fee']); 1389 $event['location'] =& $prepFunction($event['location']); 1390 $event['street1'] =& $prepFunction($event['street1']); 1391 $event['street2'] =& $prepFunction($event['street2']); 1392 $event['city'] =& $prepFunction($event['city']); 1393 $event['state'] =& $prepFunction($event['state']); 1394 $event['postal'] =& $prepFunction($event['postal']); 1395 $tpl->assign_by_ref('A_EVENT',$event); 1396 //================================================================= 1397 // populate the template $ADMIN_OPTIONS 1398 //================================================================= 1399 $target=''; 1400 if(_SETTING_OPEN_NEW_WINDOW) { 1401 $target = 'target="csCalendar"'; 1402 } 1403 1404 $admin_edit_url = $admin_delete_url = ''; 1405 if (pnSecAuthAction(0, 'PostCalendar::', '::', ACCESS_ADMIN)) { 1406 $admin_edit_url = pnModURL(__POSTCALENDAR__,'admin','submit',array('pc_event_id'=>$eid)); 1407 $admin_delete_url = pnModURL(__POSTCALENDAR__,'admin','adminevents',array('action'=>_ACTION_DELETE,'pc_event_id'=>$eid)); 1408 } 1409 $user_edit_url = $user_delete_url = ''; 1410 if(pnUserLoggedIn()) { 1411 $logged_in_uname = pnUserGetVar('uname'); 1412 } else { 1413 $logged_in_uname = ''; 1414 } 1415 $can_edit = false; 1416 if (pnSecAuthAction(0, 'PostCalendar::', '::', ACCESS_ADD) && $logged_in_uname == $event['uname']) { 1417 $user_edit_url = pnModURL(__POSTCALENDAR__,'user','submit',array('pc_event_id'=>$eid)); 1418 $user_delete_url = pnModURL(__POSTCALENDAR__,'user','delete',array('pc_event_id'=>$eid)); 1419 $can_edit = true; 1420 } 1421 $tpl->assign_by_ref('ADMIN_TARGET',$target); 1422 $tpl->assign_by_ref('ADMIN_EDIT',$admin_edit_url); 1423 $tpl->assign_by_ref('ADMIN_DELETE',$admin_delete_url); 1424 $tpl->assign_by_ref('USER_TARGET',$target); 1425 $tpl->assign_by_ref('USER_EDIT',$user_edit_url); 1426 $tpl->assign_by_ref('USER_DELETE',$user_delete_url); 1427 $tpl->assign_by_ref('USER_CAN_EDIT',$can_edit); 1428 } 1429 //================================================================= 1430 // Parse the template 1431 //================================================================= 1432 if($popup != 1 && $print != 1) { 1433 $output = "\n\n<!-- START POSTCALENDAR OUTPUT [-: HTTP://POSTCALENDAR.TV :-] -->\n\n"; 1434 $output .= $tpl->fetch($template,$cacheid); 1435 $output .= "\n\n<!-- END POSTCALENDAR OUTPUT [-: HTTP://POSTCALENDAR.TV :-] -->\n\n"; 1436 } else { 1437 $theme = pnUserGetTheme(); 1438 echo "<html><head>"; 1439 echo "<LINK REL=\"StyleSheet\" HREF=\"themes/$theme/style/styleNN.css\" TYPE=\"text/css\">\n\n\n"; 1440 echo "<style type=\"text/css\">\n"; 1441 echo "@import url(\"themes/$theme/style/style.css\"); "; 1442 echo "</style>\n"; 1443 echo "</head><body>\n"; 1444 $tpl->display($template,$cacheid); 1445 echo postcalendar_footer(); 1446 echo "\n</body></html>"; 1447 session_write_close(); 1448 exit; 1449 } 1450 1451 return $output; 1452 } 1453 1454 function postcalendar_footer() 1455 { 1456 // lets get the module's information 1457 $modinfo = pnModGetInfo(pnModGetIDFromName(__POSTCALENDAR__)); 1458 $footer = "<p align=\"right\"><a href=\"http://noc.postnuke.com/projects/postcalendar\">PostCalendar v$modinfo[version]</a></p>"; 1459 return $footer; 1460 } 1461 1462 function postcalendar_smarty_pc_sort_day($params, &$smarty) 1463 { 1464 extract($params); 1465 1466 if (empty($var)) { 1467 $smarty->trigger_error("sort_array: missing 'var' parameter"); 1468 return; 1469 } 1470 1471 if (!in_array('value', array_keys($params))) { 1472 $smarty->trigger_error("sort_array: missing 'value' parameter"); 1473 return; 1474 } 1475 1476 if (!in_array('order', array_keys($params))) { 1477 $order = 'asc'; 1478 } 1479 1480 if (!in_array('inc', array_keys($params))) { 1481 $inc = '15'; 1482 } 1483 1484 if (!in_array('start', array_keys($params))) { 1485 $sh = '08'; 1486 $sm = '00'; 1487 } else { 1488 list($sh,$sm) = explode(':',$start); 1489 } 1490 1491 if (!in_array('end', array_keys($params))) { 1492 $eh = '21'; 1493 $em = '00'; 1494 } else { 1495 list($eh,$em) = explode(':',$end); 1496 } 1497 1498 if(strtolower($order) == 'asc') $function = 'sort_byTimeA'; 1499 if(strtolower($order) == 'desc') $function = 'sort_byTimeD'; 1500 1501 foreach($value as $events) { 1502 usort($events,$function); 1503 $newArray = $events; 1504 } 1505 1506 // here we want to create an intelligent array of 1507 // columns and rows to build a nice day view 1508 $ch = $sh; $cm = $sm; 1509 while("$ch:$cm" <= "$eh:$em") { 1510 $hours["$ch:$cm"] = array(); 1511 $cm += $inc; 1512 if($cm >= 60) { 1513 $cm = '00'; 1514 $ch = sprintf('%02d',$ch+1); 1515 } 1516 } 1517 1518 $alldayevents = array(); 1519 foreach($newArray as $event) { 1520 list($sh,$sm,$ss) = explode(':',$event['startTime']); 1521 $eh = sprintf('%02d',$sh + $event['duration_hours']); 1522 $em = sprintf('%02d',$sm + $event['duration_minutes']); 1523 1524 if($event['alldayevent']) { 1525 // we need an entire column . save till later 1526 $alldayevents[] = $event; 1527 } else { 1528 //find open time slots - avoid overlapping 1529 $needed = array(); 1530 $ch = $sh; $cm = $sm; 1531 //what times do we need? 1532 while("$ch:$cm" < "$eh:$em") { 1533 $needed[] = "$ch:$cm"; 1534 $cm += $inc; 1535 if($cm >= 60) { 1536 $cm = '00'; 1537 $ch = sprintf('%02d',$ch+1); 1538 } 1539 } 1540 $i = 0; 1541 foreach($needed as $time) { 1542 if($i==0) { 1543 $hours[$time][] = $event; 1544 $key = count($hours[$time])-1; 1545 } else { 1546 $hours[$time][$key] = 'continued'; 1547 } 1548 $i++; 1549 } 1550 } 1551 } 1552 //pcDebugVar($hours); 1553 $smarty->assign_by_ref($var,$hours); 1554 } 1555 1556 function sort_byCategoryA($a,$b) { 1557 if($a['catname'] < $b['catname']) return -1; 1558 elseif($a['catname'] > $b['catname']) return 1; 1559 // rjf 7/20/2004 Begin: if the categories are equal, sort based on start time 1560 elseif($a['catname'] == $b['catname']) return sort_byTimeA($a,$b); 1561 // rjf 7/20/2004 End: 1562 } 1563 function sort_byCategoryD($a,$b) { 1564 if($a['catname'] < $b['catname']) return 1; 1565 elseif($a['catname'] > $b['catname']) return -1; 1566 // rjf 7/20/2004 Begin: if the categories are equal, sort based on start time 1567 elseif($a['catname'] == $b['catname']) return sort_byTimeD($a,$b); 1568 // rjf 7/20/2004 End: 1569 } 1570 function sort_byTitleA($a,$b) { 1571 if($a['title'] < $b['title']) return -1; 1572 elseif($a['title'] > $b['title']) return 1; 1573 } 1574 function sort_byTitleD($a,$b) { 1575 if($a['title'] < $b['title']) return 1; 1576 elseif($a['title'] > $b['title']) return -1; 1577 } 1578 function sort_byTimeA($a,$b) { 1579 if($a['startTime'] < $b['startTime']) return -1; 1580 elseif($a['startTime'] > $b['startTime']) return 1; 1581 } 1582 function sort_byTimeD($a,$b) { 1583 if($a['startTime'] < $b['startTime']) return 1; 1584 elseif($a['startTime'] > $b['startTime']) return -1; 1585 } 1586 /** 1587 * pc_clean 1588 * @param s string text to clean 1589 * @return string cleaned up text 1590 */ 1591 function pc_clean($s) 1592 { 1593 $display_type = substr($s,0,6); 1594 if($display_type == ':text:') { 1595 $s = substr($s,6); 1596 } elseif($display_type == ':html:') { 1597 $s = substr($s,6); 1598 } 1599 unset($display_type); 1600 $s = preg_replace('/[\r|\n]/i','',$s); 1601 $s = str_replace("'","\'",$s); 1602 $s = str_replace('"','"',$s); 1603 // ok, now we need to break really long lines 1604 // we only want to break at spaces to allow for 1605 // correct interpretation of special characters 1606 $tmp = explode(' ',$s); 1607 return join("'+' ",$tmp); 1608 } 1609 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Feb 16 22:40:07 2005 | Cross-referenced by PHPXref 0.6 |