science-ation/nav.php
2010-09-23 16:37:19 +00:00

74 lines
2.6 KiB
PHP

<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2010 James Grant <james@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
?>
<?
include "common.inc.php";
//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($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($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;
//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")."<br />";
echo "Perhaps you should fix this in <a href=\"".$config['SFIABDIRECTORY']."/super/roletasks.php\">Superuser Role Tasks Setup</a>";
echo "<br /><br />";
echo "<br />Channel :";
print_r($pri);
echo "<br />Division :";
print_r($sec);
send_footer();
}