Commit graph

56 commits

Author SHA1 Message Date
Jelle van der Waa
06fa8ab5f3
Convert comment editing to vanilla JavaScript
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
2021-06-21 15:19:22 -04:00
Vladimir Panteleev
f046dd5828
pkg_comments.php: Make comment timestamps link to the comment
As of today, there is no easy way to obtain a link to a specific
comment on a package page.

Many implementations of forums and comment systems today seem to
follow a convention where a comment's timestamp is an unobtrusive link
to the comment itself. Some examples are:

- phpBB (e.g. bbs.archlinux.org)
- GitHub
- Disqus
- Discourse

This patch adopts this convention as well, by making the timestamp a
link to the comment.
2018-10-16 21:45:19 -04:00
Johannes Löthberg
3578e77ad4 Allow listing all comments from a user
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-08-06 06:03:58 +02:00
Lukas Fleischer
4b8b2e3eb1 Stop using each()
The each() function has been deprecated as of PHP 7.2.0. Use foreach
loops instead.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-05-12 13:35:11 +02:00
Lukas Fleischer
4be9aa6350 Fix the comment collapse feature
In commit 4abde89 (Use JavaScript to collapse long comments,
2017-04-19), support for collapsing/expanding long comments was added.
This was broken by the recent Markdown support since comments no longer
live inside a single HTML paragraph. Fix this by wrapping each comment
in another div container.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-24 21:10:02 +02:00
Lukas Fleischer
016b40f99d Render comments when storing them in the database
Instead of converting package comments from plain text to HTML code when
they are displayed, do the conversion when the comment is posted and
store the rendered result in the database. The conversion itself is done
by a Python script which uses Bleach for sanitizing the text.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-23 18:43:26 +02:00
Lukas Fleischer
4abde895a5 Use JavaScript to collapse long comments
Instead of using CSS to limit the height of package comments as
implemented in 7b13203 (Limit comment height to 15 lines, 2016-03-12),
use JavaScript to collapse long comments and add a link to expand them.
Clicking the same link twice results in the corresponding comment being
collapsed again.

If JavaScript is disabled, the full comments are shown (without any
possibility to collapse or expand).

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-20 07:03:54 +02:00
Mark Weiman
608c483090 Add user set timezones
Currently, aurweb displays all dates and times in UTC time. This patch
adds a capability for each logged in user to set their preferred
timezone.

Implements FS#48729.

Signed-off-by: Mark Weiman <mark.weiman@markzz.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-01-20 23:20:40 +01:00
Mark Weiman
b3a6809bad Fix duplicate ids from pinned comments
Fixed duplicate ids caused from pinned comments introduced in 7d4c0c9
(Implement capability to pin comments above others, 2015-12-12).

Signed-off-by: Mark Weiman <mark.weiman@markzz.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2016-01-24 21:34:54 +01:00
Marcel Korpel
bd85441cf6 Add comment undeletion functionality
Only Developers and Trusted Users can undelete comments.

Signed-off-by: Marcel Korpel <marcel.korpel@gmail.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2016-01-23 11:50:03 +01:00
Lukas Fleischer
4653945226 Hide names of deleted accounts in comment headings
When the account of a user who edited/deleted a comment is removed, drop
occurrences of his user name in comment headings instead of replacing
the user name with "None".

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-12-13 21:20:39 +01:00
Lukas Fleischer
51407d4a29 Store current date and time when deleting comments
Instead of modifying EditedTS when a comment is deleted, use a separate
field DelTS. Use this field to determine whether a comment has been
deleted, instead of checking DelUsersID which might be unset when the
corresponding user is deleted.

Fixes FS#47362.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-12-13 21:19:31 +01:00
Lukas Fleischer
c085be8c0d Only show "last edited" to logged in users
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-12-12 21:59:35 +01:00
Mark Weiman
7d4c0c9ffa Implement capability to pin comments above others
Adds capability to pin comments before others.

Implements FS#10863.

