3 * Site Admin: Trove Admin: edit category
5 * This page is linked from trove_cat_list.php, page to browse full
8 * Copyright 1999-2001 (c) VA Linux Systems
9 * Copyright (C) 2010 Alain Peyrat - Alcatel-Lucent
11 * This file is part of FusionForge. FusionForge is free software;
12 * you can redistribute it and/or modify it under the terms of the
13 * GNU General Public License as published by the Free Software
14 * Foundation; either version 2 of the Licence, or (at your option)
17 * FusionForge is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License along
23 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 require_once '../../env.inc.php';
29 require_once $gfcommon.'include/pre.php';
30 require_once $gfwww.'include/trove.php';
31 require_once $gfwww.'admin/admin_utils.php';
33 session_require_global_perm ('forge_admin');
35 // ########################################################
37 if (getStringFromRequest('submit')) {
38 $form_parent = getStringFromRequest('form_parent');
39 $form_shortname = getStringFromRequest('form_shortname');
40 $form_trove_cat_id = getIntFromRequest('form_trove_cat_id');
41 $form_shortname = getStringFromRequest('form_shortname');
42 $form_fullname = getStringFromRequest('form_fullname');
43 $form_description = getStringFromRequest('form_description');
44 $newroot = trove_getrootcat($form_parent);
46 if ($form_shortname) {
47 if ($form_trove_cat_id == $form_parent) {
48 exit_error(_("Error: a category can't be the same as its own parent: ").db_error(),'trove');
50 $res = db_query_params ('
60 array(htmlspecialchars($form_shortname),
61 htmlspecialchars($form_fullname),
62 htmlspecialchars($form_description),
64 date("Ymd",time()).'01',
69 if (!$res || db_affected_rows($res)<1) {
70 exit_error(_('Error In Trove Operation :').db_error(),'trove');
73 // update full paths now
75 trove_genfullpaths($newroot,trove_getfullname($newroot),$newroot);
76 trove_updaterootparent($form_trove_cat_id,$newroot);
79 trove_genfullpaths($form_trove_cat_id,trove_getfullname($form_trove_cat_id),$form_trove_cat_id);
80 trove_updaterootparent($form_trove_cat_id,$form_trove_cat_id);
82 db_query_params ('update trove_group_link set trove_cat_root=(select root_parent from trove_cat where trove_cat_id=trove_group_link.trove_cat_id)',
86 session_redirect("/admin/trove/trove_cat_list.php");
89 if (getStringFromRequest("delete")) {
90 $form_trove_cat_id = getIntFromRequest('form_trove_cat_id');
91 if ($form_trove_cat_id==forge_get_config('default_trove_cat')){
92 exit_error( _('Error in trove operation, can\'t delete trove category defined as default in configuration.'),'trove');
94 trove_del_cat_id($form_trove_cat_id);
95 session_redirect("/admin/trove/trove_cat_list.php");
102 $trove_cat_id = getIntFromRequest("trove_cat_id");
104 $res_cat = db_query_params ('SELECT * FROM trove_cat WHERE trove_cat_id=$1',
105 array($trove_cat_id)) ;
107 if (db_numrows($res_cat)<1) {
108 exit_error( _('No such category, that trove cat does not exist'), 'trove');
110 $row_cat = db_fetch_array($res_cat);
112 site_admin_header(array('title'=>_('Edit Trove Category')));
115 <form action="trove_cat_edit.php" method="post">
117 <p><?php echo _('Parent Category:'); ?>
118 <br /><select name="form_parent">
121 // generate list of possible parents (a category can't be a parent of itself)
122 $res_parent = db_query_params ('SELECT shortname,fullname,trove_cat_id FROM trove_cat WHERE trove_cat_id <> $1',
123 array($trove_cat_id));
125 // Place the root node at the start of the list
126 print('<option value="0"');
127 if ($row_cat["parent"] == 0) {
128 print(' selected="selected"');
130 print('>root</option>');
131 while ($row_parent = db_fetch_array($res_parent)) {
132 print ('<option value="'.$row_parent["trove_cat_id"].'"');
133 if ($row_cat["parent"] == $row_parent["trove_cat_id"]) print ' selected="selected"';
134 print ('>'.$row_parent["fullname"]."</option>\n");
140 <input type="hidden" name="form_trove_cat_id" value="<?php
141 print $GLOBALS['trove_cat_id']; ?>" /></p>
143 <p><?php echo _('Category short name (no spaces, unix-like)'); ?>:
144 <br /><input type="text" name="form_shortname" value="<?php print $row_cat["shortname"]; ?>" /></p>
146 <p><?php echo _('Category full name (Maximum length is 80 chars)'); ?>:
147 <br /><input type="text" name="form_fullname" value="<?php print $row_cat["fullname"]; ?>" /></p>
149 <p><?php echo _('Category description (Maximum length is 255 chars)'); ?>:
150 <br /><input type="text" name="form_description" size="80" value="<?php print $row_cat["description"]; ?>" /></p>
152 <br /><input type="submit" name="submit" value="<?php echo _('Update'); ?>" /><input type="submit" name="delete" value="<?php echo _('Delete'); ?>" />
157 site_admin_footer(array());
161 // c-file-style: "bsd"