<?php
include("admin_header.php");
include_once(XOOPS_ROOT_PATH."/class/xoopstopic.php");
include_once(XOOPS_ROOT_PATH."/modules/".$xoopsModule->dirname()."/class/class.newsstory.php");
include_once(XOOPS_ROOT_PATH."/class/module.errorhandler.php");
include(XOOPS_ROOT_PATH."/modules/".$xoopsModule->dirname()."/cache/config.php");

/*
 * Show new submissions
 */
function newSubmissions(){
	global $xoopsConfig, $xoopsDB;
	$storyarray = NewsStory::getAllSubmitted();
	if ( count($storyarray) > 0 ) {
		OpenTable();
		echo "<div style='text-align: center;'><b>"._AM_NEWSUB."</b><br /><table width='100%' border='1'><tr class='bg2'><td align='center'>"._AM_TITLE."</td><td align='center'>"._AM_POSTED."</td><td align='center'>"._AM_POSTER."</td><td align='center'>"._AM_ACTION."</td></tr>\n";
		foreach($storyarray as $newstory){
			echo "<tr><td>\n";
			$title = $newstory->title();
			if ( !isset($title) || ($title == "") ) {
			    echo "<a href='index.php?op=edit&amp;storyid=".$newstory->storyid()."'>"._AD_NOSUBJECT."</a>\n";
			} else {
			    echo "&nbsp;<a href='index.php?op=edit&amp;storyid=".$newstory->storyid()."'>".$title."</a>\n";
			}
			echo "</td><td align='center' class='nw'>".formatTimestamp($newstory->created())."</td><td align='center'><a href='".XOOPS_URL."/userinfo.php?uid=".$newstory->uid()."'>".$newstory->uname()."</a></td><td align='right'><a href='index.php?op=delete&amp;storyid=".$newstory->storyid()."'>"._AM_DELETE."</a></td></tr>\n";
		}
		echo "</table></div>\n";
		CloseTable();
		echo "<br />";
	}
}

/*
 * Shows automated stories
 */
function autoStories(){
    	global $xoopsDB, $xoopsConfig, $xoopsModule;
	$storyarray = NewsStory::getAllAutoStory();
	if ( count($storyarray) > 0 ) {
		OpenTable();
    		echo "<div style='text-align: center;'><b>"._AM_AUTOARTICLES."</b><br />\n";
		echo "<table border='1' width='100%'><tr class='bg2'><td align='center'>"._AM_STORYID."</td><td align='center'>"._AM_TITLE."</td><td align='center'>"._AM_TOPIC."</td><td align='center'>"._AM_POSTER."</td><td align='center' class='nw'>"._AM_PROGRAMMED."</td><td align='center'>"._AM_ACTION."</td></tr>";
    		foreach($storyarray as $autostory){
			$topic = $autostory->topic();
        		echo "
        		<tr><td align='center'><b>".$autostory->storyid()."</b>
        		</td><td align='left'><a href='".XOOPS_URL."/modules/".$xoopsModule->dirname()."/article.php?storyid=".$autostory->storyid()."'>".$autostory->title()."</a>
        		</td><td align='center'>".$topic->topic_title()."
        		</td><td align='center'><a href='".XOOPS_URL."/userinfo.php?uid=".$autostory->uid()."'>".$autostory->uname()."</a></td><td align='center' class='nw'>".formatTimestamp($autostory->published())."</td><td align='center'><a href='index.php?op=edit&amp;storyid=".$autostory->storyid()."'>"._AM_EDIT."</a>-<a href='index.php?op=delete&amp;storyid=".$autostory->storyid()."'>"._AM_DELETE."</a>";
        		echo "</td></tr>\n";
    		}
    		echo "</table>";
		echo "</div>";
		CloseTable();
		echo "<br />";
	}
}

/*
 * Shows last 10 published stories
 */
