<?php
// $Id: groupform.php,v 1.1 2004/07/11 10:28:51 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
// ------------------------------------------------------------------------- //

global $HTTP_SERVER_VARS;
if ( preg_match("/groupform\.php/i", $HTTP_SERVER_VARS['PHP_SELF']) ) {
	exit();
	}

include_once(XOOPS_ROOT_PATH."/class/xoopsformloader.php");

$name_text      = new XoopsFormText(_AM_NAME, "name", 30, 50, $name_value);
$desc_text      = new XoopsFormTextArea(_AM_DESCRIPTION, "desc", $desc_value);


// GET modules with admin rights
$modules_array  = array();
$modules_array  = XoopsModule::getHasAdminModulesList();
$a_mod_checkbox = new XoopsFormCheckBox(_AM_ACTIVERIGHTS, "admin_mids[]", $a_mod_value);
foreach ($modules_array as $key=>$value) {
	$modules_array[$key] = $value."<br />";
}
$a_mod_checkbox->addOptionArray($modules_array);


// GET normal modules
$modules_array  = array();
$modules_array  = XoopsModule::getHasMainModulesList();
$r_mod_checkbox = new XoopsFormCheckBox(_AM_ACCESSRIGHTS, "read_mids[]", $r_mod_value);
foreach ($modules_array as $key=>$value) {
	$modules_array[$key] = "$value<br />";
}
$r_mod_checkbox->addOptionArray($modules_array);


// GET leftblocks
$new_blocks_array  = array();
$r_lblock_checkbox = new XoopsFormCheckBox(_AM_BLOCKRIGHTS.":<br /><i>"._LEFT."</i>", "read_bids[]", $r_block_value);
$blocks_array      = XoopsBlock::getAllBlocks("list", XOOPS_SIDEBLOCK_LEFT, 1, "weight", 1);
foreach ($blocks_array as $key=>$value) {
	$new_blocks_array[$key] = "<a href='".XOOPS_URL."/modules/system/admin.php?fct=blocksadmin&op=edit&bid=".$key."'>".$value."</a><br />";
}
$r_lblock_checkbox->addOptionArray($new_blocks_array);


// GET top-centerblocks
$new_blocks_array   = array();
$r_tcblock_checkbox = new XoopsFormCheckBox(_AM_BLOCKRIGHTS.":<br /><i>"._TOP."-"._CENTER."</i>", "read_bids[]", $r_block_value);
$blocks_array       = XoopsBlock::getAllBlocks("list", XOOPS_CENTERBLOCK_TOPALL, 1, "weight", 1);
foreach ($blocks_array as $key=>$value) {
	$new_blocks_array[$key] = "<a href='".XOOPS_URL."/modules/system/admin.php?fct=blocksadmin&op=edit&bid=".$key."'>".$value."</a><br />";
}
$r_tcblock_checkbox->addOptionArray($new_blocks_array);


// GET bottom-centerblocks
$new_blocks_array   = array();
$r_bcblock_checkbox = new XoopsFormCheckBox(_AM_BLOCKRIGHTS.":<br /><i>"._BOTTOM."-"._CENTER."</i>", "read_bids[]", $r_block_value);
$blocks_array       = XoopsBlock::getAllBlocks("list", XOOPS_CENTERBLOCK_BOTTOMALL, 1, "weight", 1);
foreach ($blocks_array as $key=>$value) {
	$new_blocks_array[$key] = "<a href='".XOOPS_URL."/modules/system/admin.php?fct=blocksadmin&op=edit&bid=".$key."'>".$value."</a><br />";
}
$r_bcblock_checkbox->addOptionArray($new_blocks_array);


// GET rightblocks
$new_blocks_array  = array();
$r_rblock_checkbox = new XoopsFormCheckBox(_AM_BLOCKRIGHTS.":<br /><i>"._RIGHT."</i>", "read_bids[]", $r_block_value);
$blocks_array      = XoopsBlock::getAllBlocks("list", XOOPS_SIDEBLOCK_RIGHT, 1, "weight", 1);
foreach ($blocks_array as $key=>$value) {
	$new_blocks_array[$key] = "<a href='".XOOPS_URL."/modules/system/admin.php?fct=blocksadmin&op=edit&bid=".$key."'>".$value."</a><br />";
}
$r_rblock_checkbox->addOptionArray($new_blocks_array);


$op_hidden     = new XoopsFormHidden("op", $op_value);
$fct_hidden    = new XoopsFormHidden("fct", "groups");
$submit_button = new XoopsFormButton("", "groupsubmit", $submit_value, "submit");

$form = new XoopsThemeForm($form_title, "groupform", "admin.php");
$form->addElement($name_text);
$form->addElement($desc_text);
$form->addElement($a_mod_checkbox);
$form->addElement($r_mod_checkbox);
$form->addElement($r_lblock_checkbox);
$form->addElement($r_tcblock_checkbox);
$form->addElement($r_bcblock_checkbox);
$form->addElement($r_rblock_checkbox);

$form->addElement($op_hidden);
$form->addElement($fct_hidden);


if ( !empty($g_id_value) ) {
	$g_id_hidden = new XoopsFormHidden("g_id", $g_id_value);
	$form->addElement($g_id_hidden);
}


$form->addElement($submit_button);
$form->setRequired("name");
$form->display();
?>
