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
12 * This file is part of GForge.
14 * GForge is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * GForge is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with GForge; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 require_once('../../env.inc.php');
31 require_once('pre.php');
32 require_once('www/include/trove.php');
33 require_once('www/admin/admin_utils.php');
35 session_require(array('group'=>'1','admin_flags'=>'A'));
37 // ########################################################
39 if (getStringFromRequest('submit')) {
40 $form_parent = getStringFromRequest('form_parent');
41 $form_shortname = getStringFromRequest('form_shortname');
42 $form_trove_cat_id = getIntFromRequest('form_trove_cat_id');
43 $form_shortname = getStringFromRequest('form_shortname');
44 $form_fullname = getStringFromRequest('form_fullname');
45 $form_description = getStringFromRequest('form_description');
46 $newroot = trove_getrootcat($form_parent);
48 if ($form_shortname) {
49 if ($form_trove_cat_id == $form_parent) {
50 exit_error($Language->getText(
51 'admin_trove_cat_edit','error_tove_equal_parent'),
57 SET shortname='".htmlspecialchars($form_shortname)."',
58 fullname='".htmlspecialchars($form_fullname)."',
59 description='".htmlspecialchars($form_description)."',
60 parent='$form_parent',
61 version='".date("Ymd",time())."01',
62 root_parent='$newroot'
63 WHERE trove_cat_id='$form_trove_cat_id'
67 if (!$res || db_affected_rows($res)<1) {
69 _('Error In Trove Operation'),
74 // update full paths now
76 trove_genfullpaths($newroot,trove_getfullname($newroot),$newroot);
77 trove_updaterootparent($form_trove_cat_id,$newroot);
80 trove_genfullpaths($form_trove_cat_id,trove_getfullname($form_trove_cat_id),$form_trove_cat_id);
81 trove_updaterootparent($form_trove_cat_id,$form_trove_cat_id);
83 db_query("update trove_group_link set trove_cat_root=(select root_parent from trove_cat where trove_cat_id=trove_group_link.trove_cat_id)");
85 session_redirect("/admin/trove/trove_cat_list.php");
88 if (getStringFromRequest("delete")) {
89 $form_trove_cat_id = getIntFromRequest('form_trove_cat_id');
90 if ($form_trove_cat_id==$default_trove_cat){
91 exit_error( _('Error In Trove Operation, can\'t delete trove category define as default in local.inc'));
93 $res=db_query("SELECT * FROM trove_cat WHERE parent='$form_trove_cat_id'");
95 exit_error( _('Error In Trove Operation'), db_error());
97 if (db_numrows($res)>0) {
98 exit_error( _('Can\'t delete, That trove cat has sub categories'), db_error());
100 $res=db_query("DELETE FROM trove_treesums WHERE trove_cat_id='$form_trove_cat_id'");
102 exit_error( _('Error In Trove Operation'), db_error());
104 $res=db_query("DELETE FROM trove_group_link WHERE trove_cat_id='$form_trove_cat_id'");
106 exit_error( _('Error In Trove Operation'), db_error());
108 $res=db_query("DELETE FROM trove_cat WHERE trove_cat_id='$form_trove_cat_id'");
109 if (!$res || db_affected_rows($res)<1) {
110 exit_error( _('Error In Trove Operation'), db_error());
113 session_redirect("/admin/trove/trove_cat_list.php");
120 $trove_cat_id = getIntFromRequest("trove_cat_id");
122 $res_cat = db_query("SELECT * FROM trove_cat WHERE trove_cat_id=$trove_cat_id");
123 if (db_numrows($res_cat)<1) {
124 exit_error( _('No Such Category, That trove cat does not exist'));
126 $row_cat = db_fetch_array($res_cat);
128 site_admin_header(array('title'=>_('Site Admin: Trove - Edit Category')));
131 <h3><?php echo _('Edit Trove Category'); ?></h3>
133 <form action="trove_cat_edit.php" method="post">
135 <p><?php echo _('Parent Category:'); ?>
136 <br /><select name="form_parent">
139 // generate list of possible parents (a category can't be a parent of itself)
140 $res_parent = db_query("SELECT shortname,fullname,trove_cat_id FROM trove_cat WHERE trove_cat_id <> ".$trove_cat_id);
142 // Place the root node at the start of the list
143 print('<option value="0"');
144 if ($row_cat["parent"] == 0) {
145 print(' selected="selected"');
147 print('>root</option>');
148 while ($row_parent = db_fetch_array($res_parent)) {
149 print ('<option value="'.$row_parent["trove_cat_id"].'"');
150 if ($row_cat["parent"] == $row_parent["trove_cat_id"]) print ' selected="selected"';
151 print ('>'.$row_parent["fullname"]."</option>\n");
157 <input type="hidden" name="form_trove_cat_id" value="<?php
158 print $GLOBALS['trove_cat_id']; ?>" /></p>
160 <p><?php echo _('New category short name (no spaces, unix-like)'); ?>:
161 <br /><input type="text" name="form_shortname" value="<?php print $row_cat["shortname"]; ?>" /></p>
163 <p><?php echo _('New category full name (VARCHAR 80)'); ?>:
164 <br /><input type="text" name="form_fullname" value="<?php print $row_cat["fullname"]; ?>" /></p>
166 <p><?php echo _('New category description (VARCHAR 255)'); ?>:
167 <br /><input type="text" name="form_description" size="80" value="<?php print $row_cat["description"]; ?>" /></p>
169 <br /><input type="submit" name="submit" value="<?php echo _('Update'); ?>" /><input type="submit" name="delete" value="<?php echo _('Update'); ?>" />
174 site_admin_footer(array());