if (PEAR::isError($sth)) { report_error('Unable to save data!'); } else { if (isset($_POST['tags']) && is_array($_POST['tags'])) { $manager = new Tags_Manager(); $manager->clearTags($_POST['name']); foreach ($_POST['tags'] as $tag) { if (!$tag) { continue; } $manager->createPackageTag($tag, $_POST['name']); } } include_once 'pear-rest.php'; $pear_rest = new pearweb_Channel_REST_Generator(PEAR_REST_PATH, $dbh); $pear_rest->saveAllPackagesREST(); $pear_rest->savePackageREST($_POST['name']); $pear_rest->savePackagesCategoryREST(package::info($_POST['name'], 'category')); report_success('Package information successfully updated.'); } } } else { if (isset($_GET['action'])) { switch ($_GET['action']) { case 'release_remove': if (!isset($_GET['release'])) { report_error('Missing package ID!'); break; } include_once 'pear-database-release.php'; if (release::remove($_GET['id'], $_GET['release'])) {
/** * Updates fields of an existant package * * @param int $pkgid The package ID to update * @param array $data Assoc in the form 'field' => 'value'. * @return mixed True or PEAR_Error */ static function updateInfo($pkgid, $data) { global $dbh, $auth_user; $package_id = package::info($pkgid, 'id'); if (PEAR::isError($package_id) || empty($package_id)) { return PEAR::raiseError('Package not registered or not approved. Please register it first with "New Package" or wait until it gets approved.'); } if ($auth_user->isAdmin() === false && $auth_user->isQA() === false) { include_once 'pear-database-user.php'; $role = user::maintains($auth_user->handle, $package_id); if ($role != 'lead' && $role != 'developer') { return PEAR::raiseError('package::updateInfo: insufficient privileges'); } } // XXX (cox) what about 'name'? $allowed = array('license', 'summary', 'description', 'category'); $fields = $prep = array(); foreach ($allowed as $a) { if (isset($data[$a])) { $fields[] = "{$a} = ?"; $prep[] = $data[$a]; } } if (!count($fields)) { return; } $sql = 'UPDATE packages SET ' . implode(', ', $fields) . " WHERE id = {$package_id}"; $row = package::info($pkgid, 'name'); include_once 'pear-rest.php'; $pear_rest = new pearweb_Channel_REST_Generator(PEAR_REST_PATH, $dbh); $pear_rest->saveAllPackagesREST(); $pear_rest->savePackageREST($row); $pear_rest->savePackagesCategoryREST(package::info($pkgid, 'category')); return $dbh->query($sql, $prep); }