Fix clicking on secondary nav

This commit is contained in:
james 2010-09-23 16:37:19 +00:00
parent 60c6235649
commit ffd09ae67e
3 changed files with 30 additions and 17 deletions

View File

@ -315,15 +315,16 @@ $CWSFDivisions=array(
//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
//set things to 0 to start
$_SESSION['nav']['primary']=0;
$_SESSION['nav']['secondary']=0;
$_SESSION['nav']['tertiary']=0;
$navTree=array();
upTree($r->id,&$navTree);
@ -343,5 +344,7 @@ if($r=mysql_fetch_object($q)) {
}
}
else {
//if we didnt find it, we only set the tertiary to 0, because we probably want to keep our primary and secondary navs if they exist
$_SESSION['nav']['tertiary']=0;
}

View File

@ -289,7 +289,6 @@ if(array_key_exists('users_id', $_SESSION)) {
<div id="division-menu" class="clear">
<?
$q=mysql_query("SELECT * FROM rolestasks WHERE pid='{$_SESSION['nav']['primary']}' AND level=1 AND conferencetype='{$conference['type']}' ORDER By ord,task");
echo mysql_error();
echo "<ul class=\"secondarynav\">";
$cl="";
while($r=mysql_fetch_object($q)) {
@ -333,18 +332,19 @@ if(array_key_exists('users_id', $_SESSION)) {
?>
</div>
<?
//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'])) {
?>
<script type="text/javascript">
$(document).ready(function(){
$("#division-menu").hide();
$("#topic-menu").hide();
<?
if(!$_SESSION['nav']['secondary']) {
echo "$(\"#division-menu\").hide();\n";
}
if(!$_SESSION['nav']['tertiary']) {
echo "$(\"#topic-menu\").hide();\n";
}
?>
});
</script>
<?
}
/*
if(is_array($nav)) {
echo "<div id=\"mainwhere\">".i18n('You are here:').' ';

18
nav.php
View File

@ -31,15 +31,23 @@ $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) {
if($r->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;
$pri=$r;
$sec=$r2;
$_SESSION['nav']['primary']=$id;
}
else if($level==1) {
else if($r->level==1) {
$secondary=$id;
//we still need to find the primary so we can make sure its set properly
$pq=mysql_query("SELECT * FROM rolestasks WHERE id='$r->pid'");
$pri=mysql_fetch_object($pq);
$sec=$r;
$_SESSION['nav']['primary']=$pri->id;
}
$_SESSION['nav']['secondary']=$secondary;
@ -55,8 +63,10 @@ if($r3=mysql_fetch_object($q3)) {
echo error("Hmm something seems mis-configured. We hit a topic-level menu that doesnt have any linkable items")."<br />";
echo "Perhaps you should fix this in <a href=\"".$config['SFIABDIRECTORY']."/super/roletasks.php\">Superuser Role Tasks Setup</a>";
echo "<br /><br />";
echo "DEBUG:";
print_r($r);
echo "<br />Channel :";
print_r($pri);
echo "<br />Division :";
print_r($sec);
send_footer();
}