<?php
/************************************************************************/
/* Maximus CMS: Web Portal System                                       */
/* ==============================                                       */
/*                                                                      */
/* Copyright (c) 2002 - 2006                                            */
/* http://www.php-maximus.fr                                            */
/* dev@php-maximus.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; either version 2 of the License.       */
/************************************************************************/
/* Based on PHP-NUKE: Web Portal System                                 */
/************************************************************************/
if (!defined('ADMIN_ALLOW') && !defined('ADMIN_MAX')) {
	die ("Access Denied");
}

if ($acces == 1) {
if($admintest && $adminsecu)  {

if (!defined('SECUR_MAX')) {
	die ();
}

if (!is_god($admin)) { redirect_url("".$admin_file.".php"); }
if (!is_admin($admin)) { redirect_url("".$admin_file.".php"); }
if (!is_user($user)) { redirect_url("".$admin_file.".php"); }

		$del_aid = substr("$del_aid", 0,25);
		$result = $GLOBALS['db']->sql_query("SELECT `admins` FROM `".TABLE_MODULES."` WHERE `title`='News'");
		$row2 = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("SELECT `name` FROM `".TABLE_AUTHORS."` WHERE `aid`='$del_aid'"));
		while ($row = $GLOBALS['db']->sql_fetchrow($result)) {
			$admins = explode(",", $row['admins']);
			$auth_user = 0;
			for ($i=0; $i < sizeof($admins); $i++) {
				if ($row2['name'] == "$admins[$i]") {
					$auth_user = 1;
				}
			}
			if ($auth_user == 1) {
				$radminarticle = 1;
			}
		}
		if ($radminarticle == 1) {
			$row2 = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("SELECT `sid` FROM `".TABLE_STORIES."` WHERE `aid`='$del_aid'"));
			$sid = $GLOBALS['db']->XMFnum($row2['sid']);
			if ($sid != "") {
				incoh();
				Max_OpenTable();
				echo "<center><font class='title'><b>" . _AUTHORSADMIN . "</b></font></center>";
				Max_CloseTable();
				br('1');
				Max_OpenTable();
				echo "<center><font class=\"option\"><b>" . _PUBLISHEDSTORIES . "</b></font><br /><br />"
				."" . _SELECTNEWADMIN . ":<br /><br />";
				$result3 = $GLOBALS['db']->sql_query("SELECT `aid` FROM `".TABLE_AUTHORS."` WHERE `aid`!='$del_aid'");
				echo "<form action=\"".$admin_file.".php\" method=\"post\"><select name=\"newaid\">";
				while ($row3 = $GLOBALS['db']->sql_fetchrow($result3)) {
					$oaid = stripslashes($row3['aid']);
					$oaid = substr("$oaid", 0,25);
					echo "<option name=\"newaid\" value=\"$oaid\">$oaid</option>";
				}
				echo "</select><input type=\"hidden\" name=\"del_aid\" value=\"$del_aid\">"
				."<input type=\"hidden\" name=\"op\" value=\"assignstories\">"
				."<input type=\"submit\" value=\"" . _OK . "\">"
				."</form>";
				Max_CloseTable();
				incof();
				return;
			}
		}
		redirect_url("".$admin_file.".php?op=delpromotionconf&del_aid=$del_aid");

}
}else {
	echo "Access Denied";
}