<?php
/***************************************************************************
* categories.php
* -------------------
* begin : mar, ago 28, 2007
* copyright : (C)
* email : hide@address.com
* Desc : Categories managment
*
*
***************************************************************************/
define('IN_ADSERVER', true);
include_once("./inc/common.inc.php");
//Revisar logeo
checkLogin($web_address);
get_User_Settings($session['id_User'], 'edit_Cat', $web_address);
/* Declare the TPL */
$categories_Tpl = new tpl($s_path_Tpl . "/categories.tpl");
$s_msg = "";
//Create New Category
if(isset($_POST['add_Category']) && $_POST['new_Category'] != ""){
$q = "
INSERT INTO ".$db_Pre."categories (name, active)
VALUES ('".$_POST['new_Category']."',1)
";
$q_New_Categories = mysql_query($q) or die("Unable to Create New Category: " . mysql_error());
$s_Warning = "New category added";
}
//Modify a Category
if(isset($_POST['change_Category']) && $_POST['curr_Category_Value'] != ""){
$q = "
UPDATE ".$db_Pre."categories
SET name = '".$_POST['curr_Category_Value']."',
active = ".(isset($_POST['active']) ? 1 : 0)."
WHERE id_Category = ".$_POST['curr_Category_Id']."
";
$q_Mod_Categories = mysql_query($q) or die("Unable to Modify Category: " . mysql_error());
$s_Warning = $_lang['cats_Msg_Mod'];
}
//Select all categories
$s_Categories = "";
$q = "
SELECT *
FROM ".$db_Pre."categories
";
$q_Categories = mysql_query($q) or die("Unable to Get Category List: " . mysql_error());
if(mysql_num_rows($q_Categories) > 0){
$a_Categories_Keys = array(
"{CATS_IDS}",
"{CATS_NAME}",
"{CATS_NAME_VALUE}",
"{CATS_ACTIVE}",
"{CATS_ACTIVE_CHECK}"
);
while($row = mysql_fetch_array($q_Categories, MYSQL_ASSOC)){
$a_Categories_Values[] = array(
$row['id_Category'],
$_lang['cats_Name'],
$row['name'],
$_lang['cats_Active'],
($row['active'] == 1 ? "checked" : "")
);
}
}
else{
$s_Categories = $_lang['cats_No_Cats'];
}
/* Main Value Array */
$a_Categories = array(
"{CATS_HELP_TITLE}" => $_lang['cats_Help_Title'],
"{CATS_HELP_TEXT}" => $_lang['cats_Help_Text'],
"{CATS_NEW}" => $_lang['cats_New'],
"{CATS_ADD}" => $_lang['cats_Add']
);
$categories_Tpl->rBlock($a_Categories, "");
$categories_Tpl->rBlock_Several($a_Categories_Keys, $a_Categories_Values, "CATS");
$categories_Tpl->localize_It($_lang);
include_once("./header.inc.php");
/* Print the tpl */
$categories_Tpl->print_Tpl();
include_once("./footer.inc.php");
?>