Commit eda71303 authored by Lukas Fleischer's avatar Lukas Fleischer Committed by Loui Chang
Browse files

Add timestamp when a package is flagged out-of-date (FS#20848).


Signed-off-by: default avatarLoui Chang <louipc.ist@gmail.com>
- resolve conflict and omit i18n changes.
parent dbb8bb78
Upgrading
=========
From 1.7.0 to 1.8.0
-------------------
ALTER TABLE Packages ADD OutOfDateTS BIGINT UNSIGNED NULL DEFAULT NULL;
UPDATE Packages SET OutOfDateTS = UNIX_TIMESTAMP() WHERE OutOfDate = 1;
ALTER TABLE Packages DROP OutOfDate;
From 1.6.0 to 1.7.0
-------------------
ALTER TABLE Users ADD Salt CHAR(32) NOT NULL DEFAULT '';
......
......@@ -119,7 +119,7 @@ CREATE TABLE Packages (
License CHAR(40) NOT NULL DEFAULT '',
LocationID TINYINT UNSIGNED NOT NULL DEFAULT 1,
NumVotes INTEGER UNSIGNED NOT NULL DEFAULT 0,
OutOfDate TINYINT UNSIGNED DEFAULT 0,
OutOfDateTS BIGINT UNSIGNED NULL DEFAULT NULL,
SubmittedTS BIGINT UNSIGNED NOT NULL,
ModifiedTS BIGINT UNSIGNED NOT NULL,
SubmitterUID INTEGER UNSIGNED NOT NULL DEFAULT 0, -- who submitted it?
......@@ -130,7 +130,6 @@ CREATE TABLE Packages (
INDEX (CategoryID),
INDEX (LocationID),
INDEX (DummyPkg),
INDEX (OutOfDate),
INDEX (NumVotes),
INDEX (SubmitterUID),
INDEX (MaintainerUID),
......
......@@ -313,7 +313,7 @@ if ($_COOKIE["AURSID"]):
}
# Update package data
$q = sprintf("UPDATE Packages SET ModifiedTS = UNIX_TIMESTAMP(), Name = '%s', Version = '%s-%s', License = '%s', Description = '%s', URL = '%s', LocationID = 2, FSPath = '%s', URLPath = '%s', OutOfDate = 0 WHERE ID = %d",
$q = sprintf("UPDATE Packages SET ModifiedTS = UNIX_TIMESTAMP(), Name = '%s', Version = '%s-%s', License = '%s', Description = '%s', URL = '%s', LocationID = 2, FSPath = '%s', URLPath = '%s', OutOfDateTS = NULL WHERE ID = %d",
mysql_real_escape_string($new_pkgbuild['pkgname']),
mysql_real_escape_string($new_pkgbuild['pkgver']),
mysql_real_escape_string($new_pkgbuild['pkgrel']),
......
......@@ -21,7 +21,7 @@ class AurJSON {
private $exposed_methods = array('search','info','msearch');
private $fields = array('Packages.ID','Name','Version','CategoryID',
'Description', 'LocationID', 'URL','URLPath','License','NumVotes',
'OutOfDate');
'(OutOfDateTS IS NOT NULL) AS OutOfDate');
/**
* Handles post data, and routes the request.
......
......@@ -457,7 +457,7 @@ function pkg_search_page($SID="") {
PackageCategories.Category,
PackageLocations.Location,
Packages.Name, Packages.Version, Packages.Description, Packages.NumVotes,
Packages.ID, Packages.OutOfDate
Packages.ID, Packages.OutOfDateTS
FROM Packages
LEFT JOIN Users ON (Packages.MaintainerUID = Users.ID) ";
......@@ -510,7 +510,7 @@ function pkg_search_page($SID="") {
}
if (isset($_GET['outdated'])) {
$q .= "AND OutOfDate = 1 ";
$q .= "AND OutOfDateTS IS NOT NULL ";
}
$order = $_GET["SO"] == 'd' ? 'DESC' : 'ASC';
......@@ -642,8 +642,13 @@ function pkg_flag ($atype, $ids, $action = True) {
}
}
$ood = $action ? 1 : 0;
$q = "UPDATE Packages SET OutOfDate = " . $ood;
$q = "UPDATE Packages SET";
if ($action) {
$q.= " OutOfDateTS = UNIX_TIMESTAMP()";
}
else {
$q.= " OutOfDateTS = NULL";
}
$q.= " WHERE ID IN (" . $flag . ")";
db_query($q, $dbh);
......
......@@ -59,7 +59,7 @@ function user_table($user, $dbh)
$maintainer_unsupported_count = db_cache_value(sprintf($base_q, 'unsupported'), $dbh,
$apc_prefix . 'user_unsupported_count:' . $escuser);
$q = "SELECT count(*) FROM Packages,Users WHERE Packages.OutOfDate = 1 AND Packages.MaintainerUID = Users.ID AND Users.Username='" . $escuser . "'";
$q = "SELECT count(*) FROM Packages,Users WHERE Packages.OutOfDateTS IS NOT NULL AND Packages.MaintainerUID = Users.ID AND Users.Username='" . $escuser . "'";
$flagged_outdated = db_cache_value($q, $dbh,
$apc_prefix . 'user_flagged_outdated:' . $escuser);
......
......@@ -27,7 +27,7 @@
echo " value='".__("UnNotify")."' title='".__("No New Comment Notification")."'> ";
}
if ($row["OutOfDate"] == 0) {
if ($row["OutOfDateTS"] === NULL) {
echo "<input type='submit' class='button' name='do_Flag'";
echo " value='".__("Flag Out-of-date")."'>\n";
} else {
......
......@@ -35,6 +35,7 @@ $license = empty($row['License']) ? $msg : $row['License'];
# Print the timestamps for last updates
$updated_time = ($row["ModifiedTS"] == 0) ? $msg : gmdate("r", intval($row["ModifiedTS"]));
$submitted_time = ($row["SubmittedTS"] == 0) ? $msg : gmdate("r", intval($row["SubmittedTS"]));
$out_of_date_time = ($row["OutOfDateTS"] == 0) ? $msg : gmdate("r", intval($row["OutOfDateTS"]));
?>
<div class="pgbox">
......@@ -69,8 +70,8 @@ $submitted_time = ($row["SubmittedTS"] == 0) ? $msg : gmdate("r", intval($row["S
print "<a href='$urlpath.tar.gz'>".__("Tarball")."</a> :: <a href='$urlpath'>".__("Files")."</a> :: <a href='$urlpath/PKGBUILD'>PKGBUILD</a></span>";
}
if ($row["OutOfDate"] == 1) {
echo "<br /><span class='f6'>".__("This package has been flagged out of date.")."</span>";
if ($row["OutOfDateTS"] !== NULL) {
echo "<br /><span class='f6'>".__("This package has been flagged out of date.")." (${out_of_date_time})</span>";
}
?>
</p>
......
......@@ -46,7 +46,7 @@
$atype = account_from_sid($_COOKIE['AURSID']);
for ($i = 0; $row = mysql_fetch_assoc($result); $i++) {
(($i % 2) == 0) ? $c = "data1" : $c = "data2";
if ($row["OutOfDate"]): $c = "outofdate"; endif;
if ($row["OutOfDateTS"] !== NULL): $c = "outofdate"; endif;
?>
<tr>
<?php if ($SID): ?>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment