<?php
/********************************************************/
/* NSN Groupes Sections                                 */
/* By: NukeScripts Network (webmaster@nukescripts.fr)   */
/* http://www.nukescripts.fr                            */
/* Copyright  2000-2005 by NukeScripts Network         */
/* ==================================================== */
/* Based from:                                          */
/* PHP-NUKE: Web Portal System                          */
/********************************************************/
defined('MAXIMUS') or Header("Location: index.php");

$module_name = "Sections";

function menu () {
global $sitename;
$sections_config = sections_get_configs();
$actsearch = $GLOBALS['db']->XMFbin($sections_config['actsearch']);
$title     = stripslashes($sections_config['title']);
$sstitle   = stripslashes($sections_config['sstitle']);
 Max_opentable();
 echo "<table><tr><td width='30%'>";
 echo "<a href='modules.php?name=Sections'><img src='modules/Sections/images/admin/nsngrsections.png' border='0' alt='' /></a></center>";
 echo "</td><td width='70%'><font size='3'>$title $sitename</font><br /><br />";
 if ($actsearch) { SearchForm(); }
 echo "</td></tr></table> $sstitle";
 Max_CloseTable();
 br('1');

}

function viewsections ($secid, $image, $secname, $nbartcles, $count, $view2) {
global $module_name;
$sections_config = sections_get_configs();
$nblect = $sections_config['nblect'];
$nbart  = $sections_config['nbart'];
$affvis = $sections_config['affvis'];
Max_OpenTable();
echo "<table border='0' width='100%' align='center' valign='top'>";
if ($image) { $w1 = "10%"; $w2 ="90%" ;} else {$w1 = ""; $w2 ="100%"; }
echo "<tr><td width='$w1' align='center' valign='top' rowspan='3'>";
if ($image) {
echo "<a href=\"modules.php?name=$module_name&amp;op=listarticles&amp;secid=$secid\"><img src=\"images/sections/$image\" border=\"0\" alt=\"$secname\" /></a>";
}
echo "</td><td width='$w2' valign='top'>&nbsp;<b>"._SC_TITLE." :</b> <a href=\"modules.php?name=$module_name&amp;op=listarticles&amp;secid=$secid\">$secname</a><br />";
if ($nbart) {
echo "&nbsp;<b>"._SC_NBARTICLES."</b>: $nbartcles<br />";
}
if ($nblect) {
echo "&nbsp;<b>"._SC_READS."</b>: $count<br />";
}
if ($affvis) {
echo "&nbsp;<b>"._SC_DROITS."</b>: $view2";
}
echo "</td></tr>";
echo "</table>";
Max_CloseTable();
}

function sections_save_config($config_name, $config_value){
    if (defined('ADMIN_ALLOW')) {
    $GLOBALS['db']->sql_query("UPDATE `".TABLE_NSNSECTIONS_CONFIG."` SET `config_value`='$config_value' WHERE `config_name`='$config_name'");
	}
}

function sections_get_configs(){
    $configresult = $GLOBALS['db']->sql_query("SELECT `config_name`, `config_value` FROM `".TABLE_NSNSECTIONS_CONFIG."`");
    while (list($config_name, $config_value) = $GLOBALS['db']->sql_fetchrow($configresult)) {
        $config[$config_name] = $config_value;
    }
    return $config;
}

function SearchForm() {
    global $module_name, $query;
    echo "<table border='0' cellspacing='0' cellpadding='0' align='center'>\n";
    echo "<form action='modules.php?name=$module_name&amp;op=search&amp;query=$query' method='post'>\n";
    echo "<tr><td><font class='content'><input type='text' size='25' name='query' value='$query' /> <input type='submit' value='"._SC_SEARCH."' /></td></tr>\n";
    echo "</form>\n";
    echo "</table>\n";
}