Signed-off-by: Mark Weiman <mark.weiman@markzz.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-12-12 15:09:47 +01:00
Mark Weiman
3088fd0f38 Remove reassignment of base_id in pkg_comments.php
Removes reassignment of $base_id in web/template/pkg_comments.php as it is
assigned in both pkgbase_display_details() and pkg_display_details().

Signed-off-by: Mark Weiman <mark.weiman@markzz.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-12-12 15:09:44 +01:00
Marcel Korpel
54d812ec79 pkg_comments.php: Add JavaScript function to edit comments
Signed-off-by: Marcel Korpel <marcel.korpel@gmail.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-08-08 12:59:24 +02:00
Marcel Korpel
41b6cff7c0 pkg_comments.php: Merge two DIVs with same ID
Signed-off-by: Marcel Korpel <marcel.korpel@gmail.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-08-08 12:59:24 +02:00
Marcel Korpel
67cff2cd5a Add IDs to comments
Signed-off-by: Marcel Korpel <marcel.korpel@gmail.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-08-08 12:59:24 +02:00
Marcel Korpel
9cde6b0566 Show dateline when a comment is edited or deleted
Signed-off-by: Marcel Korpel <marcel.korpel@gmail.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-08-08 12:59:24 +02:00
Marcel Korpel
92e19e95f3 Add comment edit icon and form
Show an icon next to the comment deletion icon, which leads to a
comment edit form.

Signed-off-by: Marcel Korpel <marcel.korpel@gmail.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-08-08 12:59:23 +02:00
Marcel Korpel
8375d21210 Use SVG image for comment deletion icon
This also puts the icon to the right and the timestamp in the byline
and wipes out a repeated instance of the byline.

Signed-off-by: Marcel Korpel <marcel.korpel@gmail.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-08-08 12:59:23 +02:00
Lukas Fleischer
daceef50eb Make deleted comments visible to Trusted Users
This allows Trusted Users to check whether a user posted a politically
incorrect comment, even if he already deleted it.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-07-25 11:30:32 +02:00
Lukas Fleischer
68abf41b94 Display correct comment count on package base page
Show the correct number of package base comments in the tool tip message
of the "Latest Comments" link.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-07-23 11:14:40 +02:00
Lukas Fleischer
088aab44ea Drop comment count from translatable message
The title "View all %s comments" becomes "View all %s comment" when
adding plural support (which is needed for other languages that have
more than one plural form). Simply remove the comment count from the
message and add it in parentheses.

Suggested-by: Safa Alfulaij <safa1996alfulaij@gmail.com>
Suggested-by: Sebastian Wilzbach <sebi@wilzbach.me>
Suggested-by: kachelaqa <kachelaqa@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-07-23 11:09:40 +02:00
Lukas Fleischer
03c6304e19 Rework permission handling
Add a new function has_credential() that checks whether the currently
logged in user is allowed to perform a given action. Moving all
permission handling to this central place makes adding new user groups
and adjusting permissions much more convenient.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-07-15 22:56:57 +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
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
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
8ee6888f1d pkg_comments.php: Move delete button to same line as poster info
The delete button is currently on a separate line. Change some logic
to allow for the button to be on the same line as poster info.

Reported-by: Dave Reisner <d@falconindy.com>
Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-10-11 21:20:01 +02:00
Lukas Fleischer
6102759b7c Use echo shortcut syntax
Replace all occurrences of "<?php echo" and "<?php print" by "<?=" to
reduce noise in templates.

Note that as of PHP 5.4.0, "<?=" is always available and no longer
requires "short_open_tag" to be set.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-09-24 12:23:04 +02:00
Lukas Fleischer
c318a50435 pkg_comments.php: Fix "Latest Comments" link
Avoid adding "?comments=all" more than once if the "Latest Comments"
link is clicked multiple times.

Reported-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-09-18 14:13:26 +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
Lukas Fleischer
9de84d2fd5 pkg_comments.php: Fix comment deletion links
* Add a missing quote to the "alt" attribute. Regression introduced in
  d8b2eb4b62.

* Retrieve and store the package name before overwriting the "$row"
  variable.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-07-18 08:07:17 +02:00
Lukas Fleischer
bd4a7aa0ff pkg_comments.php: Fix links to user accounts
Regression introduced in 2425f963f8.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-07-18 08:07:17 +02:00
Lukas Fleischer
af95c2b1fe pkg_comments.php: Fix notice
Fix a notice that appeared if comments were available and the package
was requested by name. See 07d3649c2d for
a similar fix for links to the voters page.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-07-17 22:44:27 +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
Lukas Fleischer
a03c684ecd Use absolute URIs for style sheets and images
This is needed for our new URI scheme, since we will use virtual
directories, such as "/packages/" instead of "/packages.php" etc.

Having relative URIs results in incorrect paths, such as
"/packages/css/aur.css" (instead of "/css/aur.css").

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-07-15 22:42:45 +02:00
Lukas Fleischer
f3ce74c714 Merge branch 'maint'
Conflicts:
	web/html/account.php
	web/html/addvote.php
	web/html/pkgsubmit.php
	web/lib/acctfuncs.inc.php
	web/template/actions_form.php
	web/template/pkg_comment_form.php
	web/template/pkg_comments.php
	web/template/pkg_details.php
	web/template/pkg_search_results.php
	web/template/tu_details.php
2012-07-14 22:52:04 +02:00
canyonknight
d8b2eb4b62 pkg_comments.php: Overhaul to match archweb
* Limit PHP echoing XHTML as much as possible, and use pure XHTML
* Switch to alternative syntax in control structures for better readability of
inter-mixed XHTML
* Remove box for every comment and switch to archweb news post style

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-07-06 11:26:23 +02:00
Lukas Fleischer
4a4f26cda6 Use sane date format strings everywhere
We fixed this for the fields displayed on the package details page in
commit b5fffe9a02cd4fd3b7da66e403f02eea89c8fcad. This should fix the
remaining ones.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Signed-off-by: canyonknight <canyonknight@gmail.com>
2012-07-06 11:25:50 +02:00
canyonknight
2c93f0a98f Implement token system to fix CSRF vulnerabilities
Specially crafted pages can force authenticated users to unknowingly perform
actions on the AUR website despite being on an attacker's website. This
cross-site request forgery (CSRF) vulnerability applies to all POST data on
the AUR.

Implement a token system using a double submit cookie. Have a hidden form
value on every page containing POST forms. Use the newly added check_token() to
verify the token sent via POST matches the "AURSID" cookie value. Random
nature of the token limits potential for CSRF.

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-06-24 10:59:23 +02:00
Dario Giovannetti
937cda9ccb HTML/DOM fixes
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-05-31 12:01:23 +02:00
Lukas Fleischer
cf2f667512 Support canonical links to packages
This is more user-friendly than supporting package IDs only and can be
used as a basis to support direct links to AUR packages in places where
links are computer-produced (e.g. Wiki templates).

Addresses FS#21600 and FS#28839.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-03-24 10:34:35 +01:00
Lukas Fleischer
3aa2240b7d Fix XSS vulnerabilities in package comment templates.
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-03-30 10:49:51 +02:00
Lukas Fleischer
7f9e498e48 Fix broken XHTML.
Fix a lot of invalid XHTML in the templates and actions. There might
still be some legacy code left, but this should cover most of it.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-03-11 19:00:50 +01:00
Lukas Fleischer
60edcd04e5 Make external links in comments clickable (FS#20137).
Comments are now split at link boundaries and links are converted
separately. I find this to be a much cleaner way than re-converting
comments that have already been converted using htmlspecialchars(). This
also doesn't require any callback procedure.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-01-19 21:18:45 +01:00
Dan Vratil
57a5cbfd88 Auto redirect from confirmation screens.
Finally move comment deletion and category editing into functions and
remove pkgedit.php

Signed-off-by: Loui Chang <louipc.ist@gmail.com>
-Fix indentation
-Fix variable naming conflict $id vs $cid
2010-11-21 03:37:17 -05:00