00001 <?PHP
00074
00075 $modules_names[] = "Event Manager";
00076 $mopules_versions[] = "0.1";
00077 $modules_descriptions[] = "An events-based calendar";
00078
00079
00080
00081 $modules_setup[] = "modulesetup_events";
00082
00083 $modules_globalID[] = "globalID_events";
00084
00085 $profilemodules[] = "profilemodule_events";
00086
00087 $modules[] = "parse_events_calendar";
00088 $modules[] = "parse_events_events";
00089 $modules[] = "parse_events_event";
00090
00091
00092
00093 $page_help["\calendar(txt1)"] = "This will show a calendar with events in the categories defined by txt1. txt1 is a space-separated list.";
00094 $page_help["\events(txt1)"] = "This will show the events for the next txt1 days. If txt1 is not present, it will show events for the next 7 days";
00095 $page_help["\event(txt1,txt2)"] = "This will show the event on the timestamp txt2 as defined by the user txt1";
00096
00097
00098
00099
00100 $events_folder = "$module_folder/events";
00101
00102 if ( !file_exists( $events_folder ) )
00103 mkdir($events_folder, 0775);
00104
00105 class eventsEvent {
00106 var $title;
00107 var $description;
00108 var $timestamp;
00109 var $duration;
00110 var $creator;
00111 var $viewlevel;
00112 var $editlevel;
00113 var $commentlevel;
00114 var $participatelevel;
00115 var $participants;
00116 var $comments;
00117 var $filename;
00118
00119 function eventsEvent( $creator, $timestamp )
00120 {
00121 $this->creator = $creator;
00122 $this->timestamp = $timestamp;
00123 $this->generateFilename();
00124 $this->load();
00125 if( userAllows( $this->creator, $this->editlevel ) )
00126 {
00127 if( $_REQUEST["event_creator"] == $this->creator && $_REQUEST["deleteEvent"] == $this->timestamp && $_REQUEST["confirm_delete"] == "yes" )
00128 {
00129 $this->delete();
00130 header("Location: " . thisPageURL(true) . "event_selectedyear=" . date("Y", $this->timestamp) . "&event_selectedmonth=" . date("n", $this->timestamp) . "&event_selectedday=" . date("j", $this->timestamp));
00131 }
00132 else if( $_REQUEST["event_creator"] == $this->creator && $_REQUEST["event_timestamp"] == $this->timestamp && $_POST["confirm_delete"] && is_array( $_POST["selectedParticipants"] ) )
00133 {
00134 foreach( $_POST["selectedParticipants"] as $key => $value )
00135 unset( $this->participants[$value] );
00136 }
00137 }
00138 if( userAllows( $this->creator, $this->participatelevel ) )
00139 {
00140 if( $_REQUEST["event_creator"] == $this->creator && $_REQUEST["event_timestamp"] == $this->timestamp )
00141 {
00142 if( $_REQUEST["participate"] == "yes" )
00143 $this->addParticipant(currentUser());
00144 else if( $_REQUEST["participate"] == "no" )
00145 $this->removeParticipant(currentUser());
00146
00147 if( $_POST["contactConfirm"] && is_array( $_POST["selectedParticipants"] ) )
00148 {
00149 $message_success = true;
00150 foreach( $_POST["selectedParticipants"] as $key => $value )
00151 if( !sendMessage( $value, $_POST["subject"], $_POST["message"], currentUser() ) )
00152 $message_success = false;
00153
00154 if( $message_success )
00155 {
00156 $year = date( "Y", $this->timestamp );
00157 $month = date( "n", $this->timestamp );
00158 $day = date( "j", $this->timestamp );
00159 header( "Location: " . $thisPageURL(true) . "&event_selectedyear=$year&event_selectedmonth=$month&event_selectedday=$day&event_creator=" . $this->creator . "&event_timestamp=" . $this->timestamp . "#" . $this->creator . "." . $this->timestamp );
00160 }
00161 }
00162 }
00163 }
00164 }
00165
00169 function generateFilename()
00170 {
00171 global $userinfo_folder;
00172 $year = date( "Y", $this->timestamp );
00173 $month = date( "n", $this->timestamp );
00174 $day = date( "j", $this->timestamp );
00175 $this->filename = "$userinfo_folder/" . $this->creator . "/events/$year/$month/$day/" . $this->timestamp . ".php";
00176 }
00177
00178 function addParticipant( $user_id )
00179 {
00180 $this->participants[$user_id] = time();
00181 $this->save();
00182 }
00183
00184 function removeParticipant( $user_id )
00185 {
00186 unset( $this->participants[$user_id] );
00187 $this->save();
00188 }
00189
00190 function load()
00191 {
00192 global $userinfo_folder;
00193 if ( file_exists( $this->filename ) )
00194 {
00195 include( $this->filename );
00196 }
00197 else
00198 {
00199 $event["title"] = i18n("No such event!");
00200 $event["description"] = i18n("No such event! If you found your way here by normal means, the event might have been deleted in the meantime.");
00201 $event["creator"] = $creator;
00202 $event["timestamp"] = $timestamp;
00203 $event["duration"] = 0;
00204 }
00205 $this->title = $event["title"];
00206 $this->description = $event["description"];
00207 $this->timestamp = $event["timestamp"];
00208 $this->duration = $event["duration"];
00209 $this->creator = $event["creator"];
00210 $this->viewlevel = $event["viewlevel"];
00211 $this->editlevel = $event["editlevel"];
00212 $this->commentlevel = $event["commentlevel"];
00213 $this->participatelevel = $event["participatelevel"];
00214 $this->participants = $event["participants"];
00215 $this->comments = $event["comments"];
00216 }
00217
00218 function save()
00219 {
00220 global $userinfo_folder;
00221 $event["title"] = $this->title;
00222 $event["description"] = $this->description;
00223 $event["timestamp"] = $this->timestamp;
00224 $event["duration"] = $this->duration;
00225 $event["creator"] = $this->creator;
00226 $event["viewlevel"] = $this->viewlevel;
00227 $event["editlevel"] = $this->editlevel;
00228 $event["commentlevel"] = $this->commentlevel;
00229 $event["participatelevel"] = $this->participatelevel;
00230 $event["participants"] = $this->participants;
00231 $event["comments"] = $this->comments;
00232
00233 $this->generateFilename();
00234
00235 if( !is_dir( dirname( $this->filename ) ) )
00236 RecursiveMkdir( dirname( $this->filename ) );
00237
00238 if( file_exists( $this->filename ) )
00239 unlink( $this->filename );
00240
00241 file_put_contents( $this->filename, array_export( $event, "event" ) );
00242 }
00243
00244 function delete()
00245 {
00246 if ( file_exists( $this->filename ) )
00247 unlink( $this->filename );
00248
00249 }
00250
00251 function render()
00252 {
00253 $commenthandler = new commentHandler($this->comments, $this->creator, $this->commentlevel, $this->editlevel);
00254
00255 if( userAllows( $this->creator, $this->viewlevel ) )
00256 {
00257 $year = date("Y", $this->timestamp);
00258 $month = date("n", $this->timestamp);
00259 $day = date("j", $this->timestamp);
00260
00261 $thisEventURL = thisPageURL( false, true, array( "event_selectedyear" => $year, "event_selectedmonth" => $month, "event_selectedday" => $day, "event_creator" => $this->creator, "event_timestamp" => $this->timestamp ) );
00262 $thisEventURLMarker = "#{$this->creator}.{$this->timestamp}";
00263
00264 if (userAllows($this->creator, $this->participatelevel)) {
00265 $editAllowed = userAllows($this->creator, $this->editlevel);
00266 if( $_REQUEST["event_timestamp"] == $this->timestamp && $_REQUEST["event_creator"] == $this->creator && $_REQUEST["event_showparticipants"] == "true" )
00267 {
00268 $participateControl = "<a class=\"command\" href=\"$thisEventURL&event_showparticipants=false$thisEventURLMarker\">[" . i18n("Hide") . "]</a> ";
00269 $renderedParticipants = "
00270 <form action=\"$thisEventURL&event_showparticipants=true$thisEventURLMarker\" method=\"POST\">
00271 <ul class=\"event_participants\">";
00272 if ( count( $this->participants ) > 0 )
00273 {
00274 foreach( $this->participants as $key => $value )
00275 {
00276 $participantChecked = "";
00277 foreach ( $_REQUEST["selectedParticipants"] as $key2 => $value )
00278 {
00279 if ( $key == $value )
00280 $participantChecked = " checked";
00281 }
00282
00283 $renderedParticipants .= "
00284 <li class=\"event_participant\"><label>
00285 <input type=\"checkbox\" name=\"selectedParticipants[$key]\"$participantChecked />
00286 " . i18n("##0## joined on ##1##", array(getUserInfo($key, "name"), formatTime( $value ))) . "
00287 </label></li>";
00288 }
00289 }
00290 else
00291 {
00292 $renderedParticipants .= "
00293 <li class=\"event_participant\">" . i18n("No participants") . "</li>";
00294 }
00295
00296 $renderedParticipants .= "
00297 </ul>";
00298
00299 if ( $editAllowed && $_POST["removeSelected"] )
00300 {
00301 $renderedParticipants .= "
00302 <p>" . i18n("Are you sure you wish to delete the selected participants?") . "</p>
00303 <input type=\"submit\" name=\"confirm_delete\" value=\"" . i18n("Confirm delete") . "\" />
00304 <input type=\"submit\" name=\"abort_delete\" value=\"" . i18n("Abort delete") . "\" />";
00305 }
00306 else if ( $_POST["contactSelected"] )
00307 {
00308 $renderedParticipants .= "
00309 <input style=\"width: 100%;\" type=\"text\" name=\"subject\" value=\"" . i18n("Message regarding ##0##", array($this->title)) . "\" />
00310 <textarea style=\"width: 100%;\" name=\"message\">" . i18n("Write your message here") . "</textarea>
00311 <input type=\"submit\" name=\"contactConfirm\" value=\"" . i18n("Send message") . "\" />
00312 <input type=\"submit\" name=\"contactAbort\" value=\"" . i18n("Abort message") . "\" />";
00313 }
00314 else if ( $_REQUEST["message_success"] == "true" )
00315 {
00316 $renderedParticipants .= "
00317 <p>" . i18n("The message was successfully sent to the participants") . "</p>";
00318 }
00319 else
00320 {
00321 if ( $editAllowed )
00322 $renderedParticipants .= "
00323 <input type=\"submit\" name=\"removeSelected\" value=\"" . i18n("Remove selected") . "\" />";
00324
00325 $renderedParticipants .= "
00326 <input type=\"submit\" name=\"contactSelected\" value=\"" . i18n("Contact selected") . "\" />
00327 <input type=\"reset\" value=\"" . i18n("Reset changes") . "\" />";
00328 }
00329
00330 $renderedParticipants .= "
00331 </form>";
00332 }
00333 else
00334 {
00335 $participateControl = "<a class=\"command\" href=\"$thisEventURL&event_showparticipants=true$thisEventURLMarker\">[" . i18n("Show") . "]</a> ";
00336 $renderedParticipants = "";
00337 }
00338 $participateControl .= i18n("Participants: ##0##", array(count($this->participants))) . " ";
00339 $isParticipating = false;
00340 if (is_array($this->participants))
00341 {
00342 foreach($this->participants as $key => $value)
00343 if ($key == currentUser())
00344 $isParticipating = true;
00345 }
00346 if ($isParticipating)
00347 {
00348 $participateControl .= "<a class=\"command\" href=\"$thisEventURL&participate=no$thisEventURLMarker\">[" . i18n("Don't participate") . "]</a> |";
00349 }
00350 else
00351 {
00352 $participateControl .= "<a class=\"command\" href=\"$thisEventURL&participate=yes$thisEventURLMarker\">[" . i18n("Participate") . "]</a> |";
00353 }
00354 }
00355 else
00356 {
00357 }
00358
00359 if ( userAllows( $this->creator, $this->editlevel ) )
00360 {
00361 $editControl = "<a class=\"command\" href=\"" . globalIDtoURL("user/{$this->creator}/events") . "?event_selectedyear=$year&event_selectedmonth=$month&event_selectedday=$day&event_creator=" . $this->creator . "&event_timestamp=" . $this->timestamp . "&editEvent={$this->timestamp}#editEvent\">[" . i18n("Edit event") . "]</a>";
00362
00363 if( $_REQUEST["deleteEvent"] == $this->timestamp )
00364 {
00365 $deleteControlTop = "
00366 <div class=\"event_confirmdelete\">
00367 <p class=\"event_confirmdelete\">" . i18n("Please confirm that you wish to delete this event. Warning: This cannot be undone!") . "</p>
00368 <p class=\"event_confirmdelete\">
00369 <a class=\"command\" href=\"$thisEventURL&confirm_delete=yes&deleteEvent={$this->timestamp}#" . $this->creator . "." . $this->timestamp . "\">[" . i18n("Confirm delete") . "]</a>
00370 <a class=\"command\" href=\"$thisEventURL$thisEventURLMarker\">[" . i18n("Abort delete") . "]</a>
00371 </p>
00372 <hr />";
00373 $deleteControlBottom = "
00374 </div>";
00375 }
00376 else
00377 {
00378 $deleteControlBottom = " <a class=\"command\" href=\"$thisEventURL&deleteEvent={$this->timestamp}$thisEventURLMarker\">[" . i18n("Delete event") . "]</a>";
00379 }
00380 }
00381
00382 if( $_REQUEST["show_comments"] == "true" || $_REQUEST["add_comment"] == "true" )
00383 {
00384 $renderedComments = $commenthandler->renderComments();
00385 $commentControl = " <a class=\"command\" href=\"" . $thisEventURL . "&show_comments=false$thisEventURLMarker\">[" . i18n("Hide comments") . "]</a>";
00386 }
00387 else if( $commenthandler->numberOfComments() > 0 )
00388 {
00389 $commentControl = " <a class=\"command\" href=\"" . $thisEventURL . "&show_comments=true$thisEventURLMarker\">[" . i18n("Show ##0## comments", array($commenthandler->numberOfComments())) . "]</a>";
00390 }
00391 if( userAllows( $this->creator, $this->commentlevel ) )
00392 {
00393 if( $_REQUEST["add_comment"] == "true" )
00394 {
00395 $renderedComments .= $commenthandler->renderCommentsAdder();
00396 $commentControl .= " <a class=\"command\" href=\"" . $thisEventURL . "&add_comment=false$thisEventURLMarker\">[" . i18n("Abort add comment") . "]</a>";
00397 }
00398 else
00399 {
00400 $commentControl .= " <a class=\"command\" href=\"" . $thisEventURL . "&add_comment=true#comment\">[" . i18n("Add comment") . "]</a>";
00401 }
00402 }
00403 else
00404 {
00405 }
00406 if( $commenthandler->commentsChanged )
00407 {
00408 $this->comments = $commenthandler->comments;
00409 $this->save();
00410 }
00411
00412 $timing = i18n( "Starts: ##0## - Ends: ##1##", array( date( "h:i:s", $this->timestamp ), date( "h:i:s d/n", $this->timestamp + ( $this->duration * 60 ) ) ) );
00413
00414 $data = "
00415 $deleteControlTop
00416 <h3 class=\"event_title\"><a class=\"namedanchor\" name=\"" . $this->creator . "." . $this->timestamp . "\">" . $this->title . "</a></h3>
00417 <p class=\"event_timing\">$timing</p>
00418 $editControl
00419 $deleteControlBottom
00420 " . parse_page_data($this->description) . "
00421 $renderedComments
00422 $renderedParticipants
00423 $participateControl
00424 $commentControl";
00425 } else {
00426 $data = "
00427 <h3 class=\"event_event\">" . i18n("Access disabled") . "</h3>
00428 <p>" . i18n("The event's creator has disabled access to this event.") . "</p>";
00429 }
00430
00431 return $data;
00432 }
00433 }
00434
00435 class eventsDay
00436 {
00437 var $year;
00438 var $month;
00439 var $day;
00440 var $events = array();
00441 var $isSelected;
00442 var $hasOwnEvent;
00443
00444 function eventsDay( $year, $month, $day )
00445 {
00446 $this->year = $year;
00447 $this->month = $month;
00448 $this->day = $day;
00449 $this->load();
00450 }
00451
00452 function load()
00453 {
00454 global $userinfo_folder;
00455 $i = 0;
00456 $this_day = $this->year . "/" . $this->month . "/" . $this->day;
00457 $this->events = array();
00458 $all_users = allUsersArray();
00459 foreach( $all_users as $key => $value )
00460 {
00461 $day_folder = "$userinfo_folder/$value/events/$this_day";
00462 if( is_dir( $day_folder ) )
00463 {
00464 if( $f = opendir( $day_folder ) )
00465 {
00466 while( false !== ( $file = readdir( $f ) ) )
00467 {
00468 if( substr($file, 0, 1) != "." )
00469 {
00470
00471 $timestamp = substr( $file, 0, -4 );
00472
00473 $id = "$value.$timestamp";
00474
00475 $this->events[$id] = new eventsEvent( $value, $timestamp );
00476
00477 if( isAuth() && $this->events[$id]->creator == currentUser() )
00478 $this->hasOwnEvent = true;
00479 }
00480 }
00481 }
00482 }
00483 }
00484 }
00485
00486 function addEvent( $title, $description, $timestamp, $duration, $creator, $viewlevel, $editlevel, $commentlevel, $participatelevel, $categories )
00487 {
00488 $newkey = "$creator.$timestamp";
00489 $this->events[$newkey] = new eventsEvent($creator, $timestamp);
00490 $this->events[$newkey]->title = $title;
00491 $this->events[$newkey]->description = $description;
00492 $this->events[$newkey]->timestamp = $timestamp;
00493 $this->events[$newkey]->duration = $duration;
00494 $this->events[$newkey]->creator = $creator;
00495 $this->events[$newkey]->viewlevel = $viewlevel;
00496 $this->events[$newkey]->editlevel = $editlevel;
00497 $this->events[$newkey]->commentlevel = $commentlevel;
00498 $this->events[$newkey]->participatelevel = $participatelevel;
00499 $this->events[$newkey]->categories = $categories;
00500 $this->events[$newkey]->save();
00501 }
00502
00503 function renderEventsList()
00504 {
00506 global $language;
00507 $data = "
00508 <dl class=\"events_eventlist\">";
00509 foreach( $this->events as $key => $value )
00510 $data .= "
00511 <dt>" . date("H:i", $value->timestamp) . "</dt>
00512 <dd class=\"events_eventlist\"><a class=\"events_eventlist_event\" href=\"" . thisPageURL( false, true, array( "page_id" => "", "page" => "Events", "language" => $language, "event_selectedyear" => $this->year, "event_selectedmonth" => $this->month, "event_selectedday" => $this->day ) ) . "#{$value->creator}.{$value->timestamp}\">" . $value->title . "</a></li>";
00513
00514 $data .= "
00515 </dl>";
00516 return $data;
00517 }
00518
00519 function render()
00520 {
00521 if ($this->isSelected) {
00522 $additional_css = "_selected";
00523 } else if ($this->hasOwnEvent) {
00524 $additional_css = "_ownevent";
00525 }
00526 if (count($this->events) == 0) {
00527 $eventsLabel = " ";
00528 } else if (count($this->events) == 1) {
00529 $eventsLabel = i18n("##0## event", array(count($this->events)));
00530 } else {
00531 $eventsLabel = i18n("##0## events", array(count($this->events)));
00532 }
00533 if (date("w", mktime(0, 0, 0, $this->month, $this->day, $this->year)) == "1") $data = "
00534 <tr class=\"event_calendar_week\">";
00535
00536 $data .= "
00537 <td class=\"event_calendar_day$additional_css\">
00538 <a href=\"" . thisPageURL( false, true, array( "event_selectedyear" => $this->year, "event_selectedmonth" => $this->month, "event_selectedday" => $this->day ) ) . "#events\" class=\"event_calendar_day$additional_css\"><table class=\"event_calendar_day$additional_css\">
00539 <tr class=\"event_calendar_day_top$additional_css\">
00540 <td class=\"event_calendar_day_tl$additional_css\">" . i18n(date("D", mktime(0, 0, 0, $this->month, $this->day, $this->year))) . "</td>
00541 <td class=\"event_calendar_day_tr$additional_css\">" . $this->day . "</td>
00542 </tr>
00543 <tr class=\"event_calendar_day_bottom$additional_css\">
00544 <td colspan=\"2\" class=\"event_calendar_day_b$additional_css\">$eventsLabel</td>
00545 </tr>
00546 </table></a>
00547 </td>";
00548 if (date("w", mktime(0, 0, 0, $this->month, $this->day, $this->year)) == "0") $data .= "
00549 </tr>";
00550 return $data;
00551 }
00552 }
00553
00554 class eventsMonth {
00555 var $selectedDay;
00556 var $year;
00557 var $month;
00558 var $categories = "";
00559 var $days = array();
00560
00561 function eventsMonth($year = 0, $month = 0) {
00562 if ($_REQUEST["event_selectedyear"] != "") {
00563 $this->year = $_REQUEST["event_selectedyear"];
00564 } else {
00565 $this->year = date("Y");
00566 }
00567 if ($_REQUEST["event_selectedmonth"] != "") {
00568 $this->month = $_REQUEST["event_selectedmonth"];
00569 } else {
00570 $this->month = date("n");
00571 }
00572 if ($_REQUEST["event_selectedday"] != "") {
00573 $this->selectedDay = $_REQUEST["event_selectedday"];
00574 } else {
00575 $this->selectedDay = date("j");
00576 }
00577 if ($year != 0) $this->year = $year;
00578 if ($month != 0) $this->month = $month;
00579
00580 if ($_POST["event_navigator_prev_year"]) $this->year--;
00581 if ($_POST["event_navigator_next_year"]) $this->year++;
00582 if ($_POST["event_navigator_prev_month"]) {
00583 if ($this->month == 1) {
00584 $this->month = 12;
00585 $this->year--;
00586 } else {
00587 $this->month--;
00588 }
00589 }
00590 if ($_POST["event_navigator_next_month"]) {
00591 if ($this->month == 12) {
00592 $this->month = 1;
00593 $this->year++;
00594 } else {
00595 $this->month++;
00596 }
00597 }
00598
00599 if ($_POST["event_navigator_today"]) {
00600 $this->year = date("Y");
00601 $this->month = date("n");
00602 $this->selectedDay = date("j");
00603 }
00604
00605 $this->load();
00606 }
00607
00613 function load() {
00614 $this->days = array();
00615 if ($this->year > 0 && (int)$this->month > 0) {
00616 $number_of_days = date("t", mktime(0, 0, 0, $this->month, 1, $this->year));
00617
00618 for ($i = 1; $i <= $number_of_days; $i++) {
00619 $this->days[$i] = new eventsDay($this->year, $this->month, $i);
00620 }
00621 $this->days[$this->selectedDay]->isSelected = true;
00622
00623 return true;
00624 } else {
00625 return false;
00626 }
00627 }
00628
00629 function render() {
00630 $startyear = $this->year - 50;
00631 for($i = 0; $i < 100; $i++) {
00632 $theyear = $startyear + $i;
00633 if ($theyear == $this->year) {
00634 $selected = " selected";
00635 } else {
00636 $selected = "";
00637 }
00638 $navigator_year .= "
00639 <option value=\"$theyear\"$selected>$theyear</option>";
00640 }
00641 $allmonths = array(1 => i18n("January"), 2 => i18n("February"), 3 => i18n("March"), 4 => i18n("April"), 5 => i18n("May"), 6 => i18n("June"), 7 => i18n("July"), 8 => i18n("August"), 9 => i18n("September"), 10 => i18n("October"), 11 => i18n("November"), 12 => i18n("December"));
00642 for($i = 1; $i < 13; $i++) {;
00643 if ($i == $this->month) {
00644 $selected = " selected";
00645 } else {
00646 $selected = "";
00647 }
00648 $navigator_month .= "
00649 <option value=\"$i\"$selected>" . i18n($allmonths[$i]) . "</option>";
00650 }
00651 $navigator = "
00652 <form class=\"event_navigator\" name=\"event_navigator\" action=\"" . thisPageURL( false, true, array( "event_selectedyear" => $this->year, "event_selectedmonth" => $this->month, "event_selectedday" => $this->selectedDay ) ) . "\" method=\"post\">
00653 <tr>
00654 <td class=\"event_navigator\" colspan=\"3\"><input class=\"event_navigator_prev_year\" type=\"submit\" name=\"event_navigator_prev_year\" value=\"«\"
00655 /><select onchange=\"document.event_navigator.submit();\" class=\"event_navigator_select_year\" name=\"event_selectedyear\">$navigator_year
00656 </select><input class=\"event_navigator_next_year\" type=\"submit\" name=\"event_navigator_next_year\" value=\"»\" /></td>
00657 <td class=\"event_navigator\" colspan=\"3\"><input class=\"event_navigator_prev_month\" type=\"submit\" name=\"event_navigator_prev_month\" value=\"«\"
00658 /><select onchange=\"document.event_navigator.submit();\" class=\"event_navigator_select_month\" name=\"event_selectedmonth\">$navigator_month
00659 </select><input class=\"event_navigator_next_month\" type=\"submit\" name=\"event_navigator_next_month\" value=\"»\" /></td>
00660 <td class=\"event_navigator\"><input class=\"event_navigator_today\" type=\"submit\" name=\"event_navigator_today\" value=\"" . i18n("Go to today") . "\" /></td>
00661 </tr>
00662 </form>";
00663
00664 $leadinDays = date("w", mktime(0, 0, 0, $this->month, 1, $this->year)) - 1;
00665
00666 if ($leadinDays == -1) $leadinDays = 6;
00667 else if ($leadinDays == 0) $leadinDays = 7;
00668
00669 $leadinYear = date("Y", mktime(0, 0, 0, $this->month - 1, 1, $this->year));
00670 $leadinMonth = date("n", mktime(0, 0, 0, $this->month - 1, 1, $this->year));
00671
00672 $leadinData = "
00673 <tr class=\"event_calendar_week\">";
00674 for($i = -$leadinDays; $i < 0; $i++) {
00675 $thedate = date("j", mktime(0, 0, 0, (int)$this->month, 1+$i, $this->year));
00676 $leadinData .= "
00677 <td class=\"event_calendar_day_leadin\">
00678 <a href=\"" . thisPageURL( false, true, array( "event_selectedyear" => $leadinYear, "event_selectedmonth" => $leadinMonth, "event_selectedday" => $thedate ) ) . "\" class=\"event_calendar_day_leadin$additional_css\"><table class=\"event_calendar_day$additional_css\">
00679 <table class=\"event_calendar_day_leadin\">
00680 <tr class=\"event_calendar_day_top_leadin\">
00681 <td class=\"event_calendar_day_tl_leadin\"> </td>
00682 <td class=\"event_calendar_day_tr_leadin\">$thedate</td>
00683 </tr>
00684 <tr class=\"event_calendar_day_bottom_leadin\">
00685 <td colspan=\"2\" class=\"event_calendar_day_b_leadin\"> </td>
00686 </tr>
00687 </table>
00688 </a>
00689 </td>";
00690 }
00691 if ($leadinDays == 7) $leadinData .= "
00692 </tr>";
00693
00694 $leadoutDays = date("w", mktime(0, 0, 0, (int)$this->month + 1, 1, $this->year));
00695
00696 switch ($leadoutDays) {
00697 case 0: $leadoutDays = 0; break;
00698 case 1: $leadoutDays = 6; break;
00699 case 2: $leadoutDays = 5; break;
00700 case 3: $leadoutDays = 4; break;
00701 case 4: $leadoutDays = 3; break;
00702 case 5: $leadoutDays = 2; break;
00703 case 6: $leadoutDays = 1; break;
00704 }
00705
00706 $leadoutYear = date("Y", mktime(0, 0, 0, (int)$this->month + 1, 1, $this->year));
00707 $leadoutMonth = date("n", mktime(0, 0, 0, (int)$this->month + 1, 1, $this->year));
00708
00709 if ($leadoutDays == 6) $leadoutData .="
00710 <tr class=\"event_calendar_week\">";
00711
00712 for($i = 0; $i <= $leadoutDays; $i++) {
00713 $thedate = date("j", mktime(0, 0, 0, (int)$this->month, 1+$i, $this->year));
00714 $leadoutData .= "
00715 <td class=\"event_calendar_day_leadout\">
00716 <a href=\"" . thisPageURL( false, true, array( "event_selectedyear" => $leadoutYear, "event_selectedmonth" => $leadoutMonth, "event_selectedday" => $thedate ) ) . "\" class=\"event_calendar_day_leadout$additional_css\"><table class=\"event_calendar_day$additional_css\">
00717 <table class=\"event_calendar_day_leadout\">
00718 <tr class=\"event_calendar_day_top_leadout\">
00719 <td class=\"event_calendar_day_tl_leadout\"> </td>
00720 <td class=\"event_calendar_day_tr_leadout\">$thedate</td>
00721 </tr>
00722 <tr class=\"event_calendar_day_bottom_leadout\">
00723 <td colspan=\"2\" class=\"event_calendar_day_b_leadout\"> </td>
00724 </tr>
00725 </table>
00726 </a>
00727 </td>";
00728 }
00729 $leadoutData .= "
00730 </tr>";
00731
00732
00733 foreach($this->days as $key => $value) {
00734 $renderedDays .= $value->render();
00735 }
00736
00737
00738 $renderedEvents = "<h2 class=\"event_calendar_events\">" . i18n("Events for ##0##", array(formatTime( mktime(0, 0, 0, $this->month, $this->selectedDay, $this->year) ) ) ) . "<a class=\"namedanchor\" name=\"events\"> </a></h2>";
00739 if (count($this->days[$this->selectedDay]->events) > 0) {
00740 foreach($this->days[$this->selectedDay]->events as $key => $value) {
00741 $renderedEvents .= $value->render();
00742 }
00743 } else {
00744 $renderedEvents .= "<p>" . i18n("There are no events on this date") . "</p>";
00745 }
00746
00747 $data = "
00748 <table class=\"event_calendar\">
00749 $navigator
00750 $leadinData
00751 $renderedDays
00752 $leadoutData
00753 </table>
00754 $renderedEvents";
00755 return $data;
00756 }
00757 }
00758
00766 function globalID_events( $splitID )
00767 {
00768 $pageID = null;
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780 if( $splitID[0] == "user" && $splitID[2] == "events" )
00781 {
00782 $_REQUEST["page_id"] = "13";
00783 $_REQUEST["user_id"] = $splitID[1];
00784 $_REQUEST["module"] = "profilemodule_events";
00785
00786 if( array_key_exists( 3, $splitID ) && array_key_exists( 4, $splitID ) )
00787 {
00788 $_REQUEST["event_creator"] = $splitID[3];
00789 $_REQUEST["event_timestamp"] = $splitID[4];
00790 }
00791
00792 $pageID = "13";
00793 }
00794
00795 return $pageID;
00796 }
00797
00798 function parse_events_calendar($page_data) {
00799 global $setup_folder;
00800
00801 while (true) {
00802 $begpos = strpos($page_data, "\\calendar(");
00803 if ($begpos === false) break;
00804 $endpos = strpos($page_data, ")", $begpos + 9);
00805
00806 $categories = substr( $page_data, $begpos + 10, ($endpos - $begpos) - 10);
00807
00808 $calendar = new eventsMonth();
00809 $data = $calendar->render();
00810
00811 $page_data = str_replace("\\calendar($categories)", $data, $page_data);
00812 }
00813 return $page_data;
00814 }
00815
00816 function parse_events_event( $page_data )
00817 {
00818 global $setup_folder;
00819
00820 while( true )
00821 {
00822 $begpos = strpos( $page_data, "\\event(" );
00823 if( $begpos === false )
00824 break;
00825 $endpos = strpos( $page_data, ")", $begpos + 6 );
00826
00827 $creator_and_timestamp = substr( $page_data, $begpos + 7, ( $endpos - $begpos ) - 7 );
00828
00829 if( $_REQUEST["event_creator"] != "" && $_REQUEST["event_timestamp"] != "" )
00830 $creator_and_timestamp = $_REQUEST["event_creator"] . ", " . $_REQUEST["event_timestamp"];
00831
00832 if( $creator_and_timestamp != "" )
00833 {
00834 list( $creator, $timestamp ) = explode( ",", $user_and_timestamp );
00835 $creator = trim( $creator );
00836 $timestamp = trim( $timestamp );
00837 $theevent = new eventsEvent($creator, $timestamp);
00838 $data = $theevent->render();
00839 }
00840
00841 $page_data = str_replace("\\event($creator_and_timestamp)", $data, $page_data);
00842 }
00843 return $page_data;
00844 }
00845
00846 function parse_events_events( $page_data )
00847 {
00848 global $setup_folder;
00849
00850 while( true )
00851 {
00852 $begpos = strpos( $page_data, "\\events(" );
00853 if( $begpos === false )
00854 break;
00855 $endpos = strpos( $page_data, ")", $begpos + 7 );
00856
00857 $number_of_days = trim( substr( $page_data, $begpos + 8, ( $endpos - $begpos ) - 8 ) );
00858 if( $number_of_days == "" )
00859 $number_of_days = 7;
00860
00861 $theday = time();
00862
00863 for( $i = 0; $i < $number_of_days; $i++ )
00864 {
00865 $year = date("Y", $theday);
00866 $month = date("n", $theday);
00867 $day = date("j", $theday);
00868 $theEventsDay = new eventsDay( $year, $month, $day );
00869
00870 if( count( $theEventsDay->events ) > 0 )
00871 $data .= "
00872 <div class=\"events_eventlist_day\">" . i18n( date( "l", $theday ) ) . date( " j/n", $theday ) . "</div>" . $theEventsDay ->renderEventsList();
00873
00874 $theday = mktime(0, 0, 0, $month, $day + 1, $year);
00875 }
00876
00877 if( $data == "" )
00878 $data = "<div class=\"events_eventlist_empty\">" . i18n("There are no events in the next ##0## days", array( $number_of_days ) ) . "</div>";
00879
00880 $page_data = str_replace("\\events($number_of_days)", $data, $page_data);
00881 }
00882 return $page_data;
00883 }
00884
00885 function profilemodule_events() {
00886 global $tabwidget, $setup_folder, $userinfo_folder, $language, $languages, $permissionlevels_array, $eventcategories, $formatting_toolbar, $viewUser;
00887
00888 $allowEdit = isAllowed("global_user_edit") || ($_REQUEST["user_id"] != "" && $_REQUEST["user_id"] == currentUser());
00889
00890 if ($_POST["event_save_settings"]) {
00891 saveUserInfo($_REQUEST["user_id"], "event_viewlevel", $_REQUEST["event_viewlevel"]);
00892 saveUserInfo($_REQUEST["user_id"], "event_editlevel", $_REQUEST["event_editlevel"]);
00893 saveUserInfo($_REQUEST["user_id"], "event_commentlevel", $_REQUEST["event_commentlevel"]);
00894 saveUserInfo($_REQUEST["user_id"], "event_participatelevel", $_REQUEST["event_participatelevel"]);
00895 if (is_array($_REQUEST["event_category"])) {
00896 foreach ($_REQUEST["event_category"] as $key => $value) {
00897 $categories_temp[] = $value;
00898 }
00899 saveUserInfo($_REQUEST["user_id"], "event_categories", serialize($categories_temp));
00900 }
00901 }
00902
00903 $temp_options["viewlevel"] = getUserInfo($_REQUEST["user_id"], "event_viewlevel");
00904 if ($temp_options["viewlevel"] == i18n("No ##0## information\n", array("event_viewlevel"))) {
00905 $temp_options["viewlevel"] = 0;
00906 saveUserInfo($_REQUEST["user_id"], "event_viewlevel", 0);
00907 }
00908 $temp_options["editlevel"] = getUserInfo($_REQUEST["user_id"], "event_editlevel");
00909 if ($temp_options["editlevel"] == i18n("No ##0## information\n", array("event_editlevel"))) {
00910 $temp_options["editlevel"] = 4;
00911 saveUserInfo($_REQUEST["user_id"], "event_editlevel", 0);
00912 }
00913 $temp_options["commentlevel"] = getUserInfo($_REQUEST["user_id"], "event_commentlevel");
00914 if ($temp_options["commentlevel"] == i18n("No ##0## information\n", array("event_commentlevel"))) {
00915 $temp_options["commentlevel"] = 2;
00916 saveUserInfo($_REQUEST["user_id"], "event_commentlevel", 0);
00917 }
00918 $temp_options["participatelevel"] = getUserInfo($_REQUEST["user_id"], "event_participatelevel");
00919 if ($temp_options["participatelevel"] == i18n("No ##0## information\n", array("event_participatelevel"))) {
00920 $temp_options["participatelevel"] = 2;
00921 saveUserInfo($_REQUEST["user_id"], "event_participatelevel", 0);
00922 }
00923
00924 $temp_options["categories"] = getUserInfo($_REQUEST["user_id"], "event_categories");
00925 if ($temp_options["categories"] == i18n("No ##0## information\n", array("event_categories"))) {
00926 $temp_options["categories"] = array();
00927 saveUserInfo($_REQUEST["user_id"], "event_categories", serialize(array()));
00928 } else {
00929 $temp_options["categories"] = unserialize($temp_options["categories"]);
00930 }
00931
00932 $eventcategories_user = getUserInfo($_REQUEST["user_id"], "event_usercategories");
00933 if ($eventcategories_user == i18n("No ##0## information\n", array("event_usercategories"))) {
00934 $eventcategories_user = array();
00935 } else {
00936 $eventcategories_user = unserialize($eventcategories_user);
00937 }
00938
00939 if ($_REQUEST["action"] == "options" && $allowEdit) {
00940 $tabwidget->addCommand(i18n("View calendar"), i18n("View the calendar"), siteURL() . "?page_id=13&user_id={$_REQUEST['user_id']}&profile_mode=module&module=profilemodule_events&event_selectedday={$_REQUEST['event_selectedday']}");
00941
00942 foreach($permissionlevels_array as $key => $value) {
00943 if ($temp_options["viewlevel"] == $key) {
00944 $default = " selected";
00945 } else {
00946 $default = "";
00947 }
00948 $eventoptions_viewlevel .= "<option value=\"$key\"$default>$value</option>";
00949 }
00950
00951 foreach($permissionlevels_array as $key => $value) {
00952 if ($temp_options["editlevel"] == $key) {
00953 $default = " selected";
00954 } else {
00955 $default = "";
00956 }
00957 $eventoptions_editlevel .= "<option value=\"$key\"$default>$value</option>";
00958 }
00959
00960 foreach($permissionlevels_array as $key => $value) {
00961 if ($temp_options["commentlevel"] == $key) {
00962 $default = " selected";
00963 } else {
00964 $default = "";
00965 }
00966 $eventoptions_commentlevel .= "<option value=\"$key\"$default>$value</option>";
00967 }
00968
00969 foreach($permissionlevels_array as $key => $value) {
00970 if ($temp_options["participatelevel"] == $key) {
00971 $default = " selected";
00972 } else {
00973 $default = "";
00974 }
00975 $eventoptions_participatelevel .= "<option value=\"$key\"$default>$value</option>";
00976 }
00977
00978 if ($_REQUEST["event_add_category"]) {
00979 $temp_options["categories"][] = "";
00980 }
00981
00982 if (is_array($_REQUEST["event_remove_category"])) {
00983 foreach ($_REQUEST["event_remove_category"] as $key => $value) {
00984 unset($temp_options["categories"][$key]);
00985 }
00986 saveUserInfo($_REQUEST["user_id"], "event_categories", serialize($temp_options["categories"]));
00987 }
00988
00989 $data = "
00990 <form action=\"" . thisPageURL() . "\" method=\"post\">
00991 <table class=\"setup\">
00992 <tr class=\"setup\">
00993 <th class=\"setup\" colspan=\"2\">" . i18n("By default new events have the following settings") . "</th>
00994 </tr>
00995 <tr class=\"setup\">
00996 <td class=\"setup\" width=\"50%\">" . i18n("Viewing allowance level") . "</td>
00997 <td class=\"setup\" width=\"50%\"><select style=\"width: 100%\" name=\"event_viewlevel\">$eventoptions_viewlevel</select></td>
00998 </tr>
00999 <tr class=\"setup\">
01000 <td class=\"setup\" width=\"50%\">" . i18n("Editing allowance level") . "</td>
01001 <td class=\"setup\" width=\"50%\"><select style=\"width: 100%\" name=\"event_editlevel\">$eventoptions_editlevel</select></td>
01002 </tr>
01003 <tr class=\"setup\">
01004 <td class=\"setup\" width=\"50%\">" . i18n("Commenting allowance level") . "</td>
01005 <td class=\"setup\" width=\"50%\"><select style=\"width: 100%\" name=\"event_commentlevel\">$eventoptions_commentlevel</select></td>
01006 </tr>
01007 <tr class=\"setup\">
01008 <td class=\"setup\">" . i18n("Participation allowance level") . "</td>
01009 <td class=\"setup\"><select style=\"width: 100%\" name=\"event_participatelevel\">$eventoptions_participatelevel</select></td>
01010 </tr>
01011 <tr class=\"setup\">
01012 <td class=\"setup\">
01013 " . i18n("Default categories");
01014
01015 foreach ($temp_options["categories"] as $key => $value) {
01016 $categories_temp = "<optgroup label=\"" . i18n("Your categories") . "\">";
01017 foreach($eventcategories_user as $key2 => $value2) {
01018 if ($value2 == $value) { $default_temp = " selected"; } else { $default_temp = ""; }
01019 $categories_temp .= "<option value=\"$value2\"$default_temp>" . i18n($value2) . "</option>";
01020 }
01021 $categories_temp .= "</optgroup><optgroup label=\"" . i18n("Site-wide categories") . "\">";
01022 foreach($eventcategories as $key2 => $value2) {
01023 if ($value2 == $value) { $default_temp = " selected"; } else { $default_temp = ""; }
01024 $categories_temp .= "<option value=\"$value2\"$default_temp>" . i18n($value2) . "</option>";
01025 }
01026 $data .= "<input style=\"float: right;\" type=\"submit\" name=\"event_remove_category[$key]\" value=\"-\" /></td>
01027 <td class=\"setup\"><select style=\"width: 100%\" name=\"event_category[$key]\">$categories_temp</optgroup></select></td>
01028 </tr>
01029 <tr class=\"setup\">
01030 <td class=\"setup\">";
01031 }
01032
01033 $data .= " </td>
01034 <td class=\"setup\"><input type=\"submit\" name=\"event_add_category\" value=\"" . i18n("Add category") . "\" /></td>
01035 </tr>
01036 <tr class=\"setup\">
01037 <td class=\"setup\"><input type=\"submit\" name=\"event_save_settings\" value=\"" . i18n("Save options") . "\" /></td>
01038 <td class=\"setup wikirightalign\"><input type=\"reset\" value=\"" . i18n("Revert to saved") . "\" /></td>
01039 </tr>
01040 </table>
01041 </form>";
01042 } else {
01043 $calendar = new eventsMonth();
01044 foreach($calendar->days as $key => $value) {
01045 $calendar->days[$key]->hasOwnEvent = false;
01046 foreach($calendar->days[$key]->events as $key2 => $value2) {
01047 if ($value2->creator == $_REQUEST["user_id"]) $calendar->days[$key]->hasOwnEvent = true;
01048 }
01049 }
01050 $data = $calendar->render();
01051
01052 if ($allowEdit) {
01053 if ($_REQUEST["action"] == "addEvent") {
01054 $timestamp = mktime(date("h"), date("i"), date("s"), $calendar->month, $calendar->selectedDay, $calendar->year);
01055 $calendar->days[$calendar->selectedDay]->addEvent(i18n("Untitled event"), i18n("Type your description here"), $timestamp, 0, $_REQUEST["user_id"], $temp_options["viewlevel"], $temp_options["editlevel"], $temp_options["commentlevel"], $temp_options["participatelevel"], $temp_options["categories"]);
01056 header("Location: " . siteURL() . "?page_id=13&user_id={$_REQUEST['user_id']}&profile_mode=module&module=profilemodule_events&event_selectedyear={$calendar->year}&event_selectedmonth={$calendar->month}&event_selectedday={$calendar->selectedDay}&event_creator={$_REQUEST['user_id']}&editEvent=$timestamp#editEvent");
01057 } else if ($_REQUEST["editEvent"] != "" && $_REQUEST["event_creator"]) {
01058 $event = new eventsEvent($_REQUEST["event_creator"], $_REQUEST["editEvent"]);
01059
01060 if ($_POST) {
01061 $temp_year = $_REQUEST["year"];
01062 $temp_month = $_REQUEST["month"];
01063 $temp_date = $_REQUEST["day"];
01064 $temp_hour = $_REQUEST["hour"];
01065 $temp_minute = $_REQUEST["minute"];
01066 $temp_second = $_REQUEST["second"];
01067 $event->title = htmlspecialchars(stripslashes($_REQUEST["event_title"]));
01068 $event->description = htmlspecialchars(stripslashes($_REQUEST["event_description"]));
01069 $event->duration = ($_REQUEST["duration_days"] * 1440) + ($_REQUEST["duration_hours"] * 60) + $_REQUEST["duration_minutes"];
01070 $event->viewlevel = $_REQUEST["event_viewlevel"];
01071 $event->editlevel = $_REQUEST["event_editlevel"];
01072 $event->editlevel = $_REQUEST["event_commentlevel"];
01073 $event->participatelevel = $_REQUEST["event_participatelevel"];
01074 $event->categories = $_REQUEST["event_category"];
01075 if (is_array($_POST["event_remove_category"])) {
01076 foreach($_POST["event_remove_category"] as $key => $value) {
01077 unset($event->categories[$key]);
01078 }
01079 }
01080 if ($_POST["event_add_category"]) $event->categories[] = "";
01081 } else {
01082
01083 $temp_year = date("Y", $event->timestamp);
01084 $temp_month = date("n", $event->timestamp);
01085 $temp_date = date("j", $event->timestamp);
01086 $temp_hour = date("H", $event->timestamp);
01087 $temp_minute = date("i", $event->timestamp);
01088 $temp_second = date("s", $event->timestamp);
01089 }
01090
01091 if ($_POST["save_event"]) {
01092 $event->delete();
01093 $event->timestamp = mktime($temp_hour, $temp_minute, $temp_second, $temp_month, $temp_date, $temp_year);
01094 $event->save();
01095 header("Location: " . globalIDtoURL("user/$userView/events") . "?event_selectedyear=$temp_year&event_selectedmonth=$temp_month&event_selectedday=$temp_date");
01096 }
01097
01098 for ($i = date("Y") - 50; $i <= date("Y") + 50; $i++) { $allyears[] = $i; }
01099 foreach ($allyears as $key => $value) {
01100 if ($value == $temp_year) { $selected = " selected"; } else { $selected = ""; }
01101 $temp_years .= "<option value=\"$value\"$selected>$value</option>";
01102 }
01103
01104 $allmonths = array(1 => i18n("January"), 2 => i18n("February"), 3 => i18n("March"), 4 => i18n("April"), 5 => i18n("May"), 6 => i18n("June"), 7 => i18n("July"), 8 => i18n("August"), 9 => i18n("September"), 10 => i18n("October"), 11 => i18n("November"), 12 => i18n("December"));
01105 foreach ($allmonths as $key => $value) {
01106 if ($key == $temp_month) { $selected = " selected"; } else { $selected = ""; }
01107 $temp_months .= "<option value=\"$key\"$selected>$value</option>";
01108 }
01109
01110 for ($i = 1; $i <= 31; $i++) { $alldates[] = $i; }
01111 foreach ($alldates as $key => $value) {
01112 if ($value == $temp_date) { $selected = " selected"; } else { $selected = ""; }
01113 $temp_days .= "<option value=\"$value\"$selected>$value</option>";
01114 }
01115
01116 for ($i = 0; $i <= 23; $i++) { if (strlen($i) < 2) { $allhours[] = "0$i"; } else { $allhours[] = $i; } }
01117 foreach ($allhours as $key => $value) {
01118 if ($value == $temp_hour) { $selected = " selected"; } else { $selected = ""; }
01119 $temp_hours .= "<option value=\"$value\"$selected>$value</option>";
01120 }
01121
01122 for ($i = 0; $i <= 59; $i++) { if (strlen($i) < 2) { $allminutes[] = "0$i"; } else { $allminutes[] = $i; } }
01123 foreach ($allminutes as $key => $value) {
01124 if ($value == $temp_minute) { $selected = " selected"; } else { $selected = ""; }
01125 $temp_minutes .= "<option value=\"$value\"$selected>$value</option>";
01126 }
01127 foreach ($allminutes as $key => $value) {
01128 if ($value == $temp_second) { $selected = " selected"; } else { $selected = ""; }
01129 $temp_seconds .= "<option value=\"$value\"$selected>$value</option>";
01130 }
01131
01132
01133 $test_days = floor($event->duration / 1440);
01134 for($i = 0; $i <= 31; $i++) {
01135 if ($test_days == $i) {
01136 $selected = " selected";
01137 } else {
01138 $selected = "";
01139 }
01140 $temp_duration_days .= "<option value=\"$i\"$selected>" . i18n("##0## days", array($i)) . "</option>";
01141 }
01142 $test_hours = floor(($event->duration - ($test_days * 1440)) / 60);
01143 for($i = 0; $i <= 24; $i++) {
01144 if ($test_hours == $i) {
01145 $selected = " selected";
01146 } else {
01147 $selected = "";
01148 }
01149 $temp_duration_hours .= "<option value=\"$i\"$selected>" . i18n("##0## hours", array($i)) . "</option>";
01150 }
01151 $test_minutes = ($event->duration - ($test_days * 1440) - ($test_hours * 60));
01152 for($i = 0; $i <= 60; $i++) {
01153 if ($test_minutes == $i) {
01154 $selected = " selected";
01155 } else {
01156 $selected = "";
01157 }
01158 $temp_duration_minutes .= "<option value=\"$i\"$selected>" . i18n("##0## minutes", array($i)) . "</option>";
01159 }
01160
01161
01162 foreach($permissionlevels_array as $key => $value) {
01163 if ($event->viewlevel == $key) {
01164 $default = " selected";
01165 } else {
01166 $default = "";
01167 }
01168 $viewlevel .= "<option value=\"$key\"$default>$value</option>";
01169 }
01170
01171 foreach($permissionlevels_array as $key => $value) {
01172 if ($event->editlevel == $key) {
01173 $default = " selected";
01174 } else {
01175 $default = "";
01176 }
01177 $editlevel .= "<option value=\"$key\"$default>$value</option>";
01178 }
01179
01180 foreach($permissionlevels_array as $key => $value) {
01181 if ($event->commentlevel == $key) {
01182 $default = " selected";
01183 } else {
01184 $default = "";
01185 }
01186 $commentlevel .= "<option value=\"$key\"$default>$value</option>";
01187 }
01188
01189 foreach($permissionlevels_array as $key => $value) {
01190 if ($event->participatelevel == $key) {
01191 $default = " selected";
01192 } else {
01193 $default = "";
01194 }
01195 $participatelevel .= "<option value=\"$key\"$default>$value</option>";
01196 }
01197 $data .= "<form action=\"" . thisPageURL( false, true, array( "event_selectedyear" => $calendar->year, "event_selectedmonth" => $calendar->month, "event_selectedday" => $calendar->selectedDay, "event_creator" => $event->creator, "editEvent" => $event->timestamp ) ) . "#editEvent\" method=\"post\"><table class=\"setup\">
01198 <tr class=\"setup\">
01199 <th colspan=\"2\" class=\"setup\"><a class=\"namedanchor\" name=\"editEvent\">" . i18n("Edit event") . "</a></th>
01200 </tr>
01201 <tr class=\"setup\">
01202 <td class=\"setup\">" . i18n("Creator:") . "
01203 <small class=\"comment\">" . i18n("This is always you - this cannot be changed") . "</small></td>
01204 <td class=\"setup\"><input type=\"hidden\" name=\"event_creator\" value=\"{$_REQUEST["user_id"]}\" />{$_REQUEST['user_id']}</td>
01205 </tr>
01206 <tr class=\"setup\">
01207 <td class=\"setup\">" . i18n("Title:") . "
01208 <small class=\"comment\">" . i18n("The headline for this event") . "</small></td>
01209 <td class=\"setup\"><input style=\"width: 99%;\" type=\"text\" name=\"event_title\" value=\"{$event->title}\" /></td>
01210 </tr>
01211 <tr class=\"setup\">
01212 <td class=\"setup\">" . i18n("Start time:") . "
01213 <small class=\"comment\">" . i18n("When does the event begin?") . "</small></td>
01214 <td class=\"setup\"><div style=\"width: 10%; overflow: hidden; display: inline-block;\">
01215 " . i18n("On") . "</div><select style=\"width: 30%;\" name=\"year\">$temp_years
01216 </select><select style=\"width: 40%;\" name=\"month\">$temp_months
01217 </select><select style=\"width: 20%;\" name=\"day\">$temp_days
01218 </select><br />
01219 <div style=\"width: 10%; overflow: hidden; display: inline-block;\">
01220 " . i18n("At") . "</div><select style=\"width: 30%;\" name=\"hour\">$temp_hours
01221 </select><select style=\"width: 30%;\" name=\"minute\">$temp_minutes
01222 </select><select style=\"width: 30%;\" name=\"second\">$temp_seconds
01223 </select></td>
01224 </tr>
01225 <tr class=\"setup\">
01226 <td class=\"setup\">" . i18n("Duration:") . "
01227 <small class=\"comment\">" . i18n("How long does the event last?") . "</small></td>
01228 <td class=\"setup\"><select style=\"width: 30%;\" name=\"duration_days\">$temp_duration_days
01229 </select><select style=\"width: 30%;\" name=\"duration_hours\">$temp_duration_hours
01230 </select><select style=\"width: 40%;\" name=\"duration_minutes\">$temp_duration_minutes
01231 </select></td>
01232 </tr>
01233 <tr class=\"setup\">
01234 <td class=\"setup\">" . i18n("Viewing allowance level:") . "
01235 <small class=\"comment\">" . i18n("Who except you are allowed to see this event in the calendar?") . "</small></td>
01236 <td class=\"setup\"><select style=\"width: 100%\" name=\"event_viewlevel\">$viewlevel</select></td>
01237 </tr>
01238 <tr class=\"setup\">
01239 <td class=\"setup\">" . i18n("Editing allowance level:") . "
01240 <small class=\"comment\">" . i18n("Who except you are allowed to edit this event?") . "</small></td>
01241 <td class=\"setup\"><select style=\"width: 100%\" name=\"event_editlevel\">$editlevel</select></td>
01242 </tr>
01243 <tr class=\"setup\">
01244 <td class=\"setup\">" . i18n("Commenting allowance level:") . "
01245 <small class=\"comment\">" . i18n("Who except you are allowed to comment on this event?") . "</small></td>
01246 <td class=\"setup\"><select style=\"width: 100%\" name=\"event_editlevel\">$commentlevel</select></td>
01247 </tr>
01248 <tr class=\"setup\">
01249 <td class=\"setup\">" . i18n("Participation allowance level:") . "
01250 <small class=\"comment\">" . i18n("Who except you are allowed to join this event?") . "</small></td>
01251 <td class=\"setup\"><select style=\"width: 100%\" name=\"event_participatelevel\">$participatelevel</select></td>
01252 </tr>
01253 <tr class=\"setup\">
01254 <td class=\"setup\">" . i18n("Categories") . ":";
01255
01256 if (is_array($event->categories)) {
01257 foreach ($event->categories as $key => $value) {
01258 $categories_temp = "<optgroup label=\"" . i18n("Your categories") . "\">";
01259 foreach($eventcategories_user as $key2 => $value2) {
01260 if ($value2 == $value) { $default_temp = " selected"; } else { $default_temp = ""; }
01261 $categories_temp .= "<option value=\"$value2\"$default_temp>" . i18n($value2) . "</option>";
01262 }
01263 $categories_temp .= "</optgroup><optgroup label=\"" . i18n("Site-wide categories") . "\">";
01264 foreach($eventcategories as $key2 => $value2) {
01265 if (!isAllowed($_REQUEST["user_id"], "global_admin") && $key2 == 0) continue;
01266 if ($value2 == $value) { $default_temp = " selected"; } else { $default_temp = ""; }
01267 $categories_temp .= "<option value=\"$value2\"$default_temp>" . i18n($value2) . "</option>";
01268 }
01269 $data .= "<input style=\"float: right;\" type=\"submit\" name=\"event_remove_category[$key]\" value=\"-\" /></td>
01270 <td class=\"setup\"><select style=\"width: 100%\" name=\"event_category[$key]\">$categories_temp</optgroup></select></td>
01271 </tr>
01272 <tr class=\"setup\">
01273 <td class=\"setup\">";
01274 }
01275 }
01276
01277 $data .= " </td>
01278 <td class=\"setup\"><input type=\"submit\" name=\"event_add_category\" value=\"" . i18n("Add category") . "\" /></td>
01279 </tr>
01280 $formatting_toolbar
01281 <tr class=\"setup\"><td class=\"setup\" colspan=\"2\">
01282 <textarea rows=\"15\" cols=\"70\" style=\"width: 100%;\" id=\"edit\" name=\"event_description\">{$event->description}</textarea>
01283 </td></tr>
01284 <tr class=\"setup\">
01285 <td width=\"50%\" class=\"setup\"><input type=\"submit\" name=\"save_event\" value=\"" . i18n("Save event") . "\" /></td>
01286 <td width=\"50%\" class=\"setup\ wikirightalign\"><input type=\"reset\" value=\"" . i18n("Reset") . "\" /></td>
01287 </tr>
01288 </table></form>";
01289 } else {
01290 $tabwidget->addCommand(i18n("Add event"), i18n("Add a new event on this day"), globalIDtoURL("user/$viewUser/events", array( "event_selectedyear" => $calendar->year, "event_selectedmonth" => $calendar->month, "event_selectedday" => $calendar->selectedDay, "action" => "addEvent" ) ) );
01291 }
01292 if ($allowEdit) $tabwidget->addCommand(i18n("Options"), i18n("Edit your options"), globalIDtoURL("user/$viewUser/events", array( "event_selectedday" => $_REQUEST['event_selectedday'], "action" => "options" ) ) );
01293 }
01294 }
01295 return $data;
01296 }
01297
01298 function events_savecategories() {
01299 global $events_folder, $eventcategories;
01300 natcasesort($eventcategories);
01301 $file = array_export($eventcategories, "eventcategories");
01302 $filename = "$events_folder/categories.php";
01303 if (file_exists($filename)) unlink($filename);
01304 file_put_contents($filename, $file);
01305 }
01306
01307 function modulesetup_events() {
01308 global $setup_folder, $eventcategories, $language;
01309 switch ($_REQUEST["module_action"]) {
01310 case "category_add":
01311 if ($_REQUEST["new_category"] != "") {
01312 $eventcategories[] = str_replace(" ", "_", $_REQUEST["new_category"]);
01313 events_savecategories();
01314 header("Location: " . thisPageURL(true));
01315 } else {
01316 $data = "
01317 <form action=\"" . globalIDtoURL("setup/modulesetup/events/na/na/category_add") . "\" method=\"post\">
01318 <table class=\"setup\">
01319 <tr class=\"setup\">
01320 <td class=\"setup\" width=\"50%\">" . i18n("Category name") . ":
01321 </td>
01322 <td class=\"setup\" width=\"50%\"><input style=\"width: 100%;\" type=\"text\" name=\"new_category\" /></td>
01323 </tr>
01324 <tr class=\"setup\">
01325 <td class=\"setup\">
01326 <input type=\"submit\" value=\"" . i18n("Create category") . "\" />
01327 </td><td class=\"setup\" align=\"right\">
01328 <input type=\"reset\" value=\"" . i18n("Reset") . "\" />
01329 </td>
01330 </tr>
01331 </table>
01332 </form>";
01333 }
01334 break;
01335 case "category_remove":
01336 if ($_REQUEST["category_key"] == 0) {
01337 $data = "<p>" . i18n("You are not allowed to remove the system category as it is integral to the system. In fact there is not even any GUI to let you do this, so the only way to get this message is to attempt writing the URL yourself. Naughty!") . "</p>";
01338 } else {
01339 if ($_REQUEST["confirm_delete"] == "true") {
01340 $category_name = $eventcategories[$_REQUEST['category_key']];
01341 unset($eventcategories[$_REQUEST['category_key']]);
01342 events_savecategories();
01343 $data = "<p>" . i18n("The "##0##" was deleted, click here to return...", $category_name) . "</a></p>";
01344 header("Location: " . thisPageURL(true));
01345 } else {
01346 $data = "
01347 <p>" . i18n("You have requested to remove the category "##0##". Please confirm this choice below. Deleting the category WILL NOT delete posts already created using the category - the category will only not be available for new entries.", array($eventcategories[$_REQUEST["category_key"]])) . "</p>
01348 <div class=\"wikicenteralign\"><a class=\"command\" href=\"" . thisPageURL( false, true, array( "module_action" => "category_remove", "category_key" => $_REQUEST['category_key'], "confirm_delete" => "true" ) ) . "\">[" . i18n("Comfirm delete") . "]</a>
01349 <a class=\"command\" href=\"" . thisPageURL() . "\">[" . i18n("Abort") . "]</a></div>";
01350 }
01351 }
01352 break;
01353 case "category_edit":
01354 if ($_REQUEST["category_key"] == 0) {
01355 $data = "<p>" . i18n("You are not allowed to edit the system category as it is integral to the system. In fact there is not even any GUI to let you do this, so the only way to get this message is to attempt writing the URL yourself. Naughty!") . "</p>";
01356 } else {
01357 if ($_REQUEST["new_category"] != "") {
01358 $category_name = $eventcategories[$_REQUEST['category_key']];
01359 $eventcategories[$_REQUEST['category_key']] = str_replace(" ", "_", $_REQUEST["new_category"]);
01360 events_savecategories();
01361 $data = "<p>" . i18n("The "##0##" was changed successfully to "##1##", click here to return...", array($category_name, $_REQUEST["new_category"])) . "</a></p>";
01362 header("Location: " . thisPageURL(true));
01363 } else {
01364 $data = "
01365 <form action=\"" . thisPageURL( false, true, array( "module_action" => "category_edit", "category_key" => $_REQUEST["category_key"] ) ) . "\" method=\"post\">
01366 <table class=\"setup\">
01367 <tr class=\"setup\">
01368 <td class=\"setup\" width=\"50%\">" . i18n("Old category name") . ":
01369 </td>
01370 <td class=\"setup\" width=\"50%\">" . $eventcategories[$_REQUEST["category_key"]] . "</td>
01371 </tr>
01372 <tr class=\"setup\">
01373 <td class=\"setup\">" . i18n("New category name") . ":
01374 <small class=\"comment\">" . i18n("Please take note that the changes made to this category will not affect events already created") . "</small>
01375 </td>
01376 <td class=\"setup\"><input style=\"width: 100%;\" type=\"text\" name=\"new_category\" value=\"" . $eventcategories[$_REQUEST["category_key"]] . "\" /></td>
01377 </tr>
01378 <tr class=\"setup\">
01379 <td class=\"setup\">
01380 <input type=\"submit\" value=\"" . i18n("Save category") . "\" />
01381 </td><td class=\"setup\" align=\"right\">
01382 <input type=\"reset\" value=\"" . i18n("Reset") . "\" />
01383 </td>
01384 </tr>
01385 </table>
01386 </form>";
01387 }
01388 }
01389 break;
01390 case "help":
01391 $help_data = "<div style=\"border: 1px dashed grey;\">" . i18n("To create system entries, sign into a site administrator account and add a blog entry to the System category. Only administrators are allowed to use the System category. Use \\calendar(system_category) to show these entries.") . "</div>";
01392 $help_link = "<a class=\"command\" href=\"" . thisPageURL() . "\">[" . i18n("Hide help") . "]</a>";
01393 default:
01394 if (strlen($help_link) == 0) $help_link = "<a class=\"command\" href=\"" . thisPageURL( false, true, array("module_action" => "help") ) . "\">[" . i18n("Show help") . "]</a>";
01395 $data .= "
01396 <div align=\"right\">
01397 $help_link
01398 <a class=\"command\" href=\"" . globalIDtoURL("setup/modulesetup/events/na/na/category_add") . "\">[" . i18n("Add category") . "]</a>
01399 </div>
01400 $help_data
01401 <table class=\"setup\">
01402 <tr class=\"setup\">
01403 <th class=\"setup\" width=\"50%\">" . i18n("Category") . "</th>
01404 <th class=\"setup\" width=\"50%\">" . i18n("Functions") . "</th>
01405 </tr>";
01406 foreach($eventcategories as $key => $value) {
01407 $data .= "
01408 <tr class=\"setup\">
01409 <td class=\"setup\">" . i18n($value) . "</td>
01410 <td class=\"setup\" align=\"right\">";
01411 if ($key == 0) {
01412 $data .= "<small class=\"comment\">" . i18n("Edit and delete not allowed on system category.") . "</small>";
01413 } else {
01414 $data .= "
01415 <a class=\"command\" href=\"" . thisPageURL( false, true, array( "module_action" => "category_remove", "category_key" => $key ) ) . "\">[" . i18n("Delete") . "]</a>
01416 <a class=\"command\" href=\"" . thisPageURL( false, true, array( "module_action" => "category_edit", "category_key" => $key ) ) . "\">[" . i18n("Edit") . "]</a>
01417 ";
01418 }
01419 $data .= "
01420 </td>
01421 </tr>";
01422 }
01423 $data .= "
01424 </table>";
01425 }
01426 return $data;
01427 }
01428
01429 $filename = "$events_folder/categories.php";
01430 if (file_exists($filename)) {
01431 include($filename);
01432 } else {
01433 $eventcategories = array("system_category");
01434 events_savecategories();
01435 }
01436
01445 function globalIDThumbnail_events( $splitID )
01446 {
01447 global $module_folder;
01448 $data = array( "uri" => siteURL(true) . "$module_folder/events/thumb.png", "width" => 64, "height" => 64 );
01449 return $data;
01450 }
01451 ?>