function lastStories() {
    	global $xoopsDB, $xoopsConfig, $xoopsModule;
	OpenTable();
    	echo "<div style='text-align: center;'><b>"._AM_LAST10ARTS."</b><br />";
	$storyarray = NewsStory::getAllPublished(10, 0, 0, 1);
    	echo "<table border='1' width='100%'><tr class='bg2'><td align='center'>"._AM_STORYID."</td><td align='center'>"._AM_TITLE."</td><td align='center'>"._AM_TOPIC."</td><td align='center'>"._AM_POSTER."</td><td align='center' class='nw'>"._AM_PUBLISHED."</td><td align='center'>"._AM_ACTION."</td></tr>";
    	foreach($storyarray as $eachstory){
		$published = formatTimestamp($eachstory->published());
		$topic = $eachstory->topic();
        	echo "
        	<tr><td align='center'><b>".$eachstory->storyid()."</b>
        	</td><td align='left'><a href='".XOOPS_URL."/modules/".$xoopsModule->dirname()."/article.php?storyid=".$eachstory->storyid()."'>".$eachstory->title()."</a>
        	</td><td align='center'>".$topic->topic_title()."
        	</td><td align='center'><a href='".XOOPS_URL."/userinfo.php?uid=".$eachstory->uid()."'>".$eachstory->uname()."</a></td><td align='center' class='nw'>".$published."</td><td align='center'><a href='index.php?op=edit&amp;storyid=".$eachstory->storyid()."'>"._AM_EDIT."</a>-<a href='index.php?op=delete&amp;storyid=".$eachstory->storyid()."'>"._AM_DELETE."</a>";
        	echo "</td></tr>\n";
    	}
    	echo "</table><br />";
	echo "<form action='index.php' method='post'>
    	"._AM_STORYID." <input type='text' name='storyid' size='10' />
    	<select name='op'>
    	<option value='edit' selected='selected'>"._AM_EDIT."</option>
    	<option value='delete'>"._AM_DELETE."</option>
    	</select>
    	<input type='submit' value='"._AM_GO."' />
    	</form>
	</div>
    	";
    	CloseTable();
}

function topicsmanager(){
	global $xoopsDB, $xoopsConfig, $xoopsModule;
	xoops_cp_header();
	$xt = new XoopsTopic($xoopsDB->prefix("topics"));
	//$xoopsModule->printAdminMenu();
	//echo "<br />";
// Add a New Main Topic
    	OpenTable();
   	echo "<form method='post' action='index.php'>\n";
    	echo "<h4>"._AM_ADDMTOPIC."</h4><br />";
	echo "<b>"._AM_TOPICNAME."</b> "._AM_MAX40CHAR."<br /><input type='text' name='topic_title' size='20' maxlength='20' /><br />";
	echo "<b>"._AM_TOPICIMG."</b> (". sprintf(_AM_IMGNAEXLOC,"modules/".$xoopsModule->dirname()."/images/topics/").")<br />"._AM_FEXAMPLE."<br /><input type='text' name='topic_imgurl' size='20' maxlength='20' /><br />";
	echo "<br />";
	echo "<input type='hidden' name='topic_pid' value='0' />\n";
	echo "<input type='hidden' name='op' value='addTopic' />";
	echo "<input type='submit' value="._AM_ADD." /><br /></form>";
    	CloseTable();
    	echo "<br />";
// Add a New Sub-Topic
    	$result=$xoopsDB->query("select count(*) from ".$xoopsDB->prefix("topics")."");
	list($numrows)=$xoopsDB->fetchRow($result);
    	if ($numrows>0) {
		OpenTable();
    		echo "<form method='post' action='index.php'>";
    		echo "<h4>"._AM_ADDSUBTOPIC."</h4><br />";
		echo "<b>"._AM_TOPICNAME."</b> "._AM_MAX40CHAR."<br /><input type='text' name='topic_title' size='20' maxlength='40' />"._AM_IN."&nbsp;";
		$xt->makeTopicSelBox(0,0,"topic_pid");
		echo "<br />";
		echo "<b>"._AM_TOPICIMG."</b> (". sprintf(_AM_IMGNAEXLOC,"modules/".$xoopsModule->dirname()."/images/topics/").")<br />"._AM_FEXAMPLE."<br /><input type='text' name='topic_imgurl' size='20' maxlength='20' /><br />";

		echo "<br />";
    		echo "<input type='hidden' name='op' value='addTopic' />";
		echo "<input type='submit' value='"._AM_ADD."' /><br /></form>";
		CloseTable();
		echo "<br />";
   	
// Modify Topic
    		OpenTable();
    		echo "
    		<form method='post' action='index.php'>
    		<h4>"._AM_MODIFYTOPIC."</h4><br />";
    		echo "<b>"._AM_TOPIC."</b><br />";
    		$xt->makeTopicSelBox();
    		echo "<br /><br />\n";
    		echo "<input type='hidden' name='op' value='modTopic' />\n";
    		echo "<input type='submit' value='"._AM_MODIFY."' />\n";
		echo "</form>";
		CloseTable();
    	}
}

