Revision: 1365
http://mrbs.svn.sourceforge.net/mrbs/?rev=1365&view=rev
Author: cimorrison
Date: 2010-07-01 13:39:28 +0000 (Thu, 01 Jul 2010)
Log Message:
-----------
Modified the function get_default_area() so that it first tries to return the
area corresponding to the $default_room if it is set and exists. Only if that
fails will it return the first area by alphabetical order of areaname. (Also
fixed the comments to reflect the fact that it is returning the first area by
name, rather than id).
Modified Paths:
--------------
mrbs/trunk/web/functions.inc
Modified: mrbs/trunk/web/functions.inc
===================================================================
--- mrbs/trunk/web/functions.inc 2010-07-01 13:12:47 UTC (rev 1364)
+++ mrbs/trunk/web/functions.inc 2010-07-01 13:39:28 UTC (rev 1365)
@@ -360,11 +360,23 @@
}
// Return a default area; used if no area is already known. This returns the
-// lowest area ID in the database (no guaranty there is an area 1).
+// area that contains the default room (if it is set and valid) otherwise the
+// first area in alphabetical order in the database (no guarantee there is an
area 1).
// This could be changed to implement something like per-user defaults.
function get_default_area()
{
- global $tbl_area;
+ global $tbl_area, $tbl_room, $default_room;
+
+ // If the $default_room is set and exists, then return the corresponding area
+ if (isset($default_room))
+ {
+ $area = sql_query1("SELECT area_id FROM $tbl_room WHERE id=$default_room
LIMIT 1");
+ if ($area >= 0)
+ {
+ return $area;
+ }
+ }
+ // Otherwise return the first area in alphabetical order in the database
$area = sql_query1("SELECT id FROM $tbl_area ORDER BY area_name LIMIT 1");
return ((!isset($area) || ($area < 0)) ? 0 : $area);
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits