<?php

#############################################################################
#                              Site@School
# Site@School is a website management system designed for schools.
#
# About Site@School:
# Original Idea: Mark de Haan (mark@starwave.nl)
# PHP coding & Design: Mark de Haan (mark@starwave.nl)
# Comissioned by: Stadsdeel de Baarsjes, Amsterdam, Netherlands
############################################################################
# admin.php: last changed 15/02/2006  S@S version 2.4
#              by Fred Stuurman (fc.stuurman@hccnet.nl)
#$Id: admin.php,v 1.1 2006/10/03 09:16:25 fstuurman Exp $
############################################################################
#                        LICENSE INFORMATION
# Copyright (C) 2002 - 2005 Municipality of Amsterdam, City District
#  'de Baarsjes', Amsterdam, the Netherlands.
#
# 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; either version 2
# of the License, or (at your option) any later version.
#
# 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; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
##############################################################################
if (!defined('IN_SAS'))
{
	die("Hacking attempt");
}
if (IsSet ($_GET['delete_link']))
{
	$delete_link = $_GET['delete_link'];
}
if (IsSet ($_GET['id']))
{
	$id = $_GET['id'];
}
if (IsSet ($_GET['delete_cat']))
{
	$delete_cat = $_GET['delete_cat'];
}
if (IsSet ($_GET['save_link']))
{
	$save_link = $_GET['save_link'];
}
if (IsSet ($_GET['edit_link']))
{
	$edit_link = $_GET['edit_link'];
}
if (IsSet ($_GET['modoption']))
{
	$modoption = $_GET['modoption'];
}
if (IsSet ($_GET['pagename']))
{
	$pagename = $_GET['pagename'];
}
if (IsSet ($_POST['link_row_count']))
{
	$link_row_count = $_POST['link_row_count'];
}
if (IsSet ($_POST['link_title']))
{
	$link_title = $_POST['link_title'];
}
if (IsSet ($_POST['link_icon']))
{
	$link_icon = $_POST['link_icon'];
}
if (IsSet ($_POST['link_url']))
{
	$link_url = $_POST['link_url'];
}
if (IsSet ($_POST['link_sort']))
{
	$link_sort = $_POST['link_sort'];
}
if (IsSet ($_POST['link_description']))
{
	$link_description = $_POST['link_description'];
}
if (IsSet ($_POST['link_pagename']))
{
	$link_pagename = $_POST['link_pagename'];
}
if (IsSet ($_POST['link_category']))
{
	$link_category = $_POST['link_category'];
}
if (IsSet ($_POST['owner_email']))
{
	$owner_email = $_POST['owner_email'];
}
if (IsSet ($_POST['propose']))
{
	$propose = $_POST['propose'];
}
if (IsSet ($_POST['showlink']))
{
	$showlink = $_POST['showlink'];
}
if (IsSet ($_POST['initial']))
{
	$initial = $_POST['initial'];
}

if (!get_magic_quotes_gpc())
{
	$welcometext = addslashes($_POST['welcometext']);
}
else
{
	$welcometext = $_POST['welcometext'];
}
if (!get_magic_quotes_gpc())
{
	$propose_welcome = addslashes($_POST['propose_welcome']);
}
else
{
	$propose_welcome = $_POST['propose_welcome'];
}

load_language('', 'sn_links'); //load language file

include ("interface/header.inc.php");
include ("interface/menubar.inc.php");
include ("interface/menustart.inc.php");
print "<span class=heading>" . $sas_lang['filemanager_menu'] . "</span><p>";
print "<span class=link>
<a href=index.php?option=modulemanager&module=$module&modoption=links>" . $sas_lang['links_module_links'] . "</a><p>
<a href=index.php?option=modulemanager&module=$module&modoption=proposed>" . $sas_lang['links_module_proposed'] . "</a><p>";
include ("interface/menuend.inc.php");
include ("interface/pagestart.inc.php");

$query = "SELECT name FROM $table_modules where id=$module";
$result = mysql_query($query) or die_script($query, mysql_error());
$modulename = mysql_result($result, 0);
unset ($query);
unset ($result);

$table_links = $dbprefix . "m_links";
$table_links_cat = $dbprefix . "m_links_cat";

if (IsSet ($delete_link))
{
	mysql_query("DELETE from $table_links WHERE id='$delete_link'");
}

if (IsSet ($delete_cat))
{
	mysql_query("DELETE from $table_links WHERE pagename='$delete_cat'");
	mysql_query("DELETE from $table_links_cat WHERE id='$delete_cat'");
}

if ($modoption == "save_page_link")
{
	if ($id == "new")
	{
		mysql_query("INSERT INTO $table_links_cat (id, pagename, owner_email, row_count, welcome, icon, propose, propose_welcome, showlink)
			VALUES (NULL, '$link_category', '$owner_email', '$link_row_count', '$welcometext', '$link_icon', '$propose', '$propose_welcome', '$showlink')");
	}
	else
	{
		mysql_query("UPDATE $table_links_cat 
							SET pagename='$link_category' ,
							owner_email='$owner_email' ,
							welcome='$welcometext' ,
							row_count='$link_row_count' ,
							icon='$link_icon',
							propose='$propose',
							propose_welcome='$propose_welcome',
							showlink = '$showlink'
							WHERE id='$id'");
	}
}

if (IsSet ($save_link))
{
	if ($save_link == "new")
	{
		mysql_query("INSERT INTO $table_links (id, title, url, description, sort, pagename, category)
			VALUES (NULL, '$link_title', '$link_url', '$link_description', '$link_sort', '$link_pagename', '$link_category')");
	}
	else
	{
		mysql_query("UPDATE $table_links 
							SET url = '$link_url' ,
							title = '$link_title' ,
							description = '$link_description' ,
							pagename = '$link_pagename' ,
							sort = '$link_sort',
							category = '$link_category',
							initial = '$initial'
							WHERE id='$save_link'");
	}
}

if ($modoption == "add_page_link")
{
	print "<span class=\"heading\">$modulename<br><br></span>";
	print "<span class=\"text\">" . $sas_lang['links_module_add_page_link'] . "</center><p></span>";
	print "<form METHOD=\"POST\" enctype=\"multipart/link-data\" ACTION=\"index.php?option=modulemanager&module=$module&modoption=save_page_link&id=new\" 
	       onsubmit=\"return checkinput(this);\">";
	print "<table cellspacing=\"0\" cellpadding=\"0\">";

	print "<tr><td><span class=\"text\">" . $sas_lang['links_module_pagename'] . "&nbsp;</span></td></tr>
			<tr><td><input type=\"text\" size=30 class=\"textfield\" name=\"link_category\"></td></tr>";
	print "<tr><td colspan=\"3\">&nbsp;</td></tr>";
	print "<tr><td><span class=\"text\">" . $sas_lang['links_module_owner_email'] . ":&nbsp;</span></td></tr>
			<tr><td><input type=\"text\" size=60 class=\"textfield\" name=\"owner_email\"></td></tr>";
	print "<tr><td colspan=\"3\">&nbsp;</td></tr>";
	print "<tr><td valign=\"top\"><span class=\"text\">" . $sas_lang['links_module_welcome_text'] . ":&nbsp;</span></td></tr>
			<tr><td><textarea cols=\"70\" rows=\"4\" name=\"welcometext\"></textarea></td></tr>";
	print "<tr><td>&nbsp;</td></tr>";
	print "<tr><td><span class=\"text\">" . $sas_lang['links_module_max_items'] . ":&nbsp;</span></td></tr>
			<tr><td><input type=\"text\" size=4 class=\"textfield\" name=\"link_row_count\" value=\"1\"></td></tr>";
	print "<tr><td>&nbsp;</td></tr>";
	print "<tr><td><span class=\"text\">" . $sas_lang['links_module_icon'] . " &nbsp;</span></td></tr>
			<tr><td><input type=\"text\" size=50 class=\"textfield\" name=\"link_icon\" value=\"starnet/modules/sn_links/link.gif\"></td></tr>";
	print "<tr><td>&nbsp;</td></tr>";
	print "<tr><td><span class=\"text\">" . $sas_lang['links_module_propose'] . " &nbsp;" . $sas_lang['yes'] . "</span>";

	print "<input type=\"radio\" value=\"1\" name=\"propose\">";
	print "<span class=text>&nbsp;&nbsp;&nbsp; " . $sas_lang['no'] . "</span>";
	print "<input type=\"radio\" name=\"propose\" value=\"0\" checked>";

	print "<tr><td colspan=\"3\">&nbsp;</td></tr>";
	print "<tr><td><span class=\"text\">" . $sas_lang['links_module_showlink'] . " &nbsp;" . $sas_lang['yes'] . "</span>";

	print "<input type=\"radio\" value=\"1\" name=\"showlink\">";
	print "<span class=text>&nbsp;&nbsp;&nbsp; " . $sas_lang['no'] . "</span>";
	print "<input type=\"radio\" name=\"showlink\" value=\"0\" checked>";

	print "<tr><td colspan=\"3\">&nbsp;</td></tr>";
	print "<tr><td valign=\"top\"><span class=\"text\">" . $sas_lang['links_module_propose_welcome_text'] . ":&nbsp;</span></td></tr>
			<tr><td><textarea cols=\"70\" rows=\"4\" name=\"propose_welcome\">$cat_list[6]</textarea></td></tr>";
	print "</table>";

	print "<p><input type=\"button\" value=\"&nbsp;&nbsp;&nbsp;$sas_lang[goback]\" name=\"backbutton\"
	onClick=\"javascript:parent.location='index.php?option=modulemanager&module=$module';\" class=\"backbutton\">";

	print "&nbsp;<input type=\"submit\" value=\"&nbsp;&nbsp;&nbsp;$sas_lang[save]\" name=\"savebutton\" class=\"savebutton\">";
	print "</span></form>";

	include ("interface/pageend.inc.php");
	include ("interface/footer.inc.php");
	exit;
}

if ($modoption == "edit_page_link")
{
	$query = "SELECT pagename, owner_email, welcome, row_count, icon, propose, propose_welcome, showlink FROM $table_links_cat WHERE id='$id'";
	$result = mysql_query($query) or die_script($query, mysql_error());
	$cat_list = mysql_fetch_array($result);
	print "<span class=\"heading\">$modulename<br><br></span>";
	print "<span class=\"text\">" . $sas_lang['links_module_edit_page_link'] . "</center><p></span>";
	print "<form METHOD=\"POST\" enctype=\"multipart/link-data\" ACTION=\"index.php?option=modulemanager&module=$module&modoption=save_page_link&id=$id\" 
	       onsubmit=\"return checkinput(this);\">";
	print "<table cellspacing=\"0\" cellpadding=\"0\">";

	print "<tr><td><span class=\"text\">" . $sas_lang['links_module_pagename'] . "&nbsp;</span></td></tr>
			<tr><td><input type=\"text\" size=30 class=\"textfield\" name=\"link_category\" value=\"$cat_list[0]\"></td></tr>";
	print "<tr><td colspan=\"3\">&nbsp;</td></tr>";
	print "<tr><td><span class=\"text\">" . $sas_lang['links_module_owner_email'] . ":&nbsp;</span></td></tr>
			<tr><td><input type=\"text\" size=60 class=\"textfield\" name=\"owner_email\" value=\"$cat_list[1]\"></td></tr>";
	print "<tr><td colspan=\"3\">&nbsp;</td></tr>";
	print "<tr><td valign=\"top\"><span class=\"text\">" . $sas_lang['links_module_welcome_text'] . ":&nbsp;</span></td></tr>
			<tr><td><textarea cols=\"70\" rows=\"4\" name=\"welcometext\">$cat_list[2]</textarea></td></tr>";
	print "<tr><td>&nbsp;</td></tr>";
	print "<tr><td><span class=\"text\">" . $sas_lang['links_module_max_items'] . ":&nbsp;</span></td></tr>
			<tr><td><input type=\"text\" size=4 class=\"textfield\" name=\"link_row_count\" value=\"$cat_list[3]\"></td></tr>";
	print "<tr><td>&nbsp;</td></tr>";
	print "<tr><td><span class=\"text\">" . $sas_lang['links_module_icon'] . " &nbsp;</span></td></tr>
			<tr><td><input type=\"text\" size=50 class=\"textfield\" name=\"link_icon\" value=\"$cat_list[4]\"></td></tr>";
	print "<tr><td>&nbsp;</td></tr>";
	print "<tr><td><span class=\"text\">" . $sas_lang['links_module_propose'] . " &nbsp;" . $sas_lang['yes'] . "</span>";
	if ($cat_list[5] == "1")
	{
		print "<input type=\"radio\" value=\"1\" name=\"propose\" checked>";
		print "<span class=text>&nbsp;&nbsp;&nbsp; " . $sas_lang['no'] . "</span>";
		print "<input type=\"radio\" name=\"propose\" value=\"0\">";
	}
	else
	{
		print "<input type=\"radio\" value=\"1\" name=\"propose\">";
		print "<span class=text>&nbsp;&nbsp;&nbsp; " . $sas_lang['no'] . "</span>";
		print "<input type=\"radio\" name=\"propose\" value=\"0\" checked>";
	}
	print "<tr><td colspan=\"3\">&nbsp;</td></tr>";
	print "<tr><td><span class=\"text\">" . $sas_lang['links_module_showlink'] . " &nbsp;" . $sas_lang['yes'] . "</span>";
	if ($cat_list[7] == "1")
	{
		print "<input type=\"radio\" value=\"1\" name=\"showlink\" checked>";
		print "<span class=text>&nbsp;&nbsp;&nbsp; " . $sas_lang['no'] . "</span>";
		print "<input type=\"radio\" name=\"showlink\" value=\"0\">";
	}
	else
	{
		print "<input type=\"radio\" value=\"1\" name=\"showlink\">";
		print "<span class=text>&nbsp;&nbsp;&nbsp; " . $sas_lang['no'] . "</span>";
		print "<input type=\"radio\" name=\"showlink\" value=\"0\" checked>";
	}
	print "<tr><td colspan=\"3\">&nbsp;</td></tr>";
	print "<tr><td valign=\"top\"><span class=\"text\">" . $sas_lang['links_module_propose_welcome_text'] . ":&nbsp;</span></td></tr>
			<tr><td><textarea cols=\"70\" rows=\"4\" name=\"propose_welcome\">$cat_list[6]</textarea></td></tr>";
	print "</td></tr></table>";

	print "<p><input type=\"button\" value=\"&nbsp;&nbsp;&nbsp;$sas_lang[goback]\" name=\"backbutton\"
	onClick=\"javascript:parent.location='index.php?option=modulemanager&module=$module';\" class=\"backbutton\">";

	print "&nbsp;<input type=\"submit\" value=\"&nbsp;&nbsp;&nbsp;$sas_lang[save]\" name=\"savebutton\" class=\"savebutton\">";
	print "</span></form>";

	include ("interface/pageend.inc.php");
	include ("interface/footer.inc.php");
	exit;
}

if ($modoption == "add_link")
{
	print "<span class=\"heading\">$modulename<br><br></span>";
	print "<span class=\"text\">" . $sas_lang['links_module_add'] . "</center><p></span>";
	print "<form METHOD=\"POST\" enctype=\"multipart/link-data\" ACTION=\"index.php?option=modulemanager&module=$module&pagename=$pagename&save_link=new\" 
	       onsubmit=\"return checkinput(this);\">";
	print "<table cellspacing=\"0\" cellpadding=\"0\">";

	print "<tr><td><span class=\"text\">" . $sas_lang['links_module_category'] . ": &nbsp;</span></td>
			<td><input type=\"text\" size=50 class=\"textfield\" name=\"link_category\"></td></tr>";
	print "<tr><td colspan=\"3\">&nbsp;</td></tr>";
	print "<tr><td><span class=\"text\">" . $sas_lang['links_module_title'] . " &nbsp;</span></td>
			<td><input type=\"text\" size=50 class=\"textfield\" name=\"link_title\"></td></tr>";
	print "<tr><td colspan=\"3\">&nbsp;</td></tr>";
	print "<tr><td><span class=\"text\">" . $sas_lang['links_module_url'] . "&nbsp;</span></td>
			<td><input type=\"text\" size=50 class=\"textfield\" name=\"link_url\" value=\"http://\"></td></tr>";
	print "<tr><td colspan=\"3\">&nbsp;</td></tr>";
	print "<tr><td valign=\"top\"><span class=\"text\">" . $sas_lang['links_module_description'] . "&nbsp;</span></td>
			<td><textarea cols=\"70\" rows=\"4\" name=\"link_description\"></textarea></td></tr>";
	print "<tr><td colspan=\"3\">&nbsp;</td></tr>";
	print "<tr><td><span class=\"text\">" . $sas_lang['links_module_order'] . "&nbsp;</span></td>
			<td><input type=\"text\" size=4 class=\"textfield\" name=\"link_sort\"></td></tr>";
	print "<tr><td colspan=\"3\">&nbsp;</td></tr>";
	print "<tr><td><span class=\"text\">" . $sas_lang['links_module_pagename'] . " &nbsp;</span></td><td><select size=\"1\" class=text name=\"link_pagename\">";

	$query2 = "SELECT id, pagename FROM $table_links_cat";
	$result2 = mysql_query($query2) or die_script($query2, mysql_error());
	while ($category_list = mysql_fetch_array($result2))
	{
		print "<option value=\"$category_list[0]\">$category_list[1]</option>\n";
	}
	print "</select></TD></tr></table>";

	print "<p><input type=\"button\" value=\"&nbsp;&nbsp;&nbsp;$sas_lang[goback]\" name=\"backbutton\"
	onClick=\"javascript:parent.location='index.php?option=modulemanager&module=$module';\" class=\"backbutton\">";

	print "&nbsp;<input type=\"submit\" value=\"&nbsp;&nbsp;&nbsp;$sas_lang[save]\" name=\"savebutton\" class=\"savebutton\">";
	print "</span></form>";

	include ("interface/pageend.inc.php");
	include ("interface/footer.inc.php");
	exit;
}

if (IsSet ($edit_link))
{
	$query = "SELECT id, title, url, description, sort, pagename, category, initial FROM $table_links WHERE id='$edit_link'";
	$result = mysql_query($query) or die_script($query, mysql_error());
	$link_list = mysql_fetch_array($result);

	print "<span class=\"heading\">$modulename<br><br></span>";
	print "<span class=\"text\"><b>" . $sas_lang['links_module_edit'] . "</b><p></span>";
	print "<form METHOD=\"POST\" enctype=\"multipart/link-data\" ACTION=\"index.php?option=modulemanager&module=$module&modoption=$modoption&pagename=$pagename&save_link=$edit_link\">
	       <table cellspacing=\"0\" cellpadding=\"0\">";

	print "<tr><td><span class=\"text\">" . $sas_lang['links_module_category'] . ": &nbsp;</span></td>
			<td><input type=\"text\" size=50 class=\"textfield\" name=\"link_category\" value=\"$link_list[6]\"></td></tr>";
	print "<tr><td colspan=\"3\">&nbsp;</td></tr>";
	print "<tr><td><span class=\"text\">" . $sas_lang['links_module_title'] . " &nbsp;</span></td>
			<td><input type=\"text\" size=50 class=\"textfield\" name=\"link_title\" value=\"$link_list[1]\"></td></tr>";
	print "<tr><td colspan=\"3\">&nbsp;</td></tr>";
	print "<tr><td><span class=\"text\">" . $sas_lang['links_module_url'] . "&nbsp;</span></td>
			<td><input type=\"text\" size=50 class=\"textfield\" name=\"link_url\" value=\"$link_list[2]\"></td></tr>";
	print "<tr><td colspan=\"3\">&nbsp;</td></tr>";
	print "<tr><td valign=\"top\"><span class=\"text\">" . $sas_lang['links_module_description'] . "&nbsp;</span></td>
			<td><textarea cols=\"70\" rows=\"4\" name=\"link_description\">" . $link_list[3] . "</textarea></td></tr>";
	print "<tr><td colspan=\"3\">&nbsp;</td></tr>";
	print "<tr><td><span class=\"text\">" . $sas_lang['links_module_order'] . "&nbsp;</span></td>
			<td><input type=\"text\" size=4 class=\"textfield\" name=\"link_sort\" value=\"$link_list[4]\"></td></tr>";
	print "<tr><td colspan=\"3\">&nbsp;</td></tr>";
	print "<tr><td><span class=\"text\">" . $sas_lang['links_module_pagename'] . " &nbsp;</span></td>
			<td><select size=\"1\" class=text name=\"link_pagename\">";

	$query2 = "SELECT id, pagename FROM $table_links_cat";
	$result2 = mysql_query($query2) or die_script($query2, mysql_error());
	while ($category_list = mysql_fetch_array($result2))
	{
		if ($category_list[0] == $link_list[5])
		{
			print "<option selected value=\"$category_list[0]\">$category_list[1]</option>\n";
		}
		else
		{
			print "<option value=\"$category_list[0]\">$category_list[1]</option>\n";
		}
	}
	print "</select></TD></tr>";
	print "<tr><td colspan=\"3\">&nbsp;</td></tr>";
	print "<tr><td><span class=\"text\">" . $sas_lang['links_module_publish_propose_link'] . "&nbsp;</span></td><td><span class=\"text\">&nbsp;" . $sas_lang['yes'] . "</span>";
	if ($link_list[7] == "1")
	{
		print "<input type=\"radio\" value=\"1\" name=\"initial\" checked>";
		print "<span class=text>&nbsp;&nbsp;&nbsp; " . $sas_lang['no'] . "</span>";
		print "<input type=\"radio\" name=\"initial\" value=\"0\">";
	}
	else
	{
		print "<input type=\"radio\" value=\"1\" name=\"initial\">";
		print "<span class=text>&nbsp;&nbsp;&nbsp; " . $sas_lang['no'] . "</span>";
		print "<input type=\"radio\" name=\"initial\" value=\"0\" checked>";
	}
	print "</td></tr></table>";

	print "<p><input type=\"button\" value=\"&nbsp;&nbsp;&nbsp;$sas_lang[goback]\" name=\"backbutton\"
	onClick=\"javascript:parent.location='index.php?option=modulemanager&module=$module';\" class=\"backbutton\">";

	print "&nbsp;<input type=\"submit\" value=\"&nbsp;&nbsp;&nbsp;$sas_lang[save]\" name=\"savebutton\" class=\"savebutton\">";
	print "</span></form>";

	include ("interface/pageend.inc.php");
	include ("interface/footer.inc.php");
	exit;
}

print "<span class=\"heading\">$modulename</span>
<p><span class=\"text\">" . $sas_lang['links_module_intro'] . "</span> ";

if ($modoption == "proposed")
{
	print "<p><span class=\"text\"><b>" . $sas_lang['links_module_proposed'] . "</b></span>";
}

$query = "SELECT id, pagename,welcome, row_count, owner_email, icon FROM $table_links_cat";
$result = mysql_query($query) or die_script($query, mysql_error());
$Recordcount = mysql_num_rows($result); //number oflinks categories
if ($Recordcount > 0)
{
	print "<table border=\"0\">";

	while ($page_list = mysql_fetch_array($result)) //loop through pagenames
	{
		if ($modoption == "proposed")
		{
			$query2 = "SELECT category FROM $table_links WHERE pagename = $page_list[0] AND initial = 0 GROUP BY category";
			$query3 = "SELECT category FROM $table_links WHERE pagename = $page_list[0] AND initial = 0 ";
		}
		else
		{
			$query2 = "SELECT category FROM $table_links WHERE pagename = $page_list[0] AND initial = 1 GROUP BY category";
			$query3 = "SELECT category FROM $table_links WHERE pagename = $page_list[0] AND initial = 1 ";
		}
		$result2 = mysql_query($query2) or die_script($query2, mysql_error());
		$result3 = mysql_query($query3) or die_script($query3, mysql_error());
		$Recordcount1 = mysql_num_rows($result3); //number of links

		print "	<tr><td colspan=\"3\">&nbsp;</td></tr>
						<tr><td><img border=\"0\" src=\"graphics/delete.gif\" alt=\"" . $sas_lang['delete'] . "\" title=\"" . $sas_lang['delete'] . "\" width=\"16\" height=\"16\" 
						onClick=\"if(confirm('$sas_lang[links_module_cat_delete_confirm]'))
						parent.location='index.php?option=modulemanager&module=$module&modoption=$modoption&delete_cat=$page_list[0]';\">
						<img border=\"0\" src=\"graphics/edit.gif\" alt=\"" . $sas_lang['edit'] . "\" title=\"" . $sas_lang['edit'] . "\" width=\"16\" height=\"16\" 
						onClick=\"parent.location='index.php?option=modulemanager&module=$module&modoption=edit_page_link&id=$page_list[0]'\">
						<td colspan=\"2\"><span class=\"link\"><a href=index.php?option=modulemanager&module=$module&modoption=$modoption&pagename=$page_list[0]>" . $page_list[1] . "</a> ($Recordcount1)</span></td></tr>";

		if ($page_list[0] == $pagename)
		{
			if ($Recordcount1 == 0)
			{
				print "<tr><td>&nbsp;</td><td><span class=\"text\">" . $sas_lang['links_module_no_links'] . "</span></td></tr>";
			}
			while ($cat_list = mysql_fetch_array($result2))
			{
				print "<tr><td>&nbsp;</td><td colspan=\"2\"><span class=\"text\"><b><i>$cat_list[0]</i></b></span></td></tr>";
				if ($modoption == "proposed")
				{
					$query3 = "SELECT id, title, url, description, pagename, sort FROM $table_links WHERE pagename = '$pagename' AND initial = '0' AND category = '$cat_list[0]' ORDER BY sort";
				}
				else
				{
					$query3 = "SELECT id, title, url, description, pagename, sort FROM $table_links WHERE pagename = '$pagename' AND initial = '1' AND category = '$cat_list[0]' ORDER BY sort";
				}
				$result3 = mysql_query($query3) or die_script($query3, mysql_error());

				while ($links_list = mysql_fetch_array($result3))
				{
					print "<tr><td colspan=\"2\">&nbsp;</td>
											  <td><img border=\"0\" src=\"graphics/delete.gif\" alt=\"" . $sas_lang['delete'] . "\" title=\"" . $sas_lang['delete'] . "\" width=\"16\" height=\"16\" 
											  onClick=\"if(confirm('$sas_lang[links_module_delete_confirm]'))
											  parent.location='index.php?option=modulemanager&module=$module&modoption=$modoption&pagename=$pagename&delete_link=$links_list[0]';\">
											  <img border=\"0\" src=\"graphics/edit.gif\" alt=\"" . $sas_lang['edit'] . "\" title=\"" . $sas_lang['edit'] . "\" width=\"16\" height=\"16\" 
											  onClick=\"parent.location='index.php?option=modulemanager&module=$module&modoption=$modoption&edit_link=$links_list[0]'\">
											  &nbsp;<span class=link><a href=\"index.php?option=modulemanager&module=$module&modoption=$modoption&pagename=$page_list[0]&edit_link=$links_list[0]\">$links_list[1]</a> ($links_list[5])</span></td>
											  </tr>";

				}
			}
		}
	}
}
else
{
	print "<p><span class=text>" . $sas_lang['links_module_addcategory_please'] . "</span>";
}
print "</table><p><p><img border=\"0\" src=\"graphics/document.gif\">
       <span class=\"link\"><a href=\"index.php?option=modulemanager&module=$module&modoption=add_page_link\">" . $sas_lang['links_module_add_page_link'] . "</a></span>
	   &nbsp;&nbsp;<img border=\"0\" src=\"graphics/document.gif\">
       <span class=\"link\"><a href=\"index.php?option=modulemanager&module=$module&pagename=$pagename&modoption=add_link\">" . $sas_lang['links_module_add'] . "</a></span><p>";
print "<input type=\"button\" value=\"&nbsp;&nbsp;&nbsp;" . $sas_lang['goback'] . "\" name=\"backbutton\" onClick=\"javascript:parent.location='index.php?option=modulemanager';\" class=\"backbutton\">";

include ("interface/pageend.inc.php");
include ("interface/footer.inc.php");
?>
