[vhffs-dev] [1216] You can now tag groups at creation time. |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 1216
Author: beuss
Date: 2008-06-04 22:46:12 +0200 (Wed, 04 Jun 2008)
Log Message:
-----------
You can now tag groups at creation time.
Modified Paths:
--------------
trunk/vhffs-api/src/Vhffs/Constants.pm
trunk/vhffs-api/src/Vhffs/Tag/Category.pm
trunk/vhffs-panel/admin/tag/category/create.pl
trunk/vhffs-panel/admin/tag/category/edit.pl
trunk/vhffs-panel/group/create.pl
trunk/vhffs-panel/group/prefs.pl
trunk/vhffs-panel/templates/group/create.tmpl
trunk/vhffs-themes/vhffs/main.css
Modified: trunk/vhffs-api/src/Vhffs/Constants.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Constants.pm 2008-06-04 20:44:05 UTC (rev 1215)
+++ trunk/vhffs-api/src/Vhffs/Constants.pm 2008-06-04 20:46:12 UTC (rev 1216)
@@ -78,6 +78,7 @@
TYPE_CRON => 70,
# Tags visibility MUST BE ORDERED BY PRIVILEGE LEVEL!
+ TAG_VISIBILITY_GROUP_CREATION => 10,
TAG_VISIBILITY_PUBLIC => 20,
TAG_VISIBILITY_MODERATORS => 30,
TAG_VISIBILITY_ADMINS => 40,
Modified: trunk/vhffs-api/src/Vhffs/Tag/Category.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Tag/Category.pm 2008-06-04 20:44:05 UTC (rev 1215)
+++ trunk/vhffs-api/src/Vhffs/Tag/Category.pm 2008-06-04 20:46:12 UTC (rev 1216)
@@ -43,6 +43,7 @@
package Vhffs::Tag::Category;
my @VISIBILITY_STRING;
+$VISIBILITY_STRING[Vhffs::Constants::TAG_VISIBILITY_GROUP_CREATION] = 'Public (available on group creation)';
$VISIBILITY_STRING[Vhffs::Constants::TAG_VISIBILITY_PUBLIC] = 'Public';
$VISIBILITY_STRING[Vhffs::Constants::TAG_VISIBILITY_MODERATORS] = 'Moderators';
$VISIBILITY_STRING[Vhffs::Constants::TAG_VISIBILITY_ADMINS] = 'Administrators';
Modified: trunk/vhffs-panel/admin/tag/category/create.pl
===================================================================
--- trunk/vhffs-panel/admin/tag/category/create.pl 2008-06-04 20:44:05 UTC (rev 1215)
+++ trunk/vhffs-panel/admin/tag/category/create.pl 2008-06-04 20:46:12 UTC (rev 1216)
@@ -69,6 +69,7 @@
$template->param( DESCRIPTION_TEXT => gettext('Description') );
$template->param( VISIBILITY_TEXT => gettext('Visibility') );
$template->param( VISIBILITIES => [
+ { CODE => Vhffs::Constants::TAG_VISIBILITY_GROUP_CREATION, LABEL => gettext('Public (available on group creation)') },
{ 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') }
Modified: trunk/vhffs-panel/admin/tag/category/edit.pl
===================================================================
--- trunk/vhffs-panel/admin/tag/category/edit.pl 2008-06-04 20:44:05 UTC (rev 1215)
+++ trunk/vhffs-panel/admin/tag/category/edit.pl 2008-06-04 20:46:12 UTC (rev 1216)
@@ -80,6 +80,7 @@
$template->param( DESCRIPTION_TEXT => gettext('Description') );
$template->param( VISIBILITY_TEXT => gettext('Visibility') );
$template->param( VISIBILITIES => [
+ { CODE => Vhffs::Constants::TAG_VISIBILITY_GROUP_CREATION, LABEL => gettext('Public (available on group creation)') },
{ 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') }
Modified: trunk/vhffs-panel/group/create.pl
===================================================================
--- trunk/vhffs-panel/group/create.pl 2008-06-04 20:44:05 UTC (rev 1215)
+++ trunk/vhffs-panel/group/create.pl 2008-06-04 20:46:12 UTC (rev 1216)
@@ -32,7 +32,6 @@
use strict;
use utf8;
use POSIX qw(locale_h);
-use HTML::Template;
use locale;
use Locale::gettext;
use CGI;
@@ -40,10 +39,13 @@
use Encode;
use lib '%VHFFS_LIB_DIR%';
-use Vhffs::User;
use Vhffs::Main;
use Vhffs::Panel::Main;
use Vhffs::Panel::Group;
+use Vhffs::Panel::Template;
+use Vhffs::Tag;
+use Vhffs::Tag::Category;
+use Vhffs::User;
my $panel = new Vhffs::Panel::Main();
exit 0 unless $panel;
@@ -70,16 +72,28 @@
$panel->add_error( gettext('You must enter a full name') );
} elsif( substr($groupname,0,1) ne lc substr($realname,0,1) ) {
$panel->add_error( gettext('The first letter of groupname and full name must be the same') );
- } elsif( ! defined(my $group = Vhffs::Panel::Group::create_group( $groupname , $realname, $user , $vhffs, $description ) ) ) {
- $panel->add_error( gettext('Error creating group (maybe a group with the same name already exists)') );
} else {
- my $url = '/group/index.pl?msg='.gettext('Project Successfully created !');
- $panel->redirect($url);
+ my $group;
+ if( ! defined($group = Vhffs::Panel::Group::create_group( $groupname , $realname, $user , $vhffs, $description ) ) ) {
+ $panel->add_error( gettext('Error creating group (maybe a group with the same name already exists)') );
+ } else {
+ # Creation succeeded. Since we don't care about the correctness
+ # of the tags we were passed, we don't do display any error messages
+ my @tags = $cgi->param('tags');
+ foreach my $tag_id (@tags) {
+ my $tag = Vhffs::Tag::get_by_tag_id($vhffs, $tag_id);
+ if(defined $tag && $tag->get_category()->{visibility} == Vhffs::Constants::TAG_VISIBILITY_GROUP_CREATION) {
+ $group->add_tag($tag, $user);
+ }
+ }
+ my $url = '/group/index.pl?msg='.gettext('Project Successfully created !');
+ $panel->redirect($url);
+ }
}
}
if( ! $submitted || $panel->has_errors() ) {
- my $template = new HTML::Template( filename => $templatedir.'/panel/group/create.tmpl' );
+ my $template = new Vhffs::Panel::Template( filename => $templatedir.'/panel/group/create.tmpl', die_on_bad_params => 0, loop_context_vars => 1 );
$panel->set_title( gettext('Create a Project') );
$template->param( PROJECT_NAME => gettext('Project Name') );
@@ -93,6 +107,14 @@
$template->param( PROJECT_VALUE => $groupname );
$template->param( REALNAME_VALUE => $realname );
$template->param( DESCRIPTION_VALUE => $description );
+
+ my $categories =
+ Vhffs::Tag::Category::get_all($vhffs, Vhffs::Constants::TAG_VISIBILITY_GROUP_CREATION);
+ foreach my $c (@{$categories}) {
+ $c->{tags} = Vhffs::Tag::get_by_category_id($vhffs, $c->{category_id});
+ }
+
+ $template->param( TAG_CATEGORIES => $categories );
$panel->build( $template );
$panel->display;
Modified: trunk/vhffs-panel/group/prefs.pl
===================================================================
--- trunk/vhffs-panel/group/prefs.pl 2008-06-04 20:44:05 UTC (rev 1215)
+++ trunk/vhffs-panel/group/prefs.pl 2008-06-04 20:46:12 UTC (rev 1216)
@@ -74,7 +74,7 @@
} else {
$template = new Vhffs::Panel::Template( filename => $templatedir.'/panel/group/prefs.tmpl', global_vars => 1,
- die_on_bad_params => 0 );
+ die_on_bad_params => 0, loop_context_vars => 1 );
if( defined( $cgi->param( 'update_desc_submit' ) ) ) {
# Description modification
Modified: trunk/vhffs-panel/templates/group/create.tmpl
===================================================================
--- trunk/vhffs-panel/templates/group/create.tmpl 2008-06-04 20:44:05 UTC (rev 1215)
+++ trunk/vhffs-panel/templates/group/create.tmpl 2008-06-04 20:46:12 UTC (rev 1216)
@@ -29,6 +29,22 @@
<TMPL_VAR ESCAPE=1 NAME="WARNING_PUBLIC">
</p>
</TMPL_IF>
+ <TMPL_IF NAME="TAG_CATEGORIES">
+ <p class="info">
+ <TMPL_I18N KEY="You can chose some tags to be applied to your group right now. More tags will be available in your project's preferences once it is created">
+ </p>
+ <ul>
+ <TMPL_LOOP NAME="TAG_CATEGORIES">
+ <li><TMPL_VAR NAME="LABEL">:
+ <TMPL_LOOP NAME="TAGS">
+ <input type="checkbox" name="tags" value="<TMPL_VAR NAME="TAG_ID">" id="tag_<TMPL_VAR NAME="TAG_ID">"/> <label class="checkbox" for="tag_<TMPL_VAR NAME="TAG_ID">"><TMPL_VAR NAME="LABEL"></label><TMPL_UNLESS NAME="__LAST__">,</TMPL_UNLESS>
+ </TMPL_LOOP>
+ <TMPL_UNLESS NAME="__LAST__">;</TMPL_UNLESS>
+ <TMPL_IF NAME="__LAST__">.</TMPL_IF>
+ </li>
+ </TMPL_LOOP>
+ </ul>
+ </TMPL_IF>
<p class="button" id="buttonSend">
<input type="submit" value="<TMPL_VAR ESCAPE=1 NAME="SEND">" name="project_submit"/>
</p>
Modified: trunk/vhffs-themes/vhffs/main.css
===================================================================
--- trunk/vhffs-themes/vhffs/main.css 2008-06-04 20:44:05 UTC (rev 1215)
+++ trunk/vhffs-themes/vhffs/main.css 2008-06-04 20:46:12 UTC (rev 1216)
@@ -254,10 +254,10 @@
}
-/* Les deux d\xE9finitions suivantes sont un hack pour ie afin de regler le
+/* Les deux d�finitions suivantes sont un hack pour ie afin de regler le
bug 62.
-L'astuce a \xE9t\xE9 trouv\xE9e sur le blog alsa cr\xE9ation :
+L'astuce a �t� trouv�e sur le blog alsa cr�ation :
http://www.alsacreations.com/blog/index.php?2004/08/17/54-min-%20style=%22background:yellow%22%3Eheight-sur-internet-explorer
@@ -814,3 +814,7 @@
text-align:center;
}
+label.checkbox {
+ display: inline;
+ float:none;
+}