3 * Project Admin page to edit Trove categorization of the project
5 * This page is linked from index.php
7 * Copyright 1999-2001 (c) VA Linux Systems
8 * Copyright 2002-2004 (c) GForge Team
9 * Copyright 2016,2018, Franck Villaume - TrivialDev
10 * http://fusionforge.org/
12 * This file is part of FusionForge. FusionForge is free software;
13 * you can redistribute it and/or modify it under the terms of the
14 * GNU General Public License as published by the Free Software
15 * Foundation; either version 2 of the Licence, or (at your option)
18 * FusionForge is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License along
24 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
25 * 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.'project/admin/project_admin_utils.php';
33 global $use_tooltips, $HTML;
35 $group_id = getIntFromRequest('group_id');
36 session_require_perm('project_admin', $group_id);
38 if (!forge_get_config('use_trove')) {
39 exit_disabled('summary');
42 // Check for submission. If so, make changes and redirect
44 if (getStringFromRequest('submit') && getStringFromRequest('root1')) {
45 if (!form_key_is_valid(getStringFromRequest('form_key'))) {
46 exit_form_double_submit('summary');
48 group_add_history(_('Changed Trove'), '', $group_id);
50 // there is at least a $root1[xxx]
52 $allroots = getStringFromRequest('root1');
53 //$eachroot = ;//must make this bypass because it wouldn't compile otherwise
54 foreach ($allroots as $rootnode => $value) {
55 // check for array, then clear each root node for group
57 DELETE FROM trove_group_link
64 for ($i=1;$i<=$TROVE_MAXPERROOT;$i++) {
66 // check to see if exists first, then insert into DB
67 //@TODO change this to use the escaping utils
68 $var_aux = getStringFromRequest($varname);
69 $category = $var_aux[$rootnode];
71 trove_setnode($group_id,$category,$rootnode);
75 $feedback = _('Trove Update Success');
76 session_redirect('/project/admin/?group_id='.$group_id);
79 project_admin_header(array('title'=>_('Edit Trove Categorization'),'group'=>$group_id));
82 <p><?php echo _('Select up to three locations for this project in each of the Trove root categories. If the project does not require any or all of these locations, simply select “None Selected”.') ?></p>
83 <p><?php echo _('IMPORTANT: Projects should be categorized in the most specific locations available in the map. Simultaneous categorization in a specific category AND a parent category will result in only the more specific categorization being accepted.') ?></p>
86 echo $HTML->openForm(array('action' => getStringFromServer('PHP_SELF'), 'method' => 'post'));
88 $CATROOTS = trove_getallroots();
89 foreach ($CATROOTS as $catroot => $fullname) {
92 $res_cat = db_query_params ('SELECT * FROM trove_cat WHERE trove_cat_id=$1', array($catroot));
93 if (db_numrows($res_cat)>=1 && $use_tooltips) {
94 $title = db_result($res_cat, 0, 'description');
98 print "\n<h2>".$fullname."</h2>\n";
100 $res_grpcat = db_query_params ('
102 FROM trove_group_link
104 AND trove_cat_root=$2',
108 for ($i=1;$i<=$TROVE_MAXPERROOT;$i++) {
109 // each drop down, consisting of all cats in each root
110 $name= "root$i"."[$catroot]";
111 // see if we have one for selection
112 if ($row_grpcat = db_fetch_array($res_grpcat)) {
113 $selected = $row_grpcat["trove_cat_id"];
117 trove_catselectfull($catroot, $selected, $name, $title);
122 <input type="hidden" name="form_key" value="<?php echo form_generate_key();?>"/>
123 <input type="hidden" name="group_id" value="<?php echo $group_id; ?>" />
124 <p><input type="submit" name="submit" value="<?php echo _('Update All Category Changes') ?>" /></p>
126 echo $HTML->closeForm();
128 project_admin_footer();
132 // c-file-style: "bsd"