122 lines
4.7 KiB
PHP
122 lines
4.7 KiB
PHP
<?php
|
|
if (SessionActive() != 1 || ! UserLoggedIn()) return;
|
|
|
|
// if ($school_num == 18) startLog("menu.additional-pages.php");
|
|
|
|
$visible_to_parents = true;
|
|
$results = db_query("show columns from content_tabs like 'visible_to_parents'");
|
|
$visible_to_parents = (db_num_rows($results))?TRUE:FALSE;
|
|
|
|
$pwhere = "";
|
|
$vwhere = "";
|
|
if (in_array($_SESSION['UserInfo']['type'],array('Parent','Guest','Staff'))) {
|
|
$pwhere = "AND public_page = 'Y'";
|
|
$vwhere = "AND visible_to_parents = 'Y'";
|
|
}
|
|
|
|
// Check if there are additional pages defined
|
|
$numPages = db_getVal("SELECT count(*) FROM formatted_content WHERE school_num = $school_num AND content_type = 'A' $pwhere");
|
|
if ($numPages == 0) return;
|
|
|
|
// Get any pages that are not on a tab
|
|
$query = "SELECT * FROM formatted_content WHERE school_num = $school_num AND content_type = 'A' AND tab_num = 0 $pwhere ORDER BY sequence";
|
|
writeLog($query);
|
|
$homePages = db_query($query);
|
|
writeLog("homePages: ".db_num_rows($homePages));
|
|
if (db_num_rows($homePages) > 0) {
|
|
while ($row = db_fetch_assoc($homePages)) {
|
|
$rnum = $row['record_num'];
|
|
$title = $row['content_id'];
|
|
$link = $row['page_link'];
|
|
|
|
if (strlen($link) > 0) {
|
|
if (!$list_started) echo(" <ul>\n");
|
|
$list_started = true;
|
|
writeLog(" - $title");
|
|
echo(" <li><a href='?$link'>$title</a></li>\n");
|
|
}
|
|
else {
|
|
if (!$list_started) echo(" <ul>\n");
|
|
$list_started = true;
|
|
writeLog(" - $title");
|
|
echo(" <li><a href='?action=view-page&rnum=$rnum'>$title</a></li>\n");
|
|
}
|
|
}
|
|
}
|
|
|
|
// Check if there are tabs defined
|
|
if (db_tableExists("content_tabs")) {
|
|
$query = "SELECT count(*) FROM content_tabs WHERE school_num = $school_num $vwhere ORDER BY sequence";
|
|
writeLog($query);
|
|
$numTabs = db_getVal($query);
|
|
writeLog("numTabs: $numTabs");
|
|
|
|
// Get any additional pages
|
|
if ($numTabs == 0 || $school_record['implement_page_tabs'] == 'N') {
|
|
$query = "SELECT * FROM formatted_content WHERE school_num = $school_num AND content_type = 'A' AND tab_num != 0 $pwhere ORDER BY sequence";
|
|
writeLog($query);
|
|
$results = db_query($query);
|
|
if (db_num_rows($results)) {
|
|
if (!$list_started) echo(" <ul>\n");
|
|
$list_started = true;
|
|
|
|
writeLog(" - ".$school_record['additional_pages_title']);
|
|
echo(" <li><a href='#'>" . $school_record['additional_pages_title'] . "</a>\n");
|
|
echo(" <ul>\n");
|
|
|
|
while ($row = db_fetch_assoc($results)) {
|
|
$rnum = $row['record_num'];
|
|
$title = $row['content_id'];
|
|
$link = $row['page_link'];
|
|
|
|
if (strlen($link) > 0) {
|
|
echo(" <li><a href='?$link'>$title</a></li>\n");
|
|
}
|
|
else {
|
|
echo(" <li><a href='?action=view-page&rnum=$rnum'>$title</a></li>\n");
|
|
}
|
|
}
|
|
|
|
echo(" </ul>\n");
|
|
echo(" </li>\n");
|
|
}
|
|
}
|
|
else {
|
|
if (!$list_started) echo(" <ul>\n");
|
|
$list_started = true;
|
|
|
|
// Get tabs
|
|
$query = "SELECT * FROM content_tabs WHERE school_num = $school_num $vwhere ORDER BY sequence";
|
|
writeLog($query);
|
|
$tabs = db_query($query);
|
|
|
|
while ($row = db_fetch_assoc($tabs)) {
|
|
$tab_title = $row['tab_title'];
|
|
$tab_num = $row['record_num'];
|
|
|
|
$pages = db_query("SELECT * FROM formatted_content WHERE school_num = $school_num AND content_type = 'A' AND tab_num = $tab_num $pwhere ORDER BY sequence");
|
|
if (db_num_rows($pages)) {
|
|
echo(" <li><a href='#'>$tab_title</a>\n");
|
|
echo(" <ul>\n");
|
|
|
|
while ($row = db_fetch_assoc($pages)) {
|
|
$rnum = $row['record_num'];
|
|
$title = $row['content_id'];
|
|
$link = $row['page_link'];
|
|
|
|
if (strlen($link) > 0) {
|
|
echo(" <li><a href='?$link'>$title</a></li>\n");
|
|
}
|
|
else {
|
|
echo(" <li><a href='?action=view-page&rnum=$rnum'>$title</a></li>\n");
|
|
}
|
|
}
|
|
|
|
echo(" </ul>\n");
|
|
echo(" </li>\n");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
?>
|