/**
* index
* Display the main books categories
*/
function index($bkid, $highlight)
{
$dbconn =& pnDBGetConn(true);
pnModDBInfoLoad('books');
$pntable =& pnDBGetTables();
$bookstable = $pntable['books_books'];
$categoriestable = $pntable['books_categories'];
$subcategoriestable = $pntable['books_subcategories'];
$urlinsfunc=pnModGetVar('books','urlinsfunc');
$imagesdir=pnModGetVar('books','imagesdir');
$booksdir=pnModGetVar('books','booksdir');
$emptyimage=pnModGetVar('books','emptyimage');
$tablecolor=pnModGetVar('books','tablecolor');
$barcolor=pnModGetVar('books','barcolor');
$showsubcat=pnModGetVar('books','showsubcat');
$books_showed=pnModGetVar('books','books_showed');
$showlastbooks=pnModGetVar('books','showlastbooks');
include("header.php");
//This routine may be called with a bkid from
//admin.php to show a user's book view
if (isset [88]($bkid)) {
menu(1);
OpenTable();
showbook($bkid, $highlight);
if ($highlight=='') {
$urlret = "modules.php?op=modload&name=books&file=index&bkid=$bkid";
} else {
$urlret = "modules.php?op=modload&name=books&file=index&bkid=$bkid&highlight=$highlight";
}
echo [89] pnModCallHooks('item', 'display', $bkid, $urlret);
CloseTable();
include 'footer.php';
} else {
$mainlink = 0;
if (!pnSecAuthAction(0, 'books::', '::', ACCESS_READ)) {
echo [90] _BOOKSNOAUTH;
include 'footer.php';
exit [91];
}
$catcolumn = &$pntable['books_categories_column'];
$result =& $dbconn->Execute("select $catcolumn[cid], $catcolumn[title], $catcolumn[cdescription]
from $categoriestable
ORDER BY $catcolumn[title]");
$numcats = $result->PO_RecordCount();
if ($numcats == 0) {
echo [92] _NOCATEGORIES;
include 'footer.php';
} else {
menu($mainlink);
OpenTable();
echo [93] "<div style=\"text-align:center\"><span class=\"pn-title\">"._BOOKSMAINCAT."</span></div><br />";
echo [94] "<table width=\"100%\" border=\"0\" cellspacing=\"30\" cellpadding=\"0\" align=\"center\">
<tr>
<td valign=\"top\" width=\"50%\">";
echo [95] "<table border=\"0\" cellspacing=\"2\" cellpadding=\"0\" width=\"98%\" summary=\""._BOOKSMAINCAT."\">";
$count = 0;
while(list [96]($cid, $title, $cdescription) = $result->fields)
{
$result->MoveNext();
/* Hide this books category if have no access to it */
if (!pnSecAuthAction(0, 'books::Category', "$title::$cid", ACCESS_READ)) {
continue;
}
if ($count == 0) {
// we need to start a row
echo [97] "<tr>";
}
$count++;
$cnumrows = countsubbooks($cid);
echo [98] "<td valign=\"top\" style=\"width:50%\">"
."<span class=\"pn-normal\">"
."<img src=\"modules/".pnVarPrepForOS($GLOBALS['name'])."/images/cat.gif\" height=\"13\" width=\"15\" alt=\"" . pnVarPrepForDisplay($title) . "\" /> "
."<a class=\"pn-title\" href=\"".$GLOBALS['modurl']."&req=view_cat&cid=$cid\">".pnVarPrepForDisplay($title)."</a>"
." ($cnumrows)";
categorynewbookgraphic($cid);
echo [99] "</span>";
echo [100] "<br />";
if ($cdescription) {
echo [101] "<span class=\"pn-normal\">".pnVarPrepHTMLDisplay($cdescription)."</span><br />";
}
if (pnModGetVar('books','showsubcat')) {
$subcatcolumn = &$pntable['books_subcategories_column'];
$result2 =& $dbconn->Execute("SELECT $subcatcolumn[sid], $subcatcolumn[title] FROM $subcategoriestable WHERE $subcatcolumn[cid]='".pnVarPrepForStore($cid)."' ORDER BY $subcatcolumn[title]");
while(list [102]($sid, $stitle) = $result2->fields) {