[schoorbs commit] r716 - trunk

0 views
Skip to first unread message

codesite...@google.com

unread,
Nov 4, 2008, 10:14:16 AM11/4/08
to schoor...@googlegroups.com
Author: xhochy
Date: Tue Nov 4 07:13:49 2008
New Revision: 716

Modified:
trunk/edit-room.php

Log:
Added some comments to edit-room

Modified: trunk/edit-room.php
==============================================================================
--- trunk/edit-room.php (original)
+++ trunk/edit-room.php Tue Nov 4 07:13:49 2008
@@ -1,6 +1,6 @@
<?php
/**
- * Edit a room
+ * Edit a room, the name, the capacity and its description can be edited.
*
* @author Uwe L. Korn <uw...@xhochy.org>
* @package Schoorbs
@@ -15,42 +15,41 @@
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';
+
+/// Main ///

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

+// Check if an room id was supplied, if there is none, we won't know which
room
+// we want to edit, a default room selecton might be nice, but if the user
+// doesn't directly knows that he is editing a random room, he might
change the
+// false room.
if (!isset($_REQUEST['room'])) {
SchoorbsTPL::error(Lang::_('No valid room(-id) was provided!'));
exit();
-}
-
-if (empty($_REQUEST['room'])) {
+// An emty room id might indicate a false call, if we would use intval() on
+// this, it will return 0, so room 0 would be edited which might be
confusing.
+} else if (empty($_REQUEST['room'])) {
SchoorbsTPL::error(Lang::_('No valid room(-id) was provided!'));
exit();
}

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

-if ($nRoom != $_REQUEST['room']) {
- SchoorbsTPL::error(Lang::_('No valid room(-id) was provided!'));
- exit();
-}
-
/** @todo report if an empty string was submitted **/
if (isset($_REQUEST['room-name']) && !empty($_REQUEST['room-name'])) {
- // Update! and redirect
+ // Get the room out of the database
$oRoom = Room::getById($nRoom);
+ // Set the new values
$oRoom->setName(unslashes($_REQUEST['room-name']));
$oRoom->setCapacity(intval($_REQUEST['capacity']));
$oRoom->setDescription(unslashes($_REQUEST['description']));
+ // Get the id of the area of this room to know where we will redirect
+ // the user after he finished editing the room.
$nArea = $oRoom->getArea()->getId();
// destruct to save it
$oRoom = null;

Reply all
Reply to author
Forward
0 new messages