<?php
include_once("core/main.php");
if( !check_user_class($config["admmenu"]["links_edit"]["class"]) ) exit;
if( !check_module("links") ) die( "module not enabled" );

$index_page = false;
$page_name = $lang["LINKS_EDIT_TITLE"];

draw_header();

require_once("phpdbform/phpdbform_{$config["dbtype"]}.php");
require_once("phpdbform/phpdbform_db.php");

$db = new phpdbform_db( $config["database"], $config["host"], $config["user"], $config["password"] );
$db->connect();
$formdb = new phpdbform( $db, "{$config["prefix"]}_links", "id", "id,name", "name" );

$formdb->add_listbox( "category", $lang["LINKS_CAT_TITLE"], $db, "{$config["prefix"]}_linkscat", "cod", "cod,name", "name");
$formdb->add_checkbox( "active", $lang["LINKS_ACTIVE_TITLE"], 'Y', 'N' );
$formdb->add_textbox( "name", $lang["LINKS_NAME_TITLE"], 30 );
$formdb->add_textbox( "url", $lang["LINKS_URL_TITLE"], 60 );
$formdb->add_textarea( "descr", $lang["LINKS_DESCR_TITLE"], 60, 10 );
$formdb->add_textarea( "obs", $lang["LINKS_OBS_TITLE"], 60, 5 );
if( isset($_GET["id"]) )  $formdb->keyvalue = array( intval($_GET["id"]) );

theme_draw_centerbox_open($page_name);
$formdb->process();
$formdb->draw();

echo "<br><br><a href=\"adm_linkspend.php\">{$lang["LINKS_PENDING"]}</a>";

theme_draw_centerbox_close();
draw_footer();
?>
