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. FusionForge is free software;
9 * you can redistribute it and/or modify it under the terms of the
10 * GNU General Public License as published by the Free Software
11 * Foundation; either version 2 of the Licence, or (at your option)
14 * FusionForge 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 along
20 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 require_once '../../env.inc.php';
25 require_once $gfcommon.'include/pre.php';
26 require_once $gfwww.'include/trove.php';
27 require_once $gfwww.'admin/admin_utils.php';
29 session_require_global_perm ('forge_admin');
31 // ########################################################
33 if (getStringFromRequest('submit')) {
34 if (!form_key_is_valid(getStringFromRequest("form_key"))) {
35 exit_form_double_submit();
38 $form_parent = getIntFromRequest('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 && $form_fullname) {
46 $res = db_query_params ('
48 (shortname,fullname,description,parent,version,root_parent)
49 VALUES ($1, $2, $3, $4, $5, $6)
51 array(htmlspecialchars($form_shortname),
52 htmlspecialchars($form_fullname),
53 htmlspecialchars($form_description),
55 date("Ymd",time()).'01',
58 if (!$res || db_affected_rows($res)<1) {
59 form_release_key(getStringFromRequest("form_key"));
60 exit_error(sprintf(_('Error in Trove Operation: %s'), db_error()), 'trove');
63 // update full paths now
64 trove_genfullpaths($newroot,trove_getfullname($newroot),$newroot);
66 session_redirect("/admin/trove/trove_cat_list.php");
68 $error_msg = _('Missing category short name or full name');
72 site_admin_header(array('title'=>_('Add New Trove Category')));
75 <form action="trove_cat_add.php" method="post">
76 <input type="hidden" name="form_key" value="<?php echo form_generate_key(); ?>" />
77 <p><?php echo _('Parent Category').utils_requiredField()._(':'); ?>
78 <br /><select name="form_parent">
82 // generate list of possible parents
83 // <paul@zootweb.com> 4/2/2003 - If we were given a parent trove use it
84 // in the "Parent Category" box otherwise give them the complete list.
85 $parent_trove_cat_id = getIntFromRequest("parent_trove_cat_id", -1);
86 if ($parent_trove_cat_id != -1) {
87 if ($parent_trove_cat_id == 0) {
88 print ('<option value="0">root</option>');
90 $res_cat = db_query_params ('SELECT shortname,fullname,trove_cat_id FROM trove_cat WHERE trove_cat_id=$1',
91 array($parent_trove_cat_id)) ;
93 while ($row_cat = db_fetch_array($res_cat)) {
94 print ('<option value="'.$row_cat["trove_cat_id"].'">'.$row_cat["fullname"]."</option>");
98 print ('<option value="0">root</option>');
99 $res_cat = db_query_params ('SELECT shortname,fullname,trove_cat_id FROM trove_cat',
102 while ($row_cat = db_fetch_array($res_cat)) {
103 print ('<option value="'.$row_cat["trove_cat_id"].'">'.$row_cat["fullname"]."</option>");
110 <p><?php echo _('New category short name (no spaces, Unix-like)').utils_requiredField()._(':'); ?>
111 <br /><input type="text" required="required" name="form_shortname" /></p>
112 <p><?php echo _('New category full name (80 characters max): ').utils_requiredField(); ?>
113 <br /><input type="text" required="required" name="form_fullname" /></p>
114 <p><?php echo _('New category description (255 characters max: )'); ?>
115 <br /><input type="text" size="80" name="form_description" /></p>
116 <p><input type="submit" name="submit" value="<?php echo _('Add'); ?>" /></p>
121 site_admin_footer(array());