// dsm($rows);
// dsm($view);
// Get all the flags for the user.
$flagged = flag_get_user_flags('node');
// dsm($flagged);
// Build a grid that we can use for our table.
foreach ($rows as $id => $row) {
    $results[$view->result[$id]->node_data_field_session_day_field_session_day_value][$view->result[$id]->node_data_field_session_room_field_session_time_value][$view->result[$id]->node_data_field_session_day_field_session_room_value] = array('content' => $row, 'nid' => $view->result[$id]->nid, 'id' => 'node-' . $view->result[$id]->nid);
}
dsm($results);
// Sorting so that time goes ASC.
ksort($results['saturday']);
ksort($results['sunday']);
// Gather the room cck field values for the table headers
$field_rooms = content_fields('field_session_room');
$allowed = content_allowed_values($field_rooms);
$saturday_header = array($allowed[1], $allowed[2], $allowed[3], $allowed[4], $allowed[5], $allowed[8]);
$sunday_header = array($allowed[2], $allowed[3], $allowed[4], $allowed[5], $allowed[8]);
// Add some js magic to catch a vote request and then update the td class
drupal_add_js("\$(document).ready(function() {\n    \$(window).bind('flagGlobalAfterLinkUpdate', function(e, data) {\n      var selector = '#node-' + data.contentId;\n      if (data.flagStatus == 'flagged') {\n        \$(selector).addClass('flagged').removeClass('not-flagged');\n      }\n      else {\n        \$(selector).addClass('not-flagged').removeClass('flagged');\n      }\n    });\n  });", 'inline');
// dsm($results);
?>

<?php 
if (user_access('manage schedule')) {
    ?>
  <div class="manage-link"><?php 
    echo l('Manage Schedule', 'manage/schedule', array('query' => 'destination=schedule'));
    ?>
</div>
<?php 
<?php

/**
 * This template is used to print a single field in a view. It is not
 * actually used in default Views, as this is registered as a theme
 * function which has better performance. For single overrides, the
 * template is perfectly okay.
 *
 * Variables available:
 * - $view: The view object
 * - $field: The field handler object that can process the input
 * - $row: The raw SQL result that can be used
 * - $output: The processed output that will normally be used.
 *
 * When fetching output from the $row, this construct should be used:
 * $data = $row->{$field->field_alias}
 *
 * The above will guarantee that you'll always get the correct data,
 * regardless of any changes in the aliasing that might happen if
 * the view is modified.
 */
?>
<?php

$options = content_allowed_values(content_fields('field_active_flag'), FALSE);
print $options[$output];
?>