3 * Site Admin: Trove Admin: add new leaf category
5 * Copyright 1999-2001 (c) VA Linux Systems
6 * Copyright (C) 2010 Alain Peyrat - Alcatel-Lucent
8 * This file is part of FusionForge.
10 * FusionForge is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * FusionForge is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with FusionForge; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 require_once('../../env.inc.php');
26 require_once $gfcommon.'include/pre.php';
27 require_once $gfwww.'include/trove.php';
28 require_once $gfwww.'admin/admin_utils.php';
30 session_require_global_perm ('forge_admin');
32 // ########################################################
34 if (getStringFromRequest('submit')) {
35 if (!form_key_is_valid(getStringFromRequest("form_key"))) {
36 exit_form_double_submit();
39 $form_parent = getIntFromRequest('form_parent');
40 $form_shortname = getStringFromRequest('form_shortname');
41 $form_fullname = getStringFromRequest('form_fullname');
42 $form_description = getStringFromRequest('form_description');
44 $newroot = trove_getrootcat($form_parent);
46 if ($form_shortname && $form_fullname) {
47 $res = db_query_params ('
49 (shortname,fullname,description,parent,version,root_parent)
59 array(htmlspecialchars($form_shortname),
60 htmlspecialchars($form_fullname),
61 htmlspecialchars($form_description),
63 date("Ymd",time()).'01',
66 if (!$res || db_affected_rows($res)<1) {
67 form_release_key(getStringFromRequest("form_key"));
68 exit_error(_('Error In Trove Operation: ').db_error(),'trove');
71 // update full paths now
72 trove_genfullpaths($newroot,trove_getfullname($newroot),$newroot);
74 session_redirect("/admin/trove/trove_cat_list.php");
76 $error_msg = 'Missing category short name or full name';
80 site_admin_header(array('title'=>_('Add New Trove Category')));
83 <form action="trove_cat_add.php" method="post">
84 <input type="hidden" name="form_key" value="<?php echo form_generate_key(); ?>" />
85 <p><?php echo _('Parent Category'); ?>:<?php echo utils_requiredField(); ?>
86 <br /><select name="form_parent">
90 // generate list of possible parents
91 // <paul@zootweb.com> 4/2/2003 - If we were given a parent trove use it
92 // in the "Parent Category" box otherwise give them the complete list.
93 $parent_trove_cat_id = getIntFromRequest("parent_trove_cat_id", -1);
94 if ($parent_trove_cat_id != -1) {
95 if ($parent_trove_cat_id == 0) {
96 print ('<option value="0">root</option>');
98 $res_cat = db_query_params ('SELECT shortname,fullname,trove_cat_id FROM trove_cat WHERE trove_cat_id=$1',
99 array($parent_trove_cat_id)) ;
101 while ($row_cat = db_fetch_array($res_cat)) {
102 print ('<option value="'.$row_cat["trove_cat_id"].'">'.$row_cat["fullname"]."</option>");
106 print ('<option value="0">root</option>');
107 $res_cat = db_query_params ('SELECT shortname,fullname,trove_cat_id FROM trove_cat',
110 while ($row_cat = db_fetch_array($res_cat)) {
111 print ('<option value="'.$row_cat["trove_cat_id"].'">'.$row_cat["fullname"]."</option>");
118 <p><?php echo _('New category short name (no spaces, unix-like)'); ?>:<?php echo utils_requiredField(); ?>
119 <br /><input type="text" name="form_shortname" /></p>
120 <p><?php echo _('New category full name (Maximum length is 80 chars)'); ?>:<?php echo utils_requiredField(); ?>
121 <br /><input type="text" name="form_fullname" /></p>
122 <p><?php echo _('New category description (Maximum length is 255 chars)'); ?>:
123 <br /><input type="text" size="80" name="form_description" /></p>
124 <p><input type="submit" name="submit" value="<?php echo _('Add'); ?>" /></p>
129 site_admin_footer(array());