Revision: 1231
http://mrbs.svn.sourceforge.net/mrbs/?rev=1231&view=rev
Author: cimorrison
Date: 2009-10-27 16:52:17 +0000 (Tue, 27 Oct 2009)
Log Message:
-----------
Added a sort key for rooms, so that rooms can be sorted in an order defined by
the administrator rather than alphabetically. By default the sort key is the
same as the room name and rooms will be sorted alphabetically as before. The
sort order applies whenever rooms are listed, eg in the main day view and in
drop-down lists.
Modified Paths:
--------------
mrbs/trunk/tables.my.sql
mrbs/trunk/tables.pg.73and_above.sql
mrbs/trunk/tables.pg.sql
mrbs/trunk/web/add.php
mrbs/trunk/web/admin.php
mrbs/trunk/web/day.php
mrbs/trunk/web/dbsys.inc
mrbs/trunk/web/edit_area_room.php
mrbs/trunk/web/edit_entry.php
mrbs/trunk/web/functions.inc
mrbs/trunk/web/lang.en
mrbs/trunk/web/month.php
mrbs/trunk/web/report.php
mrbs/trunk/web/week.php
Added Paths:
-----------
mrbs/trunk/web/upgrade/8/
mrbs/trunk/web/upgrade/8/mysql.sql
mrbs/trunk/web/upgrade/8/pgsql.sql
mrbs/trunk/web/upgrade/8/post.inc
Modified: mrbs/trunk/tables.my.sql
===================================================================
--- mrbs/trunk/tables.my.sql 2009-10-22 16:21:18 UTC (rev 1230)
+++ mrbs/trunk/tables.my.sql 2009-10-27 16:52:17 UTC (rev 1231)
@@ -36,11 +36,13 @@
id int NOT NULL auto_increment,
area_id int DEFAULT '0' NOT NULL,
room_name varchar(25) DEFAULT '' NOT NULL,
+ sort_key varchar(25) DEFAULT '' NOT NULL,
description varchar(60),
capacity int DEFAULT '0' NOT NULL,
room_admin_email text,
- PRIMARY KEY (id)
+ PRIMARY KEY (id),
+ KEY idxSortKey (sort_key)
);
CREATE TABLE mrbs_entry
@@ -105,6 +107,6 @@
);
INSERT INTO mrbs_variables (variable_name, variable_content)
- VALUES ( 'db_version', '7');
+ VALUES ( 'db_version', '8');
INSERT INTO mrbs_variables (variable_name, variable_content)
VALUES ( 'local_db_version', '1');
Modified: mrbs/trunk/tables.pg.73and_above.sql
===================================================================
--- mrbs/trunk/tables.pg.73and_above.sql 2009-10-22 16:21:18 UTC (rev
1230)
+++ mrbs/trunk/tables.pg.73and_above.sql 2009-10-27 16:52:17 UTC (rev
1231)
@@ -50,10 +50,12 @@
id serial primary key,
area_id int DEFAULT 0 NOT NULL,
room_name varchar(25) NOT NULL,
+ sort_key varchar(25) NOT NULL,
description varchar(60),
capacity int DEFAULT 0 NOT NULL,
room_admin_email text
);
+create index idxSortKey on mrbs_room(sort_key);
CREATE TABLE mrbs_entry
(
@@ -109,6 +111,6 @@
);
INSERT INTO mrbs_variables (variable_name, variable_content)
- VALUES ('db_version', '7');
+ VALUES ('db_version', '8');
INSERT INTO mrbs_variables (variable_name, variable_content)
VALUES ('local_db_version', '1');
Modified: mrbs/trunk/tables.pg.sql
===================================================================
--- mrbs/trunk/tables.pg.sql 2009-10-22 16:21:18 UTC (rev 1230)
+++ mrbs/trunk/tables.pg.sql 2009-10-27 16:52:17 UTC (rev 1231)
@@ -38,10 +38,12 @@
id serial primary key,
area_id int DEFAULT 0 NOT NULL,
room_name varchar(25) DEFAULT '' NOT NULL,
+ sort_key varchar(25) DEFAULT '' NOT NULL,
description varchar(60),
capacity int DEFAULT 0 NOT NULL,
room_admin_email text
);
+create index idxSortKey on mrbs_room(sort_key);
CREATE TABLE mrbs_entry
(
Modified: mrbs/trunk/web/add.php
===================================================================
--- mrbs/trunk/web/add.php 2009-10-22 16:21:18 UTC (rev 1230)
+++ mrbs/trunk/web/add.php 2009-10-27 16:52:17 UTC (rev 1231)
@@ -88,8 +88,8 @@
// If so, insert the room into the datrabase
else
{
- $sql = "insert into $tbl_room (room_name, area_id, description, capacity)
- values ('$room_name_q',$area, '$description_q',$capacity)";
+ $sql = "INSERT INTO $tbl_room (room_name, sort_key, area_id, description,
capacity)
+ VALUES ('$room_name_q', '$room_name_q', $area,
'$description_q',$capacity)";
if (sql_command($sql) < 0)
{
fatal_error(1, sql_error());
Modified: mrbs/trunk/web/admin.php
===================================================================
--- mrbs/trunk/web/admin.php 2009-10-22 16:21:18 UTC (rev 1230)
+++ mrbs/trunk/web/admin.php 2009-10-27 16:52:17 UTC (rev 1231)
@@ -105,7 +105,7 @@
// This one has the rooms
if(isset($area))
{
- $res = sql_query("select id, room_name, description, capacity from $tbl_room
where area_id=$area order by room_name");
+ $res = sql_query("select id, room_name, description, capacity from $tbl_room
where area_id=$area order by sort_key");
if (! $res)
{
fatal_error(0, sql_error());
Modified: mrbs/trunk/web/day.php
===================================================================
--- mrbs/trunk/web/day.php 2009-10-22 16:21:18 UTC (rev 1230)
+++ mrbs/trunk/web/day.php 2009-10-27 16:52:17 UTC (rev 1231)
@@ -238,7 +238,7 @@
// pull the data from the db and store it. Convienently we can print the room
// headings and capacities at the same time
-$sql = "SELECT room_name, capacity, id, description FROM $tbl_room WHERE
area_id=$area ORDER BY room_name";
+$sql = "SELECT room_name, capacity, id, description FROM $tbl_room WHERE
area_id=$area ORDER BY sort_key";
$res = sql_query($sql);
Modified: mrbs/trunk/web/dbsys.inc
===================================================================
--- mrbs/trunk/web/dbsys.inc 2009-10-22 16:21:18 UTC (rev 1230)
+++ mrbs/trunk/web/dbsys.inc 2009-10-27 16:52:17 UTC (rev 1231)
@@ -15,7 +15,7 @@
$tbl_variables = $db_tbl_prefix . "variables";
-$db_schema_version = 7;
+$db_schema_version = 8;
$local_db_schema_version = 1;
Modified: mrbs/trunk/web/edit_area_room.php
===================================================================
--- mrbs/trunk/web/edit_area_room.php 2009-10-22 16:21:18 UTC (rev 1230)
+++ mrbs/trunk/web/edit_area_room.php 2009-10-27 16:52:17 UTC (rev 1231)
@@ -14,6 +14,7 @@
$old_area = get_form_var ('old_area', 'int');
$room = get_form_var('room', 'int');
$room_name = get_form_var('room_name', 'string');
+$sort_key = get_form_var('sort_key', 'string');
$old_room_name = get_form_var('old_room_name', 'string');
$area_name = get_form_var('area_name', 'string');
$description = get_form_var('description', 'string');
@@ -142,6 +143,7 @@
else
{
$sql = "UPDATE $tbl_room SET room_name='" . addslashes($room_name)
+ . "', sort_key='" . addslashes($sort_key)
. "', description='" . addslashes($description)
. "', capacity=$capacity, area_id=$new_area, room_admin_email='"
. addslashes($room_admin_email) . "' WHERE id=$room";
@@ -219,6 +221,13 @@
</div>
<div>
+ <?php
+ echo "<label for=\"sort_key\" title=\"" . get_vocab("sort_key_note") .
"\">" . get_vocab("sort_key") . ":</label>\n";
+ ?>
+ <input type="text" id="sort_key" name="sort_key" value="<?php echo
htmlspecialchars($row["sort_key"]); ?>">
+ </div>
+
+ <div>
<label for="description"><?php echo get_vocab("description") ?>:</label>
<input type="text" id="description" name="description" value="<?php echo
htmlspecialchars($row["description"]); ?>">
</div>
Modified: mrbs/trunk/web/edit_entry.php
===================================================================
--- mrbs/trunk/web/edit_entry.php 2009-10-22 16:21:18 UTC (rev 1230)
+++ mrbs/trunk/web/edit_entry.php 2009-10-27 16:52:17 UTC (rev 1231)
@@ -615,7 +615,7 @@
{
print " case \"".$row['id']."\":\n";
// get rooms for this area
- $sql2 = "select id, room_name from $tbl_room where
area_id='".$row['id']."' order by room_name";
+ $sql2 = "select id, room_name from $tbl_room where
area_id='".$row['id']."' order by sort_key";
$res2 = sql_query($sql2);
if ($res2)
{
@@ -681,7 +681,7 @@
<select id="rooms" name="rooms[]" multiple="multiple" size="5">
<?php
// select the rooms in the area determined above
- $sql = "select id, room_name from $tbl_room where area_id=$area_id
order by room_name";
+ $sql = "select id, room_name from $tbl_room where area_id=$area_id
order by sort_key";
$res = sql_query($sql);
if ($res)
{
Modified: mrbs/trunk/web/functions.inc
===================================================================
--- mrbs/trunk/web/functions.inc 2009-10-22 16:21:18 UTC (rev 1230)
+++ mrbs/trunk/web/functions.inc 2009-10-27 16:52:17 UTC (rev 1231)
@@ -263,12 +263,12 @@
}
// Return a default room given a valid area; used if no room is already known.
-// This returns the first room in alphbetic order in the database.
+// This returns the first room in sort_key order in the database.
// This could be changed to implement something like per-user defaults.
function get_default_room($area)
{
global $tbl_room;
- $room = sql_query1("SELECT id FROM $tbl_room WHERE area_id=$area ORDER BY
room_name LIMIT 1");
+ $room = sql_query1("SELECT id FROM $tbl_room WHERE area_id=$area ORDER BY
sort_key LIMIT 1");
return ($room < 0 ? 0 : $room);
}
@@ -584,7 +584,7 @@
<div>
<select name=\"room\"
onchange=\"document.forms['roomChangeForm'].submit()\">";
- $sql = "select id, room_name from $tbl_room where area_id=$area order by
room_name";
+ $sql = "select id, room_name from $tbl_room where area_id=$area order by
sort_key";
$res = sql_query($sql);
if ($res)
{
Modified: mrbs/trunk/web/lang.en
===================================================================
--- mrbs/trunk/web/lang.en 2009-10-22 16:21:18 UTC (rev 1230)
+++ mrbs/trunk/web/lang.en 2009-10-27 16:52:17 UTC (rev 1231)
@@ -282,6 +282,8 @@
$vocab["treat_respect"] = "Respect the privacy setting of the
booking";
$vocab["treat_private"] = "Treat all bookings as private, ignoring
their privacy settings";
$vocab["treat_public"] = "Treat all bookings as public, ignoring
their privacy settings";
+$vocab["sort_key"] = "Sort key";
+$vocab["sort_key_note"] = "This is the key used for ordering rooms";
// Used in edit_users.php
$vocab["name_empty"] = "You must enter a name.";
Modified: mrbs/trunk/web/month.php
===================================================================
--- mrbs/trunk/web/month.php 2009-10-22 16:21:18 UTC (rev 1230)
+++ mrbs/trunk/web/month.php 2009-10-27 16:52:17 UTC (rev 1231)
@@ -174,7 +174,7 @@
else
{
$sql = "select id, room_name from $tbl_room
- where area_id=$area order by room_name";
+ where area_id=$area order by sort_key";
$res = sql_query($sql);
if ($res)
{
Modified: mrbs/trunk/web/report.php
===================================================================
--- mrbs/trunk/web/report.php 2009-10-22 16:21:18 UTC (rev 1230)
+++ mrbs/trunk/web/report.php 2009-10-27 16:52:17 UTC (rev 1231)
@@ -911,12 +911,12 @@
if ( $sortby == "r" )
{
// Order by Area, Room, Start date/time
- $sql .= " ORDER BY area_name, room_name, start_time";
+ $sql .= " ORDER BY area_name, sort_key, start_time";
}
else
{
// Order by Start date/time, Area, Room
- $sql .= " ORDER BY start_time, area_name, room_name";
+ $sql .= " ORDER BY start_time, area_name, sort_key";
}
// echo "<p>DEBUG: SQL: <tt> $sql </tt></p>\n";
Added: mrbs/trunk/web/upgrade/8/mysql.sql
===================================================================
--- mrbs/trunk/web/upgrade/8/mysql.sql (rev 0)
+++ mrbs/trunk/web/upgrade/8/mysql.sql 2009-10-27 16:52:17 UTC (rev 1231)
@@ -0,0 +1,5 @@
+# $Id$
+
+ALTER TABLE %DB_TBL_PREFIX%room
+ADD COLUMN sort_key varchar(25) DEFAULT '' NOT NULL AFTER room_name,
+ADD KEY idxSortKey (sort_key);
Property changes on: mrbs/trunk/web/upgrade/8/mysql.sql
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Added: mrbs/trunk/web/upgrade/8/pgsql.sql
===================================================================
--- mrbs/trunk/web/upgrade/8/pgsql.sql (rev 0)
+++ mrbs/trunk/web/upgrade/8/pgsql.sql 2009-10-27 16:52:17 UTC (rev 1231)
@@ -0,0 +1,7 @@
+-- $Id$
+
+ALTER TABLE %DB_TBL_PREFIX%room
+ADD COLUMN sort_key varchar(25) DEFAULT '' NOT NULL;
+
+create index idxSortKey on mrbs_room(sort_key);
+
Property changes on: mrbs/trunk/web/upgrade/8/pgsql.sql
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Added: mrbs/trunk/web/upgrade/8/post.inc
===================================================================
--- mrbs/trunk/web/upgrade/8/post.inc (rev 0)
+++ mrbs/trunk/web/upgrade/8/post.inc 2009-10-27 16:52:17 UTC (rev 1231)
@@ -0,0 +1,14 @@
+<?php
+
+// $Id$
+
+// Populate the room sort_key with the room name (the default value)
+
+global $tbl_room;
+
+if (sql_command("UPDATE $tbl_room SET sort_key=room_name") < 0)
+{
+ fatal_error(0, "Error updating table. " . sql_error());
+}
+
+?>
Property changes on: mrbs/trunk/web/upgrade/8/post.inc
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Modified: mrbs/trunk/web/week.php
===================================================================
--- mrbs/trunk/web/week.php 2009-10-22 16:21:18 UTC (rev 1230)
+++ mrbs/trunk/web/week.php 2009-10-27 16:52:17 UTC (rev 1231)
@@ -168,7 +168,7 @@
else
{
$sql = "select id, room_name from $tbl_room
- where area_id=$area order by room_name";
+ where area_id=$area order by sort_key";
$res = sql_query($sql);
if ($res)
{
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits