Commit graph

75 commits

Author SHA1 Message Date
Lukas Fleischer
5415bc945a Refactor pkgbase_comments()
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-04-05 19:52:51 +02:00
Lukas Fleischer
724a737815 Fix searching by category
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-04-05 17:42:19 +02:00
Lukas Fleischer
434b04e826 pkgfuncs.inc.php: Remove several unused functions
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-04-05 16:02:20 +02:00
Lukas Fleischer
ee1048b268 Split out package base functions
Move functions operating on package bases to a separate file.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-04-05 15:58:44 +02:00
Lukas Fleischer
676595f9bf Prefix package functions with pkg_/pkgbase_
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-04-05 15:55:31 +02:00
Lukas Fleischer
d16f7cf712 Use snake case for all package functions
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-04-05 15:54:21 +02:00
Lukas Fleischer
f461344211 Move package actions to package bases
Package actions now operate on package bases instead of packages. Move
all actions to the correct locations.

This also fixes some issues with comment notifications.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-04-05 13:54:06 +02:00
Lukas Fleischer
c1c77836a8 Allow for searching by package base name
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-04-05 13:51:28 +02:00
Lukas Fleischer
f7d13b5b36 Add package base detail pages
This adds package base details pages, similar to the package details
pages. Each package base details page contains general information
(package base name, category, submitter, maintainer, ...) and links to
all the corresponding packages. As on the package details pages,
comments and links to several package actions are also provided.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-04-05 12:21:36 +02:00
Lukas Fleischer
fb81bfd8df Add full support for the new .AURINFO format
This adds full support for the new .AURINFO format used by mkaurball,
including support for split packages.

The old PKGBUILD parser is still available for compatibility reasons.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-04-05 12:21:36 +02:00
Lukas Fleischer
b558572a2e Make the delete function remove package bases
Deleting a single package without deleting the whole package base makes
no sense. Comments and votes are already stored on a per-package basis,
making this a straightforward extension.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-04-05 12:21:36 +02:00
Lukas Fleischer
d35cf67f7b Store comments on a per-package base basis
Move comments from the Packages table to PackageBases. Sharing comments
makes sense since they almost always refer to a source package.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-04-05 12:21:35 +02:00
Lukas Fleischer
b7941073ac Add provisional support for package bases
This adds a PackageBases table to the database schema and moves the
following fields from the Packages table to PackageBases:

* CategoryID
* NumVotes
* OutOfDateTS
* SubmittedTS
* ModifiedTS
* SubmitterUID
* MaintainerUID

It also fixes all database accesses to comply with the new layout.

Having a separate PackageBases table is the first step to split package
support. By now, we create one PackageBases entry per package (where the
package base has the same name as the corresponding package). When
adding full support for split packages later, the package base name will
be derived from the pkgbase variable and a single package base will be
shared amongst all packages built from one source package.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-04-05 12:21:35 +02:00
Lukas Fleischer
94a4f597ff Set Content-type header when sending UTF-8 mails
Fixes FS#38568.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-02-10 21:00:36 +01:00
Lukas Fleischer
16c3a86193 Use CRLF to separate headers in mail()
This is the correct delimiter for mail headers according to the PHP
documentation and RFC 2822.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-02-10 20:48:34 +01:00
Lukas Fleischer
8c07c091e8 Remove LastVoted column
This has been introduced by commit aae43d9 (started working on package
comments, 2005-03-05) but it seems to be of no practical use. Remove the
field to save some space.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-02-09 01:43:37 +01:00
Lukas Fleischer
c09dcc4e98 Simplify canDeleteComment()
Use COUNT(*) instead of COUNT(ID) and PDO::FETCH_NUM instead of
PDO::FETCH_ASSOC. This also includes some minor formatting fixes.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-02-06 18:59:40 +01:00
Lukas Fleischer
3f0a1a827a pkgfuncs.inc.php: Fix comment style
* Use C-style comments (/* */) instead of # or //.
* Remove some superfluous comments and slightly reword others.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-02-06 18:59:40 +01:00
Lukas Fleischer
165bcba54e Style fixes: Capitalization of "true" and "false"
Use "true" instead of "TRUE" and "false" instead of "FALSE" or "False".

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-02-06 16:32:31 +01:00
Lukas Fleischer
b8a31dcc72 Do not allow unauthenticated users to delete comments
Since commit fb7bde3 (Add support for anonymous comments, 2014-02-04),
we support comments with no specific author. Add a check to
canDeleteComment() and canDeleteCommentArray() to ensure an
unauthenticated user cannot delete such comments.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-02-06 16:28:33 +01:00
Lukas Fleischer
fb7bde3a6c Add support for anonymous comments
This allows for removing users without also removing the corresponding
comments. Instead, all comments from deleted users will be displayed as
"Anonymous comment".

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-02-04 18:48:23 +01:00
canyonknight
1e9d539acf Further optimize voters.php to only need the package name
* Extends changes in 81d4cc13dc
* Modify getvotes() to use the package name rather than package ID
* Rename getvotes() to votes_for_pkgname() for clarity with new changes
* Modify routing framework and links to now use package names for voters.php

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-01-22 18:27:42 +01:00
Lukas Fleischer
c1c7f9b350 Move package comment check to packages.php
Checking whether to add a comment is something that really does not
belong to a function named display_package_details().

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-08-27 11:35:26 +02:00
Lukas Fleischer
23867a211c Add boolean return values to several pkg_*() functions
Change the return values of following functions to return both
error/success and an error/success message:

* pkg_flag()
* pkg_unflag()
* pkg_adopt()
* pkg_vote()
* pkg_delete()
* pkg_notify()
* pkg_delete_comment()
* pkg_change_category()

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-08-27 11:19:45 +02:00
Connor Behan
a386bbd35d Fix typo in delete permission warning
Signed-off-by: Connor Behan <connor.behan@gmail.com>
Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-03-19 13:50:45 +01:00
canyonknight
cf2ab50b82 Remove checks before calling connection method
Large amount of boilerplate code that checks if a database
connection exists is useless now that the new connection method
automatically does the same check.

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-02-10 12:10:38 +01:00
canyonknight
4235d24039 Remove documentation references to database parameter
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-02-10 12:10:38 +01:00
canyonknight
8d6c872297 Remove unnecessary database connection parameter from all functions
All functions now have a database connection method that will use
the same database connection. This imitates the functionality of
passing a database connection as an argument and makes it redundant.

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-02-10 12:10:38 +01:00
canyonknight
8e03e68d68 Add database wrapper class and new connection method
Uses the Singleton pattern to ensure all queries use the same
database connection that is released upon script completion.

All database connections should now be called with DB::connect() and
not db_connect().

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-02-10 12:10:37 +01:00
Marcel Korpel
8e1051932e Add description meta-element to package pages
Implements FS#33294

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-01-19 12:18:13 +01:00
canyonknight@gmail.com
20407bb8c6 Split package flagging and unflagging into separate functions
Currently, package flagging and unflagging takes place within the
pkg_flag() function. A bool is set to true or false depending on the
action.

Create new pkg_unflag() function with sole purpose of unflagging
and keep pkg_flag() in place. This split will be useful in the
overhaul of the notification system.

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-12-07 23:24:11 +01:00
canyonknight
16a20693be pkgfuncs.inc.php: Rework query to avoid "Required by" duplicates
Packages with multiple DepConditions are returned multiple
times in the "Required by" column.

Limit SQL results to distinct packages.

Fixes FS#32478

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-11-15 20:03:33 +01:00
Lukas Fleischer
f190a84577 Avoid double slashes in notifications
Both get_pkg_uri() and get_user_uri() should always return root-relative
URLs -- do not prepend another "/".

Fixes FS#32460.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-11-04 19:19:22 +01:00
canyonknight
f3325ce66f pkgfuncs.inc.php: Fix blacklisting functionality
An array that contains whether the package is blacklisted is
being improperly used for a comparison. Use fetchColumn() to
avoid the array completely and compare a value directly.

Regression with e171f6f34e