function modTopic() {
    	global $xoopsDB, $HTTP_POST_VARS, $xoopsConfig;
	global $xoops_newsConfig, $xoopsModule;
	$xt = new XoopsTopic($xoopsDB->prefix("topics"), $HTTP_POST_VARS['topic_id']);
	xoops_cp_header();
	//$xoopsModule->printAdminMenu();
	//echo "<br />";
    	OpenTable();
    	echo "<h4>"._AM_MODIFYTOPIC."</h4><br />";
	echo "<div style='text-align: right;'><img src='".XOOPS_URL."/modules/".$xoopsModule->dirname()."/images/topics/".$xt->topic_imgurl()."'></div>";
	echo "<form action='index.php' method='post'>";
	echo "<b>"._AM_TOPICNAME."</b>&nbsp;"._AM_MAX40CHAR."<br /><input type='text' name='topic_title' size='20' maxlength='40' value='".$xt->topic_title()."' /><br />";
	echo "<b>"._AM_TOPICIMG."</b>&nbsp;(". sprintf(_AM_IMGNAEXLOC,"modules/".$xoopsModule->dirname()."/images/topics/").")<br />"._AM_FEXAMPLE."<br /><input type='text' name='topic_imgurl' size='20' maxlength='20' value='".$xt->topic_imgurl()."' /><br />\n";
	echo "<b>"._AM_PARENTTOPIC."<b><br />\n";
	$xt->makeTopicSelBox(1, $xt->topic_pid(), "topic_pid");
	echo "\n<br /><br />";

	echo "<input type='hidden' name='topic_id' value='".$xt->topic_id()."' />\n";
	echo "<input type='hidden' name='op' value='modTopicS' />";
	echo "<input type='submit' value='"._AM_SAVECHANGE."' />&nbsp;<input type='button' value='"._AM_DEL."' onclick='location=\"index.php?topic_pid=".$xt->topic_pid()."&amp;topic_id=".$xt->topic_id()."&amp;op=delTopic\"' />\n";
	echo "&nbsp;<input type='button' value='"._AM_CANCEL."' onclick='javascript:history.go(-1)' />\n";
	echo "</form>";
    	CloseTable();
}
function modTopicS() {
    	global $xoopsDB, $HTTP_POST_VARS;
    	$xt = new XoopsTopic($xoopsDB->prefix("topics"), $HTTP_POST_VARS['topic_id']);
	if ( $HTTP_POST_VARS['topic_pid'] == $HTTP_POST_VARS['topic_id'] ) {
		echo "ERROR: Cannot select this topic for parent topic!";
		exit();
	}
	$xt->setTopicPid($HTTP_POST_VARS['topic_pid']);
	$xt->setTopicTitle($HTTP_POST_VARS['topic_title']);
	if ( isset($HTTP_POST_VARS['topic_imgurl']) && $HTTP_POST_VARS['topic_imgurl'] != "" ) {
		$xt->setTopicImgurl($HTTP_POST_VARS['topic_imgurl']);
	}
	$xt->store();
	redirect_header("index.php?op=topicsmanager",1,_AM_DBUPDATED);
	exit();
}
function delTopic() {
    	global $xoopsDB, $HTTP_POST_VARS, $HTTP_GET_VARS, $xoopsConfig, $xoopsModule;
    	if ( $HTTP_GET_VARS['ok'] != 1 ) {
		xoops_cp_header();
		//$xoopsModule->printAdminMenu();
		//echo "<br />";
		OpenTable();
		echo "<div style='text-align: center;'>";
		echo "<h4><font color='#ff0000'>";
		echo ""._AM_WAYSYWTDTTAL."</font></h4><br />";
		echo "<table><tr><td>\n";
		echo myTextForm("index.php?op=delTopic&topic_id=".$HTTP_GET_VARS['topic_id']."&ok=1",_AM_YES);
		echo "</td><td>\n";
		echo myTextForm("index.php?op=topicsmanager",_AM_NO);
		echo "</td></tr></table>\n";
		echo "</div><br /><br />";
    		CloseTable();
    	} else {
		$xt = new XoopsTopic($xoopsDB->prefix("topics"),$HTTP_GET_VARS['topic_id']);
		//get all subtopics under the specified topic
		$topic_arr = $xt->getAllChildTopics();
		array_push($topic_arr, $xt);
		foreach($topic_arr as $eachtopic){
			//get all stories in each topic
			$story_arr = NewsStory::getByTopic($eachtopic->topic_id());
			foreach($story_arr as $eachstory){
				$eachstory->delete();
			}
			//all stories for each topic is deleted, now delete the topic data
    	    		$eachtopic->delete();
		}
		redirect_header("index.php?op=topicsmanager",1,_AM_DBUPDATED);
		exit();	
    	}
}

