[vhffs-dev] [1175] Let's add tag categories. |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 1175
Author: beuss
Date: 2008-03-19 07:59:56 +0100 (Wed, 19 Mar 2008)
Log Message:
-----------
Let's add tag categories.
Modified Paths:
--------------
trunk/vhffs-api/src/Vhffs/Constants.pm
trunk/vhffs-api/src/Vhffs/Makefile.am
trunk/vhffs-api/src/Vhffs/Panel/Admin.pm
trunk/vhffs-api/src/Vhffs/Services/Svn.pm
trunk/vhffs-intl/extra_strings.pl
trunk/vhffs-panel/Makefile.am
trunk/vhffs-panel/templates/Makefile.am
trunk/vhffs-panel/templates/group/prefs.tmpl
Added Paths:
-----------
trunk/vhffs-api/src/Vhffs/Tag/
trunk/vhffs-api/src/Vhffs/Tag/Category.pm
trunk/vhffs-api/src/Vhffs/Tag.pm
trunk/vhffs-panel/admin/tag/
trunk/vhffs-panel/admin/tag/category/
trunk/vhffs-panel/admin/tag/category/create.pl
trunk/vhffs-panel/admin/tag/category/edit.pl
trunk/vhffs-panel/admin/tag/category/list.pl
trunk/vhffs-panel/admin/tag/index.pl
trunk/vhffs-panel/templates/admin/tag/
trunk/vhffs-panel/templates/admin/tag/category/
trunk/vhffs-panel/templates/admin/tag/category/create.tmpl
trunk/vhffs-panel/templates/admin/tag/category/edit.tmpl
trunk/vhffs-panel/templates/admin/tag/category/list.tmpl
trunk/vhffs-panel/templates/group/tags.tmpl
Modified: trunk/vhffs-api/src/Vhffs/Constants.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Constants.pm 2008-03-17 21:41:06 UTC (rev 1174)
+++ trunk/vhffs-api/src/Vhffs/Constants.pm 2008-03-19 06:59:56 UTC (rev 1175)
@@ -75,6 +75,11 @@
TYPE_DNS => 50,
TYPE_MAIL => 60,
TYPE_ML => 61,
+
+# Tags visibility
+ TAG_VISIBILITY_PUBLIC => 1,
+ TAG_VISIBILITY_MODERATORS => 2,
+ TAG_VISIBILITY_ADMINS => 3,
};
1;
Modified: trunk/vhffs-api/src/Vhffs/Makefile.am
===================================================================
--- trunk/vhffs-api/src/Vhffs/Makefile.am 2008-03-17 21:41:06 UTC (rev 1174)
+++ trunk/vhffs-api/src/Vhffs/Makefile.am 2008-03-19 06:59:56 UTC (rev 1175)
@@ -18,6 +18,7 @@
Robots.pm \
Services.pm \
Stats.pm \
+ Tag.pm \
User.pm \
Panel/Admin.pm \
Panel/Avatar.pm \
@@ -60,7 +61,8 @@
Services/Pgsql.pm \
Services/Repository.pm \
Services/Svn.pm \
- Services/Git.pm
+ Services/Git.pm \
+ Tag/Category.pm
# Define the substitution we need to point perl script at correct location
do_sed = $(SED) --in-place \
Modified: trunk/vhffs-api/src/Vhffs/Panel/Admin.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Admin.pm 2008-03-17 21:41:06 UTC (rev 1174)
+++ trunk/vhffs-api/src/Vhffs/Panel/Admin.pm 2008-03-19 06:59:56 UTC (rev 1175)
@@ -136,6 +136,25 @@
}
+=head2 get_tag_category
+
+ Vhffs::Panel::Admin::get_tag_cagtegory
+
+Returns a hashref (CATNAME, ITEM, CATTYPE) containing tags'
+administration items
+
+=cut
+
+sub get_tag_category {
+ my $items = [
+ { LINK => '/admin/tag/create.pl', LABEL => gettext( 'Create new tag' ) },
+ { LINK => '/admin/tag/category/create.pl', LABEL => gettext( 'Create new category' )},
+ { LINK => '/admin/tag/category/list.pl', LABEL => gettext( 'Manage existing categories' )},
+ { LINK => '/admin/tag/request.pl', LABEL => gettext('Manage requests')}
+ ];
+ return { CATNAME => gettext( 'Tags Admin'), ITEMS => $items, CATTYPE => 'tags' };
+}
+
=head2 get_web_category
Vhffs::Panel::Admin::get_web_category;
@@ -339,6 +358,7 @@
push @$categories, get_mail_category if($config->get_service_availability('mail'));
push @$categories, get_mailing_category if($config->get_service_availability('mailinglist'));
push @$categories, get_repo_category if($config->get_service_availability('repository'));
+ push @$categories, get_tag_category;
return $categories;
}
Modified: trunk/vhffs-api/src/Vhffs/Services/Svn.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Svn.pm 2008-03-17 21:41:06 UTC (rev 1174)
+++ trunk/vhffs-api/src/Vhffs/Services/Svn.pm 2008-03-19 06:59:56 UTC (rev 1175)
@@ -223,7 +223,7 @@
my $dbh = $vhffs->get_db_object();
my $sth = $dbh->prepare($sql);
- $sth->execute(@params) or die($sql) ; #return undef;
+ $sth->execute(@params) or return undef;
while(my $s = $sth->fetchrow_arrayref()) {
push(@$svn, _new Vhffs::Services::Svn($vhffs, @$s));
Added: trunk/vhffs-api/src/Vhffs/Tag/Category.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Tag/Category.pm (rev 0)
+++ trunk/vhffs-api/src/Vhffs/Tag/Category.pm 2008-03-19 06:59:56 UTC (rev 1175)
@@ -0,0 +1,154 @@
+# Copyright (c) vhffs project and its contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+#3. Neither the name of vhffs nor the names of its contributors
+# may be used to endorse or promote products derived from this
+# software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+=head1 Vhffs::Tag::Category
+=head2 SYNOPSIS
+
+Object allowing tags categories manipulation
+
+=cut
+
+use strict;
+use utf8;
+
+use Vhffs::Constants;
+
+package Vhffs::Tag::Category;
+
+my @VISIBILITY_STRING;
+$VISIBILITY_STRING[Vhffs::Constants::TAG_VISIBILITY_PUBLIC] = 'Public';
+$VISIBILITY_STRING[Vhffs::Constants::TAG_VISIBILITY_MODERATORS] = 'Moderators';
+$VISIBILITY_STRING[Vhffs::Constants::TAG_VISIBILITY_ADMINS] = 'Administrators';
+
+sub create {
+ my ($main, $label, $description, $visibility, $creator, $updated) = @_;
+ $updated = time() unless(defined $updated);
+
+ my $dbh = $main->get_db_object();
+
+ my $sql = q{INSERT INTO vhffs_tag_category(label, description, visibility, updated, updater_id) VALUES (?, ?, ?, ?, ?)};
+ $dbh->do($sql, undef, $label, $description, $visibility, $updated, $creator->get_uid);
+
+ my $category_id = $dbh->last_insert_id(undef, undef, 'vhffs_tag_category', undef);
+ return get_by_category_id($main, $category_id);
+}
+
+sub get_by_category_id {
+ my ($main, $category_id) = @_;
+
+ my $dbh = $main->get_db_object();
+
+ my $sql = q{SELECT tag_category_id, label, description, visibility, updated, updater_id
+ FROM vhffs_tag_category WHERE tag_category_id = ?};
+
+ my $sth = $dbh->prepare($sql);
+ $sth->execute($category_id) or return undef;
+ my @results = $sth->fetchrow_array();
+ return undef unless @results;
+
+ my $category = _new Vhffs::Tag::Category($main, @results);
+
+ return $category;
+}
+
+
+sub get_all {
+ my ($main, $visibility) = @_;
+
+ my @params = ();
+ my $cats = [];
+
+ my $sql = q{SELECT tag_category_id, label, description, visibility, updated, updater_id
+ FROM vhffs_tag_category};
+ if(defined $visibility) {
+ $sql .= q{ WHERE visibility = ?};
+ push @params, $visibility;
+ }
+ $sql .= q{ ORDER BY label};
+
+ my $dbh = $main->get_db_object();
+
+ my $sth = $dbh->prepare($sql);
+ $sth->execute(@params) or return undef;
+
+ while(my $c = $sth->fetchrow_arrayref()) {
+ push @$cats, _new Vhffs::Tag::Category($main, @$c);
+ }
+
+ return $cats;
+}
+
+sub _new {
+ my($class, $main, $category_id, $label, $description, $visibility, $updated, $updater_id) = @_;
+
+ my $self = {};
+
+ bless($self, $class);
+
+ $self->{main} = $main;
+ $self->{category_id} = $category_id;
+ $self->{label} = $label;
+ $self->{description} = $description;
+ $self->{visibility} = $visibility;
+ $self->{updated} = $updated;
+ $self->{updater_id} = $updater_id;
+
+ return $self;
+}
+
+sub save {
+ my ($self) = @_;
+ my $sql = q{UPDATE vhffs_tag_category SET label = ?, description = ?, visibility = ?, updated = ?, updater_id = ? WHERE tag_category_id = ?};
+ my $dbh = $self->{main}->get_db_object();
+ return $dbh->do($sql, undef, $self->{label}, $self->{description}, $self->{visibility}, $self->{updated}, $self->{updater_id}, $self->{category_id});
+}
+
+sub delete {
+ my ($self) = @_;
+ my $sql = q{DELETE FROM vhffs_tag_category WHERE tag_category_id = ?};
+ my $dbh = $self->{main}->get_db_object();
+ return $dbh->do($sql, undef, $self->{category_id});
+}
+
+sub get_updater {
+ my ($self) = @_;
+
+ unless( defined $self->{updater} ) {
+ $self->{updater} = Vhffs::User::get_by_uid($self->{main}, $self->{updater_id});
+ }
+ return $self->{updater};
+}
+
+sub get_visibility_string {
+ my($visibility_id) = @_;
+ return $VISIBILITY_STRING[$visibility_id];
+}
+
+1;
\ No newline at end of file
Added: trunk/vhffs-api/src/Vhffs/Tag.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Tag.pm (rev 0)
+++ trunk/vhffs-api/src/Vhffs/Tag.pm 2008-03-19 06:59:56 UTC (rev 1175)
@@ -0,0 +1,58 @@
+# Copyright (c) vhffs project and its contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+#3. Neither the name of vhffs nor the names of its contributors
+# may be used to endorse or promote products derived from this
+# software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+=head1 Vhffs::Tag
+=head2 SYNOPSIS
+
+Object allowing tags manipulation
+
+=cut
+
+
+use strict;
+use utf8;
+
+package Vhffs::Tag;
+
+sub create {
+ my ($main, $label, $description, $creator, $category, $created) = @_;
+ $created = time() unless(defined $created);
+
+ my $dbh = $main->get_db_object();
+
+ my $sql = q{INSERT INTO vhffs_tag(label, description, created, category_id, creator_id) VALUES(?, ?, ?, ?)};
+ my $sth = $dbh->prepare($sql);
+ $sth->execute($label, $description, $created, $category->get_id, $creator->get_uid);
+
+ my $tag_id = $dbh->last_insert_id(undef, undef, 'vhffs_tag', undef);
+ return get_by_tag_id($tag_id);
+}
+
+1;
\ No newline at end of file
Modified: trunk/vhffs-intl/extra_strings.pl
===================================================================
--- trunk/vhffs-intl/extra_strings.pl 2008-03-17 21:41:06 UTC (rev 1174)
+++ trunk/vhffs-intl/extra_strings.pl 2008-03-19 06:59:56 UTC (rev 1175)
@@ -44,3 +44,8 @@
gettext_noop('Mail Domain');
gettext_noop('Mailing List');
+# Tags' visibility
+
+gettext_noop('Public');
+gettext_noop('Moderators');
+gettext_noop('Administrators');
Modified: trunk/vhffs-panel/Makefile.am
===================================================================
--- trunk/vhffs-panel/Makefile.am 2008-03-17 21:41:06 UTC (rev 1174)
+++ trunk/vhffs-panel/Makefile.am 2008-03-19 06:59:56 UTC (rev 1175)
@@ -57,6 +57,10 @@
admin/svn/index.pl \
admin/svn/list.pl \
admin/svn/search.pl \
+ admin/tag/index.pl \
+ admin/tag/category/create.pl \
+ admin/tag/category/edit.pl \
+ admin/tag/category/list.pl \
admin/git/index.pl \
admin/git/list.pl \
admin/git/search.pl \
Added: trunk/vhffs-panel/admin/tag/category/create.pl
===================================================================
--- trunk/vhffs-panel/admin/tag/category/create.pl (rev 0)
+++ trunk/vhffs-panel/admin/tag/category/create.pl 2008-03-19 06:59:56 UTC (rev 1175)
@@ -0,0 +1,98 @@
+#!%PERL% -w
+# Copyright (c) vhffs project and its contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+#3. Neither the name of vhffs nor the names of its contributors
+# may be used to endorse or promote products derived from this
+# software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+
+use utf8;
+use POSIX qw(locale_h);
+use locale;
+use Locale::gettext;
+use strict;
+
+
+use lib '%VHFFS_LIB_DIR%';
+use Vhffs::Panel::Main;
+use Vhffs::Panel::Admin;
+use Vhffs::Panel::Template;
+use Vhffs::Tag::Category;
+
+my $panel = new Vhffs::Panel::Main();
+exit 0 unless $panel;
+my $session = $panel->get_session;
+exit 0 unless $session;
+
+$panel->check_admin;
+
+my $cgi = $panel->{cgi};
+
+if(defined $cgi->param('create_tag_category_submit')) {
+ if(create()) {
+ $panel->redirect('/admin/tag/index.pl?msg='.gettext('Tag category successfully created'));
+ exit(0);
+ }
+}
+
+my $templatedir = $panel->{templatedir};
+
+my $template = new Vhffs::Panel::Template(filename => $templatedir.'/panel/admin/tag/category/create.tmpl');
+
+$panel->set_title(gettext('Create Tag Category'));
+
+$template->param( LABEL_TEXT => gettext('Label') );
+$template->param( DESCRIPTION_TEXT => gettext('Description') );
+$template->param( VISIBILITY_TEXT => gettext('Visibility') );
+$template->param( VISIBILITIES => [
+ { CODE => Vhffs::Constants::TAG_VISIBILITY_PUBLIC, LABEL => gettext('Public') },
+ { CODE => Vhffs::Constants::TAG_VISIBILITY_MODERATORS, LABEL => gettext('Moderators') },
+ { CODE => Vhffs::Constants::TAG_VISIBILITY_ADMINS, LABEL => gettext('Administrators') }
+]);
+$template->param( CREATE_TEXT => gettext('Create') );
+
+$panel->build( $template );
+$panel->display;
+
+
+sub create {
+ my $vhffs = $panel->{vhffs};
+ my $label = $cgi->param('label');
+ my $description = $cgi->param('description');
+ my $visibility = $cgi->param('visibility');
+
+ if(!(defined $label && defined $description && defined $visibility)) {
+ $panel->add_error( gettext('CGI error') );
+ return 0;
+ }
+
+ if(!defined Vhffs::Tag::Category::create($vhffs, $label, $description, $visibility, $panel->{user})) {
+ $panel->add_error( gettext('Unable to create category') );
+ return 0;
+ }
+ return 1;
+}
\ No newline at end of file
Added: trunk/vhffs-panel/admin/tag/category/edit.pl
===================================================================
--- trunk/vhffs-panel/admin/tag/category/edit.pl (rev 0)
+++ trunk/vhffs-panel/admin/tag/category/edit.pl 2008-03-19 06:59:56 UTC (rev 1175)
@@ -0,0 +1,132 @@
+#!%PERL% -w
+# Copyright (c) vhffs project and its contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+#3. Neither the name of vhffs nor the names of its contributors
+# may be used to endorse or promote products derived from this
+# software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+
+use utf8;
+use POSIX qw(locale_h);
+use HTML::Template;
+use locale;
+use Locale::gettext;
+use strict;
+
+
+use lib '%VHFFS_LIB_DIR%';
+use Vhffs::Panel::Admin;
+use Vhffs::Panel::Main;
+use Vhffs::Panel::Template;
+use Vhffs::Tag::Category;
+
+my $panel = new Vhffs::Panel::Main();
+exit 0 unless $panel;
+my $session = $panel->get_session;
+exit 0 unless $session;
+
+$panel->check_admin;
+
+my $cgi = $panel->{cgi};
+my $category;
+my $template;
+my $templatedir = $panel->{templatedir};
+my $user = $panel->{user};
+
+if(!defined $cgi->param('category_id')) {
+ $template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
+ $template->param( MESSAGE => gettext('CGI Error!') );
+} elsif(!defined($category = Vhffs::Tag::Category::get_by_category_id($panel->{vhffs}, $cgi->param('category_id')))) {
+ $template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
+ $template->param( MESSAGE => gettext('Category not found!') );
+} else {
+ if(defined $cgi->param('update_tag_category_submit')) {
+ if(update()) {
+ $panel->add_info( gettext('Tag category successfully updated') );
+ } else {
+ $panel->add_error( gettext('Unable to update category') )
+ }
+ }
+
+ $template = new Vhffs::Panel::Template(filename => $templatedir.'/panel/admin/tag/category/edit.tmpl');
+
+ $panel->set_title(gettext('Update Tag Category'));
+
+ $template->param( LABEL_TEXT => gettext('Label') );
+ $template->param( DESCRIPTION_TEXT => gettext('Description') );
+ $template->param( VISIBILITY_TEXT => gettext('Visibility') );
+ $template->param( VISIBILITIES => [
+ { CODE => Vhffs::Constants::TAG_VISIBILITY_PUBLIC, LABEL => gettext('Public') },
+ { CODE => Vhffs::Constants::TAG_VISIBILITY_MODERATORS, LABEL => gettext('Moderators') },
+ { CODE => Vhffs::Constants::TAG_VISIBILITY_ADMINS, LABEL => gettext('Administrators') }
+ ]);
+ $template->param( UPDATE_TEXT => gettext('Update') );
+ $template->param( LABEL_VALUE => $category->{label} );
+ $template->param( DESCRIPTION_VALUE => $category->{description} );
+ $template->param( VISIBILITY_VALUE => $category->{visibility} );
+ $template->param( CATEGORY_ID_VALUE => $category->{category_id} );
+
+}
+$panel->build( $template );
+$panel->display;
+
+
+sub update {
+ my $vhffs = $panel->{vhffs};
+ my $label = $cgi->param('label');
+ my $description = $cgi->param('description');
+ my $visibility = $cgi->param('visibility');
+
+ if(!(defined $label && defined $description && defined $visibility)) {
+ $panel->add_error( gettext('CGI error') );
+ return 0;
+ }
+
+ if($label =~ /^\s*$/) {
+ $panel->add_error( gettext('You have to enter a label') );
+ }
+
+ if($description =~ /^\s*$/) {
+ $panel->add_error( gettext('You have to enter a description') );
+ }
+
+ if($visibility !~ /^[1-3]$/) {
+ $panel->add_error( gettext('Invalid visibility') );
+ }
+
+ if($panel->has_errors()) {
+ return 0;
+ }
+
+
+ $category->{label} = $label;
+ $category->{description} = $description;
+ $category->{visibility} = $visibility;
+ $category->{updated} = time();
+ $category->{updater_id} = $user->get_uid;
+ return $category->save();
+}
\ No newline at end of file
Added: trunk/vhffs-panel/admin/tag/category/list.pl
===================================================================
--- trunk/vhffs-panel/admin/tag/category/list.pl (rev 0)
+++ trunk/vhffs-panel/admin/tag/category/list.pl 2008-03-19 06:59:56 UTC (rev 1175)
@@ -0,0 +1,95 @@
+#!%PERL% -w
+# Copyright (c) vhffs project and its contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+#3. Neither the name of vhffs nor the names of its contributors
+# may be used to endorse or promote products derived from this
+# software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+
+use utf8;
+use POSIX qw(locale_h);
+use locale;
+use Locale::gettext;
+use DateTime;
+use DateTime::Locale;
+use strict;
+
+
+use lib '%VHFFS_LIB_DIR%';
+use Vhffs::Panel::Main;
+use Vhffs::Panel::Admin;
+use Vhffs::Panel::Template;
+use Vhffs::Tag::Category;
+
+my $panel = new Vhffs::Panel::Main();
+exit 0 unless $panel;
+my $session = $panel->get_session;
+exit 0 unless $session;
+
+$panel->check_admin;
+
+my $cgi = $panel->{cgi};
+
+if(defined $cgi->param('delete_category_submit')) {
+ if(delete_category()) {
+ $panel->add_info( gettext('Category deleted') );
+ } else {
+ $panel->add_error( gettext('Unable to delete category') );
+ }
+}
+
+my $templatedir = $panel->{templatedir};
+
+my $template = new Vhffs::Panel::Template(filename => $templatedir.'/panel/admin/tag/category/list.tmpl', die_on_bad_params => 0 );
+
+$panel->set_title(gettext('Tag categories'));
+
+my $categories = Vhffs::Tag::Category::get_all($panel->{vhffs});
+# We should really drop HTML::Template....
+my $user = $panel->{user};
+my $loc = DateTime::Locale->load($user->get_lang);
+foreach(@$categories) {
+ my $dt = DateTime->from_epoch( epoch => $_->{updated}, locale => $user->get_lang);
+ $_->{updated} = $dt->strftime($loc->medium_date_format().' '.$loc->long_time_format());
+ $_->{updater_name} = $_->get_updater()->get_username();
+ $_->{visibility_string} = Vhffs::Tag::Category::get_visibility_string($_->{visibility});
+}
+
+$template->param( 'CATEGORIES' => $categories );
+
+$panel->build( $template );
+$panel->display;
+
+sub delete_category {
+ my $category_id = $cgi->param('category_id');
+ my $category = Vhffs::Tag::Category::get_by_category_id($panel->{vhffs}, $category_id);
+ if(!defined $category) {
+ return 0;
+ }
+
+ return $category->delete();
+}
Added: trunk/vhffs-panel/admin/tag/index.pl
===================================================================
--- trunk/vhffs-panel/admin/tag/index.pl (rev 0)
+++ trunk/vhffs-panel/admin/tag/index.pl 2008-03-19 06:59:56 UTC (rev 1175)
@@ -0,0 +1,61 @@
+#!%PERL% -w
+# Copyright (c) vhffs project and its contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+#3. Neither the name of vhffs nor the names of its contributors
+# may be used to endorse or promote products derived from this
+# software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+
+use utf8;
+use POSIX qw(locale_h);
+use HTML::Template;
+use locale;
+use Locale::gettext;
+use strict;
+
+
+use lib '%VHFFS_LIB_DIR%';
+use Vhffs::Panel::Main;
+use Vhffs::Panel::Admin;
+
+my $panel = new Vhffs::Panel::Main();
+exit 0 unless $panel;
+my $session = $panel->get_session;
+exit 0 unless $session;
+
+$panel->check_admin;
+
+my $templatedir = $panel->{templatedir};
+
+my $template = new HTML::Template(filename => $templatedir.'/panel/admin/index.tmpl');
+
+$panel->set_title(gettext('Tags\' administration'));
+
+$template->param( CATEGORIES => [ Vhffs::Panel::Admin::get_tag_category ] );
+
+$panel->build( $template );
+$panel->display;
Modified: trunk/vhffs-panel/templates/Makefile.am
===================================================================
--- trunk/vhffs-panel/templates/Makefile.am 2008-03-17 21:41:06 UTC (rev 1174)
+++ trunk/vhffs-panel/templates/Makefile.am 2008-03-19 06:59:56 UTC (rev 1175)
@@ -38,6 +38,9 @@
admin/repository/search.tmpl \
admin/svn/part.tmpl \
admin/svn/search.tmpl \
+ admin/tag/category/create.tmpl \
+ admin/tag/category/edit.tmpl \
+ admin/tag/category/list.tmpl \
admin/git/part.tmpl \
admin/git/search.tmpl \
admin/user/part.tmpl \
@@ -65,6 +68,7 @@
group/history.tmpl \
group/history_part.tmpl \
group/index.tmpl \
+ group/tags.tmpl \
mail/create.tmpl \
mailinglist/create.tmpl \
mailinglist/list_part.tmpl \
Added: trunk/vhffs-panel/templates/admin/tag/category/create.tmpl
===================================================================
--- trunk/vhffs-panel/templates/admin/tag/category/create.tmpl (rev 0)
+++ trunk/vhffs-panel/templates/admin/tag/category/create.tmpl 2008-03-19 06:59:56 UTC (rev 1175)
@@ -0,0 +1,16 @@
+<form name="createTagCategory" accept-charset="utf-8" method="post">
+<p><label for="label"><TMPL_VAR NAME="LABEL_TEXT"></label>
+ <input type="text" name="label" id="label" value="<TMPL_VAR NAME="LABEL_VALUE">"/></p>
+<p><label for="description"><TMPL_VAR NAME="DESCRIPTION_TEXT"></label>
+ <textarea name="description" id="description"></textarea></p>
+<p><label for="visibility"><TMPL_VAR NAME="VISIBILITY_TEXT"></label>
+<select name="visibility" id="visibility">
+<TMPL_LOOP NAME="VISIBILITIES">
+<option value="<TMPL_VAR NAME="CODE">"><TMPL_VAR NAME="LABEL"></option>
+</TMPL_LOOP>
+</select>
+</p>
+<p class="button">
+ <input type="submit" name="create_tag_category_submit" value="<TMPL_VAR NAME="CREATE_TEXT">"/>
+</p>
+</form>
\ No newline at end of file
Added: trunk/vhffs-panel/templates/admin/tag/category/edit.tmpl
===================================================================
--- trunk/vhffs-panel/templates/admin/tag/category/edit.tmpl (rev 0)
+++ trunk/vhffs-panel/templates/admin/tag/category/edit.tmpl 2008-03-19 06:59:56 UTC (rev 1175)
@@ -0,0 +1,19 @@
+<form name="updateTagCategory" accept-charset="utf-8" method="post">
+<p><label for="label"><TMPL_VAR NAME="LABEL_TEXT"></label>
+ <input type="text" name="label" id="label" value="<TMPL_VAR ESCAPE=1 NAME="LABEL_VALUE">"/></p>
+<p><label for="description"><TMPL_VAR NAME="DESCRIPTION_TEXT"></label>
+ <textarea name="description" id="description"><TMPL_VAR NAME="DESCRIPTION_VALUE"></textarea></p>
+<p><label for="visibility"><TMPL_VAR NAME="VISIBILITY_TEXT" ESCAPE=1></label>
+<select name="visibility" id="visibility">
+<TMPL_LOOP NAME="VISIBILITIES">
+<option value="<TMPL_VAR NAME="CODE">"
+ <TMPL_IF EXPR="visibility_value==CODE">selected="selected"</TMPL_IF>>
+<TMPL_VAR NAME="LABEL"></option>
+</TMPL_LOOP>
+</select>
+</p>
+<p class="button">
+ <input type="hidden" name="category_id" value="<TMPL_VAR NAME="CATEGORY_ID_VALUE">"/>
+ <input type="submit" name="update_tag_category_submit" value="<TMPL_VAR NAME="UPDATE_TEXT">"/>
+</p>
+</form>
Added: trunk/vhffs-panel/templates/admin/tag/category/list.tmpl
===================================================================
--- trunk/vhffs-panel/templates/admin/tag/category/list.tmpl (rev 0)
+++ trunk/vhffs-panel/templates/admin/tag/category/list.tmpl 2008-03-19 06:59:56 UTC (rev 1175)
@@ -0,0 +1,27 @@
+<table border="1">
+<thead>
+<tr>
+<th><TMPL_I18N KEY="Label"></th><th><TMPL_I18N KEY="Description"></th>
+<th><TMPL_I18N KEY="Visibility"></th><th><TMPL_I18N KEY="Updated"></th>
+<th><TMPL_I18N KEY="By"></th><th><TMPL_I18N KEY="Edit"></th>
+<th><TMPL_I18N KEY="Delete"></th>
+</tr>
+</thead>
+<tbody>
+<TMPL_LOOP NAME="CATEGORIES">
+<tr>
+<td><TMPL_VAR NAME="label"></td><td><TMPL_VAR NAME="description"></td>
+<td><TMPL_VAR NAME="visibility_string"></td><td><TMPL_VAR NAME="updated"></td>
+<td><TMPL_VAR NAME="updater_name"></td>
+<td><form action="edit.pl" method="post">
+ <input type="hidden" name="category_id" value="<TMPL_VAR NAME="category_id">"/>
+ <input type="submit" value="<TMPL_I18N KEY="Edit">"/>
+</form></td>
+<td><form action="#" method="post">
+ <input type="hidden" name="category_id" value="<TMPL_VAR NAME="category_id">"/>
+ <input type="submit" value="<TMPL_I18N KEY="Delete">" name="delete_category_submit"/>
+</form></td>
+</tr>
+</TMPL_LOOP>
+</tbody>
+</table>
\ No newline at end of file
Modified: trunk/vhffs-panel/templates/group/prefs.tmpl
===================================================================
--- trunk/vhffs-panel/templates/group/prefs.tmpl 2008-03-17 21:41:06 UTC (rev 1174)
+++ trunk/vhffs-panel/templates/group/prefs.tmpl 2008-03-19 06:59:56 UTC (rev 1175)
@@ -61,6 +61,8 @@
<TMPL_IF NAME="ADD_USER_MSG"><p class="<TMPL_VAR ESCAPE=1 NAME="ADD_USER_MSG_CLASS">"><TMPL_VAR ESCAPE=1 NAME="ADD_USER_MSG"></p></TMPL_IF>
<TMPL_VAR ESCAPE=1 NAME="USERS_LIST">
+<TMPL_INCLUDE NAME="tags.tmpl">
+
<TMPL_VAR ESCAPE=0 name="AVATAR">
<h2><TMPL_VAR ESCAPE=1 NAME="TEXT_ACL_ADMIN"></h2>
Added: trunk/vhffs-panel/templates/group/tags.tmpl
===================================================================
--- trunk/vhffs-panel/templates/group/tags.tmpl (rev 0)
+++ trunk/vhffs-panel/templates/group/tags.tmpl 2008-03-19 06:59:56 UTC (rev 1175)
@@ -0,0 +1,4 @@
+<h2>Tags</h2>
+<h3><TMPL_I18N KEY="Current tags for this project"></h3>
+
+<h3><TMPL_I18N KEY="Add a new tag"></h3>