[aur-dev] [PATCH] Further optimize voters.php to only need the package name
* Extends changes in 81d4cc13dcae2f159ed937d4ce41e1df7d3c82b0 * 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 --- web/html/index.php | 2 +- web/html/voters.php | 4 ++-- web/lib/pkgfuncs.inc.php | 11 ++- web/template/pkg_details.php | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/web/html/index.php b/web/html/index.php index ccc94d2..542d594 100644 --- a/web/html/index.php +++ b/web/html/index.php @@ -56,7 +56,7 @@ if (!empty($tokens[1]) && '/' . $tokens[1] == get_pkg_route()) { include('pkgmerge.php'); return; case "voters": - $_GET['ID'] = pkgid_from_name($tokens[2]); + $_GET['N'] = $tokens[2]; include('voters.php'); return; default: diff --git a/web/html/voters.php b/web/html/voters.php index 42fe2b5..9a0bdd3 100644 --- a/web/html/voters.php +++ b/web/html/voters.php @@ -4,8 +4,8 @@ include_once('aur.inc.php'); include_once('pkgfuncs.inc.php'); $SID = $_COOKIE['AURSID']; -$pkgname = pkgname_from_id(intval($_GET['ID']); -$votes = getvotes($pkgid); +$pkgname = htmlspecialchars($_GET['N']); +$votes = votes_for_pkgname($pkgname); $atype = account_from_sid($SID); html_header(__("Voters")); diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php index a4deee6..870f55a 100644 --- a/web/lib/pkgfuncs.inc.php +++ b/web/lib/pkgfuncs.inc.php @@ -1075,16 +1075,17 @@ function pkg_vote ($atype, $ids, $action=true) { /** * Get all usernames and IDs that voted for a specific package * - * @param string $pkgid The package ID to get all votes for + * @param string $pkgname The name of the package to retrieve votes for * * @return array User IDs and usernames that voted for a specific package */ -function getvotes($pkgid) { +function votes_for_pkgname($pkgname) { $dbh = DB::connect(); - $q = "SELECT UsersID,Username FROM PackageVotes "; - $q.= "LEFT JOIN Users on (UsersID = ID) "; - $q.= "WHERE PackageID = ". $dbh->quote($pkgid) . " "; + $q = "SELECT UsersID,Username,Name FROM PackageVotes "; + $q.= "LEFT JOIN Users on (UsersID = Users.ID) "; + $q.= "LEFT JOIN Packages on (PackageID = Packages.ID) "; + $q.= "WHERE Name = ". $dbh->quote($pkgname) . " "; $q.= "ORDER BY Username"; $result = $dbh->query($q); diff --git a/web/template/pkg_details.php b/web/template/pkg_details.php index bc20a22..bd08282 100644 --- a/web/template/pkg_details.php +++ b/web/template/pkg_details.php @@ -194,7 +194,7 @@ if ($row["MaintainerUID"]): - + -- 1.8.5.3
Re: [aur-dev] [PATCH] account_details.php: Add link to edit a user's account
On Mon, Jan 20, 2014 at 9:39 AM, Lukas Fleischer wrote: > On Mon, 20 Jan 2014 at 02:29:33, canyonknight wrote: >> This improves the ability to edit a user's account directly through >> UI features rather than manually appending 'edit' to the URL or >> searching for the account and selecting edit. >> >> Signed-off-by: canyonknight >> --- >> web/template/account_details.php | 4 >> 1 file changed, 4 insertions(+) >> >> diff --git a/web/template/account_details.php >> b/web/template/account_details.php >> index 02ed32b..1f10bc1 100644 >> --- a/web/template/account_details.php >> +++ b/web/template/account_details.php >> @@ -53,6 +53,10 @@ >> Links: >> >> > this user's packages") ?> >> + > $row, uid_from_sid($_COOKIE['AURSID']))): ?> >> + >> + > ?> >> + > > Yes, this is useful. Do we want an unordered list instead of links > separated by newlines here? The downside of converting this into a list > is that most users will only see one item. So maybe use a with > "list-style-type: none;"? Sounds like a good compromise. I'll re-submit. > >> >> >> >> -- >> 1.8.5.3 >>
Re: [aur-dev] [PATCH] voters.php: Remove extra call to pkgname_from_id()
On Mon, 20 Jan 2014 at 02:27:49, canyonknight wrote: > No need to store package ID and call pkgname_from_id() twice when > the end goal is the package name. > > Signed-off-by: canyonknight > --- > web/html/voters.php | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > Good catch. Merged, thanks! > diff --git a/web/html/voters.php b/web/html/voters.php > index 9cedeef..42fe2b5 100644 > --- a/web/html/voters.php > +++ b/web/html/voters.php > @@ -4,8 +4,7 @@ include_once('aur.inc.php'); > include_once('pkgfuncs.inc.php'); > > $SID = $_COOKIE['AURSID']; > - > -$pkgid = intval($_GET['ID']); > +$pkgname = pkgname_from_id(intval($_GET['ID']); > $votes = getvotes($pkgid); > $atype = account_from_sid($SID); > > @@ -15,7 +14,7 @@ if ($atype == 'Trusted User' || $atype== 'Developer'): > ?> > > > - Votes for > + Votes for ?> > > > > -- > 1.8.5.3 >
Re: [aur-dev] [PATCH] account_details.php: Add link to edit a user's account
On Mon, 20 Jan 2014 at 02:29:33, canyonknight wrote: > This improves the ability to edit a user's account directly through > UI features rather than manually appending 'edit' to the URL or > searching for the account and selecting edit. > > Signed-off-by: canyonknight > --- > web/template/account_details.php | 4 > 1 file changed, 4 insertions(+) > > diff --git a/web/template/account_details.php > b/web/template/account_details.php > index 02ed32b..1f10bc1 100644 > --- a/web/template/account_details.php > +++ b/web/template/account_details.php > @@ -53,6 +53,10 @@ > Links: > > this user's packages") ?> > +$row, uid_from_sid($_COOKIE['AURSID']))): ?> > + > +?> > + Yes, this is useful. Do we want an unordered list instead of links separated by newlines here? The downside of converting this into a list is that most users will only see one item. So maybe use a with "list-style-type: none;"? > > > > -- > 1.8.5.3 >
Re: [aur-dev] [PATCH] acctfuncs.inc.php: Allow translation of missing strings
On Mon, 20 Jan 2014 at 02:37:34, canyonknight wrote: > Signed-off-by: canyonknight > --- > web/lib/acctfuncs.inc.php | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > Good catch, thanks! > diff --git a/web/lib/acctfuncs.inc.php b/web/lib/acctfuncs.inc.php > index fe748a2..52eb551 100644 > --- a/web/lib/acctfuncs.inc.php > +++ b/web/lib/acctfuncs.inc.php > @@ -425,7 +425,7 @@ function try_login() { > $userID = valid_user($_REQUEST['user']); > > if ( user_suspended($userID) ) { > - $login_error = "Account Suspended."; > + $login_error = __('Account suspended'); > } > elseif ( $userID && isset($_REQUEST['passwd']) > && valid_passwd($userID, $_REQUEST['passwd']) ) { > @@ -490,7 +490,7 @@ function try_login() { > > } > else { > - $login_error = "Error trying to generate > session id."; > + $login_error = __('An error occurred trying > to generate a user session.'); > } > } elseif (passwd_is_empty($userID)) { > $login_error = __('Your password has been reset. ' . > -- > 1.8.5.3 >