[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 1204
Author: beuss
Date: 2008-05-23 22:35:29 +0200 (Fri, 23 May 2008)
Log Message:
-----------
Modified Paths:
--------------
trunk/vhffs-api/src/Vhffs/Tag/Request.pm
trunk/vhffs-panel/admin/tag/request/details.pl
trunk/vhffs-panel/group/prefs.pl
trunk/vhffs-panel/templates/group/tags.tmpl
Modified: trunk/vhffs-api/src/Vhffs/Tag/Request.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Tag/Request.pm 2008-05-23 17:26:28 UTC (rev 1203)
+++ trunk/vhffs-api/src/Vhffs/Tag/Request.pm 2008-05-23 20:35:29 UTC (rev 1204)
@@ -136,4 +136,26 @@
return $dbh->do($sql, undef, $self->{request_id});
}
+package Vhffs::Object;
+
+sub get_tag_requests {
+ my ($self) = @_;
+
+ my $requests = [];
+
+ my $dbh = $self->get_db_object();
+ my $sql = q{SELECT tag_request_id, category_label, tag_label, created, requester_id, tagged_id
+ FROM vhffs_tag_request WHERE tagged_id = ? ORDER BY created};
+
+ my $sth = $dbh->prepare($sql);
+
+ $sth->execute($self->get_oid()) or return undef;
+
+ while(my $c = $sth->fetchrow_arrayref()) {
+ push @$requests, _new Vhffs::Tag::Request($self->get_main(), @$c);
+ }
+
+ return $requests;
+}
+
1;
Modified: trunk/vhffs-panel/admin/tag/request/details.pl
===================================================================
--- trunk/vhffs-panel/admin/tag/request/details.pl 2008-05-23 17:26:28 UTC (rev 1203)
+++ trunk/vhffs-panel/admin/tag/request/details.pl 2008-05-23 20:35:29 UTC (rev 1204)
@@ -88,6 +88,10 @@
$template->param('TAG' => $cgi->param('tag_label'));
$template->param('TAG_DESCRIPTION' => $cgi->param('tag_description'));
}
+} elsif(defined $cgi->param('discard_request_submit')) {
+ $request->delete();
+ my $url = '/admin/tag/request/list.pl?msg='.gettext('Tag request deleted');
+ $panel->redirect($url);
} else {
$template->param('CATEGORY' => $request->{category_label});
$template->param('TAG' => $request->{tag_label});
Modified: trunk/vhffs-panel/group/prefs.pl
===================================================================
--- trunk/vhffs-panel/group/prefs.pl 2008-05-23 17:26:28 UTC (rev 1203)
+++ trunk/vhffs-panel/group/prefs.pl 2008-05-23 20:35:29 UTC (rev 1204)
@@ -205,6 +205,8 @@
delete_tag();
} elsif( defined( $cgi->param('request_tag_submit') ) ) {
request_tag();
+ } elsif( defined( $cgi->param('cancel_tag_request_submit') ) ) {
+ cancel_request();
}
@@ -313,6 +315,8 @@
$template->param( CATEGORIES => $categories );
$template->param( CURRENT_TAGS => $group->get_tags($visibility) );
+
+ $template->param( TAG_REQUESTS => $group->get_tag_requests() );
}
sub add_tag {
@@ -402,3 +406,28 @@
}
+sub cancel_request {
+ unless( $user->can_modify( $group ) ) {
+ $panel->add_error( gettext( 'You\'re not allowed to do this (ACL rights)' ) );
+ return 0;
+ }
+
+ my $request_id = $cgi->param('request_id');
+
+ my $request = Vhffs::Tag::Request::get_by_request_id($vhffs, $request_id);
+
+ unless(defined $request) {
+ $panel->add_error( gettext('Request not found') );
+ return 0;
+ }
+
+ if($request->{tagged_id} != $group->get_oid()) {
+ $panel->add_error( gettext('You can only delete requests attached to your group') );
+ return 0;
+ }
+
+ $request->delete();
+
+ $panel->add_info( gettext('Request canceled') );
+ return 1;
+}
Modified: trunk/vhffs-panel/templates/group/tags.tmpl
===================================================================
--- trunk/vhffs-panel/templates/group/tags.tmpl 2008-05-23 17:26:28 UTC (rev 1203)
+++ trunk/vhffs-panel/templates/group/tags.tmpl 2008-05-23 20:35:29 UTC (rev 1204)
@@ -35,3 +35,14 @@
</p>
<p class="button"><input type="submit" name="request_tag_submit" value="<TMPL_I18N KEY="OK">"/></p>
</form>
+<TMPL_IF NAME="TAG_REQUESTS">
+<h3><TMPL_I18N KEY="Pending tag requests"></h3>
+<ul>
+<TMPL_LOOP NAME="TAG_REQUESTS">
+<li>
+<TMPL_VAR NAME="CATEGORY_LABEL">::<TMPL_VAR NAME="TAG_LABEL">
+[<a href="?cancel_tag_request_submit=true&request_id=<TMPL_VAR NAME="REQUEST_ID">"><TMPL_I18N KEY="Cancel"></a>]
+</li>
+</TMPL_LOOP>
+</ul>
+</TMPL_IF>
\ No newline at end of file