[vhffs-dev] [983] ACL for groups is now working for all group properties and web areas, fixed Vhffs::Functions::valid_email

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 983
Author:   gradator
Date:     2007-10-14 02:24:40 +0000 (Sun, 14 Oct 2007)

Log Message:
-----------
ACL for groups is now working for all group properties and web areas, fixed Vhffs::Functions::valid_email

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Functions.pm
    trunk/vhffs-api/src/Vhffs/Panel/Group.pm
    trunk/vhffs-api/src/Vhffs/Services/Mail.pm
    trunk/vhffs-api/src/Vhffs/Services/MailingList.pm
    trunk/vhffs-api/src/Vhffs/User.pm
    trunk/vhffs-panel/git/prefs_save.pl
    trunk/vhffs-panel/group/delete.pl
    trunk/vhffs-panel/group/history.pl
    trunk/vhffs-panel/group/prefs.pl
    trunk/vhffs-panel/mailinglist/add_sub.pl
    trunk/vhffs-panel/mailinglist/change_right.pl
    trunk/vhffs-panel/mailinglist/del_member.pl
    trunk/vhffs-panel/subscribe.pl
    trunk/vhffs-panel/svn/prefs_save.pl
    trunk/vhffs-panel/templates/group/prefs.tmpl
    trunk/vhffs-panel/user/prefs.pl
    trunk/vhffs-panel/web/create.pl


Modified: trunk/vhffs-api/src/Vhffs/Functions.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Functions.pm	2007-10-13 15:04:29 UTC (rev 982)
+++ trunk/vhffs-api/src/Vhffs/Functions.pm	2007-10-14 02:24:40 UTC (rev 983)
@@ -431,7 +431,7 @@
 	my $mail = shift;
 	use Email::Valid;
 	return 1 if( Email::Valid->rfc822 ( $mail ) );
-	return -1;
+	return 0;
 }
 
 sub status_string_from_status_id($) {

Modified: trunk/vhffs-api/src/Vhffs/Panel/Group.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Group.pm	2007-10-13 15:04:29 UTC (rev 982)
+++ trunk/vhffs-api/src/Vhffs/Panel/Group.pm	2007-10-14 02:24:40 UTC (rev 983)
@@ -147,6 +147,7 @@
 	return undef if ($group->add_user( $user->get_uid ) < 0 );
 
     return undef if ( Vhffs::Acl::add_acl( $user , $group , Vhffs::Constants::ACL_DELETE , $main ) < 0 ); 
+    return undef if ( Vhffs::Acl::add_acl( $group , $group , Vhffs::Constants::ACL_VIEW , $main ) < 0 );
 
 	return $group;
 }

