<?php $pkgbuild_uri = sprintf(config_get('options', 'pkgbuild_uri'), urlencode($row['Name'])); $log_uri = sprintf(config_get('options', 'log_uri'), urlencode($row['Name'])); $snapshot_uri = sprintf(config_get('options', 'snapshot_uri'), urlencode($row['Name'])); $git_clone_uri_anon = sprintf(config_get('options', 'git_clone_uri_anon'), htmlspecialchars($row['Name'])); $git_clone_uri_priv = sprintf(config_get('options', 'git_clone_uri_priv'), htmlspecialchars($row['Name'])); $uid = uid_from_sid($SID); $base_id = intval($row['ID']); $keywords = pkgbase_get_keywords($base_id); $submitter = username_from_id($row["SubmitterUID"]); $maintainer = username_from_id($row["MaintainerUID"]); $comaintainers = pkgbase_get_comaintainers($base_id); $packager = username_from_id($row["PackagerUID"]); if ($row["MaintainerUID"] !== NULL) { $maintainers = array_merge(array($row["MaintainerUID"]), pkgbase_get_comaintainer_uids(array($base_id))); } else { $maintainers = array(); } $unflaggers = array_merge($maintainers, array($row["FlaggerUID"])); $votes = $row['NumVotes']; $popularity = $row['Popularity']; # In case of wanting to put a custom message $msg = __('unknown'); # Print the timestamps for last updates $updated_time = $row["ModifiedTS"] == 0 ? $msg : gmdate("Y-m-d H:i", intval($row["ModifiedTS"])); $submitted_time = $row["SubmittedTS"] == 0 ? $msg : gmdate("Y-m-d H:i", intval($row["SubmittedTS"])); $out_of_date_time = $row["OutOfDateTS"] == 0 ? $msg : gmdate("Y-m-d", intval($row["OutOfDateTS"])); $pkgs = pkgbase_get_pkgnames($base_id); $base_uri = get_pkgbase_uri($row['Name']); ?>
/** * Update the list of keywords of a package base * * @param int $base_id The package base ID to update the keywords of * @param array $users Array of keywords * * @return array Tuple of success/failure indicator and error message */ function pkgbase_set_keywords($base_id, $keywords) { $base_id = intval($base_id); $maintainers = array_merge(array(pkgbase_maintainer_uid($base_id)), pkgbase_get_comaintainer_uids(array($base_id))); if (!has_credential(CRED_PKGBASE_SET_KEYWORDS, $maintainers)) { return array(false, __("You are not allowed to edit the keywords of this package base.")); } /* Remove empty and duplicate user names. */ $keywords = array_unique(array_filter(array_map('trim', $keywords))); $dbh = DB::connect(); $q = sprintf("DELETE FROM PackageKeywords WHERE PackageBaseID = %d", $base_id); $dbh->exec($q); $i = 0; foreach ($keywords as $keyword) { $q = sprintf("INSERT INTO PackageKeywords (PackageBaseID, Keyword) VALUES (%d, %s)", $base_id, $dbh->quote($keyword)); var_dump($q); $dbh->exec($q); $i++; if ($i >= 20) { break; } } return array(true, __("The package base keywords have been updated.")); }