<?php
// $Id: main.php,v 1.1 2004/07/11 10:28:49 Farsus Exp $
// -------------------------------------------------------------------------//
//			       RUNCMS                                                   //
//                                                                          //
//	 reliable - Unique - Nocost &  Simplicity & ease off use                //
//                       < http://www.runcms.org >                          //
// -------------------------------------------------------------------------//
// Original Author: Kazumi Ono
// Author Website : http://www.mywebaddons.com/ , http://www.myweb.ne.jp
// License Type   : GPL: See /manual/LICENSES/GPL.txt
// ------------------------------------------------------------------------- //

if ( !preg_match("/admin\.php/i", _PHP_SELF) ) {
	exit();
	}

include (XOOPS_ROOT_PATH."/modules/system/admin/blocksadmin/blocksadmin.php");
$op = "list";

if ( isset($HTTP_POST_VARS) ) {
	foreach ( $HTTP_POST_VARS as $k => $v ) {
		$$k = $v;
	}
}

if ( isset($HTTP_GET_VARS['op']) ) {
	if ( $HTTP_GET_VARS['op'] == "edit" || $HTTP_GET_VARS['op'] == "copy" || $HTTP_GET_VARS['op'] == "list" || $HTTP_GET_VARS['op'] == "delete" || $HTTP_GET_VARS['op'] == "delete_ok" ) {
		$op  = $HTTP_GET_VARS['op'];
		$bid = $HTTP_GET_VARS['bid'];
	}
}

if ( $op == "list" ) {
	xoops_cp_header();
	list_blocks($HTTP_POST_VARS['bcmodule']);
	xoops_cp_footer();
	exit();
}

if ( $op == "order" ) {
	$size = count($bid);
	for ( $i = 0; $i < $size; $i++ ) {
		if ( $oldweight[$i] != $weight[$i] || $oldvisible[$i] != $visible[$i] || $oldside[$i] != $side[$i] || $oldbcmodule[$i] != $bcmodule[$i] )
		order_block($bid[$i], $weight[$i], $visible[$i], $side[$i], $bcmodule[$i]);
	}
	redirect_header("admin.php?fct=blocksadmin", 1, _UPDATED);
	exit();
}

if ( $op == "save" ) {
	save_block($bside, $bweight, $bvisible, $btitle, $bcontent, $bctype, $bcmodule);
	exit();
}

if ( $op == "copy" ) {
	copy_block($bid);
	exit();
}

if ( $op == "update" ) {
	update_block($bid, $bside, $bweight, $bposition, $bvisible, $btitle, $bcontent, $bctype, $options, $bcmodule, $read_access);
	exit();
}

if ( $op == "delete" ) {
	delete_block($bid);
	exit();
}

if ( $op == "edit" ) {
	xoops_cp_header();
	edit_block($bid);
	xoops_cp_footer();
	exit();
}


if ( $op == "preview" ) {
	xoops_cp_header();
	preview_cblock($bid, $btitle, $bcontent, $bctype, $bposition, $options);
	edit_block($bid, $op);
	xoops_cp_footer();
	exit();
}
?>
