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
10 * This file is part of GForge.
12 * GForge is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * GForge 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
23 * along with GForge; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 require_once('../../env.inc.php');
29 require_once $gfwww.'include/pre.php';
30 require_once $gfwww.'include/trove.php';
31 require_once $gfwww.'admin/admin_utils.php';
33 session_require(array('group'=>'1','admin_flags'=>'A'));
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."),
52 $res = db_query_params ('
62 array(htmlspecialchars($form_shortname),
63 htmlspecialchars($form_fullname),
64 htmlspecialchars($form_description),
66 date("Ymd",time()).'01',
71 if (!$res || db_affected_rows($res)<1) {
73 _('Error In Trove Operation'),
78 // update full paths now
80 trove_genfullpaths($newroot,trove_getfullname($newroot),$newroot);
81 trove_updaterootparent($form_trove_cat_id,$newroot);
84 trove_genfullpaths($form_trove_cat_id,trove_getfullname($form_trove_cat_id),$form_trove_cat_id);
85 trove_updaterootparent($form_trove_cat_id,$form_trove_cat_id);
87 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)',
91 session_redirect("/admin/trove/trove_cat_list.php");
94 if (getStringFromRequest("delete")) {
95 $form_trove_cat_id = getIntFromRequest('form_trove_cat_id');
96 if ($form_trove_cat_id==forge_get_config('default_trove_cat')){
97 exit_error( _('Error In Trove Operation, can\'t delete trove category define as default in local.inc'));
99 trove_del_cat_id($form_trove_cat_id);
100 session_redirect("/admin/trove/trove_cat_list.php");
107 $trove_cat_id = getIntFromRequest("trove_cat_id");
109 $res_cat = db_query_params ('SELECT * FROM trove_cat WHERE trove_cat_id=$1',
110 array($trove_cat_id)) ;
112 if (db_numrows($res_cat)<1) {
113 exit_error( _('No Such Category, That trove cat does not exist'));
115 $row_cat = db_fetch_array($res_cat);
117 site_admin_header(array('title'=>_('Site Admin: Trove - Edit Category')));
120 <h1><?php echo _('Edit Trove Category'); ?></h1>
122 <form action="trove_cat_edit.php" method="post">
124 <p><?php echo _('Parent Category:'); ?>
125 <br /><select name="form_parent">
128 // generate list of possible parents (a category can't be a parent of itself)
129 $res_parent = db_query_params ('SELECT shortname,fullname,trove_cat_id FROM trove_cat WHERE trove_cat_id <> $1',
130 array($trove_cat_id));
132 // Place the root node at the start of the list
133 print('<option value="0"');
134 if ($row_cat["parent"] == 0) {
135 print(' selected="selected"');
137 print('>root</option>');
138 while ($row_parent = db_fetch_array($res_parent)) {
139 print ('<option value="'.$row_parent["trove_cat_id"].'"');
140 if ($row_cat["parent"] == $row_parent["trove_cat_id"]) print ' selected="selected"';
141 print ('>'.$row_parent["fullname"]."</option>\n");
147 <input type="hidden" name="form_trove_cat_id" value="<?php
148 print $GLOBALS['trove_cat_id']; ?>" /></p>
150 <p><?php echo _('Category short name (no spaces, unix-like)'); ?>:
151 <br /><input type="text" name="form_shortname" value="<?php print $row_cat["shortname"]; ?>" /></p>
153 <p><?php echo _('Category full name (Maximum length is 80 chars)'); ?>:
154 <br /><input type="text" name="form_fullname" value="<?php print $row_cat["fullname"]; ?>" /></p>
156 <p><?php echo _('Category description (Maximum length is 255 chars)'); ?>:
157 <br /><input type="text" name="form_description" size="80" value="<?php print $row_cat["description"]; ?>" /></p>
159 <br /><input type="submit" name="submit" value="<?php echo _('Update'); ?>" /><input type="submit" name="delete" value="<?php echo _('Delete'); ?>" />
164 site_admin_footer(array());
168 // c-file-style: "bsd"