[AG-TECH] venues server prototype update
S.Booth
spb at epcc.ed.ac.uk
Fri Mar 1 07:09:32 CST 2002
On Thu, 28 Feb 2002, Robert Olson wrote:
> Hi --
>
> this is for the folks that are experimenting with the new venues server. I
> just committed the fixes I put in place for SC Global; I don't have RPMs to
> release at this point, but this is the source tree that I typically used to
> generate the RPMs.
>
> ftp://ag-tech.mcs.anl.gov/pub/vv/ag-vv-1.0.01.tar.gz
Here are my automated booking changes again. This time as a patch
to ag-vv-1.0.01
Stephen
======================================================================
|epcc| Dr Stephen P Booth Project Manager |epcc|
|epcc| s.booth at epcc.ed.ac.uk Phone 0131 650 5746 |epcc|
======================================================================
-------------- next part --------------
diff -Naur ag-vv-1.0.01/config/DBSetup.pm ag-vv-1.0.01+booking/config/DBSetup.pm
--- ag-vv-1.0.01/config/DBSetup.pm Mon Aug 27 22:20:55 2001
+++ ag-vv-1.0.01+booking/config/DBSetup.pm Fri Mar 1 12:49:59 2002
@@ -237,7 +237,7 @@
# Grant permissions to the www user for the tables.
#
- while ($contents =~ /CREATE TABLE ([a-z0-9_]+)/g)
+ while ($contents =~ /CREATE TABLE ([a-z0-9_]+)/ig)
{
$dbh->do("grant select, insert, update on $1 to $db_www_user");
$dbh->do("grant all privileges on $1 to $db_user");
diff -Naur ag-vv-1.0.01/config/ag-tables.sql ag-vv-1.0.01+booking/config/ag-tables.sql
--- ag-vv-1.0.01/config/ag-tables.sql Thu Feb 28 22:17:40 2002
+++ ag-vv-1.0.01+booking/config/ag-tables.sql Fri Mar 1 10:34:44 2002
@@ -176,3 +176,14 @@
exit_id int4,
ordering int4,
foreign key (exit_id) references exit(id));
+
+
+CREATE TABLE booking(
+id serial NOT NULL PRIMARY KEY,
+description text,
+room_id int4 NOT NULL,
+user_id int4 NOT NULL,
+FOREIGN KEY (room_id) REFERENCES room (id),
+FOREIGN KEY (user_id) REFERENCES aguser (id),
+start_time timestamp NOT NULL,
+duration interval NOT NULL);
diff -Naur ag-vv-1.0.01/phpinc/sdp.inc ag-vv-1.0.01+booking/phpinc/sdp.inc
--- ag-vv-1.0.01/phpinc/sdp.inc Thu Feb 28 22:17:41 2002
+++ ag-vv-1.0.01+booking/phpinc/sdp.inc Fri Mar 1 12:55:13 2002
@@ -195,7 +195,6 @@
$node_name = $bridge_db->f("name");
$node_id = $bridge_db->f("node_id");
$script .= "doc.writeln('Node information: $node_name <p>');\n";
- }
#
# See if this room is bridging, and if this host has access.
@@ -217,7 +216,7 @@
}
}
$script .= "doc.writeln('</ul>');\n";
-
+ }
#
# Finalize the script
#
diff -Naur ag-vv-1.0.01/phplib/Calendar.php ag-vv-1.0.01+booking/phplib/Calendar.php
--- ag-vv-1.0.01/phplib/Calendar.php Thu Jan 1 00:00:00 1970
+++ ag-vv-1.0.01+booking/phplib/Calendar.php Fri Mar 1 10:35:48 2002
@@ -0,0 +1,411 @@
+<?
+
+// PHP Calendar Class Version 1.4 (5th March 2001)
+//
+// Copyright David Wilkinson 2000 - 2001. All Rights reserved.
+//
+// This software may be used, modified and distributed freely
+// providing this copyright notice remains intact at the head
+// of the file.
+//
+// This software is freeware. The author accepts no liability for
+// any loss or damages whatsoever incurred directly or indirectly
+// from the use of this script. The author of this software makes
+// no claims as to its fitness for any purpose whatsoever. If you
+// wish to use this software you should first satisfy yourself that
+// it meets your requirements.
+//
+// URL: http://www.cascade.org.uk/software/php/calendar/
+// Email: davidw at cascade.org.uk
+
+
+class Calendar
+{
+ /*
+ Constructor for the Calendar class
+ */
+ function Calendar()
+ {
+ }
+
+
+ /*
+ Get the array of strings used to label the days of the week. This array contains seven
+ elements, one for each day of the week. The first entry in this array represents Sunday.
+ */
+ function getDayNames()
+ {
+ return $this->dayNames;
+ }
+
+
+ /*
+ Set the array of strings used to label the days of the week. This array must contain seven
+ elements, one for each day of the week. The first entry in this array represents Sunday.
+ */
+ function setDayNames($names)
+ {
+ $this->dayNames = $names;
+ }
+
+ /*
+ Get the array of strings used to label the months of the year. This array contains twelve
+ elements, one for each month of the year. The first entry in this array represents January.
+ */
+ function getMonthNames()
+ {
+ return $this->monthNames;
+ }
+
+ /*
+ Set the array of strings used to label the months of the year. This array must contain twelve
+ elements, one for each month of the year. The first entry in this array represents January.
+ */
+ function setMonthNames($names)
+ {
+ $this->monthNames = $names;
+ }
+
+
+
+ /*
+ Gets the start day of the week. This is the day that appears in the first column
+ of the calendar. Sunday = 0.
+ */
+ function getStartDay()
+ {
+ return $this->startDay;
+ }
+
+ /*
+ Sets the start day of the week. This is the day that appears in the first column
+ of the calendar. Sunday = 0.
+ */
+ function setStartDay($day)
+ {
+ $this->startDay = $day;
+ }
+
+
+ /*
+ Gets the start month of the year. This is the month that appears first in the year
+ view. January = 1.
+ */
+ function getStartMonth()
+ {
+ return $this->startMonth;
+ }
+
+ /*
+ Sets the start month of the year. This is the month that appears first in the year
+ view. January = 1.
+ */
+ function setStartMonth($month)
+ {
+ $this->startMonth = $month;
+ }
+
+
+ /*
+ Return the URL to link to in order to display a calendar for a given month/year.
+ You must override this method if you want to activate the "forward" and "back"
+ feature of the calendar.
+
+ Note: If you return an empty string from this function, no navigation link will
+ be displayed. This is the default behaviour.
+
+ If the calendar is being displayed in "year" view, $month will be set to zero.
+ */
+ function getCalendarLink($month, $year)
+ {
+ return "";
+ }
+
+ /*
+ Return the URL to link to for a given date.
+ You must override this method if you want to activate the date linking
+ feature of the calendar.
+
+ Note: If you return an empty string from this function, no navigation link will
+ be displayed. This is the default behaviour.
+ */
+ function getDateLink($day, $month, $year)
+ {
+ return "";
+ }
+
+
+ /*
+ Return the HTML for the current month
+ */
+ function getCurrentMonthView()
+ {
+ $d = getdate(time());
+ return $this->getMonthView($d["mon"], $d["year"]);
+ }
+
+
+ /*
+ Return the HTML for the current year
+ */
+ function getCurrentYearView()
+ {
+ $d = getdate(time());
+ return $this->getYearView($d["year"]);
+ }
+
+
+ /*
+ Return the HTML for a specified month
+ */
+ function getMonthView($month, $year)
+ {
+ return $this->getMonthHTML($month, $year);
+ }
+
+
+ /*
+ Return the HTML for a specified year
+ */
+ function getYearView($year)
+ {
+ return $this->getYearHTML($year);
+ }
+
+
+
+ /********************************************************************************
+
+ The rest are private methods. No user-servicable parts inside.
+
+ You shouldn't need to call any of these functions directly.
+
+ *********************************************************************************/
+
+
+ /*
+ Calculate the number of days in a month, taking into account leap years.
+ */
+ function getDaysInMonth($month, $year)
+ {
+ if ($month < 1 || $month > 12)
+ {
+ return 0;
+ }
+
+ $d = $this->daysInMonth[$month - 1];
+
+ if ($month == 2)
+ {
+ // Check for leap year
+ // Forget the 4000 rule, I doubt I'll be around then...
+
+ if ($year%4 == 0)
+ {
+ if ($year%100 == 0)
+ {
+ if ($year%400 == 0)
+ {
+ $d = 29;
+ }
+ }
+ else
+ {
+ $d = 29;
+ }
+ }
+ }
+
+ return $d;
+ }
+
+
+ /*
+ Generate the HTML for a given month
+ */
+ function getMonthHTML($m, $y, $showYear = 1)
+ {
+ $s = "";
+
+ $a = $this->adjustDate($m, $y);
+ $month = $a[0];
+ $year = $a[1];
+
+ $daysInMonth = $this->getDaysInMonth($month, $year);
+ $date = getdate(mktime(12, 0, 0, $month, 1, $year));
+
+ $first = $date["wday"];
+ $monthName = $this->monthNames[$month - 1];
+
+ $prev = $this->adjustDate($month - 1, $year);
+ $next = $this->adjustDate($month + 1, $year);
+
+ if ($showYear == 1)
+ {
+ $prevMonth = $this->getCalendarLink($prev[0], $prev[1]);
+ $nextMonth = $this->getCalendarLink($next[0], $next[1]);
+ }
+ else
+ {
+ $prevMonth = "";
+ $nextMonth = "";
+ }
+
+ $header = $monthName . (($showYear > 0) ? " " . $year : "");
+
+ $s .= "<table class=\"calendar\">\n";
+ $s .= "<tr>\n";
+ $s .= "<td align=\"center\" valign=\"top\">" . (($prevMonth == "") ? " " : "<a href=\"$prevMonth\"><<</a>") . "</td>\n";
+ $s .= "<td align=\"center\" valign=\"top\" class=\"calendarHeader\" colspan=\"5\">$header</td>\n";
+ $s .= "<td align=\"center\" valign=\"top\">" . (($nextMonth == "") ? " " : "<a href=\"$nextMonth\">>></a>") . "</td>\n";
+ $s .= "</tr>\n";
+
+ $s .= "<tr>\n";
+ $s .= "<td align=\"center\" valign=\"top\" class=\"calendarHeader\">" . $this->dayNames[($this->startDay)%7] . "</td>\n";
+ $s .= "<td align=\"center\" valign=\"top\" class=\"calendarHeader\">" . $this->dayNames[($this->startDay+1)%7] . "</td>\n";
+ $s .= "<td align=\"center\" valign=\"top\" class=\"calendarHeader\">" . $this->dayNames[($this->startDay+2)%7] . "</td>\n";
+ $s .= "<td align=\"center\" valign=\"top\" class=\"calendarHeader\">" . $this->dayNames[($this->startDay+3)%7] . "</td>\n";
+ $s .= "<td align=\"center\" valign=\"top\" class=\"calendarHeader\">" . $this->dayNames[($this->startDay+4)%7] . "</td>\n";
+ $s .= "<td align=\"center\" valign=\"top\" class=\"calendarHeader\">" . $this->dayNames[($this->startDay+5)%7] . "</td>\n";
+ $s .= "<td align=\"center\" valign=\"top\" class=\"calendarHeader\">" . $this->dayNames[($this->startDay+6)%7] . "</td>\n";
+ $s .= "</tr>\n";
+
+ // We need to work out what date to start at so that the first appears in the correct column
+ $d = $this->startDay + 1 - $first;
+ while ($d > 1)
+ {
+ $d -= 7;
+ }
+
+ // Make sure we know when today is, so that we can use a different CSS style
+ $today = getdate(time());
+
+ while ($d <= $daysInMonth)
+ {
+ $s .= "<tr>\n";
+
+ for ($i = 0; $i < 7; $i++)
+ {
+ $class = ($year == $today["year"] && $month == $today["mon"] && $d == $today["mday"]) ? "calendarToday" : "calendar";
+ $s .= "<td class=\"$class\" align=\"right\" valign=\"top\">";
+ if ($d > 0 && $d <= $daysInMonth)
+ {
+ $link = $this->getDateLink($d, $month, $year);
+ $s .= (($link == "") ? $d : "<a href=\"$link\">$d</a>");
+ }
+ else
+ {
+ $s .= " ";
+ }
+ $s .= "</td>\n";
+ $d++;
+ }
+ $s .= "</tr>\n";
+ }
+
+ $s .= "</table>\n";
+
+ return $s;
+ }
+
+
+ /*
+ Generate the HTML for a given year
+ */
+ function getYearHTML($year)
+ {
+ $s = "";
+ $prev = $this->getCalendarLink(0, $year - 1);
+ $next = $this->getCalendarLink(0, $year + 1);
+
+ $s .= "<table class=\"calendar\" border=\"0\">\n";
+ $s .= "<tr>";
+ $s .= "<td align=\"center\" valign=\"top\" align=\"left\">" . (($prev == "") ? " " : "<a href=\"$prev\"><<</a>") . "</td>\n";
+ $s .= "<td class=\"calendarHeader\" valign=\"top\" align=\"center\">" . (($this->startMonth > 1) ? $year . " - " . ($year + 1) : $year) ."</td>\n";
+ $s .= "<td align=\"center\" valign=\"top\" align=\"right\">" . (($next == "") ? " " : "<a href=\"$next\">>></a>") . "</td>\n";
+ $s .= "</tr>\n";
+ $s .= "<tr>";
+ $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(0 + $this->startMonth, $year, 0) ."</td>\n";
+ $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(1 + $this->startMonth, $year, 0) ."</td>\n";
+ $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(2 + $this->startMonth, $year, 0) ."</td>\n";
+ $s .= "</tr>\n";
+ $s .= "<tr>\n";
+ $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(3 + $this->startMonth, $year, 0) ."</td>\n";
+ $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(4 + $this->startMonth, $year, 0) ."</td>\n";
+ $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(5 + $this->startMonth, $year, 0) ."</td>\n";
+ $s .= "</tr>\n";
+ $s .= "<tr>\n";
+ $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(6 + $this->startMonth, $year, 0) ."</td>\n";
+ $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(7 + $this->startMonth, $year, 0) ."</td>\n";
+ $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(8 + $this->startMonth, $year, 0) ."</td>\n";
+ $s .= "</tr>\n";
+ $s .= "<tr>\n";
+ $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(9 + $this->startMonth, $year, 0) ."</td>\n";
+ $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(10 + $this->startMonth, $year, 0) ."</td>\n";
+ $s .= "<td class=\"calendar\" valign=\"top\">" . $this->getMonthHTML(11 + $this->startMonth, $year, 0) ."</td>\n";
+ $s .= "</tr>\n";
+ $s .= "</table>\n";
+
+ return $s;
+ }
+
+ /*
+ Adjust dates to allow months > 12 and < 0. Just adjust the years appropriately.
+ e.g. Month 14 of the year 2001 is actually month 2 of year 2002.
+ */
+ function adjustDate($month, $year)
+ {
+ $a = array();
+ $a[0] = $month;
+ $a[1] = $year;
+
+ while ($a[0] > 12)
+ {
+ $a[0] -= 12;
+ $a[1]++;
+ }
+
+ while ($a[0] <= 0)
+ {
+ $a[0] += 12;
+ $a[1]--;
+ }
+
+ return $a;
+ }
+
+ /*
+ The start day of the week. This is the day that appears in the first column
+ of the calendar. Sunday = 0.
+ */
+ var $startDay = 0;
+
+ /*
+ The start month of the year. This is the month that appears in the first slot
+ of the calendar in the year view. January = 1.
+ */
+ var $startMonth = 1;
+
+ /*
+ The labels to display for the days of the week. The first entry in this array
+ represents Sunday.
+ */
+ var $dayNames = array("S", "M", "T", "W", "T", "F", "S");
+
+ /*
+ The labels to display for the months of the year. The first entry in this array
+ represents January.
+ */
+ var $monthNames = array("January", "February", "March", "April", "May", "June",
+ "July", "August", "September", "October", "November", "December");
+
+
+ /*
+ The number of days in each month. You're unlikely to want to change this...
+ The first entry in this array represents January.
+ */
+ var $daysInMonth = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
+
+}
+
+?>
diff -Naur ag-vv-1.0.01/phplib/Makefile.in ag-vv-1.0.01+booking/phplib/Makefile.in
--- ag-vv-1.0.01/phplib/Makefile.in Mon Aug 27 17:50:29 2001
+++ ag-vv-1.0.01+booking/phplib/Makefile.in Fri Mar 1 10:42:35 2002
@@ -40,6 +40,7 @@
ct_shm.inc \
ct_split_sql.inc \
ct_sql.inc \
+ Calendar.php \
db_msql.inc \
db_mssql.inc \
db_mysql.inc \
diff -Naur ag-vv-1.0.01/wwwroot/Makefile.in ag-vv-1.0.01+booking/wwwroot/Makefile.in
--- ag-vv-1.0.01/wwwroot/Makefile.in Sun Aug 26 15:28:09 2001
+++ ag-vv-1.0.01+booking/wwwroot/Makefile.in Fri Mar 1 10:44:03 2002
@@ -16,13 +16,16 @@
account_created.php \
ag.php \
ag-register-form.html \
+ cal.php \
create_room_action.php \
create-room-action.php \
create-room.html \
create_room.i.html \
create_room.php \
+ day.php \
db.php \
defauth.php \
+ delete-booking.php \
edit_room.i.html \
edit_room_not_allowed.i.html \
edit_room.php \
@@ -34,6 +37,7 @@
index.tmpl \
info.php \
list-rooms.php \
+ make-booking.php \
mud.php \
newindex.php \
new_user.php \
diff -Naur ag-vv-1.0.01/wwwroot/cal.php ag-vv-1.0.01+booking/wwwroot/cal.php
--- ag-vv-1.0.01/wwwroot/cal.php Thu Jan 1 00:00:00 1970
+++ ag-vv-1.0.01+booking/wwwroot/cal.php Fri Mar 1 10:35:23 2002
@@ -0,0 +1,40 @@
+<!DOCTYPE HTML SYSTEM "html.dtd">
+<HTML>
+<HEAD>
+<TITLE>Booking calendar</TITLE>
+</HEAD>
+<BODY>
+
+<?php
+require("Calendar.php");
+class MyCalendar extends Calendar
+{
+ function getDateLink($day, $month, $year)
+ {
+ return "day.php?year=$year&month=$month&day=$day";
+ }
+ function getCalendarLink($month, $year)
+ {
+ return "cal.php?year=$year&month=$month";
+ }
+
+}
+$cal = new MyCalendar;
+
+if( $month = "" ){
+ $month=0;
+}
+
+if( $year == "" ){
+ echo $cal->getCurrentYearView();
+}else{
+ if ( $month == 0 ){
+ echo $cal->getYearView($year);
+ }else{
+ echo $cal->getMonthView($year,$month);
+ }
+}
+?>
+
+</BODY>
+</HTML>
diff -Naur ag-vv-1.0.01/wwwroot/day.php ag-vv-1.0.01+booking/wwwroot/day.php
--- ag-vv-1.0.01/wwwroot/day.php Thu Jan 1 00:00:00 1970
+++ ag-vv-1.0.01+booking/wwwroot/day.php Fri Mar 1 10:35:23 2002
@@ -0,0 +1,120 @@
+<?php
+
+page_open(array("sess" => "AG_Session",
+ "auth" => "AG_Default_Auth"));
+$sess->register("room");
+$sess->register("onetime_password");
+
+require("ag_page.inc");
+
+
+ag_page_init();
+
+$uid = $auth->is_authenticated();
+
+ $d = getdate(time());
+ if( $year == "" ){
+ $year = $d["year"];
+ }
+ if( $month == "" ){
+ $month = $d["mon"];
+ }
+ if( $day == "" ){
+ $day = $d["mday"];
+ }
+
+?>
+
+<H1> Make booking for <?echo "$day $month $year" ?> </H1>
+
+<H2> Current bookings for this day </H2>
+
+<p>
+<table border="1">
+<tr><th>Room</th><th>Start time</th><th>Duration</th><th>Description</th><th>delete</th></tr>
+<?
+ $db->query(sprintf("select booking.id, user_id, name, start_time, duration, booking.description from booking, room where (room.id = room_id) and (( start_time >= '%s-%s-%s 00:00:00' and start_time < '%s-%s-%s 23:59:59' ) or ( start_time < '%s-%s-%s 00:00:00' and start_time + duration > '%s-%s-%s 00:00:00'))",$year,$month,$day,$year,$month,$day,$year,$month,$day,$year,$month,$day));
+ while( $db->next_record() ){
+ $id=$db->f("id");
+ $book_user=$db->f("user_id");
+ $name=$db->f("name");
+ $st=$db->f("start_time");
+ $dr=$db->f("duration");
+ $ds=$db->f("description");
+ echo sprintf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td>",$name,$st,$dr,$ds);
+ if( $uid == $book_user ){
+ echo sprintf("<td><a href=\"delete-booking.php?delete_id=%s\">Delete</a></tr>\n",$id);
+ }else{
+ echo "<td></td></tr>\n";
+ }
+ }
+
+?>
+</table>
+<form method="POST" action="make-booking.php">
+ <INPUT type="hidden" name="year" value="<? echo $year ?>">
+ <INPUT type="hidden" name="day" value="<? echo $day ?>">
+ <INPUT type="hidden" name="month" value="<? echo $month ?>">
+ <p> Room:
+ <SELECT name="room_id">
+<?
+ $db->query("select id, name from room");
+ while( $db->next_record() ){
+ $id=$db->f("id");
+ $name=$db->f("name");
+ echo sprintf("<option value=\"%s\">%s</option>\n",$id,$name);
+ }
+?>
+ </SELECT>
+ </p>
+ <p> Start time:
+ <SELECT name="start">
+ <option value="0:00">midnight</option>
+ <option value="1:00">1:00 AM</option>
+ <option value="2:00">2:00 AM</option>
+ <option value="3:00">3:00 AM</option>
+ <option value="4:00">4:00 AM</option>
+ <option value="5:00">5:00 AM</option>
+ <option value="6:00">6:00 AM</option>
+ <option value="7:00">7:00 AM</option>
+ <option value="8:00">8:00 AM</option>
+ <option value="9:00">9:00 AM</option>
+ <option value="10:00">10:00 AM</option>
+ <option value="11:00">11:00 AM</option>
+ <option value="12:00">noon</option>
+ <option value="13:00">1:00 PM</option>
+ <option value="14:00">2:00 PM</option>
+ <option value="15:00">3:00 PM</option>
+ <option value="16:00">4:00 PM</option>
+ <option value="17:00">5:00 PM</option>
+ <option value="18:00">6:00 PM</option>
+ <option value="19:00">7:00 PM</option>
+ <option value="20:00">8:00 PM</option>
+ <option value="21:00">9:00 PM</option>
+ <option value="22:00">10:00 PM</option>
+ <option value="23:00">11:00 PM</option>
+ </SELECT>
+ </p><p> Duration:
+ <SELECT name="duration">
+ <option selected value="1:00">1 hour</option>
+ <option value="2:00">2 hours</option>
+ <option value="3:00">3 hours</option>
+ <option value="4:00">4 hours</option>
+ <option value="5:00">5 hours</option>
+ <option value="6:00">6 hours</option>
+ <option value="7:00">7 hours</option>
+ <option value="8:00">8 hours</option>
+ <option value="9:00">9 hours</option>
+ <option value="10:00">10 hours</option>
+ <option value="11:00">11 hours</option>
+ <option value="12:00">12 hours</option>
+ </SELECT>
+ </p><p>Description:
+ <textarea rows="6" name="description" cols="46"></textarea></td>
+ </p><p>
+ <input type="submit" name="Book" value="book">
+ <input type="Reset" name="Reset" value="reset">
+ </P>
+</BODY>
+</HTML>
+
diff -Naur ag-vv-1.0.01/wwwroot/delete-booking.php ag-vv-1.0.01+booking/wwwroot/delete-booking.php
--- ag-vv-1.0.01/wwwroot/delete-booking.php Thu Jan 1 00:00:00 1970
+++ ag-vv-1.0.01+booking/wwwroot/delete-booking.php Fri Mar 1 10:35:23 2002
@@ -0,0 +1,35 @@
+<?php
+page_open(array("sess" => "AG_Session",
+ "auth" => "AG_Default_Auth"));
+$sess->register("room");
+$sess->register("onetime_password");
+
+require("ag_page.inc");
+require("ag_channels.inc");
+require("ag_config.inc");
+require("build.inc");
+
+ag_page_init();
+
+
+
+$db->query(sprintf("select id from aguser where login = '%s'",$auth->auth["uname"]));
+if (!$db->next_record())
+{
+ return sprintf("Could not get id for database entry.
+ Contact the Virtual Venues administrator.");
+}
+$user_id = $db->f("id");
+
+if ( $delete_id != "" ){
+
+
+ $q = sprintf("delete from booking where (id = %s and user_id = %s)",$delete_id , $user_id);
+# echo $q;
+ $r = $db->query($q);
+ print "$r\n";
+}
+print "<a href=\"/\">return to room</a>";
+page_close();
+
+?>
diff -Naur ag-vv-1.0.01/wwwroot/index.php ag-vv-1.0.01+booking/wwwroot/index.php
--- ag-vv-1.0.01/wwwroot/index.php Thu Feb 28 22:17:42 2002
+++ ag-vv-1.0.01+booking/wwwroot/index.php Fri Mar 1 12:56:31 2002
@@ -130,6 +130,7 @@
$admin_options .= "<tr><td><a href=\"edit_room.php\">Edit this room</a></td></tr>\n";
}
+
#
# If were a site admin, add the add-a-room link.
#
@@ -139,6 +140,16 @@
$admin_options .= "<tr><td><a href=\"create_room.php\">Create a new room</a></td></tr>\n";
}
+#
+# Room booking
+#
+if ($auth->is_authenticated())
+{
+ $admin_options .= "<tr><td><a href=\"cal.php\">Make a booking</a></td></tr>\n";
+}
+
+
+
if ($admin_options != "")
{
$admin_options = "<tr ><td><hr></td></tr>" . $admin_options;
@@ -195,18 +206,83 @@
$templ->set_var("channels", $launch);
+$exitform .= "";
+#
+# The bookings
+#
+
+# get currently active bookings and index array by room id
+
+$active_start=array();
+$active_duration=array();
+$active_desc=array();
+
+$q=sprintf("select room_id, start_time, duration, description from booking where ( start_time <= now() and start_time + duration > now())");
+$db->query($q);
+while ($db->next_record())
+{
+ $aroom = $db->f("room_id");
+ $active_start[$aroom] = $db->f("start_time");
+ $active_duration[$aroom] = $db->f("duration");
+ $active_desc[$aroom] = $db->f("description");
+}
+
+
+
+
+ $d = getdate(time());
+ $year = $d["year"];
+ $month = $d["mon"];
+ $day = $d["mday"];
+
+
+$db->query(sprintf("set DateStyle = 'Postgres'; select start_time, duration, description from booking where ( room_id = %d and start_time >= '%s-%s-%s 00:00:00' and start_time < '%s-%s-%s 23:59:59' ) or ( start_time < '%s-%s-%s 00:00:00' and start_time + duration > '%s-%s-%s 00:00:00')",$room,$year,$month,$day,$year,$month,$day,$year,$month,$day,$year,$month,$day));
+# $db->query("select start_time, duration, description from booking where room_id = $room");
+$done_header=0;
+while ($db->next_record())
+{
+
+ if( $done_header == 0 ){
+ $done_header=1;
+ $exitform .= "<p><b>Todays Bookings:</b><p>\n<table border=\"1\">\n";
+ $exitform .= "<tr><th>Start time</th><th>Duration</th><th>Description</th></tr>\n";
+ }
+ $start_time = $db->f("start_time");
+ $duration = $db->f("duration");
+ $desc = $db->f("description");
+ if( $start_time == $active_start[$room] ){
+ $exitform .= "<tr><td><b>$start_time</b></td><td><b>$duration</b></td><td><b>$desc</b></td></tr></b>\n";
+ }else{
+ $exitform .= "<tr><td>$start_time</td><td>$duration</td><td>$desc</td></tr>\n";
+ }
+}
+if( $done_header == 1){
+$exitform .= "</table>\n";
+}
+
#
# Now the exits
#
$exits = ag_get_room_exits($room);
-$exitform = "<p><b>Exits:</b><p>\n<ul>\n";
+$exitform .= "<p><b>Exits:</b><p>\n<ul>\n";
foreach ($exits as $exit)
{
$name = $exit[1];
$num= $exit[0];
$exitform .= "<li><a href=\"$PHP_SELF?moveto=$num\">$name</a>\n";
+ if( $active_desc[$num] != "" ){
+ $exitform .= "<p>Currently booked: <table border=\"1\">";
+ $exitform .= "<tr><th>Start time</th><th>Duration</th><th>Description</th></tr>\n<tr><td>";
+ $exitform .= $active_start[$num];
+ $exitform .= "</td><td>";
+ $exitform .= $active_duration[$num];
+ $exitform .= "</td><td>";
+ $exitform .= $active_desc[$num];
+ $exitform .= "</td></tr></table>";
+ }
+ $exitform .= "\n";
}
#
@@ -233,11 +309,11 @@
# Scheduler integration. Look for link to scheduler room.
#
-$db->query("select scheduler_venue_id from vv_scheduler_map where room_id = $room");
-if ($db->next_record())
-{
+#$db->query("select scheduler_venue_id from vv_scheduler_map where room_id = $room");
+#if ($db->next_record())
+#{
# $url =
-}
+#}
#
# Geek information.
diff -Naur ag-vv-1.0.01/wwwroot/make-booking.php ag-vv-1.0.01+booking/wwwroot/make-booking.php
--- ag-vv-1.0.01/wwwroot/make-booking.php Thu Jan 1 00:00:00 1970
+++ ag-vv-1.0.01+booking/wwwroot/make-booking.php Fri Mar 1 10:35:25 2002
@@ -0,0 +1,49 @@
+<?php
+page_open(array("sess" => "AG_Session",
+ "auth" => "AG_Default_Auth"));
+$sess->register("room");
+$sess->register("onetime_password");
+
+require("ag_page.inc");
+require("ag_channels.inc");
+require("ag_config.inc");
+require("build.inc");
+
+ag_page_init();
+
+
+#printf("<br>Your user id is %s<br>\n",$auth->auth["uname"] );
+
+$db->query(sprintf("select id from aguser where login = '%s'",$auth->auth["uname"]));
+if (!$db->next_record())
+{
+ return sprintf("Could not get id for database entry.
+ Contact the Virtual Venues administrator.");
+}
+$user_id = $db->f("id");
+
+$start_time=sprintf("%s-%s-%s %s:00",$year,$month,$day,$start);
+
+#printf("<br>Uid is [%d] start is [%s] interval is [%s] room is [%s]%s\n",$user_id,$start_time,$duration,$room,$room_id);
+$conflicts="";
+ $q = sprintf("select start_time, duration, description from booking where ( start_time >= timestamp '%s' and start_time < timestamp '%s' + interval '%s' ) or ( start_time < timestamp '%s' and start_time + duration > timestamp '%s')",$start_time,$start_time,$duration,$start_time,$start_time);
+# echo $q;
+ $db->query($q);
+ while( $db->next_record() ){
+ $st=$db->f("start_time");
+ $dr=$db->f("duration");
+ $ds=$db->f("description");
+ $conflicts .= sprintf("<LI> %s %s %s </LI>\n",$st,$dr,$ds);
+ }
+ if ( $conflicts == "" ){
+ $r = $db->query(sprintf("insert into booking(description, room_id, user_id, start_time, duration) values ('%s', %d, %d, timestamp '%s', interval '%s')",$description,$room_id,$user_id,$start_time,$duration));
+ $r = "booking OK";
+ }else{
+ $r = "This conflicts with the following existig bookings\n<UL>\n".$conflicts."</UL>";
+ }
+print "$r\n";
+print "<a href=\"/\">return to room</a>";
+page_close();
+
+?>
+
More information about the ag-tech
mailing list