$pear_rest = new pearweb_Channel_REST_Generator($rest_path, $dbh); } ob_end_clean(); PEAR::setErrorHandling(PEAR_ERROR_DIE); require_once 'System.php'; System::rm(array('-r', $rest_path)); System::mkdir(array('-p', $rest_path)); chmod($rest_path, 0777); echo "Generating Category REST...\n"; include_once 'pear-database-category.php'; foreach (category::listAll() as $category) { echo " {$category['name']}..."; $pear_rest->saveCategoryREST($category['name']); echo "done\n"; } $pear_rest->saveAllCategoriesREST(); echo "Generating Maintainer REST...\n"; $maintainers = $dbh->getAll('SELECT users.* FROM users, karma WHERE users.handle = karma.user AND (karma.level = "pear.dev" OR karma.level = "pear.admin")', array(), DB_FETCHMODE_ASSOC); foreach ($maintainers as $maintainer) { echo " {$maintainer['handle']}..."; $pear_rest->saveMaintainerREST($maintainer['handle']); echo "done\n"; } echo "Generating All Maintainers REST...\n"; $pear_rest->saveAllMaintainersREST(); echo "done\n"; echo "Generating Package REST...\n"; $pear_rest->saveAllPackagesREST(); require_once 'Archive/Tar.php'; require_once 'PEAR/PackageFile.php';
/** * Deletes a category * * @param integer $id Cateogry ID */ static function delete($id) { $name = $GLOBALS['dbh']->getOne('SELECT name FROM categories WHERE id = ?', array($id)); // Get parent ID if any $parentID = $GLOBALS['dbh']->getOne('SELECT parent FROM categories WHERE id = ?', array($id)); // Delete it $deleted_cat_left = $GLOBALS['dbh']->getOne('SELECT cat_left FROM categories WHERE id = ?', array($id)); $deleted_cat_right = $GLOBALS['dbh']->getOne('SELECT cat_right FROM categories WHERE id = ?', array($id)); $GLOBALS['dbh']->query('DELETE FROM categories WHERE id = ' . $id); // Renumber $GLOBALS['dbh']->query('UPDATE categories SET cat_left = cat_left - 1, cat_right = cat_right - 1 WHERE cat_left > ? AND cat_right < ?', array($deleted_cat_left, $deleted_cat_right)); $GLOBALS['dbh']->query('UPDATE categories SET cat_left = cat_left - 2, cat_right = cat_right - 2 WHERE cat_right > ?', array($deleted_cat_right)); // Update any child categories $GLOBALS['dbh']->query('UPDATE categories SET parent = ? WHERE parent = ?', array($parentID ? $parentID : 'NULL', $id)); include_once 'pear-rest.php'; $pear_rest = new pearweb_Channel_REST_Generator(PEAR_REST_PATH, $GLOBALS['dbh']); $pear_rest->deleteCategoryREST($name); $pear_rest->saveAllCategoriesREST(); return true; }