diff --git a/common.inc.bootstrap.php b/common.inc.bootstrap.php
index 16d5c06..3dd7543 100644
--- a/common.inc.bootstrap.php
+++ b/common.inc.bootstrap.php
@@ -312,4 +312,36 @@ $CWSFDivisions=array(
9=>"Physical & Mathematical Sciences"
);
+//take SFIABDIRECTORY off of the current URL
+$pageurl=substr($_SERVER['PHP_SELF'],strlen($config['SFIABDIRECTORY']));
+
+//set things to 0 to start
+$_SESSION['nav']['primary']=0;
+$_SESSION['nav']['secondary']=0;
+$_SESSION['nav']['tertiary']=0;
+
+//this code figures out if the page we're on is in the navigation structure, and if so, where, and properly sets the primary, secondary and tertiary navigation variables
+$q=mysql_query("SELECT * FROM rolestasks WHERE link='".mysql_real_escape_string($pageurl)."' AND conferencetype='{$conference['type']}'");
+if($r=mysql_fetch_object($q)) {
+ //okay we found it, now get its full tree above it
+ $navTree=array();
+ upTree($r->id,&$navTree);
+
+ //go through each one, and set the SESSION vars
+ foreach($navTree AS $t) {
+ switch($t['level']) {
+ case 0: //primary nav
+ $_SESSION['nav']['primary']=$t['id'];
+ break;
+ case 1: //secondary nav
+ $_SESSION['nav']['secondary']=$t['id'];
+ break;
+ case 2: //tertiary nav
+ $_SESSION['nav']['tertiary']=$t['id'];
+ break;
+ }
+ }
+}
+else {
+}
diff --git a/common.inc.php b/common.inc.php
index 2348635..87bd99c 100644
--- a/common.inc.php
+++ b/common.inc.php
@@ -22,12 +22,13 @@
*/
?>
+//functions contains all the common functions besides the header/footer functions
+//must go before bootstrap becuase bootstrap needs some of the functions in it
+require_once("common.inc.functions.php");
+
//bootstrap sets up the session, loads config params, etc, etc.
require_once("common.inc.bootstrap.php");
-//functions contains all the common functions besides the header/footer functions
-require_once("common.inc.functions.php");
-
$HEADER_SENT=false;
function send_header($title="", $nav=null, $icon=null, $titletranslated=false) {
global $HEADER_SENT;
@@ -59,7 +60,6 @@ function send_header($title="", $nav=null, $icon=null, $titletranslated=false) {
-
\n";
+ echo "\n";
+?>
+
-}
-else {
+
+//if the page we're on isnt part of the navigation, then hide the secondary and tertiary menus
+if(!($_SESSION['nav']['primary'] && $_SESSION['nav']['secondary'] && $_SESSION['nav']['tertiary'])) {
+?>
+
+
}
/*
if(is_array($nav)) {
@@ -348,12 +358,6 @@ if(is_array($nav)) {
echo '';
}
*/
-?>
-
-
-
-
if(is_array($_SESSION['roles'])) {
$has_config = array_key_exists('config', $_SESSION['roles']);
diff --git a/js/nav.js b/js/nav.js
deleted file mode 100644
index 2eddc74..0000000
--- a/js/nav.js
+++ /dev/null
@@ -1,45 +0,0 @@
-function taskNavLevel(l1,l2,l3,l4) {
- if(l2) {
- //we have a secondary click, which implies we also have a primary nav selected
- //we may or may not have l3 or l4 though, so they are handled separately below
- $("#division-menu").load(config.SFIABDIRECTORY+"/nav.php?level=1&id="+l1,null,function() {
- $("#division-menu").show();
-
-// $("#tertiarymenu_accordion").accordion("destroy");
- $("#topic-menu").load(config.SFIABDIRECTORY+"/nav.php?level=2&id="+l2,null,function() {
-// $("#tertiarymenu_accordion").accordion({clearStyle: true, collapsible: true, active: false}); //"option", "collapsible", true);
- $("#topic-menu").show();
-
- $(".primarynav-selected").removeClass("primarynav-selected");
- $("#primary_nav_"+l1).addClass("primarynav-selected");
-
- $(".secondarynav-selected").removeClass("secondarynav-selected");
- $("#secondary_nav_"+l2).addClass("secondarynav-selected");
-
- //if we have a 3rd level nav, open up the accordion to the appropriate place
- if(l3) {
-// $("#tertiarymenu_accordion").accordion("activate",$("#tertiary_nav_"+l3));
- }
- //if we have a 4th level nav, set the selected class on the appropriate item in the list
- if(l4) {
- $(".tertiarylinknav-selected").removeClass("tertiarylinknav-selected");
- $("#tertiarylink_nav_"+l4).addClass("tertiarylinknav-selected");
- }
- });
- });
- }
- else {
- //only the primary link clicked, so show the secondary, and thats it.
- $("#division-menu").load(config.SFIABDIRECTORY+"/nav.php?level=1&id="+l1,null,function() {
-
- $(".primarynav-selected").removeClass("primarynav-selected");
- $("#primary_nav_"+l1).addClass("primarynav-selected");
-
- //show the secondary
- $("#division-menu").show();
- //and hide the tertiary
-// $("#topic-menu").hide();
- });
- }
-
-}
diff --git a/nav.php b/nav.php
index 8a0c5e8..947cc95 100644
--- a/nav.php
+++ b/nav.php
@@ -21,64 +21,43 @@
*/
?>
- include "common.inc.php";
- $id=intval($_GET['id']);
- $level=intval($_GET['level']);
+include "common.inc.php";
- if($id && $level) {
- switch($level) {
- case 1: //populate the scecondary menu
- if($_SESSION['nav']['primary']!=$id) {
- $_SESSION['nav']['primary']=$id;
- }
- unset($_SESSION['nav']['secondary']);
- unset($_SESSION['nav']['tertiary']);
- unset($_SESSION['nav']['tertiarylink']);
- $q=mysql_query("SELECT * FROM rolestasks WHERE pid='$id' AND level=1 AND conferencetype='{$conference['type']}' ORDER By ord,task");
- echo mysql_error();
- echo "
\n";
- break;
+//if we're here, its because we didnt have a link to click, so we need to figure out the first topic-level (tertiary) menu item to redirect to
+
+$id=intval($_GET['id']);
+$q=mysql_query("SELECT * FROM rolestasks WHERE id='$id'");
+$r=mysql_fetch_object($q);
+//print_r($r);
+
+//we clicked on a channel-level (primary) nav, so we need to get the FIRST secondary under it, and teh FIRST tertiary under that.
+if($level==0) {
+ $primary=$id;
+ $q2=mysql_query("SELECT * FROM rolestasks WHERE pid='$id' ORDER BY ord LIMIT 1");
+ $r2=mysql_fetch_object($q2);
+ $secondary=$r2->id;
+ $_SESSION['nav']['primary']=$id;
+}
+else if($level==1) {
+ $secondary=$id;
+}
+$_SESSION['nav']['secondary']=$secondary;
+
+//now we have a secondary whether it was a primary clicked on, or a secondary clicked on, so now we just get the tertiary (topic) link
+$q3=mysql_query("SELECT * FROM rolestasks WHERE pid='$secondary' AND link!='' ORDER BY ord LIMIT 1");
+if($r3=mysql_fetch_object($q3)) {
+ $tertiary=$r3->id;
+ $_SESSION['nav']['tertiary']=$tertiary;
+
+ header("Location: {$config['SFIABDIRECTORY']}{$r3->link}");
+} else {
+ send_header("Navigation Error");
+ echo error("Hmm something seems mis-configured. We hit a topic-level menu that doesnt have any linkable items")."
";
+ echo "Perhaps you should fix this in
Superuser Role Tasks Setup";
+ echo "
";
+ echo "DEBUG:";
+ print_r($r);
+ send_footer();
+}
- case 2: //populate the tertiary menu
- $_SESSION['nav']['secondary']=$id;
- unset($_SESSION['nav']['tertiary']);
- unset($_SESSION['nav']['tertiarylink']);
- $q=mysql_query("SELECT * FROM rolestasks WHERE pid='$id' AND level=2 AND conferencetype='{$conference['type']}' ORDER By ord,task");
- echo "\n";
- break;
- }
- }
-?>