function addTopic() {
    	global $xoopsDB, $HTTP_POST_VARS;
	$xt = new XoopsTopic($xoopsDB->prefix("topics"));
    	$xt->setTopicPid($HTTP_POST_VARS['topic_pid']);
    	$xt->setTopicTitle($HTTP_POST_VARS['topic_title']);
    	if ( isset($HTTP_POST_VARS['topic_imgurl']) && $HTTP_POST_VARS['topic_imgurl'] != "" ) {
		$xt->setTopicImgurl($HTTP_POST_VARS['topic_imgurl']);
	}
	$xt->store();
	redirect_header("index.php?op=topicsmanager",1,_AM_DBUPDATED);
	exit();
}


function newsConfig() {
	global $xoopsConfig, $xoopsModule, $xoops_newsConfig;
	xoops_cp_header();
	//$xoopsModule->printAdminMenu();
	//echo "<br />";
	OpenTable();
	echo "<h4>" . _AM_GENERALCONF . "</h4><br>";
	echo "<form action='index.php' method='post'>";
    	echo "
    	<table width='100%' border='0'><tr><td class='nw'>
    	"._AM_STORYHOME."</td><td width='100%'>
        <select name='storyhome'>
        <option value='".$xoops_newsConfig['storyhome']."' selected='selected'>".$xoops_newsConfig['storyhome']."</option>
	<option value='5'>5</option>
        <option value='10'>10</option>
        <option value='15'>15</option>
        <option value='20'>20</option>
        <option value='25'>25</option>
        <option value='30'>30</option>
    	</select>";
	echo "</td></tr>";
	echo "<tr><td class='nw'>" . _AM_NOTIFYSUBMIT . "</td><td>";
	if ($xoops_newsConfig['notifysubmit']==1) {
		echo "<input type='radio' name='notifysubmit' value='1' checked='checked' />&nbsp;" ._AM_YES."&nbsp;";
		echo "<input type='radio' name='notifysubmit' value='0' />&nbsp;" ._AM_NO."&nbsp;";
	} else {
		echo "<input type='radio' name='notifysubmit' value='1' />&nbsp;" ._AM_YES."&nbsp;";
		echo "<input type='radio' name='notifysubmit' value='0' checked='checked' />&nbsp;" ._AM_NO."&nbsp;";
	}
	
	echo "</td></tr>";
	echo "<tr><td class='nw'>" . _AM_DISPLAYNAV . "</td><td>";
	if ($xoops_newsConfig['displaynav']==1) {
		echo "<input type='radio' name='displaynav' value='1' checked='checked' />&nbsp;" ._AM_YES."&nbsp;";
		echo "<input type='radio' name='displaynav' value='0' />&nbsp;" ._AM_NO."&nbsp;";
	} else {
		echo "<input type='radio' name='displaynav' value='1' />&nbsp;" ._AM_YES."&nbsp;";
		echo "<input type='radio' name='displaynav' value='0' checked='checked' />&nbsp;" ._AM_NO."&nbsp;";
	}
	
	echo "</td></tr>";
    	echo "</table>";
    	echo "<input type='hidden' name='op' value='newsConfigS' />";
    	echo "<input type='submit' value='"._AM_SAVECHANGE."' />";
	echo "&nbsp;<input type='button' value='"._AM_CANCEL."' onclick='javascript:history.go(-1)' />";
    	echo "</form>";
    	CloseTable();

}

