<?php
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);
$a_mod_checkbox = new XoopsFormCheckBox(_AM_ACTIVERIGHTS, "admin_mids[]", $a_mod_value);
$a_mod_checkbox->addOptionArray(XoopsModule::getHasAdminModulesList());
$r_mod_checkbox = new XoopsFormCheckBox(_AM_ACCESSRIGHTS, "read_mids[]", $r_mod_value);
$r_mod_checkbox->addOptionArray(XoopsModule::getHasMainModulesList());

$r_lblock_checkbox = new XoopsFormCheckBox("<b>"._LEFT."</b><br />", "read_bids[]", $r_block_value);
$new_blocks_array = array();
$blocks_array = XoopsBlock::getAllBlocks("list", XOOPS_SIDEBLOCK_LEFT);
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>";
}
$r_lblock_checkbox->addOptionArray($new_blocks_array);

$r_cblock_checkbox = new XoopsFormCheckBox("<b>"._CENTER."</b><br />", "read_bids[]", $r_block_value);
$new_blocks_array = array();
$blocks_array = XoopsBlock::getAllBlocks("list", XOOPS_CENTERBLOCK_ALL);
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>";
}
$r_cblock_checkbox->addOptionArray($new_blocks_array);

$r_rblock_checkbox = new XoopsFormCheckBox("<b>"._RIGHT."</b><br />", "read_bids[]", $r_block_value);
$new_blocks_array = array();
$blocks_array = XoopsBlock::getAllBlocks("list", XOOPS_SIDEBLOCK_RIGHT);
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>";
}
$r_rblock_checkbox->addOptionArray($new_blocks_array);

$r_block_tray = new XoopsFormElementTray(_AM_BLOCKRIGHTS, "<br /><br />");
$r_block_tray->addElement($r_lblock_checkbox);
$r_block_tray->addElement($r_cblock_checkbox);
$r_block_tray->addElement($r_rblock_checkbox);

$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_block_tray);
$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();
?>