Modified: trunk/vhffs-api/src/Vhffs/Services/Mail.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Mail.pm	2007-10-13 15:04:29 UTC (rev 982)
+++ trunk/vhffs-api/src/Vhffs/Services/Mail.pm	2007-10-14 02:24:40 UTC (rev 983)
@@ -502,7 +502,7 @@
 {
 	my( $self , $value ) = @_;
 	use Vhffs::Functions;
-	if( $value eq "" || Vhffs::Functions::valid_mail( $value ) == 1 )
+	if( $value eq '' || Vhffs::Functions::valid_mail( $value ) )
 	{
 		$self->{'catchall'} = $value;
 		return 1;

Modified: trunk/vhffs-api/src/Vhffs/Services/MailingList.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/MailingList.pm	2007-10-13 15:04:29 UTC (rev 982)
+++ trunk/vhffs-api/src/Vhffs/Services/MailingList.pm	2007-10-14 02:24:40 UTC (rev 983)
@@ -224,7 +224,7 @@
     my $subscriber = shift;
     my $right = shift;
 
-    return -1 if( Vhffs::Functions::valid_mail( $subscriber ) != 1 );
+    return -1 unless( Vhffs::Functions::valid_mail( $subscriber ) );
     return -2 if( $subscriber =~ /.*<.*/ );
     return -2 if( $subscriber =~ /.*>.*/ );
     return -2 if( $subscriber =~ /.*\s.*/ );
@@ -256,7 +256,7 @@
     my $self = shift;
     my $subscriber = shift;
 
-    return undef if( Vhffs::Functions::valid_mail( $subscriber ) != 1 );
+    return undef unless( Vhffs::Functions::valid_mail( $subscriber ) );
     return undef if( $subscriber =~ /.*<.*/ );
     return undef if( $subscriber =~ /.*>.*/ );
     return undef if( $subscriber =~ /.*\s.*/ );

Modified: trunk/vhffs-api/src/Vhffs/User.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/User.pm	2007-10-13 15:04:29 UTC (rev 982)
+++ trunk/vhffs-api/src/Vhffs/User.pm	2007-10-14 02:24:40 UTC (rev 983)
@@ -605,7 +605,7 @@
    	my $self  = shift;
 	my $value = shift;
    
-	if(  Vhffs::Functions::valid_mail( $value ) == 1 )
+	if( Vhffs::Functions::valid_mail( $value ) )
 	{
 		$self->{'mail'} = $value;
 		return 0;
@@ -800,6 +800,23 @@
 	return \@groups;
 }
 
+=head2 can_view
+
+    die("You are not allowed to view this object\n")
+                                unless($user->can_view($object));
+
+Returns true if the user on which the method is called can view the given
+object.
+
+=cut
+
+sub can_view
+{
+	my ($self, $o) = @_;
+	return ( Vhffs::Acl::get_perm( $self->get_main, $o, $self )  >=  Vhffs::Constants::ACL_VIEW );
+}
+
+
 =head2 can_modify
 
     die("You are not allowed to modify this object\n")
@@ -816,20 +833,21 @@
 	return ( Vhffs::Acl::get_perm( $self->get_main, $o, $self )  >=  Vhffs::Constants::ACL_MODIFY );
 }
 
-=head2 can_view
 
-    die("You are not allowed to view this object\n")
-                                unless($user->can_view($object));
+=head2 can_delete
 
-Returns true if the user on which the method is called can view the given
+    die("You are not allowed to delete this object\n")
+                                unless($user->can_delete($object));
+
+Returns true if the user on which the method is called can delete the given
 object.
 
 =cut
 
-sub can_view
+sub can_delete
 {
 	my ($self, $o) = @_;
-	return ( Vhffs::Acl::get_perm( $self->get_main, $o, $self )  >=  Vhffs::Constants::ACL_VIEW );
+	return ( Vhffs::Acl::get_perm( $self->get_main, $o, $self )  >=  Vhffs::Constants::ACL_DELETE );
 }
 
 

Modified: trunk/vhffs-panel/git/prefs_save.pl
===================================================================
--- trunk/vhffs-panel/git/prefs_save.pl	2007-10-13 15:04:29 UTC (rev 982)
+++ trunk/vhffs-panel/git/prefs_save.pl	2007-10-14 02:24:40 UTC (rev 983)
@@ -113,7 +113,7 @@
     }
 
     if ( defined $ml_name ) {
-        if( $ml_name eq '' || Vhffs::Functions::valid_mail($ml_name) > 0) {
+        if( $ml_name eq '' || Vhffs::Functions::valid_mail($ml_name) ) {
             $git->{ml_name} = $ml_name;
             if( $git->commit_option < 0 ) {
                 $message = gettext("An error occured while updating the git repository");

Modified: trunk/vhffs-panel/group/delete.pl
===================================================================
--- trunk/vhffs-panel/group/delete.pl	2007-10-13 15:04:29 UTC (rev 982)
+++ trunk/vhffs-panel/group/delete.pl	2007-10-14 02:24:40 UTC (rev 983)
@@ -52,47 +52,46 @@
 exit 0 unless $session;
 
 my $vhffs = $panel->{'vhffs'};
-my $maintemplate = $panel->{'template'};
 my $user = $panel->{'user'};
 my $group = $panel->{'group'};
 my $cgi = $panel->{'cgi'};
 my $message;
 
-my $groupname = $cgi->param("GROUPNAME");
-my $sure = $cgi->param("DELETE");
+my $groupname = $cgi->param('GROUPNAME');
+my $sure = $cgi->param('DELETE');
 
 my $templatedir = $vhffs->get_config->get_templatedir;
 
-my $retour;
-if( ( Vhffs::Acl::what_perm_for_user( $user , $group , $vhffs ) < Vhffs::Constants::ACL_DELETE ) && ( $user->is_admin != 1 ) )
+unless( $user->can_delete( $group ) )
 {
-        $message = gettext("You're not allowed to do this (ACL rights)");
+	$message = gettext('You\'re not allowed to do this (ACL rights)');
 }
 elsif( $group->get_status != Vhffs::Constants::ACTIVATED )
 {
-    $message = gettext( "This object is not functionnal yet. Please wait creation or moderation.");
+	$message = gettext( 'This object is not functionnal yet. Please wait creation or moderation.');
 }
 elsif( $sure == 0 )
 {
-	$message = gettext( "This object will NOT be DELETED" );
+	$message = gettext( 'This object will NOT be DELETED' );
 }
 elsif( $group->is_empty != 1 )
 {
-	$message = gettext( "Error, your group is not empty. Please remove all objects from this group and try again" );
+	$message = gettext( 'Error, your group is not empty. Please remove all objects from this group and try again' );
 }
 else
 {
 	$group->set_status( Vhffs::Constants::TO_DELETE );
 	# Commit all the changes for the current user
 	if( $group->commit < 0 )  {
-        	$message = gettext("An error occured while updating the project");
+		$message = gettext('An error occured while updating the project');
 	}  else  {
-        	$message = gettext("This group will be deleted");
+		$message = gettext('This group will be deleted');
 	}
 }
-my $template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
+
+my $template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
 $template->param( MESSAGE => $message );
 
-$panel->set_refresh_url( "/group/prefs.pl" );
+$panel->set_refresh_url( '/group/prefs.pl' );
 $panel->build( $template );
 $panel->display;

Modified: trunk/vhffs-panel/group/history.pl
===================================================================
--- trunk/vhffs-panel/group/history.pl	2007-10-13 15:04:29 UTC (rev 982)
+++ trunk/vhffs-panel/group/history.pl	2007-10-14 02:24:40 UTC (rev 983)
@@ -53,31 +53,26 @@
 exit 0 unless $session;
 
 my $vhffs = $panel->{'vhffs'};
-my $maintemplate = $panel->{'template'};
 my $user = $panel->{'user'};
-my $projectname = $session->param("project");
-
 my $group = $panel->{'group'};
-my $templatedir = $vhffs->get_config->get_templatedir;
-my $access_level = Vhffs::Acl::what_perm_for_user( $user , $group , $vhffs );
+my $templatedir = $panel->{'templatedir'};
 my $template;
 
 
-
-if( ! defined $group ) {
-	$template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-	$template->param( MESSAGE => gettext( "Error. This group doesn't exists") );
+unless( defined $group ) {
+	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
+	$template->param( MESSAGE => gettext( 'Error. This group doesn\'t exists') );
 } elsif( $group->get_status != Vhffs::Constants::ACTIVATED ) {
-	$template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-	$template->param( MESSAGE => gettext( "This object is not functional yet. Please wait creation or moderation.") );
-} elsif( $access_level < Vhffs::Constants::ACL_VIEW && ( $user->is_admin != 1 ) ) {
-	$template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
+	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
+	$template->param( MESSAGE => gettext( 'This object is not functional yet. Please wait creation or moderation.') );
+} elsif( ! $user->can_view( $group ) ) {
+	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
 	$template->param( MESSAGE => gettext( 'You\'re not allowed to do this (ACL rights)' ) );
 } else {
 
 	my $subtemplate;
 	my $history = $group->get_full_history;
-	my $output = "";
+	my $output = '';
 
 	$panel->set_title( gettext('Project History') );
 	$template = new HTML::Template( filename => $templatedir.'/panel/group/history.tmpl', global_vars => 1 );
@@ -88,17 +83,17 @@
 
 	unless( defined $history )
 	{
-		$template->param( HISTORY_PART => gettext("No event about this group") );
+		$template->param( HISTORY_PART => gettext('No event about this group') );
 	}
 	else
 	{
 		foreach( sort { $a <=> $b } keys %{$history} )
 		{
-			$subtemplate = new HTML::Template( filename => $templatedir."/panel/group/history_part.tmpl" );
+			$subtemplate = new HTML::Template( filename => $templatedir.'/panel/group/history_part.tmpl' );
 			use DateTime;
 			use DateTime::Locale;
 			use Encode;
-			$subtemplate->param( DATE => Encode::encode_utf8( DateTime->from_epoch( epoch => $history->{$_}{date}, locale => $user->get_lang )->strftime("%a, %d %b %Y %H:%M:%S %z") ) );			
+			$subtemplate->param( DATE => Encode::encode_utf8( DateTime->from_epoch( epoch => $history->{$_}{date}, locale => $user->get_lang )->strftime('%a, %d %b %Y %H:%M:%S %z') ) );			
 			$subtemplate->param( TYPE => Vhffs::Functions::type_string_from_type_id( $history->{$_}{type} ) );
 			my $object = Vhffs::ObjectFactory::fetch_object( $vhffs , $history->{$_}{object_id} );
 			$subtemplate->param( NAME => $object->get_label );

Modified: trunk/vhffs-panel/group/prefs.pl
===================================================================
--- trunk/vhffs-panel/group/prefs.pl	2007-10-13 15:04:29 UTC (rev 982)
+++ trunk/vhffs-panel/group/prefs.pl	2007-10-14 02:24:40 UTC (rev 983)
@@ -53,159 +53,153 @@
 exit 0 unless $session;
 
 my $vhffs = $panel->{'vhffs'};
-my $maintemplate = $panel->{'template'};
 my $user = $panel->{'user'};
-my $projectname = $session->param("project");
-
 my $group = $panel->{'group'};
-my $templatedir = $vhffs->get_config->get_templatedir;
-my $access_level = Vhffs::Acl::what_perm_for_user( $user , $group , $vhffs );
+my $templatedir = $panel->{'templatedir'};
+my $cgi = $panel->{'cgi'};
 my $template;
 
-
-
-if( ! defined $group ) {
-	$template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
+unless( defined $group ) {
+	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
 	$template->param( MESSAGE => gettext( "Error. This group doesn't exists") );
 } elsif( $group->get_status != Vhffs::Constants::ACTIVATED ) {
-	$template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-	$template->param( MESSAGE => gettext( "This object is not functional yet. Please wait creation or moderation.") );
-} elsif( $access_level < Vhffs::Constants::ACL_VIEW && ( $user->is_admin != 1 ) ) {
-	$template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
+	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
+	$template->param( MESSAGE => gettext( 'This object is not functional yet. Please wait creation or moderation.') );
+} elsif( ! $user->can_view( $group ) ) {
+	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
 	$template->param( MESSAGE => gettext( 'You\'re not allowed to do this (ACL rights)' ) );
 } else {
-    my $cgi = $panel->{cgi};
 
 	$template = new HTML::Template( filename => $templatedir.'/panel/group/prefs.tmpl', global_vars => 1 );
 
-    if( defined( $cgi->param( 'update_desc_submit' ) ) ) {
-        # Description modification
-        if( $access_level < Vhffs::Constants::ACL_MODIFY && $user->is_admin != 1 ) {
-            $panel->add_error( gettext( 'You\'re not allowed to do this (ACL rights)' ) );
-        } else {
-            my $description = $cgi->param( 'description' );
-            my $realname = $cgi->param( 'realname' );
+	if( defined( $cgi->param( 'update_desc_submit' ) ) ) {
+		# Description modification
+		unless( $user->can_modify( $group ) ) {
+			$panel->add_error( gettext( 'You\'re not allowed to do this (ACL rights)' ) );
+		} else {
+			my $description = $cgi->param( 'description' );
+			my $realname = $cgi->param( 'realname' );
 
-            if( ! defined ($description) || ! defined ($realname) ) {
-                $panel->add_error( gettext('CGI error') );
-            } elsif( $description =~ /^\s*$/ ) {
-                $panel->add_error( gettext('You must enter a description') );
-            } elsif( $realname =~ /^\s*$/ ) {
-                $panel->add_error( gettext('You must enter a full name') );
-            } elsif( substr($group->get_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') );
-            } else {
-                $group->set_description($description);
-                $group->set_realname($realname);
-                if($group->commit < 0) {
-                    $panel->add_error( gettext('An error occured while updating the project') );
-                } else {
-                    $panel->add_info( gettext('Group updated') );
-                }
-            }
-        }
-    } elsif( defined( $cgi->param( 'remove_user_submit' ) ) ) {
-        # User removal
-        if( $access_level < Vhffs::Constants::ACL_MODIFY && $user->is_admin != 1 ) {
-            $panel->add_error( gettext( 'You\'re not allowed to do this (ACL rights)' ) );
-        } else {
-            my $uid = $cgi->param( 'uid' );
-            if( ! defined($uid) || $uid !~ /^\d+$/ ) {
-                $panel->add_error( gettext('CGI error') );
-            } elsif( $uid == $group->get_owner_uid ) {
-                $panel->add_error( gettext('You cannot remove the owner of the group') );
-            } elsif( $group->remove_user($uid) ) {
-                $panel->add_info( gettext('This user will be removed from this group as soon as possible') );
-            } else {
-                $panel->add_error( gettext('Unable to remove user from group') );
-            }
-        }
-    } elsif( defined( $cgi->param( 'add_user_submit' ) ) ) {
-        if( $access_level < Vhffs::Constants::ACL_MODIFY && $user->is_admin != 1 ) {
-            $panel->add_error( gettext( 'You\'re not allowed to do this (ACL rights)' ) );
-        } else {
-            my $username = $cgi->param( 'username' );
-            if( ! defined($username)) {
-                $panel->add_error( gettext('CGI error') );
-            } elsif( $username =~ /^\s*$/ ) {
-                $template->param( ADD_USER_MSG_CLASS => 'error' );
-                $template->param( ADD_USER_MSG => gettext('You must enter an username') );
-            } else {
-                # First, we try to get an user with the *exact* name
-                my $new_user = Vhffs::User::get_by_username( $vhffs, $username);
-                if(defined $new_user) {
-                    # Fine, user exists, let's add it
-                    if( $group->add_user( $new_user->get_uid ) ) {
-                        $template->param( ADD_USER_MSG_CLASS => 'info' );
-                        $template->param( ADD_USER_MSG => gettext('User will be added as soon as possible') );
-                    } else {
-                        $template->param( ADD_USER_MSG_CLASS => 'error' );
-                        $template->param( ADD_USER_MSG => gettext('Unable to add user, he might already be in the group (waiting for addition or deletion)') );
-                    }
-                } else {
-                    # User not found with exact match,let's search
-                    my $users = Vhffs::Panel::User::search( $vhffs , $username );
-                    if( !@{$users} ) {
-                        $template->param( ADD_USER_MSG_CLASS => 'error' );
-                        $template->param( ADD_USER_MSG => gettext('User not found') );
-                    } else {
-                        # Let's make a nice table
-                        my $subtemplate = new HTML::Template( filename => $templatedir.'/panel/group/list_user.tmpl', global_vars => 1, die_on_bad_params => 0 );
-                            
-                        $subtemplate->param( USERS => $users );
-                        $subtemplate->param( TEXT_ADD => gettext('Add') );
-                        $template->param( ADD_USER_MSG_CLASS => 'info' );
-                        $template->param( ADD_USER_MSG => gettext('Many users matched your query. Please choose between them') );
-                        $template->param( USERS_LIST => $subtemplate->output );
-                    }
-                }
-            }
-        }
-    } elsif( defined( $cgi->param('add_user_list_submit') ) ) {
-        if( $access_level < Vhffs::Constants::ACL_MODIFY && $user->is_admin != 1 ) {
-            $panel->add_error( gettext( 'You\'re not allowed to do this (ACL rights)' ) );
-        } else {
-            my $uid = $cgi->param( 'uid' );
-            if( ! defined($uid) || $uid !~ /^\d+$/ ) {
-                $panel->add_error( gettext('CGI error') );
-            } else {
-                if( $group->add_user( $uid ) ) {
-                    $template->param( ADD_USER_MSG_CLASS => 'info' );
-                    $template->param( ADD_USER_MSG => gettext('User will be added as soon as possible') );
-                } else {
-                    $template->param( ADD_USER_MSG_CLASS => 'error' );
-                    $template->param( ADD_USER_MSG => gettext('Unable to add user, he might already be in the group (waiting for addition or deletion)') );
-                } 
-            }
-        }
-    } elsif( defined( $cgi->param('contact_email_submit') ) ) {
-        if( $vhffs->get_config->get_service_availability('mailgroup') == 0  ||  ( $access_level < Vhffs::Constants::ACL_MODIFY  &&  $user->is_admin != 1 ) ) {
-            $panel->add_error( gettext( 'You\'re not allowed to do this (ACL rights)' ) );
-        } else {
-            my $forward = $cgi->param( 'contact_email' );
-            if( ! defined $forward  ||  ( $forward ne ""  &&  Vhffs::Functions::valid_mail( $forward ) != 1 )  ) {
-                $panel->add_error( gettext('The email you entered fails syntax check') );
-            } else {
-		my $mg = init Vhffs::Services::MailGroup( $vhffs , $group );
-		if( defined $mg )
-		{
-			if( $forward eq "" )  {
-				$mg->delforward( $forward );
-				$panel->add_info( gettext('Forward deleted') );
-			}else {
-				$mg->addforward( $forward );
-				$panel->add_info( gettext('Forward added') );
+			unless( defined $description  &&  defined $realname ) {
+				$panel->add_error( gettext('CGI error') );
+			} elsif( $description =~ /^\s*$/ ) {
+				$panel->add_error( gettext('You must enter a description') );
+			} elsif( $realname =~ /^\s*$/ ) {
+				$panel->add_error( gettext('You must enter a full name') );
+			} elsif( substr($group->get_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') );
+			} else {
+				$group->set_description($description);
+				$group->set_realname($realname);
+				if($group->commit < 0) {
+					$panel->add_error( gettext('An error occured while updating the project') );
+				} else {
+					$panel->add_info( gettext('Group updated') );
+				}
 			}
 		}
-            }
-        }
-    }
+	} elsif( defined( $cgi->param( 'remove_user_submit' ) ) ) {
+		# User removal
+		my $uid = $cgi->param( 'uid' );
+		unless( defined $uid  &&  $uid =~ /^\d+$/ ) {
+			$panel->add_error( gettext('CGI error') );
+		} else {
+			unless( $uid == $user->get_uid || $user->can_modify( $group ) )  {
+				$panel->add_error( gettext( 'You\'re not allowed to do this (ACL rights)' ) );	
+			} elsif( $uid == $group->get_owner_uid ) {
+				$panel->add_error( gettext('You cannot remove the owner of the group') );
+			} elsif( $group->remove_user($uid) ) {
+				$panel->add_info( gettext('This user will be removed from this group as soon as possible') );
+			} else {
+				$panel->add_error( gettext('Unable to remove user from group') );
+			}
+		}
+	} elsif( defined( $cgi->param( 'add_user_submit' ) ) ) {
+		unless( $user->can_modify( $group ) ) {
+			$panel->add_error( gettext( 'You\'re not allowed to do this (ACL rights)' ) );
+		} else {
+			my $username = $cgi->param( 'username' );
+			unless( defined $username ) {
+				$panel->add_error( gettext('CGI error') );
+			} elsif( $username =~ /^\s*$/ ) {
+				$template->param( ADD_USER_MSG_CLASS => 'error' );
+				$template->param( ADD_USER_MSG => gettext('You must enter an username') );
+			} else {
+				# First, we try to get an user with the *exact* name
+				my $new_user = Vhffs::User::get_by_username( $vhffs, $username);
+				if(defined $new_user) {
+					# Fine, user exists, let's add it
+					if( $group->add_user( $new_user->get_uid ) ) {
+						$template->param( ADD_USER_MSG_CLASS => 'info' );
+						$template->param( ADD_USER_MSG => gettext('User will be added as soon as possible') );
+					} else {
+						$template->param( ADD_USER_MSG_CLASS => 'error' );
+						$template->param( ADD_USER_MSG => gettext('Unable to add user, he might already be in the group (waiting for addition or deletion)') );
+					}
+				} else {
+					# User not found with exact match,let's search
+					my $users = Vhffs::Panel::User::search( $vhffs , $username );
+					unless( @{$users} ) {
+						$template->param( ADD_USER_MSG_CLASS => 'error' );
+						$template->param( ADD_USER_MSG => gettext('User not found') );
+					} else {
+						# Let's make a nice table
+						my $subtemplate = new HTML::Template( filename => $templatedir.'/panel/group/list_user.tmpl', global_vars => 1, die_on_bad_params => 0 );
 
+						$subtemplate->param( USERS => $users );
+						$subtemplate->param( TEXT_ADD => gettext('Add') );
+						$template->param( ADD_USER_MSG_CLASS => 'info' );
+						$template->param( ADD_USER_MSG => gettext('Many users matched your query. Please choose between them') );
+						$template->param( USERS_LIST => $subtemplate->output );
+					}
+				}
+			}
+		}
+	} elsif( defined( $cgi->param('add_user_list_submit') ) ) {
+		unless( $user->can_modify( $group ) ) {
+			$panel->add_error( gettext( 'You\'re not allowed to do this (ACL rights)' ) );
+		} else {
+			my $uid = $cgi->param( 'uid' );
+			unless( defined $uid  &&  $uid =~ /^\d+$/ ) {
+				$panel->add_error( gettext('CGI error') );
+			} else {
+				if( $group->add_user( $uid ) ) {
+					$template->param( ADD_USER_MSG_CLASS => 'info' );
+					$template->param( ADD_USER_MSG => gettext('User will be added as soon as possible') );
+				} else {
+					$template->param( ADD_USER_MSG_CLASS => 'error' );
+					$template->param( ADD_USER_MSG => gettext('Unable to add user, he might already be in the group (waiting for addition or deletion)') );
+				} 
+			}
+		}
+	} elsif( defined( $cgi->param('contact_email_submit') ) ) {
+		unless( $vhffs->get_config->get_service_availability('mailgroup')  &&  $user->can_modify( $group ) ) {
+			$panel->add_error( gettext( 'You\'re not allowed to do this (ACL rights)' ) );
+		} else {
+			my $forward = $cgi->param( 'contact_email' );
+			unless( defined $forward  &&  ( $forward eq ''  ||  Vhffs::Functions::valid_mail( $forward ) )  ) {
+				$panel->add_error( gettext('The email you entered fails syntax check') );
+			} else {
+				my $mg = init Vhffs::Services::MailGroup( $vhffs , $group );
+				if( defined $mg )
+				{
+					if( $forward eq '' )  {
+						$mg->delforward( $forward );
+						$panel->add_info( gettext('Forward deleted') );
+					} else {
+						$mg->addforward( $forward );
+						$panel->add_info( gettext('Forward added') );
+					}
+				}
+			}
+		}
+	}
 
+
 	$panel->set_title( gettext('Project Preferences') );
 
-    $template->param( TEXT_QUOTA => gettext("If you want more disk space for your project, you must fill a form in the bug report section, in the menu. Don't forget to mention the name of the group.") );
-	$template->param( TEXT_PROJECTNAME => $projectname );
+	$template->param( TEXT_QUOTA => gettext("If you want more disk space for your project, you must fill a form in the bug report section, in the menu. Don't forget to mention the name of the group.") );
+	$template->param( TEXT_PROJECTNAME => $group->get_groupname );
 	$template->param( TEXT_OWNER => gettext("Project Owner") );
 	$template->param( VALUE_OWNER => $group->get_owner_username );
 	$template->param( TEXT_DESCRIPTION => gettext("Project Description") );
@@ -219,6 +213,10 @@
 	$template->param( YES => gettext("Yes I'm sure of what I do") );
 	$template->param( NO => gettext("No, I'm not sure, I prefer to keep this project.") );
 	$template->param( TEXT_DELETE => gettext("Delete") );
+	$template->param( VALUE_OID => $group->get_oid );
+	$template->param( TEXT_ACL_ADMIN => "Admin Rights on this object (ACL)" );
+	$template->param( EXPLAIN_ADMIN_ACL => "You can Manage rights on this service for each user in the VHFFS database. Please read help before manage it." );
+	$template->param( ADMIN_ACL => "Ok, go to ACL admin" );
 
 	my $mg = init Vhffs::Services::MailGroup( $vhffs , $group );
 	if( defined $mg )
@@ -251,9 +249,9 @@
 	}
 	
 	$template->param( USERS => Vhffs::Panel::Group::getall_users( $vhffs , $group->get_gid ) );
-    $template->param( REMOVE_USER_TEXT => gettext( 'Remove' ) );
-    $template->param( NO_USER_TEXT => gettext( 'No user for this group' ) );
-    $template->param( USERS_TEXT => gettext( 'Users' ) );
+	$template->param( REMOVE_USER_TEXT => gettext( 'Remove' ) );
+	$template->param( NO_USER_TEXT => gettext( 'No user for this group' ) );
+	$template->param( USERS_TEXT => gettext( 'Users' ) );
 	$template->param( CURRENT_USERS => gettext( 'All users in this group' ) );
 }
 

Modified: trunk/vhffs-panel/mailinglist/add_sub.pl
===================================================================
--- trunk/vhffs-panel/mailinglist/add_sub.pl	2007-10-13 15:04:29 UTC (rev 982)
+++ trunk/vhffs-panel/mailinglist/add_sub.pl	2007-10-14 02:24:40 UTC (rev 983)
@@ -98,7 +98,7 @@
 foreach my $member ( @members )  {
 	chomp $member;
 
-	if( Vhffs::Functions::valid_mail( $member ) < 0 )  {
+	if( ! Vhffs::Functions::valid_mail( $member ) )  {
 		$message .= sprintf( gettext("%s is not a valid mail"), $member );
 	}
 	elsif( $list->add_sub( $member , Vhffs::Constants::ML_RIGHT_SUB )  < 0 ) {

Modified: trunk/vhffs-panel/mailinglist/change_right.pl
===================================================================
--- trunk/vhffs-panel/mailinglist/change_right.pl	2007-10-13 15:04:29 UTC (rev 982)
+++ trunk/vhffs-panel/mailinglist/change_right.pl	2007-10-14 02:24:40 UTC (rev 983)
@@ -92,7 +92,7 @@
 {
 	$message = gettext("You're not allowed to do this (ACL rights)");
 }
-elsif( Vhffs::Functions::valid_mail( $member ) < 0 )
+elsif( ! Vhffs::Functions::valid_mail( $member ) )
 {
 	$message = gettext("Not valid mail");
 }

Modified: trunk/vhffs-panel/mailinglist/del_member.pl
===================================================================
--- trunk/vhffs-panel/mailinglist/del_member.pl	2007-10-13 15:04:29 UTC (rev 982)
+++ trunk/vhffs-panel/mailinglist/del_member.pl	2007-10-14 02:24:40 UTC (rev 983)
@@ -90,7 +90,7 @@
 {
 	$message = gettext("You're not allowed to do this (ACL rights)");
 }
-elsif( Vhffs::Functions::valid_mail( $member ) < 0 )
+elsif( ! Vhffs::Functions::valid_mail( $member ) )
 {
 	$message = gettext("Not valid mail");
 }

Modified: trunk/vhffs-panel/subscribe.pl
===================================================================
--- trunk/vhffs-panel/subscribe.pl	2007-10-13 15:04:29 UTC (rev 982)
+++ trunk/vhffs-panel/subscribe.pl	2007-10-14 02:24:40 UTC (rev 983)
@@ -136,7 +136,7 @@
 	{
 		push(@errors, {error => gettext("You must declare your mail address")});
 	}
-	if( Vhffs::Functions::valid_mail( $mail ) == -1 )
+	if( ! Vhffs::Functions::valid_mail( $mail ) )
 	{
 		push(@errors, {error => gettext("You must declare a valid mail address")});
 	}

Modified: trunk/vhffs-panel/svn/prefs_save.pl
===================================================================
--- trunk/vhffs-panel/svn/prefs_save.pl	2007-10-13 15:04:29 UTC (rev 982)
+++ trunk/vhffs-panel/svn/prefs_save.pl	2007-10-14 02:24:40 UTC (rev 983)
@@ -112,7 +112,7 @@
     }
 
     if ( defined $ml_name ) {
-        if( $ml_name eq '' || Vhffs::Functions::valid_mail($ml_name) > 0) {
+        if( $ml_name eq '' || Vhffs::Functions::valid_mail($ml_name) ) {
             $svn->{ml_name} = $ml_name;
             if( $svn->commit_option < 0 ) {
                 $message = gettext("An error occured while updating the Subversion repository");

Modified: trunk/vhffs-panel/templates/group/prefs.tmpl
===================================================================
--- trunk/vhffs-panel/templates/group/prefs.tmpl	2007-10-13 15:04:29 UTC (rev 982)
+++ trunk/vhffs-panel/templates/group/prefs.tmpl	2007-10-14 02:24:40 UTC (rev 983)
@@ -63,6 +63,17 @@
 
 <tmpl_var name="AVATAR">
 
+<h2><tmpl_var name="TEXT_ACL_ADMIN"></h2>
+
+<form method="post" action="../acl/view.pl">
+	<p><tmpl_var name="EXPLAIN_ADMIN_ACL"></p>
+
+	<input type="hidden" name="target_oid" value="<tmpl_var name="VALUE_OID">" />
+	<p class="button" id="buttonAclAdmin">
+		<input type="submit" value="<tmpl_var name="ADMIN_ACL">" />
+	</p>
+</form>
+
 <h2><tmpl_var name="TEXT_DELETE_PROJECT"></h2>
 
 <form method="post" action="delete.pl">

Modified: trunk/vhffs-panel/user/prefs.pl
===================================================================
--- trunk/vhffs-panel/user/prefs.pl	2007-10-13 15:04:29 UTC (rev 982)
+++ trunk/vhffs-panel/user/prefs.pl	2007-10-14 02:24:40 UTC (rev 983)
@@ -100,7 +100,7 @@
     if( $city !~ /^[^<">]+$/ ) {
         $panel->add_error( gettext( 'City is not correct !') );
     }
-    if( Vhffs::Functions::valid_mail($mail) < 0 ) {
+    if( ! Vhffs::Functions::valid_mail($mail) ) {
         $panel->add_error( gettext( 'Email is not correct !') );
     }
     if( ! ( $zipcode =~ /^[\w\d\s\-]+$/ ) ) {

Modified: trunk/vhffs-panel/web/create.pl
===================================================================
--- trunk/vhffs-panel/web/create.pl	2007-10-13 15:04:29 UTC (rev 982)
+++ trunk/vhffs-panel/web/create.pl	2007-10-14 02:24:40 UTC (rev 983)
@@ -54,48 +54,56 @@
 my $groupname = $panel->{groupname};
 my $templatedir = $panel->{templatedir};
 my $cgi = $panel->{cgi};
+my $user = $panel->{user};
+my $group = $panel->{group};
 
-my $submitted = defined($cgi->param('web_submit'));
+unless( $user->can_modify( $group ) ) {
+	my $template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
+	$template->param( MESSAGE => gettext( 'You\'re not allowed to do this (ACL rights)' ) );
 
-my $servername;
-my $description;
-
-if($submitted) {
-    my $user = $panel->{user};
-    my $group = $panel->{group};
-    $servername = $cgi->param('servername');
-    $description = $cgi->param('description');
-    if(! (defined $servername && defined $description) ) {
-        $panel->add_error( gettext('CGI error') );
-    } elsif( !Vhffs::Functions::check_domain_name($servername) ) {
-        $panel->add_error( gettext('Invalid servername (doesn\'t conform to domain names rules)') );
-    } elsif( $description =~ /^\s*$/ ) {
-        $panel->add_error( gettext('You must enter a description') );
-    } elsif( defined(Vhffs::Panel::Web::create_web( $vhffs, $servername, $description, $user, $group)) ) {
-        my $url = '/group/view.pl?project='.$panel->{groupname}.'&msg='.gettext('The webarea was successfully created !');
-        $panel->redirect($url);
-    } else {
-        $panel->add_error( gettext('Error creating webarea.') );
-    }
-} else {
-    my $webconfig = $vhffs->get_config->get_service('web');
-    $servername = '<'.gettext('new site').'>.'.$webconfig->{'default_domain'} if( defined $webconfig->{'default_domain'} );
+	$panel->build( $template );
+	$panel->display;
 }
+else  {
+	my $submitted = defined($cgi->param('web_submit'));
+	my $servername;
+	my $description;
 
-if(!$submitted || $panel->has_errors()) {
-    my $template = new HTML::Template( filename => $templatedir.'/panel/web/create.tmpl' );
-    $panel->set_title( gettext("Create a web space") );
-    $template->param( SERVERNAME_TEXT => gettext("Adress (ServerName directive)") );
-    $template->param( SERVERNAME_WARNING => gettext("Be careful, if you want create www.domain.tld, you should create a webspace with domain.tld as servername. VHFFS redirect all request from www.domain.tld to domain.tld") );
-    $template->param( SERVERNAME_VALUE => CGI::escapeHTML($servername) );
-    $template->param( GROUP_NAME => gettext("Group owning this web space") );
+	if( $submitted ) {
+		$servername = $cgi->param('servername');
+		$description = $cgi->param('description');
+		unless( defined $servername  &&  defined $description ) {
+			$panel->add_error( gettext('CGI error') );
+		} elsif( !Vhffs::Functions::check_domain_name($servername) ) {
+			$panel->add_error( gettext('Invalid servername (doesn\'t conform to domain names rules)') );
+		} elsif( $description =~ /^\s*$/ ) {
+			$panel->add_error( gettext('You must enter a description') );
+		} elsif( defined(Vhffs::Panel::Web::create_web( $vhffs, $servername, $description, $user, $group)) ) {
+			my $url = '/group/view.pl?project='.$panel->{groupname}.'&msg='.gettext('The webarea was successfully created !');
+			$panel->redirect($url);
+		} else {
+			$panel->add_error( gettext('Error creating webarea.') );
+		}
+	} else {
+		my $webconfig = $vhffs->get_config->get_service('web');
+		$servername = '<'.gettext('new site').'>.'.$webconfig->{'default_domain'} if( defined $webconfig->{'default_domain'} );
+	}
 
-    $template->param( GROUP => $groupname );
-    $template->param( SEND => gettext("Send") );
-    $template->param( DESCRIPTION => gettext("Tell us what the use of this web space will be") );
-    $template->param( WARNING_PUBLIC => gettext("Please consider that this description is going to be displayed in the public area. So you have to write it in impersonal form. You should take care to write it with correct grammar and tenses. Take all the time you need to fill it with the best content you are able to do.") ) if $panel->is_public;
-    $template->param( DESCRIPTION_VALUE => CGI::escapeHTML($description) );
+	if( !$submitted || $panel->has_errors() ) {
+		my $template = new HTML::Template( filename => $templatedir.'/panel/web/create.tmpl' );
+		$panel->set_title( gettext("Create a web space") );
+		$template->param( SERVERNAME_TEXT => gettext("Adress (ServerName directive)") );
+		$template->param( SERVERNAME_WARNING => gettext("Be careful, if you want create www.domain.tld, you should create a webspace with domain.tld as servername. VHFFS redirect all request from www.domain.tld to domain.tld") );
+		$template->param( SERVERNAME_VALUE => CGI::escapeHTML($servername) );
+		$template->param( GROUP_NAME => gettext("Group owning this web space") );
 
-    $panel->build( $template );
-$panel->display;
+		$template->param( GROUP => $groupname );
+		$template->param( SEND => gettext("Send") );
+		$template->param( DESCRIPTION => gettext("Tell us what the use of this web space will be") );
+		$template->param( WARNING_PUBLIC => gettext("Please consider that this description is going to be displayed in the public area. So you have to write it in impersonal form. You should take care to write it with correct grammar and tenses. Take all the time you need to fill it with the best content you are able to do.") ) if $panel->is_public;
+		$template->param( DESCRIPTION_VALUE => CGI::escapeHTML($description) );
+
+		$panel->build( $template );
+		$panel->display;
+	}
 }


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/