function newsConfigS() {
	global $xoopsConfig, $HTTP_POST_VARS;

	$filename = "../cache/config.php";
	$file = fopen($filename, "w");
	$content = "";
	$content .= "<?php\n";
	$content .= "\n";
	$content .= "###############################################################################\n";
	$content .= "# News Module\n";
	$content .= "#\n";
	$content .= "# \$xoops_newsConfig['storyhome']:	"._AM_STORYHOME."\n";
	$content .= "# \$xoops_newsConfig['notifysubmit']:	"._AM_NOTIFYSUBMIT." 1="._AM_YES." 0="._AM_NO."\n";
	$content .= "# \$xoops_newsConfig['displaynav']:    	"._AM_DISPLAYNAV." 1="._AM_YES." 0="._AM_NO."\n";
	$content .= "###############################################################################\n";
	$content .= "\n";
	$content .= "\$xoops_newsConfig['storyhome'] = ".$HTTP_POST_VARS['storyhome'].";\n";
	$content .= "\$xoops_newsConfig['notifysubmit'] = ".$HTTP_POST_VARS['notifysubmit'].";\n";
	$content .= "\$xoops_newsConfig['displaynav'] = ".$HTTP_POST_VARS['displaynav'].";\n";
	$content .= "\n";
	$content .= "?>";

	fwrite($file, $content);
    	fclose($file);

	redirect_header(XOOPS_ADMIN_URL,1,_AM_DBUPDATED);
	exit();
}


