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 @@ */ ?> /js/jquery/1.3.2/jquery.min.js"> - \n"; + echo "\n"; +?> + -} -else { + + +'; } */ -?> - -
-
-
- "; - $cl=""; - while($r=mysql_fetch_object($q)) { - if($_SESSION['nav']['secondary'] == $r->id) { - $cl="class=\"secondarynav-selected\""; - } - else $cl=""; - echo "
  • id}\" $cl>"; - //echo "id,$r->pid,$r->level)\">".i18n($r->task).""; - echo "pid, $r->id)\">".i18n($r->task).""; - echo "
  • \n"; - } - 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; - } - } -?>