Sorting by room_id

Are you responsible for making OCS work -- installing, upgrading, migrating or troubleshooting? Do you think you've found a bug? Post in this forum.

Moderators: jmacgreg, michael, John

Forum rules
The Public Knowledge Project Support Forum is moving to

This forum will be maintained permanently as an archived historical resource, but all new questions should be added to the new forum. Questions will no longer be monitored on this old forum after March 30, 2015.

Sorting by room_id

Postby panthergirl » Tue Apr 19, 2005 7:33 am

Can anyone suggest a way to modify schedule.php so that for a particular day and particular time the presentations are sorted by room_id?

I admit that I don't know PHP and mySQL as well as I should. But I've manage to make lots of modifications on my own without trouble. This one is stumping me, and nothing I read or try seems to help.

This may seem like a minor thing but this may make the difference between the schedule being usuable for us or not, and we've already put a lot of work into it, so "not" is an extremely depressing thought. So please, if you can help me, I'd really appreciate it.


I finally figured it out.

Postby panthergirl » Thu Apr 21, 2005 8:05 pm

Now that I have it, it doesn't seem like such a big deal. But this was long in coming (I had been working on it for quite awhile before my previous post, and a non-trivial amount since then).

It's not beautiful, but it works. I'm sure there's a better way.

Instead of the function sortEvents, use this:

Code: Select all

// Sorts by start_time of event, then by room_id
// For this to work, room_id must be added to the two places that
// the $event array is created.
// Unlike sortEvents, which this replaces, this ignores end_time  (all
// of our time slots are the same)
function sortEventsThenRooms($a, $b)
   foreach(array('start_time','room_id') as $value ) {
      if ($value=="start_time")   {
           // compare start times

         $start_a = strtotime("$a[$value]");
         $start_b = strtotime("$b[$value]");

         if($start_a != $start_b) { return ($start_a > $start_b) ? 1 : -1; }
        else if ($value=="room_id") {
           if ($a[$value] != $b[$value]) { return $a[$value] > $b[$value] ? 1: -1; }
   return 0;

Return to “OCS Technical Support”

Who is online

Users browsing this forum: No registered users and 1 guest