[schoorbs commit] r713 - in trunk: . schoorbs-includes

0 views
Skip to first unread message

codesite...@google.com

unread,
Nov 4, 2008, 9:57:12 AM11/4/08
to schoor...@googlegroups.com
Author: xhochy
Date: Tue Nov 4 06:55:47 2008
New Revision: 713

Modified:
trunk/add-area.php
trunk/add-room.php
trunk/config.xml
trunk/day-view.php
trunk/del-area.php
trunk/del-room.php
trunk/edit-area.php
trunk/schoorbs-includes/global.web.php

Log:
Add a lot of comments to PHP files in the main directory

Modified: trunk/add-area.php
==============================================================================
--- trunk/add-area.php (original)
+++ trunk/add-area.php Tue Nov 4 06:55:47 2008
@@ -1,6 +1,8 @@
<?php
/**
- * Add a room
+ * Add an area.
+ *
+ * This just requests a suitable name for the area that shall be created.
*
* @author Uwe L. Korn <uw...@xhochy.org>
* @package Schoorbs
@@ -15,24 +17,21 @@
require_once 'schoorbs-includes/global.web.php';
/** The general functions */
require_once 'schoorbs-includes/global.functions.php';
-/** The modern ORM databse layer */
-require_once 'schoorbs-includes/database/schoorbsdb.class.php';
-/** The authetication wrappers */
-require_once 'schoorbs-includes/authentication/schoorbs_auth.php';
-/** The template system */
-require_once 'schoorbs-includes/schoorbstpl.class.php';

// Only administrators should be able to create rooms and areas
if (!getAuthorised(2)) {
showAccessDenied();
}

+// Require a name for this area to be set!
if (!isset($_REQUEST['area-name'])) {
SchoorbsTPL::error(Lang::_('No name for the area was provided!'));
exit();
-}
-
-if (empty($_REQUEST['area-name'])) {
+// An empty name for an area ist not allowed.
+//
+// An empty name could indicate a false submit too, just show this warning,
+// the user could easily restore its values with the browsers back button.
+} else if (empty($_REQUEST['area-name'])) {
SchoorbsTPL::error(Lang::_('No name for the area was provided!'));
exit();
}

Modified: trunk/add-room.php
==============================================================================
--- trunk/add-room.php (original)
+++ trunk/add-room.php Tue Nov 4 06:55:47 2008
@@ -1,6 +1,9 @@
<?php
/**
- * Add a room
+ * Add a room.
+ *
+ * This just wants a name, a description and the capacity of the new room.
An
+ * area to which this room should be added needs to submitted too.
*
* @author Uwe L. Korn <uw...@xhochy.org>
* @package Schoorbs
@@ -15,30 +18,29 @@
require_once 'schoorbs-includes/global.web.php';
/** The general functions */
require_once 'schoorbs-includes/global.functions.php';
-/** The modern ORM databse layer */
-require_once 'schoorbs-includes/database/schoorbsdb.class.php';
-/** The authetication wrappers */
-require_once 'schoorbs-includes/authentication/schoorbs_auth.php';
-/** The template system */
-require_once 'schoorbs-includes/schoorbstpl.class.php';

// Only administrators should be able to create rooms and areas
if (!getAuthorised(2)) {
showAccessDenied();
}

+// Require a valid area for this room
if (!isset($_REQUEST['area'])) {
SchoorbsTPL::error(Lang::_('No valid area(-id) was provided!'));
exit();
-}
-
-if (empty($_REQUEST['area'])) {
+// An empty name for a room ist not allowed.
+//
+// An empty name could indicate a false submit too, just show this warning,
+// the user could easily restore its values with the browsers back button.
+} else if (empty($_REQUEST['area'])) {
SchoorbsTPL::error(Lang::_('No valid area(-id) was provided!'));
exit();
}

+// Get the supplied area id as an integer
$nArea = intval($_REQUEST['area']);

+// Check if the suppilied area id was a valid number
if ($nArea != $_REQUEST['area']) {
SchoorbsTPL::error(Lang::_('No valid area(-id) was provided!'));
exit();
@@ -46,14 +48,19 @@

/** @todo report if an empty string was submitted **/
if (isset($_REQUEST['room-name']) && !empty($_REQUEST['room-name'])) {
- // Update! and redirect
+ // Get the selected area, we may get the area object already while we
+ // read in the area id but if we just display the creation form, we do
+ // not need this object.
$oArea = Area::getById($nArea);
+ // Create the room
Room::create($oArea, unslashes($_REQUEST['room-name']),
unslashes($_REQUEST['description']),
intval($_REQUEST['capacity'])
);
+ // Update! and redirect
header(sprintf('Location: administration.php?area=%d', $nArea));
} else {
+ // No values supplied, so:
// Edit!
SchoorbsTPL::populateVar('area', Area::getById($nArea));
SchoorbsTPL::renderPage('add-room');

Modified: trunk/config.xml
==============================================================================
--- trunk/config.xml (original)
+++ trunk/config.xml Tue Nov 4 06:55:47 2008
@@ -1,5 +1,23 @@
+<!--
+This is the main configuration file for Schoorbs 2.0, it replaces the old
+config.inc.php of Schoorbs 1.x/MRBS 1.x. Doing everything with XML Syntax,
+we could parse this file with other languages than PHP too which makes the
+development of helper tools for Schoorbs in an other language a lot more
easier.
+
+Since in the initial Schoorbs 2.0.0 there shouldn't be a change in the
database
+format in relation to Schoorbs 1.x/MRBS 1.x and its good and open
+standardization, we used XML. In future releases (Schoorbs 3+) the
configuration
+will likely move to the database, where all other data is stored. Moving
the
+configuration to the database would make the work in multisite support a
lot
+easier and backups more efficent, since there will only be one file which
+assigns a certain database connection to a certain URL.
+-->
<?xml version="1.0" encoding="UTF-8"?>
<config>
- <option key="theme-name" value="contented6" />
+ <!-- Your company name -->
<option key="company" value="XhochY" />
+
+ <!-- THEME OPTIONS -->
+ <!-- themes are stored at schoorbs-misc/themes/<name> -->
+ <option key="theme-name" value="contented6" />
</config>

Modified: trunk/day-view.php
==============================================================================
--- trunk/day-view.php (original)
+++ trunk/day-view.php Tue Nov 4 06:55:47 2008
@@ -15,10 +15,6 @@
require_once 'schoorbs-includes/global.web.php';
/** The general functions */
require_once 'schoorbs-includes/global.functions.php';
-/** The modern ORM databse layer */
-require_once 'schoorbs-includes/database/schoorbsdb.class.php';
-/** The template system */
-require_once 'schoorbs-includes/schoorbstpl.class.php';

/// Var Init ///

@@ -32,7 +28,8 @@
/** Get the room we should display */
$oRoom = Room::getById(input_Room());

-// Check if we have a room for this area
+// Check if we have a room for this area, if there's none, we will inform
the
+// user the selected are (or the default, if no area was selected) has no
rooms.
if ($oRoom === null) {
$oArea = Area::getById(input_Area());
SchoorbsTPL::error(Lang::_(sprintf('The area \'%s\' has no rooms.',
$oArea->getName())));
@@ -41,8 +38,10 @@

// Main //

+// The time where the first unit of the day starts.
$nStartTime = mktime($morningstarts, $morningstarts_minutes, 0, $month,
$day,
$year, is_dst($month, $day, $year, $morningstarts));
+// The time where the last unit of the day *ends*.
$nEndTime = mktime($eveningends, $eveningends_minutes, 0, $month, $day,
$year, is_dst($month, $day, $year, $eveningends));

@@ -79,27 +78,47 @@

$aEntries = Entry::getBetween($oRoom, $nTime, $nTime + $resolution - 1);

+ // If periods is enabled, so display the label of that period otherwise
+ // display the hour and minute when the certain unit starts. We always
+ // use here the twentyfour-hour-format to keep code small. The usage
+ // of PM/AM would lead to more code (we want to keep Schoorbs as small
+ // as possible) and wider columns in timetables. Since this is used as
+ // a standard index in the data provided to the theme, we need a
+ // strict convention how the indexes of the array over the units of one
+ // day is named.
+ //
+ // If you still want to have AM/PM times displayed in Schoorbs, you
+ // should take care of this in your themes. This internal code shouldn't
+ // be getting fatter through this optical thing.
if ($enable_periods) {
$sTime = $periods[$nUnit];
} else {
$sTime = date('H:i', $nTime);
}

+ // If there is a booking for this unit, so add it to the array of
+ // today's units and add it to the array of unique entries of this day.
if (count($aEntries) > 0) {
- //var_dump($aEntries);die();
- //entry per id laden
- $oEntry = $aEntries[0];
- $aEntry[$sTime] = $oEntry;
- $aUniqueEntry[$oEntry->getStartTime()] = $oEntry;
+ $aEntry[$sTime] = $aEntries[0];
+ $aUniqueEntry[$oEntry->getStartTime()] = $aEntries[0];
} else {
+ // If there is no entry, set this cell to -1
+ // This indicates that this unit is free and bookable. The theme
+ // should provide a link to add an entry for this unit.
$aEntry[$sTime] = -1;
}
+
+ // Provide the starting time of this unit, so that the template may
+ // construct a link to add a new entry starting exactly in this unit.
+ // (This is just a helping information during the theming process, it
+ // may not be needed).
$aEntryTime[$sTime] = $nTime;
}

// We want an array sorted chronologically
ksort($aUniqueEntry);

+// Pass the variables to the theming engine and display the day-view
template.
SchoorbsTPL::populateVar('uniqueEntries', $aUniqueEntry);
SchoorbsTPL::populateVar('entries', $aEntry);
SchoorbsTPL::populateVar('entryTime', $aEntryTime);

Modified: trunk/del-area.php
==============================================================================
--- trunk/del-area.php (original)
+++ trunk/del-area.php Tue Nov 4 06:55:47 2008
@@ -1,6 +1,7 @@
<?php
/**
- * Delete an area
+ * Delete an area out of the database. This page does not provide a
yes/no-check
+ * by itself, yes-no.php must be called as proxy in between to do this.
*
* @author Uwe L. Korn <uw...@xhochy.org>
* @package Schoorbs
@@ -15,30 +16,31 @@
require_once 'schoorbs-includes/global.web.php';
/** The general functions */
require_once 'schoorbs-includes/global.functions.php';
-/** The modern ORM databse layer */
-require_once 'schoorbs-includes/database/schoorbsdb.class.php';
-/** The authetication wrappers */
-require_once 'schoorbs-includes/authentication/schoorbs_auth.php';
-/** The template system */
-require_once 'schoorbs-includes/schoorbstpl.class.php';

// Only administrators should be able to create rooms and areas
if (!getAuthorised(2)) {
showAccessDenied();
}

+// Check if an area id was supplied, if there is none, we won't know which
area
+// we should delete, a default area selection is very dangerous.
if (!isset($_REQUEST['area'])) {
SchoorbsTPL::error(Lang::_('No valid area(-id) for deletion was
provided!'));
exit();
-}
-
-if (empty($_REQUEST['area'])) {
+// An emty area id might indicated a false call, if we would use intval()
on
+// this, it will return 0, so area 0 would be deleted what the user mostly
does
+// not want.
+} else if (empty($_REQUEST['area'])) {
SchoorbsTPL::error(Lang::_('No valid area(-id) for deletion was
provided!'));
exit();
}

+// Get the area id is as an integer.
$nArea = intval($_REQUEST['area']);

+// Check that the integer value of area equals the string value. This
checks
+// that we won't accept alphanumerical values, only clean numerical values
+// should pass.
if ($nArea != $_REQUEST['area']) {
SchoorbsTPL::error(Lang::_('No valid area(-id) for deletion was
provided!'));
exit();

Modified: trunk/del-room.php
==============================================================================
--- trunk/del-room.php (original)
+++ trunk/del-room.php Tue Nov 4 06:55:47 2008
@@ -1,6 +1,7 @@
<?php
/**
- * Delete a room
+ * Delete a room out of the database. This page does not provide a
yes/no-check
+ * by itself, yes-no.php must be called as proxy in between to do this.
*
* @author Uwe L. Korn <uw...@xhochy.org>
* @package Schoorbs
@@ -15,39 +16,40 @@
require_once 'schoorbs-includes/global.web.php';
/** The general functions */
require_once 'schoorbs-includes/global.functions.php';
-/** The modern ORM databse layer */
-require_once 'schoorbs-includes/database/schoorbsdb.class.php';
-/** The authetication wrappers */
-require_once 'schoorbs-includes/authentication/schoorbs_auth.php';
-/** The template system */
-require_once 'schoorbs-includes/schoorbstpl.class.php';

// Only administrators should be able to create rooms and areas
if (!getAuthorised(2)) {
showAccessDenied();
}

+// Check if a room id was supplied, if there is none, we won't know which
area
+// we should delete, a default room selection is very dangerous.
if (!isset($_REQUEST['room'])) {
SchoorbsTPL::error(Lang::_('No valid room(-id) for deletion was
provided!'));
exit();
-}
-
-if (empty($_REQUEST['room'])) {
+// An emty room id might indicated a false call, if we would use intval()
on
+// this, it will return 0, so area 0 would be deleted what the user mostly
does
+// not want.
+} else if (empty($_REQUEST['room'])) {
SchoorbsTPL::error(Lang::_('No valid room(-id) for deletion was
provided!'));
exit();
}

+// Get the room id is as an integer
$nRoom = intval($_REQUEST['room']);

+// Check that the integer value of room equals the string value. This
checks
+// that we won't accept alphanumerical values, only clean numerical values
+// should pass.
if ($nRoom != $_REQUEST['room']) {
SchoorbsTPL::error(Lang::_('No valid room(-id) for deletion was
provided!'));
exit();
}

-$oRoom = Room::getById($nRoom);
-$nArea = $oRoom->getArea()->getId();
-// There should be any instance of the room before its deletion
-$oRoom = null;
+// Get the area of the room which should be deleted, we do not store the
room
+// in a variable, so that it will be destructed as early as possible by the
+// garbage collector.
+$nArea = Room::getById($nRoom)->getArea()->getId();
// delete the room in the database
Room::delete($nRoom);
// redirect to adminisrat..php?area=<id>

Modified: trunk/edit-area.php
==============================================================================
--- trunk/edit-area.php (original)
+++ trunk/edit-area.php Tue Nov 4 06:55:47 2008
@@ -15,12 +15,6 @@
require_once 'schoorbs-includes/global.web.php';
/** The general functions */
require_once 'schoorbs-includes/global.functions.php';
-/** The modern ORM databse layer */
-require_once 'schoorbs-includes/database/schoorbsdb.class.php';
-/** The authetication wrappers */
-require_once 'schoorbs-includes/authentication/schoorbs_auth.php';
-/** The template system */
-require_once 'schoorbs-includes/schoorbstpl.class.php';

// Only administrators should be able to create rooms and areas
if (!getAuthorised(2)) {
@@ -30,19 +24,12 @@
if (!isset($_REQUEST['area'])) {
SchoorbsTPL::error(Lang::_('No valid area(-id) was provided!'));
exit();
-}
-
-if (empty($_REQUEST['area'])) {
+} else if (empty($_REQUEST['area'])) {
SchoorbsTPL::error(Lang::_('No valid area(-id) was provided!'));
exit();
}

$nArea = intval($_REQUEST['area']);
-
-if ($nArea != $_REQUEST['area']) {
- SchoorbsTPL::error(Lang::_('No valid area(-id) was provided!'));
- exit();
-}

/** @todo report if an empty string was submitted **/
if (isset($_REQUEST['area-name']) && !empty($_REQUEST['area-name'])) {

Modified: trunk/schoorbs-includes/global.web.php
==============================================================================
--- trunk/schoorbs-includes/global.web.php (original)
+++ trunk/schoorbs-includes/global.web.php Tue Nov 4 06:55:47 2008
@@ -7,16 +7,20 @@
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License
*/

-## Includes ##
+/// Includes ///

/** Smarty Template Engine */
require_once 'smarty.functions.php';
/** The input getting & validating functions */
require_once 'input.functions.php';
+/** The modern ORM databse layer */
+require_once 'schoorbs-includes/database/schoorbsdb.class.php';
+/** The template system */
+require_once 'schoorbs-includes/schoorbstpl.class.php';
/** The authetication wrappers */
require_once 'schoorbs-includes/authentication/schoorbs_auth.php';

-## Var Inits ##
+/// Var Inits ///

$pview = input_PView();

Reply all
Reply to author
Forward
0 new messages