function trove_setnode($group_id, $trove_cat_id, $rootnode = 0) { // verify we were passed information if (!$group_id || !$trove_cat_id) { return 1; } // verify trove category exists $res_verifycat = db_query('SELECT trove_cat_id,fullpath_ids FROM trove_cat WHERE ' . 'trove_cat_id=' . db_ei($trove_cat_id)); if (db_numrows($res_verifycat) != 1) { return 1; } $row_verifycat = db_fetch_array($res_verifycat); // if we didnt get a rootnode, find it if (!$rootnode) { $rootnode = trove_getrootcat($trove_cat_id); } // must first make sure that this is not a subnode of anything current $res_topnodes = db_query('SELECT trove_cat.trove_cat_id AS trove_cat_id,' . 'trove_cat.fullpath_ids AS fullpath_ids FROM trove_cat,trove_group_link ' . 'WHERE trove_cat.trove_cat_id=trove_group_link.trove_cat_id AND ' . 'trove_group_link.group_id=' . db_ei($group_id) . ' AND ' . 'trove_cat.root_parent=' . db_ei($rootnode)); while ($row_topnodes = db_fetch_array($res_topnodes)) { $pathids = explode(' :: ', $row_topnodes['fullpath_ids']); for ($i = 0; $i < count($pathids); $i++) { // anything here will invalidate this setnode if ($pathids[$i] == $trove_cat_id) { return 1; } } } // need to see if this one is more specific than another // if so, delete the other and proceed with this insertion $subnodeids = explode(' :: ', $row_verifycat['fullpath_ids']); $res_checksubs = db_query('SELECT trove_cat_id FROM trove_group_link WHERE ' . 'group_id=' . db_ei($group_id) . ' AND trove_cat_root=' . db_ei($rootnode)); while ($row_checksubs = db_fetch_array($res_checksubs)) { // check against all subnodeids for ($i = 0; $i < count($subnodeids); $i++) { if ($subnodeids[$i] == $row_checksubs['trove_cat_id']) { // then delete subnode db_query('DELETE FROM trove_group_link WHERE ' . 'group_id=' . db_ei($group_id) . ' AND trove_cat_id=' . db_ei($subnodeids[$i])); } } } // if we got this far, must be ok db_query('INSERT INTO trove_group_link (trove_cat_id,trove_cat_version,' . 'group_id,trove_cat_root) VALUES (' . db_ei($trove_cat_id) . ',' . time() . ',' . db_ei($group_id) . ',' . db_ei($rootnode) . ')'); return 0; }
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ require_once '../../env.inc.php'; require_once $gfwww . 'include/pre.php'; require_once $gfwww . 'include/trove.php'; require_once $gfwww . 'admin/admin_utils.php'; session_require(array('group' => '1', 'admin_flags' => 'A')); // ######################################################## if (getStringFromRequest('submit')) { $form_parent = getStringFromRequest('form_parent'); $form_shortname = getStringFromRequest('form_shortname'); $form_trove_cat_id = getIntFromRequest('form_trove_cat_id'); $form_shortname = getStringFromRequest('form_shortname'); $form_fullname = getStringFromRequest('form_fullname'); $form_description = getStringFromRequest('form_description'); $newroot = trove_getrootcat($form_parent); if ($form_shortname) { if ($form_trove_cat_id == $form_parent) { exit_error(_("Error: a category can't be the same as its own parent."), db_error()); } else { $res = db_query("\n\t\t\t\tUPDATE trove_cat\n\t\t\t\tSET\tshortname='" . htmlspecialchars($form_shortname) . "',\n\t\t\t\t\tfullname='" . htmlspecialchars($form_fullname) . "',\n\t\t\t\t\tdescription='" . htmlspecialchars($form_description) . "',\n\t\t\t\t\tparent='{$form_parent}',\n\t\t\t\t\tversion='" . date("Ymd", time()) . "01',\n\t\t\t\t\troot_parent='{$newroot}'\n\t\t\t\tWHERE trove_cat_id='{$form_trove_cat_id}'\n\t\t\t"); } if (!$res || db_affected_rows($res) < 1) { exit_error(_('Error In Trove Operation'), db_error()); } } // update full paths now if ($newroot != 0) { trove_genfullpaths($newroot, trove_getfullname($newroot), $newroot); trove_updaterootparent($form_trove_cat_id, $newroot); } else {
<?php // // SourceForge: Breaking Down the Barriers to Open Source Development // Copyright 1999-2000 (c) The SourceForge Crew // http://sourceforge.net // // $Id: trove_cat_edit.php,v 1.2 2003/11/13 11:29:21 helix Exp $ require "pre.php"; require "trove.php"; session_require(array('group' => '1', 'admin_flags' => 'A')); // ######################################################## if ($GLOBALS["Submit"]) { $newroot = trove_getrootcat($GLOBALS['form_parent']); if ($GLOBALS[form_shortname]) { db_query('UPDATE trove_cat ' . 'SET ' . 'shortname=\'' . $GLOBALS[form_shortname] . '\',fullname=\'' . $GLOBALS[form_fullname] . '\',description=\'' . $GLOBALS[form_description] . '\',parent=\'' . $GLOBALS[form_parent] . '\',version=' . date("Ymd", time()) . '01' . ',root_parent=\'' . $newroot . '\' WHERE trove_cat_id=' . $GLOBALS["form_trove_cat_id"]); } // update full paths now trove_genfullpaths($newroot, trove_getfullname($newroot), $newroot); session_redirect("/admin/trove/trove_cat_list.php"); } $res_cat = db_query("SELECT * FROM trove_cat WHERE trove_cat_id={$trove_cat_id}"); if (db_numrows($res_cat) < 1) { exit_error("No Suck Category", "That trove cat does not exist"); } $row_cat = db_fetch_array($res_cat); $HTML->header(array(title => "Trove - Edit Category")); ?> <form action="trove_cat_edit.php" method="post"> <input type="hidden" name="form_trove_cat_id" value="<?php
<?php // // SourceForge: Breaking Down the Barriers to Open Source Development // Copyright 1999-2000 (c) The SourceForge Crew // http://sourceforge.net // // require_once 'pre.php'; require_once 'trove.php'; session_require(array('group' => '1', 'admin_flags' => 'A')); // ######################################################## $request =& HTTPRequest::instance(); if ($request->exist('Submit')) { $newroot = trove_getrootcat($request->get('form_parent')); if (db_escape_string($request->get('form_shortname'))) { db_query('UPDATE trove_cat ' . 'SET ' . 'shortname=\'' . db_escape_string($request->get('form_shortname')) . '\',fullname=\'' . db_escape_string($request->get('form_fullname')) . '\',description=\'' . db_escape_string($request->get('form_description')) . '\',parent=\'' . db_escape_string($request->get('form_parent')) . '\',version=' . date("Ymd", time()) . '01' . ',root_parent=\'' . $newroot . '\' WHERE trove_cat_id=' . $GLOBALS["form_trove_cat_id"]); } // update full paths now trove_genfullpaths($newroot, trove_getfullname($newroot), $newroot); session_redirect("/admin/trove/trove_cat_list.php"); } $res_cat = db_query("SELECT * FROM trove_cat WHERE trove_cat_id={$trove_cat_id}"); if (db_numrows($res_cat) < 1) { exit_error("ERROR", $Language->getText('admin_trove_cat_delete', 'error_nocat')); } $row_cat = db_fetch_array($res_cat); $HTML->header(array('title' => $Language->getText('admin_trove_cat_edit', 'title'))); ?> <H2><?php