switch($op){
	case "edit":
		xoops_cp_header();
		//$xoopsModule->printAdminMenu();
		//echo "<br />";
		OpenTable();
		echo "<h4>"._AM_EDITARTICLE."</h4>";
		$story = new NewsStory($storyid);
		$title = $story->title("Edit");
		$hometext = $story->hometext("Edit");
		$bodytext = $story->bodytext("Edit");
		$nohtml = $story->nohtml();
		$nosmiley = $story->nosmiley();
		$ihome = $story->ihome();
		$topicid = $story->topicid();
		$published = $story->published();
//		$notifypub = $story->notifypub();
		$type = $story->type();
		$topicdisplay = $story->topicdisplay();
		$topicalign = $story->topicalign(false);
		$isedit = 1;
		include("storyform.inc.php");
		CloseTable();
		break;

	case "newarticle":
		xoops_cp_header();
		include_once(XOOPS_ROOT_PATH."/class/module.textsanitizer.php");
		//$xoopsModule->printAdminMenu();
		//echo "<br />";
		newSubmissions();
		autoStories();
		lastStories();
		echo "<br />";
		OpenTable();
		echo "<h4>"._AM_POSTNEWARTICLE."</h4>";
		$type = "admin";
		include("storyform.inc.php");
		CloseTable();
		break;

	case "preview":
		xoops_cp_header();
		if(isset($storyid)){
			$story = new NewsStory($storyid);
			$published = $story->published();
		}else{
			$story = new NewsStory();
		}
		$story->setTitle($title);
		$story->setHomeText($hometext);
		$story->setBodyText($bodytext);
		if(isset($nohtml) && ($nohtml == 0 || $nohtml == 1)){
			$story->setNohtml($nohtml);
		}
		if(isset($nosmiley) && ($nosmiley == 0 || $nosmiley == 1)){
			$story->setNosmiley($nosmiley);
		}

		$xt = new XoopsTopic($xoopsDB->prefix("topics"));
		$p_title = $story->title("Preview");
		$p_hometext = $story->hometext("Preview");
		$p_bodytext = $story->bodytext("Preview");
		$title = $story->title("InForm");
		$hometext = $story->hometext("InForm");
		$bodytext = $story->bodytext("InForm");
		//$xoopsModule->printAdminMenu();
		//echo "<br />";
		OpenTable();
		OpenTable("75%");
		if ( $topicdisplay ) {
			if ( $topicalign == "L" ){
				$align = "left";
			} else {
				$align = "right";
			}
			if ( empty($topicid) ) {
	    			$warning = "<div style='text-align: center;'><blink><b>"._AR_SELECTTOPIC."</b></blink></div>";
				$timage = "";
			} else {
	    			$warning = "";
				$xt = new XoopsTopic($xoopsDB->prefix("topics"), $topicid);
				$timage = "<img src='".XOOPS_URL."/modules/news/images/topics/".$xt->topic_imgurl()."' align='$align' border='0' hspace='10' vspace=10' />";
			}
		} else {
			$timage = "";
		}
		if ( isset($p_bodytext) && $p_bodytext != "" ) {
    			echo "<p><b>".$p_title."</b><br /><br />".$timage."".$p_hometext."<br /><br />".$p_bodytext."<br /><br /></p>";
		} else {
			echo "<p><b>".$p_title."</b><br /><br />".$timage."".$p_hometext."<br /><br /></p>";
		}
		echo $warning;
		CloseTable();
		include("storyform.inc.php");
		CloseTable();
		break;

	case "save":
		if ( empty($storyid) ) {
			$story = new NewsStory();
			$story->setUid($xoopsUser->uid());
			if ( $autodate ) {
				$pubdate = mktime($autohour, $automin, 0, $automonth, $autoday, $autoyear);
				$offset = $xoopsUser->timezone() - $xoopsConfig['server_TZ'];
				$pubdate = $pubdate - ($offset * 3600);
				$story->setPublished($pubdate);
			} else {
				$story->setPublished(time());
			}
			$story->setType($type);
			$story->setHostname(getenv("REMOTE_ADDR"));
//			$story->setNotifyPub($notifypub);
		} else {
			$story = new NewsStory($storyid);
			if ( !empty($autodate) ) {
    				$pubdate = mktime($autohour, $automin, 0, $automonth, $autoday, $autoyear);
				$offset = $xoopsUser->timezone();
				$offset = $offset - $xoopsConfig['server_TZ'];
				$pubdate = $pubdate - ($offset * 3600);
				$story->setPublished($pubdate);
			} elseif ( ($story->published() == 0) && $approve ) {
				$story->setPublished(time());
				$isnew = 1;
			} else {
				if ( !empty($movetotop) ) {
					$story->setPublished(time());
				}
			}
		}
		$story->setApproved($approve);
		$story->setTopicId($topicid);
		$story->setTitle($title);
		$story->setHometext($hometext);
		$story->setBodytext($bodytext);
		$story->setNohtml($nohtml);
		$story->setNosmiley($nosmiley);
		$story->setIhome($ihome);
		$story->setTopicalign($topicalign);
		$story->setTopicdisplay($topicdisplay);
		$story->store();
		if ( !empty($isnew) && $story->notifypub() && $story->uid() != 0 ) {
			$poster = new XoopsUser($story->uid());
			$subject = _AM_ARTPUBLISHED;
			$message = sprintf(_AM_HELLO,$poster->uname());
			$message .= "\n\n"._AM_YOURARTPUB."\n\n";
			$message .= _AM_TITLEC.$story->title()."\n"._AM_URLC.XOOPS_URL."/modules/".$xoopsModule->dirname()."/article.php?storyid=".$story->storyid()."\n"._AM_PUBLISHEDC.formatTimestamp($story->published(),"m",0)."\n\n";
			$message .= $xoopsConfig['sitename']."\n".XOOPS_URL."";
			$xoopsMailer =& getMailer();
			$xoopsMailer->useMail();
			$xoopsMailer->setToEmails($poster->getVar("email"));
			$xoopsMailer->setFromEmail($xoopsConfig['adminmail']);
			$xoopsMailer->setFromName($xoopsConfig['sitename']);
			$xoopsMailer->setSubject($subject);
			$xoopsMailer->setBody($message);
			$xoopsMailer->send();
		}
		redirect_header(XOOPS_ADMIN_URL,1,_AM_DBUPDATED);
		exit();
		break;

	case "delete":
		if ( $ok ) {
			$story = new NewsStory($storyid);
			$story->delete();
			redirect_header(XOOPS_ADMIN_URL,1,_AM_DBUPDATED);
			exit();
		} else {
			xoops_cp_header();
			OpenTable();
			echo "<div>";
			echo "<h4 style='color:#ff0000'>"._AM_RUSUREDEL."</h4>";
			echo "<table><tr><td>\n";
			echo myTextForm("index.php?op=delete&storyid=".$storyid."&ok=1" , _AM_YES);
			echo "</td><td>\n";
			echo myTextForm("javascript:history.go(-1)" , _AM_NO);
			echo "</td></tr></table>\n";

			echo "</div>";
			CloseTable();
		}
		break;
	case "topicsmanager":
		topicsmanager();
		break;

	case "addTopic":
		addTopic();
		break;

	case "delTopic":
		delTopic();
		break;
	case "modTopic":
		modTopic();
		break;
	case "modTopicS":
		modTopicS();
		break;
	case "newsConfig":
		newsConfig();
		break;
	case "newsConfigS":
		if (xoopsfwrite()) {
			newsConfigS();
		}
		break;
	case "default":
	default:
		xoops_cp_header();
		OpenTable();
		echo " - <b><a href='index.php?op=newsConfig'>"._AM_GENERALCONF."</a></b><br /><br />\n";
		echo " - <b><a href='index.php?op=topicsmanager'>"._AM_TOPICSMNGR."</a></b>";
		echo "<br /><br />\n";
		echo " - <b><a href='index.php?op=newarticle'>"._AM_PEARTICLES."</a></b>\n";
    		CloseTable();
		break;
}

xoops_cp_footer();
?>