Commit e1a258bd authored by Lukas Fleischer's avatar Lukas Fleischer
Browse files

Remember user ID when flagging package bases



Add a new FlaggerUID field to the database and use it to store the user
ID of the account who recently flagged a package out-of-date.
Signed-off-by: Lukas Fleischer's avatarLukas Fleischer <lfleischer@archlinux.org>
parent 57250a16
......@@ -84,6 +84,7 @@ CREATE TABLE PackageBases (
OutOfDateTS BIGINT UNSIGNED NULL DEFAULT NULL,
SubmittedTS BIGINT UNSIGNED NOT NULL,
ModifiedTS BIGINT UNSIGNED NOT NULL,
FlaggerUID BIGINT UNSIGNED NULL DEFAULT NULL, -- who flagged the package out-of-date?
SubmitterUID INTEGER UNSIGNED NULL DEFAULT NULL, -- who submitted it?
MaintainerUID INTEGER UNSIGNED NULL DEFAULT NULL, -- User
PackagerUID INTEGER UNSIGNED NULL DEFAULT NULL, -- Last packager
......@@ -93,6 +94,7 @@ CREATE TABLE PackageBases (
INDEX (SubmitterUID),
INDEX (MaintainerUID),
INDEX (PackagerUID),
FOREIGN KEY (FlaggerUID) REFERENCES Users(ID) ON DELETE SET NULL,
-- deleting a user will cause packages to be orphaned, not deleted
FOREIGN KEY (SubmitterUID) REFERENCES Users(ID) ON DELETE SET NULL,
FOREIGN KEY (MaintainerUID) REFERENCES Users(ID) ON DELETE SET NULL,
......
......@@ -7,3 +7,11 @@ ALTER TABLE PackageComments
ADD COLUMN EditedUsersID INTEGER UNSIGNED NULL DEFAULT NULL,
ADD FOREIGN KEY (EditedUsersID) REFERENCES Users(ID) ON DELETE SET NULL;
----
2. Add a field to store the ID of the last user who flagged a package
out-of-date:
----
ALTER TABLE PackageBases
ADD COLUMN FlaggerUID BIGINT UNSIGNED NULL DEFAULT NULL;
----
......@@ -328,15 +328,15 @@ function pkgbase_flag($base_ids) {
return array(false, __("You did not select any packages to flag."));
}
$uid = uid_from_sid($_COOKIE['AURSID']);
$dbh = DB::connect();
$q = "UPDATE PackageBases SET";
$q.= " OutOfDateTS = UNIX_TIMESTAMP()";
$q.= " OutOfDateTS = UNIX_TIMESTAMP(), FlaggerUID = " . $uid;
$q.= " WHERE ID IN (" . implode(",", $base_ids) . ")";
$q.= " AND OutOfDateTS IS NULL";
$dbh->exec($q);
$uid = uid_from_sid($_COOKIE['AURSID']);
foreach ($base_ids as $base_id) {
notify(array('flag', $uid, $base_id));
}
......
Markdown is supported
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