Fixes FS#31867

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-10-11 21:19:16 +02:00
canyonknight
49864b9667 pkgfuncs.inc.php: Document all functions using PHPDoc format
Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-10-04 01:47:00 +02:00
Lukas Fleischer
e9ed60566e Do not notify if status is unchanged in pkg_flag()
Check if a package actually changed its status before sending an email
to prevent from spamming. Addresses FS#31745.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-10-03 00:21:21 +02:00
Lukas Fleischer
e2f3bee01e pkgfuncs.inc.php: Fix undefined variable notice
Fixes a undefined variable notice in getvotes() that popped up when a
package without any votes was requested.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-10-03 00:21:21 +02:00
canyonknight
2c7254eb60 Remove unused pkgnotify_from_sid function
Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-09-20 10:58:29 +02:00
canyonknight
2d4dda7cc2 Remove unused canManagePackage() function
Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-09-20 10:58:29 +02:00
Lukas Fleischer
4aad42d993 Sync search result statistics with archweb
* Use archweb classes for search result statistics.
* Add some space between page numbers.
* Display current page number instead of current item range.
* Hide page numbers if the result fits into a single page.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-09-19 02:42:01 +02:00
Lukas Fleischer
3b1dad229b Fix category selection
Add a package ID parameter to pkg_change_category() instead of relying
on the "ID" or "N" GET parameters.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-09-18 16:09:30 +02:00
Lukas Fleischer
96c36dc84f Fix package notification
One cannot check if the PDOStatement object returned by query()
evaluates to true in order to check for a non-empty record set. Modify
the SQL query to count the number of records instead of retrieving the
records themselves and fixing the check.

Regression introduced in e171f6f34e.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-09-18 15:14:34 +02:00
Lukas Fleischer
20704e9053 pkgfuncs.inc.php: Add missing global keyword
Use the global keyword to import "$AUR_LOCATION" in
add_package_comment().

Regression introduced in d3de667901.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-09-18 14:01:58 +02:00
canyonknight
98b6ba9479 Use URL rewriting for user info page
Navigation to the "AccountInfo" page should only require a user to know the
username of the account they are looking for. Update all AUR links that use
the user info page to reflect the new URL.

Before:
AUR_URL/account/?Action=AccountInfo&U=userfoo

After:
AUR_URL/account/userfoo

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-09-18 00:59:21 +02:00
canyonknight
e171f6f34e Migrate all DB code to use PDO
All DB code currently uses the quickly aging mysql_* functions. These
functions are strongly discouraged and may eventually be deprecated.

Transition all code to utilize the PDO data access abstraction layer. PDO
allows for consistent query code across multiple databases. This could
potentially allow for someone to use a database other than MySQL with
minimal code changes.

All functions and behaviors are reproduced as faithfully as possible with
PDO equivalents and some changes in code.

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-09-18 00:58:46 +02:00
canyonknight
e8cd6abc6e Allow only Trusted Users, Developers, and Maintainers to unflag packages
Currently everyone is allowed to unflag a package as out of date. This should
be limited to only the appropriate people for a specific package.

Fixes FS#27263

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-08-23 22:47:50 +02:00
Lukas Fleischer
3d07a58aac pkgfuncs.inc.php: Fix pkg_change_category()
Make sure that pkg_change_category() works, even if the "N" get
parameter is used and "ID" is unset. Note that this is considered to be
a hack rather than a proper fix; pkg_change_category() needs a lot of
work.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-07-18 08:07:03 +02:00
Lukas Fleischer
4679e8ef5d Move package actions to the action box
Note that this currently only works if the virtual path feature is
enabled. If you don't use virtual paths, these will still be displayed
as buttons below the package details listing.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-07-17 22:22:09 +02:00
Lukas Fleischer
03486c3b6f Use virtual paths for package details
Extend the routing front/back ends to allow for using
"/package/$pkgname/" for individual packages.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-07-15 22:48:32 +02:00
Lukas Fleischer
2425f963f8 Use virtual path feature for links
Use virtual paths in links (e.g. link to "/packages/" instead of
"/packages.php" etc.) if the virtual path feature is enabled.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-07-15 22:44:51 +02:00