get('SaveChanges')) { if (isset($_POST["name"])) print '';flush(); while (list($id,$val) = each ($_POST["name"])) { if (!$id && isset($_POST["name"][0]) && $_POST["name"][0] != "") { # it is a new one $lc_name = substr(preg_replace("/\W/","", strtolower($_POST["name"][0])),0,10); if ($lc_name == "") Fatal_Error($GLOBALS['I18N']->get('NameNotEmpty')." $lc_name"); Sql_Query("select * from {$tables['adminattribute']} where tablename = \"$lc_name\""); if (Sql_Num_Rows()) Fatal_Error($GLOBALS['I18N']->get('NameNotUnique')); $query = sprintf('insert into %s (name,type,listorder,default_value,required,tablename) values("%s","%s",%d,"%s",%d,"%s")', $tables["adminattribute"], addslashes($_POST["name"][0]), $_POST["type"][0], $_POST["listorder"][0], addslashes($_POST["default"][0]),$_POST["required"][0],$lc_name); Sql_Query($query); $insertid = Sql_Insert_id(); # text boxes and hidden fields do not have their own table if ($_POST["type"][$id] != "textline" && $_POST["type"]["id"] != "hidden") { $query = "create table $table_prefix"."adminattr_$lc_name (id integer not null primary key auto_increment, name varchar(255) unique,listorder integer default 0)"; Sql_Query($query); } else { # and they cannot currently be required, changed 29/08/01, # insert javascript to require them, except for hidden ones :-) if (!empty($_POST["type"]["id"]) && $_POST["type"]["id"] == "hidden") Sql_Query("update {$tables['attribute']} set required = 0 where id = $insertid"); } if ($_POST["type"][$id] == "checkbox") { # with a checkbox we know the values Sql_Query('insert into '.$table_prefix.'adminattr_'.$lc_name.' (name) values("Checked")'); Sql_Query('insert into '.$table_prefix.'adminattr_'.$lc_name.' (name) values("Unchecked")'); # we cannot "require" checkboxes, that does not make sense Sql_Query("update {$tables['adminattribute']} set required = 0 where id = $insertid"); } } elseif (!empty($_POST["name"][$id])) { # it is a change $query = sprintf('update %s set name = "%s" ,listorder = %d,default_value = "%s" ,required = %d where id = %d', $tables["adminattribute"],addslashes($_POST["name"][$id]), $_POST["listorder"][$id],$_POST["default"][$id],$_POST["required"][$id],$id); Sql_Query($query); } } if (isset($_POST["delete"])) while (list($id,$val) = each ($_POST["delete"])) { $res = Sql_Query("select tablename,type from {$tables['adminattribute']} where id = $id"); $row = Sql_Fetch_Row($res); if ($row[1] != "hidden" && $row[1] != "textline") Sql_Query("drop table $table_prefix"."adminattr_$row[0]"); Sql_Query("delete from {$tables['adminattribute']} where id = $id"); # delete all admin attributes as well Sql_Query("delete from {$tables['admin_attribute']} where adminattributeid = $id"); } } ?> get('ExistingAttr'); else { print $GLOBALS['I18N']->get('NoAttrYet'); } while ($row = Sql_Fetch_array($res)) { ?>
get('Attribute').$row["id"] ?>get('Delete'); ?> ]" value="1">
get('Name'); ?> ]" value="" size=40>
get('Type'); ?> ]" value="">
get('DValue'); ?> ]" value="" size=40>
get('OrderListing'); ?> ]" value="" size=5> get('IsAttrRequired'); ?> ]" value="1" >

get('AddAttr'); ?>

get('Name'); ?>
get('Type'); ?>
get('DValue'); ?>
get('OrderListing'); ?> get('IsAttrRequired'); ?>