Source for file viewbase.php
Documentation is available at viewbase.php
* Base class for viewing and editing booking information
* @author Stuart Prescott
* @copyright Copyright Stuart Prescott
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: viewbase.php,v 1.12 2007/02/05 23:36:50 themill Exp $
* path (bumblebee root)/inc/actions/viewbase.php
/** Load ancillary functions */
require_once 'inc/typeinfo.php';
require_once 'inc/bb/configreader.php';
/** date maniuplation objects */
require_once 'inc/date.php';
/** URL manipulation/generation functions */
require_once 'inc/menu.php';
require_once 'inc/actions/actionaction.php';
* Base class for booking and viewing bookings
/** @var integer instrument id number being viewed/booked etc */
/** @var array row of data representing the database entry for the instrument */
/** @var integer maximum number of days into the future that bookings can be made */
* @param BumblebeeAuth $auth Authorisation object
* @param array $pdata extra state data from the call path
* Set flags according to the permissions of the logged in user
$this->_isOwnBooking =
$this->auth->isMe($userid);
$this->_haveWriteAccess =
$this->_isOwnBooking
* Polite "go away" message if someone tries to delete a booking that they can't
$this->log('Action forbidden: '.
$msg);
* Calculate calendar offset in days
* calculates the number of days between the current date and the last date that was selected
* by the user (in making a booking etc)
* @return string URL string for inclusion in href (examples: '28' '-14')
if (isset
($this->PD['isodate'])) {
return floor($then->dsDaysBetween($now));
} elseif (isset
($this->PD['startticks'])) {
return $then->dateString();
} elseif (isset
($this->PD['bookwhen-date'])) {
return floor($then->dsDaysBetween($now));
* Makes a link back to the current calendar
* @return string URL string for link back to calendar view
return '<br /><br /><a href="'.
makeURL('calendar', array('instrid'=>
$instrument, 'caloffset'=>
$this->_offset()))
.
'">'.
T_('Return to calendar view') .
'</a>';
* Display a heading on the page with the instrument name and location
$name =
T_('Combined instrument display');
$names[] =
sprintf(T_('%s (%s)'), $this->row[$i]['longname'], $this->row[$i]['location']);
$location =
join(', ', $names);
$name =
$this->row['longname'];
$location =
$this->row['location'];
$t =
'<h2 class="instrumentname">'
.
'<p class="instrumentlocation">'
* Display a footer for the page with the instrument comments and who looks after the instrument
if ($this->row['supervisors']) {
$t .=
'<h3>'.
T_('Instrument supervisors').
'</h3>';
foreach(preg_split('/,\s*/', $this->row['supervisors']) as $username) {
$t .=
'<li><a href="mailto:'.
xssqw($user['email']) .
'">'.
xssqw($user['name']) .
'</a></li>';
* Display the instrument comment in either header or footer as configured
* @param boolean $footer called in the footer
* @returns string header/footer to display for notes section
$notesbottom =
$conf->value('calendar', 'notesbottom', true);
if ($notesbottom ==
$footer &&
$this->row['calendarcomment']) {
$t =
'<div class="calendarcomment">'
* Check if a date is within the permitted booking period for this user on this instrument.
* @param SimpleDate date to be checked
* @returns 1 if date is within permitted calendar period, returns 0 or number of days (negative) that the booking is beyond the end of the calendar
$totaloffset =
$date->dsDaysBetween($today);
#printf ('today = %s, checkDate = %s, ', $today->dateTimeString(), $date->dateTimeString());
$offset = floor($this->maxFutureDays -
$totaloffset +
$calcOffset);
function MakeBookingHref($date) {
return makeURL('book', array('instrid'=>$this->instrument));
return makeURL('bookcontact', array('instrid'=>$this->instrument));
function MakeBookingPermitted($date) {
?
BBROLE_MAKE_BOOKINGS_FUTURE
function ViewCalendarPermitted($offset) {
if (type_is_a($offset, 'SimpleDate')) {
$date = new SimpleDate(time());
#echo "Checking calendar for ". $date->dateTimeString();
?
BBROLE_VIEW_CALENDAR_FUTURE
function _loadMultiInstrument() {
$this->row =
quickSQLSelect('instruments', 'id', $this->instrument);
if (! isset
($this->row['id'])) {
$this->row[$i] =
quickSQLSelect('instruments', 'id', $i);
if (! isset
($this->row['id'])) {
function _Forbidden($message=null) {
$message = T_('Sorry, you are not permitted to do that with this instrument.');
STATUS_FORBIDDEN =>
$message
function _UnknownInstrument($message=null) {
$message = T_('Sorry, that instrument does not exist.');
STATUS_FORBIDDEN =>
$message
function _UnknownBooking($message=null) {
$message = T_('Sorry, that booking does not exist.');
STATUS_FORBIDDEN =>
$message
Documentation generated on Tue, 06 Mar 2007 10:02:11 +0000 by phpDocumentor 1.3.0