summaryrefslogtreecommitdiff
path: root/forum/utils/events.php
diff options
context:
space:
mode:
authordeva <deva>2011-11-01 09:32:21 +0000
committerdeva <deva>2011-11-01 09:32:21 +0000
commit42c62cb041a2b2b95c9cda0c20fcf70334fd244c (patch)
tree38371eb37ff7348585ee84438b326c25055e2cbe /forum/utils/events.php
parent208e3b642149a9ac701a43397d31990f9b27ca79 (diff)
Rewl og krat... needs cleaning up - after port to GIT.origin
Diffstat (limited to 'forum/utils/events.php')
-rw-r--r--forum/utils/events.php79
1 files changed, 63 insertions, 16 deletions
diff --git a/forum/utils/events.php b/forum/utils/events.php
index 9f521b8..2f46f14 100644
--- a/forum/utils/events.php
+++ b/forum/utils/events.php
@@ -8,31 +8,62 @@ class Event {
public $starttime;
public $duration;
public $description;
+ public $concert;
public $user;
public function show()
{
- global $users, $date, $client_is_mobile_device;
+ global $users, $GLOBALS, $client_is_mobile_device;
- $user = $users->getUser($this->user);
+ $str = "";
- echo " <div class=\"event\">\n";
- echo " <div class=\"title\">". $this->title . "\n";
- // echo " <a class=\"button\" href=\"\">Edit</a>\n";
- echo " </div>\n";
- echo " <div class=\"time\">" . date("G:i", $this->starttime) . " - " .
- date("G:i", $this->starttime + $this->duration) . "</div>\n";
+ $user = $users->getUser($this->user);
+ $str .= " <div class=\"event";
+ if($this->concert == "true") $str .= " concert";
+ $str .= "\">\n";
+ $str .= " <div class=\"title\">". $this->title . "\n";
+ // $str .= " <a class=\"button\" href=\"\">Edit</a>\n";
+ $str .= " </div>\n";
+ $str .= " <div class=\"time\">" . date("G:i", $this->starttime) .
+ " - " . date("G:i", $this->starttime + $this->duration) . "</div>\n";
if(!$client_is_mobile_device) {
- echo " <div class=\"description\">". $this->description . "</div>\n";
+ $str .= " <div class=\"description\">". $this->description .
+ "</div>\n";
} else {
- echo " <div class=\"mobiledescription\">". $this->description . "</div>\n";
+ $str .= " <div class=\"mobiledescription\">" .
+ $this->description . "</div>\n";
}
- echo " <div class=\"user\">By: ".$user->name . "</div>\n";
- // echo " <a href=\"?mode=calendar&amp;date=" . $date . "&amp;eid=" . $this->eid . "&amp;action=edit\">Edit</a>";
- echo " </div>\n";
+ $str .= " <div class=\"user\">By: ".$user->name . "</div>\n";
+
+ $datestr = "";
+ if(isset($GLOBALS['date'])) $datestr = "&amp;date=". $GLOBALS['date'];
+
+ $str .= " <a href=\"?mode=calendar" . $datestr .
+ "&amp;eid=" . $this->eid . "&amp;action=delete\">Delete</a>";
+ $str .= " </div>\n";
+
+ return $str;
+ }
+
+ public function show_simple()
+ {
+ global $users, $GLOBALS, $client_is_mobile_device;
+
+ $str = "";
+
+ $str .= " <div class=\"event_simple\">\n";
+ $str .= " <span class=\"date\">" . date("D d M Y", $this->starttime) . "</span>\n";
+ $str .= " <span class=\"title\">". $this->title . "\n";
+ $str .= " </span>\n";
+ $str .= " <span class=\"time\">" . date("G:i", $this->starttime) .
+ " - " . date("G:i", $this->starttime + $this->duration) . "</span>\n";
+ $str .= " </div>\n";
+
+ return $str;
}
- public function Event($eid, $title, $starttime, $duration, $description, $user)
+ public function Event($eid, $title, $concert, $starttime, $duration,
+ $description, $user)
{
$this->eid = $eid;
$this->title = $title;
@@ -40,6 +71,7 @@ class Event {
$this->duration = $duration;
$this->description = $description;
$this->user = $user;
+ $this->concert = $concert;
}
}
@@ -53,6 +85,13 @@ class Events {
$this->events[$key] = $event;
}
+ public function delete($eid) {
+ if(isset($this->events[$eid])) {
+ unset($this->events[$eid]);
+ echo "DELETE";
+ }
+ }
+
public function write()
{
$fp = fopen($this->file, "w");
@@ -68,6 +107,11 @@ class Events {
htmlspecialchars($event->eid, ENT_QUOTES, "UTF-8") . "\"\n");
fwrite($fp, " title=\"" .
htmlspecialchars($event->title, ENT_QUOTES, "UTF-8") . "\"\n");
+
+ if($event->concert == "true") $concert = "true";
+ else $concert = "false";
+ fwrite($fp, " concert=\"" . $concert . "\"\n");
+
fwrite($fp, " starttime=\"" .
htmlspecialchars($event->starttime, ENT_QUOTES, "UTF-8") . "\"\n");
fwrite($fp, " duration=\"" .
@@ -90,7 +134,7 @@ class Events {
unset($this->members[$id]);
// $this->write();
} else {
- echo "<p>ERROR: User! <em>".$id."</em> does not exist!</p>\n";
+ $str .= "<p>ERROR: User! <em>".$id."</em> does not exist!</p>\n";
return false;
}
return true;
@@ -99,10 +143,12 @@ class Events {
public function show($starttime, $endtime)
{
+ $str = "";
foreach($this->events as $event) {
if($event->starttime > $starttime && $event->starttime < $endtime)
- $event->show();
+ $str .= $event->show();
}
+ return $str;
}
public function getEvent($eid)
@@ -121,6 +167,7 @@ class Events {
foreach ($events as $e) {
$event = new Event($e->getAttribute('eid'),
$e->getAttribute('title'),
+ $e->getAttribute('concert') == "true",
$e->getAttribute('starttime'),
$e->getAttribute('duration'),
$e->getAttribute('description'),