3 * Site Admin: Trove Admin: add new leaf category
5 * Copyright 1999-2001 (c) VA Linux Systems
7 * This file is part of GForge.
9 * GForge is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * GForge is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with GForge; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 require_once('../../env.inc.php');
25 require_once $gfwww.'include/pre.php';
26 require_once $gfwww.'include/trove.php';
27 require_once $gfwww.'admin/admin_utils.php';
29 session_require(array('group'=>'1','admin_flags'=>'A'));
31 // ########################################################
33 if (getStringFromRequest('submit')) {
34 if (!form_key_is_valid(getStringFromRequest("form_key"))) {
35 exit_form_double_submit();
38 $form_parent = getStringFromRequest('form_parent');
39 $form_shortname = getStringFromRequest('form_shortname');
40 $form_fullname = getStringFromRequest('form_fullname');
41 $form_description = getStringFromRequest('form_description');
43 $newroot = trove_getrootcat($form_parent);
45 if ($form_shortname) {
46 $res = db_query_params ('
48 (shortname,fullname,description,parent,version,root_parent)
58 array(htmlspecialchars($form_shortname),
59 htmlspecialchars($form_fullname),
60 htmlspecialchars($form_description),
62 date("Ymd",time()).'01',
65 if (!$res || db_affected_rows($res)<1) {
66 form_release_key(getStringFromRequest("form_key"));
68 _('Error In Trove Operation'),
74 // update full paths now
75 trove_genfullpaths($newroot,trove_getfullname($newroot),$newroot);
77 session_redirect("/admin/trove/trove_cat_list.php");
80 site_admin_header(array('title'=>_('Site Admin: Trove - Add Node')));
83 <h1><?php echo _('Add New Trove Category'); ?></h1>
85 <form action="trove_cat_add.php" method="post">
86 <input type="hidden" name="form_key" value="<?php echo form_generate_key(); ?>" />
87 <p><?php echo _('Parent Category'); ?>:<?php echo utils_requiredField(); ?>
88 <br /><select name="form_parent">
92 // generate list of possible parents
93 // <paul@zootweb.com> 4/2/2003 - If we were given a parent trove use it
94 // in the "Parent Category" box otherwise give them the complete list.
95 $parent_trove_cat_id = getIntFromRequest("parent_trove_cat_id", -1);
96 if ($parent_trove_cat_id != -1) {
97 if ($parent_trove_cat_id == 0) {
98 print ('<option value="0">root</option>\n');
100 $res_cat = db_query_params ('SELECT shortname,fullname,trove_cat_id FROM trove_cat WHERE trove_cat_id=$1',
101 array($parent_trove_cat_id)) ;
103 while ($row_cat = db_fetch_array($res_cat)) {
104 print ('<option value="'.$row_cat["trove_cat_id"].'">'.$row_cat["fullname"]."</option>\n");
108 print ('<option value="0">root</option>\n');
109 $res_cat = db_query_params ('SELECT shortname,fullname,trove_cat_id FROM trove_cat',
112 while ($row_cat = db_fetch_array($res_cat)) {
113 print ('<option value="'.$row_cat["trove_cat_id"].'">'.$row_cat["fullname"]."</option>\n");
120 <p><?php echo _('New category short name (no spaces, unix-like)'); ?>:<?php echo utils_requiredField(); ?>
121 <br /><input type="text" name="form_shortname" /></p>
122 <p><?php echo _('New category full name (Maximum length is 80 chars)'); ?>:<?php echo utils_requiredField(); ?>
123 <br /><input type="text" name="form_fullname" /></p>
124 <p><?php echo _('New category description (Maximum length is 255 chars)'); ?>:
125 <br /><input type="text" size="80" name="form_description" />
126 <br /><input type="submit" name="submit" value="<?php echo _('Add'); ?>" /></p>
131 site_admin_footer(array());