[vhffs-dev] [1107] Bye bye Acl::what_perm_for_user , moderators may have a working panel now

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


Revision: 1107
Author:   gradator
Date:     2007-12-05 23:52:49 +0000 (Wed, 05 Dec 2007)

Log Message:
-----------
Bye bye Acl::what_perm_for_user , moderators may have a working panel now

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Acl.pm
    trunk/vhffs-api/src/Vhffs/User.pm
    trunk/vhffs-api/src/examples/perm_for_user.pl
    trunk/vhffs-panel/acl/view.pl
    trunk/vhffs-panel/cvs/delete.pl
    trunk/vhffs-panel/cvs/prefs.pl
    trunk/vhffs-panel/dns/delete.pl
    trunk/vhffs-panel/dns/prefs.pl
    trunk/vhffs-panel/git/delete.pl
    trunk/vhffs-panel/git/prefs.pl
    trunk/vhffs-panel/group/prefs.pl
    trunk/vhffs-panel/mail/delete.pl
    trunk/vhffs-panel/mail/prefs.pl
    trunk/vhffs-panel/mailinglist/delete.pl
    trunk/vhffs-panel/mailinglist/prefs.pl
    trunk/vhffs-panel/mysql/delete.pl
    trunk/vhffs-panel/mysql/prefs.pl
    trunk/vhffs-panel/object/upavatar.pl
    trunk/vhffs-panel/pgsql/delete.pl
    trunk/vhffs-panel/pgsql/prefs.pl
    trunk/vhffs-panel/repository/delete.pl
    trunk/vhffs-panel/repository/prefs.pl
    trunk/vhffs-panel/svn/delete.pl
    trunk/vhffs-panel/svn/prefs.pl
    trunk/vhffs-panel/user/prefs.pl
    trunk/vhffs-panel/web/delete.pl


Modified: trunk/vhffs-api/src/Vhffs/Acl.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Acl.pm	2007-12-05 22:18:15 UTC (rev 1106)
+++ trunk/vhffs-api/src/Vhffs/Acl.pm	2007-12-05 23:52:49 UTC (rev 1107)
@@ -73,15 +73,6 @@
 }
 
 
-sub what_perm_for_user
-{
-	my $user = shift;
-	my $object = shift;
-	my $vhffs = shift;
-	return get_perm( $vhffs , $object , $user );
-}
-
-
 =pod
 
 =head2 add_acl

Modified: trunk/vhffs-api/src/Vhffs/User.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/User.pm	2007-12-05 22:18:15 UTC (rev 1106)
+++ trunk/vhffs-api/src/Vhffs/User.pm	2007-12-05 23:52:49 UTC (rev 1107)
@@ -776,6 +776,7 @@
 sub can_view
 {
 	my ($self, $o) = @_;
+	return 0 unless( $o->get_status == Vhffs::Constants::ACTIVATED || $self->is_admin || $self->is_moderator );
 	return ( Vhffs::Acl::get_perm( $self->get_main, $o, $self )  >=  Vhffs::Constants::ACL_VIEW );
 }
 
@@ -793,10 +794,27 @@
 sub can_modify
 {
 	my ($self, $o) = @_;
+	return 0 unless( $o->get_status == Vhffs::Constants::ACTIVATED || $self->is_admin || $self->is_moderator );
 	return ( Vhffs::Acl::get_perm( $self->get_main, $o, $self )  >=  Vhffs::Constants::ACL_MODIFY );
 }
 
 
+=head2 can_manageacl
+
+    die("You are not allowed to manage acl on this object\n")
+                                unless($user->can_manageacl($object));
+
+Returns true if the user on which the method is called can modify ACLs on the given object.
+
+=cut
+
+sub can_manageacl
+{
+	my ($self, $o) = @_;
+	return ( Vhffs::Acl::get_perm( $self->get_main, $o, $self )  >=  Vhffs::Constants::ACL_MANAGEACL );
+}
+
+
 =head2 can_delete
 
     die("You are not allowed to delete this object\n")
@@ -810,6 +828,7 @@
 sub can_delete
 {
 	my ($self, $o) = @_;
+	return 0 unless( $o->get_status == Vhffs::Constants::ACTIVATED || $self->is_admin || $self->is_moderator );
 	return ( Vhffs::Acl::get_perm( $self->get_main, $o, $self )  >=  Vhffs::Constants::ACL_DELETE );
 }
 

Modified: trunk/vhffs-api/src/examples/perm_for_user.pl
===================================================================
--- trunk/vhffs-api/src/examples/perm_for_user.pl	2007-12-05 22:18:15 UTC (rev 1106)
+++ trunk/vhffs-api/src/examples/perm_for_user.pl	2007-12-05 23:52:49 UTC (rev 1107)
@@ -25,5 +25,5 @@
 die("Webarea $servername not found\n") unless(defined $httpd);
 
 print "Permission: ";
-print Vhffs::Acl::what_perm_for_user($user, $httpd, $princ);
+print Vhffs::Acl::get_perm( $princ,  $httpd , $user );
 print "\n";

Modified: trunk/vhffs-panel/acl/view.pl
===================================================================
--- trunk/vhffs-panel/acl/view.pl	2007-12-05 22:18:15 UTC (rev 1106)
+++ trunk/vhffs-panel/acl/view.pl	2007-12-05 23:52:49 UTC (rev 1107)
@@ -71,7 +71,7 @@
     $template->param( MESSAGE => sprintf( gettext('Cannot get informations on object #%d'), $oid) );
 } else {
     # Object exists, we need to know if access is granted to the user
-    if( ( $access_level < Vhffs::Constants::ACL_VIEW ) && ( $user->is_admin != 1 ) ) {
+    unless( $user->can_view( $object ) ) {
         $template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
         $template->param( MESSAGE => gettext('You\'re not allowed to view this object\'s ACL') );
     } else {
@@ -85,7 +85,7 @@
                 $panel->add_error( gettext('CGI Error') );
             } elsif( ! defined( $granted = Vhffs::Object::get_by_oid( $vhffs, $granted_oid ) ) ) {
                 $panel->add_error( gettext('Group or user not found') );
-            }  elsif( ( $access_level < Vhffs::Constants::ACL_MANAGEACL ) && ( $user->is_admin != 1 ) ) {
+            }  elsif( ! $user->can_manageacl( $object ) ) {
                 $panel->add_error( gettext('You\'re not allowed to manage this object\'s ACL') );
             } else {
                 $ret = Vhffs::Acl::add_update_or_del_acl( $vhffs, $object->get_oid, $granted_oid, $perm );

Modified: trunk/vhffs-panel/cvs/delete.pl
===================================================================
--- trunk/vhffs-panel/cvs/delete.pl	2007-12-05 22:18:15 UTC (rev 1106)
+++ trunk/vhffs-panel/cvs/delete.pl	2007-12-05 23:52:49 UTC (rev 1107)
@@ -59,52 +59,46 @@
 my $user = $panel->{'user'};
 my $group = $panel->{'group'};
 my $cgi = $panel->{'cgi'};
+my $templatedir = $panel->{'templatedir'};
+
 my $message;
-my $owner = $cgi->param("PROJECT_OWNER");
 
-my $repo = $cgi->param( "REPO_NAME" );
-my $sure = $cgi->param( "DELETE" );
+my $owner = $cgi->param('PROJECT_OWNER' );
+my $repo = $cgi->param( 'REPO_NAME' );
+my $sure = $cgi->param( 'DELETE' );
 
-my $templatedir = $vhffs->get_config->get_templatedir;
-
 my $cvs;
 
-if( ( ! defined $repo ) || ( ! defined $sure ) )
+unless( defined $repo && defined $sure )
 {
-    $message = sprintf( gettext("CGI Error ! %s"), $repo );
+	$message = sprintf( gettext('CGI Error !') );
 }
 elsif( !defined($cvs = Vhffs::Services::Cvs::get_by_cvsroot($vhffs, $repo) ) )
 {
-	$message = gettext( "Cannot retrieve informations about this CVS repository" );
+	$message = gettext( 'Cannot retrieve informations about this CVS repository' );
 }
-elsif( ( Vhffs::Acl::what_perm_for_user( $user , $cvs , $vhffs ) < Vhffs::Constants::ACL_DELETE ) && ( $user->is_admin != 1 ) )
+elsif( ! $user->can_delete( $cvs ) )
 {
-	$message = gettext( "You're not allowed to do this (ACL rights)" );
+	$message = gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' );
 }
-elsif( $cvs->get_status != Vhffs::Constants::ACTIVATED )
-{
-    $message = gettext( "This object is not functionnal yet. Please wait creation or moderation.");
-}
 elsif( $sure == 0 )
 {
-	$message = gettext( "This CVS repository will NOT be deleted" );
+	$message = gettext( 'This CVS repository will NOT be deleted' );
 }
 else
 {
 	$cvs->set_status( Vhffs::Constants::TO_DELETE );
-
-	# Commit all the changes for the current user
 	if( $cvs->commit < 0 )
 	{
-	        $message = gettext("An error occured while deleting the CVS repository");
+		$message = gettext('An error occured while deleting the CVS repository');
 	}  
 	else  
 	{
-        $message = gettext("This CVS will be delete");
+		$message = gettext('This CVS 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->build( $template );

Modified: trunk/vhffs-panel/cvs/prefs.pl
===================================================================
--- trunk/vhffs-panel/cvs/prefs.pl	2007-12-05 22:18:15 UTC (rev 1106)
+++ trunk/vhffs-panel/cvs/prefs.pl	2007-12-05 23:52:49 UTC (rev 1107)
@@ -53,70 +53,61 @@
 exit 0 unless $session;
 
 my $vhffs = $panel->{'vhffs'};
-my $maintemplate = $panel->{'template'};
 my $user = $panel->{'user'};
-my $projectname = $session->param("project");
 my $cgi = $panel->{'cgi'};
-my $repo_name = $cgi->param("name");
+my $templatedir = $panel->{'templatedir'};
+
+my $repo_name = $cgi->param('name');
 my $template;
 
 my $cvs;
 
-my $message;
-
-my $templatedir = $vhffs->get_config->get_templatedir;
-
-if( ! defined $repo_name ) {
-	$template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-	$message = gettext( "CGI Error !");
-	$template->param( MESSAGE => $message );
+unless( defined $repo_name ) {
+	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
+	$template->param( MESSAGE => gettext( 'CGI Error !' ) );
 } elsif( !defined($cvs = Vhffs::Services::Cvs::get_by_cvsroot($vhffs, $repo_name) ) ) {
-	$template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-	$message = gettext( "Cannot get informations on this object");
-	$template->param( MESSAGE => $message );
+	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
+	$template->param( MESSAGE => gettext( 'Cannot get informations on this object' ) );
 } elsif( ! $user->can_view($cvs) ) {
-	$template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-	$message = gettext( "You're not allowed to do this (ACL rights)");
-	$template->param( MESSAGE => $message );
-} elsif( ( $cvs->get_status != Vhffs::Constants::ACTIVATED ) && ( $user->is_admin != 1 ) ) {
-	$template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-    $message = gettext( "This object is not functionnal yet. Please wait creation, moderation or modification.");
-	$template->param( MESSAGE => $message );
+	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
+	$template->param( MESSAGE => gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' ) );
 } else {
-    my $cgi = $panel->{cgi};
-    if( defined $cgi->param('cvs_public_submit') ) {
-        if(! $user->can_modify($cvs)) {
-            $panel->add_error( gettext("You are not allowed to modify this object (ACL rights)") );
-        } elsif( !defined($cgi->param('public')) ) {
-            $panel->add_error( gettext("CGI error") );
-        } else {
-            $cvs->set_public($cgi->param('public'));
-            $cvs->set_status(Vhffs::Constants::WAITING_FOR_MODIFICATION);
-            if($cvs->commit > 0) {
-                $panel->add_info(gettext("CVS repository updated"));
-            } else {
-                $panel->add_error(gettext("An error occured during CVS repository update"));
-            }
-        }
-    } elsif( defined $cgi->param('cvs_fixperms_submit')) {
-        if(! $user->can_modify($cvs) ) {
-            $panel->add_error( gettext("You are not allowed to modify this object (ACL rights)") );
-        } else {
-            $cvs->set_status(Vhffs::Constants::WAITING_FOR_MODIFICATION);
-        }
-        if($cvs->commit > 0) {
-                $panel->add_info(gettext("CVS repository updated"));
-        } else {
-                $panel->add_error(gettext("An error occured during CVS repository update"));
-        }
-    }
 
+	if( defined $cgi->param('cvs_public_submit') ) {
+		unless( $user->can_modify($cvs) ) {
+			$panel->add_error( gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' ) );
+		} elsif( !defined($cgi->param('public')) ) {
+			$panel->add_error( gettext("CGI error") );
+		} else {
+			$cvs->set_public($cgi->param('public'));
+			$cvs->set_status(Vhffs::Constants::WAITING_FOR_MODIFICATION);
+			if($cvs->commit > 0) {
+				$panel->add_info(gettext("CVS repository updated"));
+			} else {
+				$panel->add_error(gettext("An error occured during CVS repository update"));
+			}
+		}
+	}
+
+	elsif( defined $cgi->param('cvs_fixperms_submit')) {
+		unless( $user->can_modify($cvs) ) {
+			$panel->add_error( gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' ) );
+		} else {
+			$cvs->set_status(Vhffs::Constants::WAITING_FOR_MODIFICATION);
+			if($cvs->commit > 0) {
+				$panel->add_info(gettext("CVS repository updated"));
+			} else {
+				$panel->add_error(gettext("An error occured during CVS repository update"));
+			}
+		}
+	}
+
 	$template = new HTML::Template( filename => $templatedir."/panel/cvs/prefs.tmpl" );
 
 	$panel->set_title( gettext('Admin CVS Repository') );
 
 	$template->param( TEXT_REPONAME => $cvs->get_cvsroot );
-    $template->param( VALUE_OID => $cvs->get_oid );
+	$template->param( VALUE_OID => $cvs->get_oid );
 	$template->param( TEXT_PUBLIC => gettext("Is this CVS repository public ??") );
 	$template->param( PUBLIC_YES => gettext("Yes") );
 	$template->param( PUBLIC_NO => gettext("No") );
@@ -128,14 +119,14 @@
 	$template->param( NO => gettext("No, I'm not sure, I prefer to keep this project.") );
 	$template->param( TEXT_DELETE => gettext("Delete") );
 
-    $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" );
-    $template->param( PERM_TITLE => "Fix permissions" );
-    $template->param( PERM_TEXT => "Fixing permissions on a repository solve permission access on the repository. Can be helpful if you encounter problems" );
-    $template->param( PERM_BUTTON => "Fix it" );
+	$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" );
+	$template->param( PERM_TITLE => "Fix permissions" );
+	$template->param( PERM_TEXT => "Fixing permissions on a repository solve permission access on the repository. Can be helpful if you encounter problems" );
+	$template->param( PERM_BUTTON => "Fix it" );
 
-    $template->param( PUBLIC => $cvs->is_public );
+	$template->param( PUBLIC => $cvs->is_public );
 
 	my $adminpart = Vhffs::Panel::Object::admin_part( $panel, $cvs );
 	$template->param( ADMIN_PART => $adminpart->output ) if( $adminpart );

Modified: trunk/vhffs-panel/dns/delete.pl
===================================================================
--- trunk/vhffs-panel/dns/delete.pl	2007-12-05 22:18:15 UTC (rev 1106)
+++ trunk/vhffs-panel/dns/delete.pl	2007-12-05 23:52:49 UTC (rev 1107)
@@ -80,18 +80,12 @@
 }
 elsif( ! defined $dns )
 {
-
 	$message = gettext( "Cannot get informations on this object");
-
 }
-elsif( ( Vhffs::Acl::what_perm_for_user( $user , $dns , $vhffs ) < Vhffs::Constants::ACL_DELETE ) && ( $user->is_admin != 1 ) )
+elsif( ! $user->can_delete( $dns ) )
 {
-    $message = gettext("You're not allowed to do this (ACL rights)");
+	$message = gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' );
 }
-elsif( $dns->get_status != Vhffs::Constants::ACTIVATED )
-{
-    $message = gettext("You're not allowed to do this (ACL rights)");
-}
 else
 {
 	if( $sure == 1 )

Modified: trunk/vhffs-panel/dns/prefs.pl
===================================================================
--- trunk/vhffs-panel/dns/prefs.pl	2007-12-05 22:18:15 UTC (rev 1106)
+++ trunk/vhffs-panel/dns/prefs.pl	2007-12-05 23:52:49 UTC (rev 1107)
@@ -54,61 +54,45 @@
 my $session = $panel->get_session;
 exit 0 unless $session;
 
+my $vhffs = $panel->{'vhffs'};
+my $templatedir = $panel->{'templatedir'};
+my $user = $panel->{'user'};
 my $cgi = $panel->{'cgi'};
 
-my $vhffs = $panel->{'vhffs'};
 my $domain_name = $cgi->param('domain');
 # FIXME Temporary hack to be compatible with project info page
 $domain_name = $cgi->param('name') unless(defined $domain_name);
-my $user = $panel->{'user'};
 
 my $dns = Vhffs::Services::DNS::get_by_domainname( $vhffs , $domain_name );
 
-my $maintemplate = $panel->{'template'};
-
-my $group = $panel->{'group'};
-
-my $templatedir = $vhffs->get_config->get_templatedir;
 my $thirdtemplate;
 my $template;
 my $output = "";
 my $message;
 
-if( ! defined $domain_name )
+unless( defined $domain_name )
 {
-	$template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-	$message = gettext( "CGI Error!");
-	$template->param( MESSAGE => $message );
+	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
+	$template->param( MESSAGE => gettext( 'CGI Error!' ) );
 }
-elsif( !defined $dns)
+elsif( ! defined $dns )
 {
-
-	$template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-	$message = gettext( "Cannot get informations on this object");
-	$template->param( MESSAGE => $message );
-
+	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
+	$template->param( MESSAGE => gettext('Cannot get informations on this object') );
 }
-elsif( ( Vhffs::Acl::what_perm_for_user( $user , $dns , $vhffs ) < Vhffs::Constants::ACL_VIEW ) && ( $user->is_admin != 1 ) )
+elsif( ! $user->can_view( $dns ) )
 {
-    $template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-    $message = gettext("You're not allowed to do this (ACL rights)");
-    $template->param( MESSAGE => $message );
+	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
+	$template->param( MESSAGE => gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' ) );
 }
-elsif( ( $dns->get_status != Vhffs::Constants::ACTIVATED ) && ( $user->is_admin != 1 ) )
-{
-    
-    $template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-    my $message = gettext( "This object is not functionnal yet. Please wait creation or moderation.");
-    $template->param( MESSAGE => $message );
-}
 else
 {
     my $action = $cgi->param('action');
 ACTION: {
     if(defined $action) {
         # Check user's rights
-        if( ( Vhffs::Acl::what_perm_for_user( $user , $dns , $vhffs ) < Vhffs::Constants::ACL_MODIFY ) && ( $user->is_admin != 1 ) ) {
-            $panel->add_error(gettext('You\'re not allowed to do this (ACL rights)'));
+        unless( $user->can_modify( $dns ) ) {
+            $panel->add_error( gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' ) );
             last ACTION;
         }
         my $id = $cgi->param('rr_id');

Modified: trunk/vhffs-panel/git/delete.pl
===================================================================
--- trunk/vhffs-panel/git/delete.pl	2007-12-05 22:18:15 UTC (rev 1106)
+++ trunk/vhffs-panel/git/delete.pl	2007-12-05 23:52:49 UTC (rev 1107)
@@ -77,9 +77,9 @@
 {
 	$message = gettext( "Cannot retrieve informations about this repository" );
 }
-elsif( ( Vhffs::Acl::what_perm_for_user( $user , $git , $vhffs ) < Vhffs::Constants::ACL_DELETE ) && ( $user->is_admin != 1 ) )
+elsif( !$user->can_delete( $git ) )
 {
-	$message = gettext( "You're not allowed to do this (ACL rights)" );
+	$message = gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' );
 }
 elsif( $git->get_status != Vhffs::Constants::ACTIVATED )
 {

Modified: trunk/vhffs-panel/git/prefs.pl
===================================================================
--- trunk/vhffs-panel/git/prefs.pl	2007-12-05 22:18:15 UTC (rev 1106)
+++ trunk/vhffs-panel/git/prefs.pl	2007-12-05 23:52:49 UTC (rev 1107)
@@ -54,97 +54,81 @@
 exit 0 unless $session;
 
 my $vhffs = $panel->{'vhffs'};
-my $maintemplate = $panel->{'template'};
 my $user = $panel->{'user'};
-my $projectname = $session->param("project");
 my $cgi = $panel->{'cgi'};
-my $repo_name = $cgi->param("name");
-my $template;
-my $output;
-my $subtemplate;
-my $git;
-my $templatedir;
-my $message;
+my $templatedir $panel->{'templatedir'};
 
-$templatedir = $vhffs->get_config->get_templatedir;
+my $repo_name = $cgi->param('name');
 
-$git = Vhffs::Services::Git::get_by_reponame( $vhffs , $repo_name );
+my $template;
 
-if( ! defined $repo_name )
+my $git = Vhffs::Services::Git::get_by_reponame( $vhffs , $repo_name );
+
+unless( defined $repo_name )
 {
-    $template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-    $message = gettext( "CGI Error" );
-    $template->param( MESSAGE => $message );
+	$template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
+	$template->param( MESSAGE => gettext( 'CGI Error' ) );
 }
 elsif( !defined $git )
 {
-    $template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-    $message = gettext( "Cannot get informations on this object");
-    $template->param( MESSAGE => $message );
-
+	$template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
+	$template->param( MESSAGE => gettext( 'Cannot get informations on this object' ) );
 }
-elsif( ( Vhffs::Acl::what_perm_for_user( $user , $git , $vhffs ) < Vhffs::Constants::ACL_VIEW ) && ( $user->is_admin != 1 ) )
+elsif( !$user->can_view( $git ) )
 {
-    $template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-    $message = gettext( "You're not allowed to do this (ACL rights)");
-    $template->param( MESSAGE => $message );
+	$template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
+	$template->param( MESSAGE => gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' ) );
 }
-elsif( ( $git->get_status != Vhffs::Constants::ACTIVATED ) && ( $user->is_admin != 1 ) )
-{
-    $template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-    $message = gettext( "This object is not functionnal yet. Please wait creation, moderation or modification.");
-    $template->param( MESSAGE => $message );
-}
 else
 {
-    if(defined $cgi->param('save_prefs_submit') ) {
-        if(save_prefs()) {
-            exit;
-        }
-    } elsif(defined $cgi->param('fix_perms_submit') ) {
-        if(fix_perms()) {
-            exit;
-        }
-    }
+	if(defined $cgi->param('save_prefs_submit') ) {
+		if(save_prefs()) {
+			exit;
+		}
+	} elsif(defined $cgi->param('fix_perms_submit') ) {
+		if(fix_perms()) {
+			exit;
+		}
+	}
 
-    $template = new Vhffs::Panel::Template( filename => $templatedir."/panel/git/prefs.tmpl" );
+	$template = new Vhffs::Panel::Template( filename => $templatedir."/panel/git/prefs.tmpl" );
 
-    $panel->set_title( gettext("Admin Git Repository") );    
+	$panel->set_title( gettext("Admin Git Repository") );    
     
-    $template->param( TEXT_REPONAME => $git->get_reponame );
-    $template->param( TITLE_PUBLIC => gettext("Public") );
-    $template->param( TEXT_PUBLIC => gettext("Is this a public repository ?") );
-    $template->param( PUBLIC_YES => gettext("Yes") );
-    $template->param( PUBLIC_NO => gettext("No") );
-    $template->param( TEXT_SEND => gettext("Modify") );
-    $template->param( TEXT_DELETE_CVS => gettext("Delete this repository") );
-    $template->param( TEXT_BEFORE_DELETE => gettext("This action is non-reversible. All services associated to this project will be DESTROYED.") );
-    $template->param( ASK_DELETE_CVS => gettext("Are you SURE you want DELETE this git repository?") );
-    $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( TEXT_REPONAME => $git->get_reponame );
+	$template->param( TITLE_PUBLIC => gettext("Public") );
+	$template->param( TEXT_PUBLIC => gettext("Is this a public repository ?") );
+	$template->param( PUBLIC_YES => gettext("Yes") );
+	$template->param( PUBLIC_NO => gettext("No") );
+	$template->param( TEXT_SEND => gettext("Modify") );
+	$template->param( TEXT_DELETE_CVS => gettext("Delete this repository") );
+	$template->param( TEXT_BEFORE_DELETE => gettext("This action is non-reversible. All services associated to this project will be DESTROYED.") );
+	$template->param( ASK_DELETE_CVS => gettext("Are you SURE you want DELETE this git repository?") );
+	$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 => $git->get_oid );
-    $template->param( TEXT_ACL_ADMIN => gettext('Admin Rights on this object (ACL)') );
-    $template->param( EXPLAIN_ADMIN_ACL => gettext('You can Manage rights on this service for each user in the VHFFS database. Please read help before manage it.') );
-    $template->param( ADMIN_ACL => gettext('Ok, go to ACL admin') );
-    $template->param( TITLE_PERM => gettext('Fix permissions in this repository') );
-    $template->param( PERM_TEXT => gettext('Fixing permissions on a repository solve permission access on the repository. Can be helpful if you encounter problems') );
-    $template->param( TEXT_BUTTON_PERM => gettext('Fix them !') );
+	$template->param( VALUE_OID => $git->get_oid );
+	$template->param( TEXT_ACL_ADMIN => gettext('Admin Rights on this object (ACL)') );
+	$template->param( EXPLAIN_ADMIN_ACL => gettext('You can Manage rights on this service for each user in the VHFFS database. Please read help before manage it.') );
+	$template->param( ADMIN_ACL => gettext('Ok, go to ACL admin') );
+	$template->param( TITLE_PERM => gettext('Fix permissions in this repository') );
+	$template->param( PERM_TEXT => gettext('Fixing permissions on a repository solve permission access on the repository. Can be helpful if you encounter problems') );
+	$template->param( TEXT_BUTTON_PERM => gettext('Fix them !') );
 
-    $template->param( TITLE_OPT => gettext('Options') );
-    $template->param( TEXT_OPT_ML => gettext('Notify changes on mailing-list :'));
-    $template->param( TEXT_OPT_ML_REMINDER => sprintf( gettext('Don\'t forget to subscribe %s to your mailing list if you are filtering posts') , $vhffs->get_config->get_service('git')->{notify_from} ) );
-    $template->param( TEXT_ML_NAME => $git->{ml_name} );
+	$template->param( TITLE_OPT => gettext('Options') );
+	$template->param( TEXT_OPT_ML => gettext('Notify changes on mailing-list :'));
+	$template->param( TEXT_OPT_ML_REMINDER => sprintf( gettext('Don\'t forget to subscribe %s to your mailing list if you are filtering posts') , $vhffs->get_config->get_service('git')->{notify_from} ) );
+	$template->param( TEXT_ML_NAME => $git->{ml_name} );
     
-    if( $git->is_public == 1 )
-    {
-            $template->param( YES_SELECTED => "selected" );
-    }
-    else
-    {
-            $template->param( NO_SELECTED => "selected" );
-    }
+	if( $git->is_public == 1 )
+	{
+		$template->param( YES_SELECTED => "selected" );
+	}
+	else
+	{
+		$template->param( NO_SELECTED => "selected" );
+	}
 
 	my $adminpart = Vhffs::Panel::Object::admin_part( $panel, $git );
 	$template->param( ADMIN_PART => $adminpart->output ) if( defined $adminpart );
@@ -155,7 +139,7 @@
 
 sub fix_perms {
     if(!$user->can_modify($git)) {
-        $panel->add_error( gettext('You are not allowed to modify this GIT repository (ACL rights)') );
+        $panel->add_error( gettext('You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights') );
         return 0;
     }
 
@@ -177,7 +161,7 @@
     my $ml_name = $cgi->param('ml_name');
 
     if(!$user->can_modify($git)) {
-        $panel->add_error( gettext('You are not allowed to modify this GIT repository (ACL rights)') );
+        $panel->add_error( gettext('You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights') );
         return 0;
     }
 

Modified: trunk/vhffs-panel/group/prefs.pl
===================================================================
--- trunk/vhffs-panel/group/prefs.pl	2007-12-05 22:18:15 UTC (rev 1106)
+++ trunk/vhffs-panel/group/prefs.pl	2007-12-05 23:52:49 UTC (rev 1107)
@@ -65,12 +65,9 @@
 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 ) {
+} elsif( !$user->can_view( $group ) ) {
 	$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)' ) );
+	$template->param( MESSAGE => gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' ) );
 } else {
 
 	$template = new Vhffs::Panel::Template( filename => $templatedir.'/panel/group/prefs.tmpl', global_vars => 1 );

Modified: trunk/vhffs-panel/mail/delete.pl
===================================================================
--- trunk/vhffs-panel/mail/delete.pl	2007-12-05 22:18:15 UTC (rev 1106)
+++ trunk/vhffs-panel/mail/delete.pl	2007-12-05 23:52:49 UTC (rev 1107)
@@ -82,9 +82,9 @@
 {
 	$message = gettext( "This object is not functionnal yet. Please wait creation or moderation.");
 }
-elsif( ( Vhffs::Acl::what_perm_for_user( $user , $mail , $vhffs ) < Vhffs::Constants::ACL_DELETE ) && ( $user->is_admin != 1 ) )
+elsif( !$user->can_delete( $mail ) )
 {
-	$message = gettext("You're not allowed to do this (ACL rights)");
+	$message = gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' );
 }
 elsif( $sure == 0 )
 {

Modified: trunk/vhffs-panel/mail/prefs.pl
===================================================================
--- trunk/vhffs-panel/mail/prefs.pl	2007-12-05 22:18:15 UTC (rev 1106)
+++ trunk/vhffs-panel/mail/prefs.pl	2007-12-05 23:52:49 UTC (rev 1107)
@@ -57,37 +57,24 @@
 exit 0 unless $session;
 
 my $vhffs = $panel->{'vhffs'};
-my $mail_config = $vhffs->get_config->get_service('mail');
-my $maintemplate = $panel->{'template'};
 my $user = $panel->{'user'};
 my $group = $panel->{'group'};
-my $projectname = $session->param("project");
 my $cgi = $panel->{'cgi'};
-my $domain = $cgi->param("name");
-my $template;
-my $subtemplate;
-my $subtemplate2;
-my $message;
-my $temp;
+my $templatedir = $panel->{'templatedir'};
 
-my $templatedir = $vhffs->get_config->get_templatedir;
+my $mail_config = $vhffs->get_config->get_service('mail');
+my $domain = $cgi->param('name');
 
+my $template;
+
 my $mail = Vhffs::Services::Mail::get_by_mxdomain( $vhffs , $domain );
 
-if( !defined $mail ) {
-	$template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-    $message = sprintf( gettext("Unable to get information on mail domain %s"), $domain );
-	$template->param( MESSAGE => $message );
-
-} elsif( ( $mail->get_status != Vhffs::Constants::ACTIVATED ) && ( $user->is_admin != 1 ) ) {
-	
-	$template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-	my $message = gettext( "This object is not functionnal yet. Please wait creation or moderation.");
-	$template->param( MESSAGE => $message );
+unless( defined $mail ) {
+	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
+	$template->param( MESSAGE => sprintf( gettext('Unable to get information on mail domain %s'), $domain ) );
 } elsif( ! $user->can_view($mail) ) {
-	$template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-	my $message = gettext("You're not allowed to do this (ACL rights)");
-	$template->param( MESSAGE => $message );
+	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
+	$template->param( MESSAGE => gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' ) );
 } else {
     my $catchall_type = lc($mail_config->{allowed_catchall});
     $catchall_type = 'domain' unless(defined $catchall_type);

Modified: trunk/vhffs-panel/mailinglist/delete.pl
===================================================================
--- trunk/vhffs-panel/mailinglist/delete.pl	2007-12-05 22:18:15 UTC (rev 1106)
+++ trunk/vhffs-panel/mailinglist/delete.pl	2007-12-05 23:52:49 UTC (rev 1107)
@@ -86,9 +86,9 @@
 {
 	$message = gettext( "This object is not functionnal yet. Please wait creation or moderation.");
 }
-elsif( ( Vhffs::Acl::what_perm_for_user( $user , $list , $vhffs ) < Vhffs::Constants::ACL_DELETE ) && ( $user->is_admin != 1 ) ) 
+elsif( !$user->can_delete( $list ) ) 
 {
-	$message = gettext("You're not allowed to do this (ACL rights)");
+	$message = gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' );
 }
 elsif( $sure == 0 )
 {

Modified: trunk/vhffs-panel/mailinglist/prefs.pl
===================================================================
--- trunk/vhffs-panel/mailinglist/prefs.pl	2007-12-05 22:18:15 UTC (rev 1106)
+++ trunk/vhffs-panel/mailinglist/prefs.pl	2007-12-05 23:52:49 UTC (rev 1107)
@@ -58,44 +58,30 @@
 exit 0 unless $session;
 
 my $vhffs = $panel->{'vhffs'};
-my $maintemplate = $panel->{'template'};
 my $user = $panel->{'user'};
 my $group = $panel->{'group'};
-my $projectname = $session->param("project");
 my $cgi = $panel->{'cgi'};
+my $templatedir = $panel->{'templatedir'};
+
 my $domain = $cgi->param("domain");
 my $lpart = $cgi->param("local");
 my $name = $cgi->param("name");
+
 my $template;
-my $subtemplate;
-my $templatedir = $vhffs->get_config->get_templatedir;
 
 #defined name in CGI overwrite lpart and domain cgi
 if( defined $name ) {
 	( $lpart , $domain ) =  ( $name =~ /(.+)\@(.+)/ );
-
 }
 
 my $list = Vhffs::Services::MailingList::get_by_mladdress( $vhffs , $lpart , $domain );
 
-
-if( ! defined $list ) {
-
-	$template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-	my $message = sprintf( gettext('Mailing list %s@%s not found'), $lpart, $domain);
-	$template->param( MESSAGE => $message );
-
-} elsif( ( $list->get_status != Vhffs::Constants::ACTIVATED ) && ( $user->is_admin != 1 ) ) {
-	
-	$template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-	my $message = gettext( "This object is not functionnal yet. Please wait creation or moderation.");
-	$template->param( MESSAGE => $message );
-}
-elsif( !$user->can_view($list) )
-{
-	$template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-	my $message = gettext("You're not allowed to do this (ACL rights)");
-	$template->param( MESSAGE => $message );
+unless( defined $list ) {
+	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
+	$template->param( MESSAGE => sprintf( gettext('Mailing list %s@%s not found'), $lpart, $domain) );
+} elsif( !$user->can_view( $list ) ) {
+	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
+	$template->param( MESSAGE => gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' ) );
 } else {
     if(defined $cgi->param('options_submit')) {
         update_ml_options();
@@ -214,7 +200,7 @@
     my $sig = Encode::decode_utf8( $cgi->param('signature') );
 
     if(!$user->can_modify($list)) {
-        $panel->add_error( gettext('You are not allowed to change options (ACL rights)') );
+        $panel->add_error( gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' ) );
         return;
     }
 
@@ -239,7 +225,7 @@
     my $member = $cgi->param('member');
 
     if(!$user->can_modify($list)) {
-        $panel->add_error( gettext('You are not allowed to delete members (ACL rights)') );
+        $panel->add_error( gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' ) );
         return;
     }
 
@@ -260,7 +246,7 @@
     my $right = $cgi->param('right');
 
     if(!$user->can_modify($list)) {
-        $panel->add_error('You are not allowed to manager subscribers\' rights (ACL rights)');
+        $panel->add_error( gettext('You are not allowed to manager subscribers\' rights (ACL rights)') );
         return;
     }
 

Modified: trunk/vhffs-panel/mysql/delete.pl
===================================================================
--- trunk/vhffs-panel/mysql/delete.pl	2007-12-05 22:18:15 UTC (rev 1106)
+++ trunk/vhffs-panel/mysql/delete.pl	2007-12-05 23:52:49 UTC (rev 1107)
@@ -54,10 +54,11 @@
 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 $templatedir = $panel->{'templatedir'};
+
 my $message;
 my $owner = $cgi->param("PROJECT_OWNER");
 my $dbname = $cgi->param("DBNAME");
@@ -65,19 +66,17 @@
 
 my $mysql = Vhffs::Services::Mysql::get_by_dbname( $vhffs, $dbname );
 
-my $templatedir = $vhffs->get_config->get_templatedir;
-
-if ( ! defined( $mysql ) )
+unless( defined $mysql )
 {
-    $message = gettext("This database doesn't exist in VHFFS database");
+	$message = gettext("This database doesn't exist in VHFFS database");
 }
 elsif( ! defined $sure )
 {
 	$message = gettext( "CGI Error !" );
 }
-elsif( ( Vhffs::Acl::what_perm_for_user( $user , $mysql , $vhffs ) < Vhffs::Constants::ACL_DELETE ) && ( $user->is_admin != 1 ) )
+elsif( !$user->can_delete( $mysql ) )
 {
-	$message = gettext( "You're not allowed to do this (ACL rights)" );	
+	$message = gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' );
 }
 elsif( $sure == 0 )
 {
@@ -86,7 +85,6 @@
 else
 {
 	$mysql->set_status( Vhffs::Constants::TO_DELETE );
-
 	if( $mysql->commit < 0 )
 	{
 		$message = "Cannot apply changes";

Modified: trunk/vhffs-panel/mysql/prefs.pl
===================================================================
--- trunk/vhffs-panel/mysql/prefs.pl	2007-12-05 22:18:15 UTC (rev 1106)
+++ trunk/vhffs-panel/mysql/prefs.pl	2007-12-05 23:52:49 UTC (rev 1107)
@@ -54,44 +54,31 @@
 exit 0 unless $session;
 
 my $vhffs = $panel->{'vhffs'};
-my $maintemplate = $panel->{'template'};
 my $user = $panel->{'user'};
 my $group = $panel->{'group'};
-my $projectname = $session->param("project");
 my $cgi = $panel->{'cgi'};
-my $dbname = $cgi->param("name");
-my $template;
+my $templatedir = $panel->{'templatedir'};
 
-my $templatedir = $vhffs->get_config->get_templatedir;
-
+my $dbname = $cgi->param('name');
 my $mysql = Vhffs::Services::Mysql::get_by_dbname( $vhffs , $dbname );
-my $message;
+my $template;
 
-if( ! defined $dbname )
+
+unless( defined $dbname )
 {
-	$template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-	$message = gettext( "CGI Error !");
-	$template->param( MESSAGE => $message );
+	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
+	$template->param( MESSAGE => gettext( 'CGI Error !' ) );
 }
 elsif( ! defined($mysql) )
 {
-	$template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-	$message = gettext( "Cannot get informations on this object");
-	$template->param( MESSAGE => $message );
-
+	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
+	$template->param( MESSAGE => gettext('Cannot get informations on this object') );
 }
-elsif( Vhffs::Acl::what_perm_for_user( $user , $mysql , $vhffs ) < Vhffs::Constants::ACL_VIEW )
+elsif( !$user->can_view( $mysql ) )
 {
-	$template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-	$message = gettext( "You're not allowed to do this (ACL rights)" );
-	$template->param( MESSAGE => $message );
+	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
+	$template->param( MESSAGE => gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' ) );
 }
-elsif( $mysql->get_status != Vhffs::Constants::ACTIVATED )
-{
-    $template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-    $message = gettext( "This object is not functionnal yet. Please wait creation or moderation.");
-    $template->param( MESSAGE => $message );
-}
 else
 {
 
@@ -136,7 +123,7 @@
 
 sub save_prefs {
     if(!$user->can_modify($mysql)) {
-        $panel->add_error('You are not allowed to modify this MySQL object (ACL rights)');
+        $panel->add_error( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' );
         return 0;
     }
 

Modified: trunk/vhffs-panel/object/upavatar.pl
===================================================================
--- trunk/vhffs-panel/object/upavatar.pl	2007-12-05 22:18:15 UTC (rev 1106)
+++ trunk/vhffs-panel/object/upavatar.pl	2007-12-05 23:52:49 UTC (rev 1107)
@@ -100,7 +100,7 @@
 {
 	$message = gettext( "Cannot find object" );
 }
-elsif( ( Vhffs::Acl::what_perm_for_user( $user , $object, $vhffs ) < Vhffs::Constants::ACL_MODIFY ) && ( $cgioid != $user->get_oid ) )
+elsif( !$user->can_modify( $object ) )
 {
 	$message = gettext( "No enough rights" );
 }

Modified: trunk/vhffs-panel/pgsql/delete.pl
===================================================================
--- trunk/vhffs-panel/pgsql/delete.pl	2007-12-05 22:18:15 UTC (rev 1106)
+++ trunk/vhffs-panel/pgsql/delete.pl	2007-12-05 23:52:49 UTC (rev 1107)
@@ -72,9 +72,9 @@
 {
     $message = gettext("This DB doesn't exist in VHFFS database");
 }
-elsif( Vhffs::Acl::what_perm_for_user( $user , $pgsql , $vhffs ) < Vhffs::Constants::ACL_DELETE )
+elsif( !$user->can_delete( $pgsql ) )
 {
-	$message = gettext("You're not allowed to do this (ACL rights)");
+	$message = gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' );
 }
 elsif( ! defined $sure )
 {

Modified: trunk/vhffs-panel/pgsql/prefs.pl
===================================================================
--- trunk/vhffs-panel/pgsql/prefs.pl	2007-12-05 22:18:15 UTC (rev 1106)
+++ trunk/vhffs-panel/pgsql/prefs.pl	2007-12-05 23:52:49 UTC (rev 1107)
@@ -53,31 +53,22 @@
 exit 0 unless $session;
 
 my $vhffs = $panel->{'vhffs'};
-my $maintemplate = $panel->{'template'};
 my $user = $panel->{'user'};
 my $group = $panel->{'group'};
-my $projectname = $session->param("project");
 my $cgi = $panel->{'cgi'};
-my $dbname = $cgi->param("name");
-my $template;
-my $message;
+my $templatedir = $panel->{'templatedir'};
+
+my $dbname = $cgi->param('name');
 my $pgsql = Vhffs::Services::Pgsql::get_by_dbname( $vhffs , $dbname );
 
-my $templatedir = $vhffs->get_config->get_templatedir;
+my $template;
 
-if( ! defined $pgsql) {
-	my $template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-	$message = gettext( "Cannot get informations on this object");
-	$template->param( MESSAGE => $message );
-
-} elsif( Vhffs::Acl::what_perm_for_user( $user , $pgsql , $vhffs ) < Vhffs::Constants::ACL_VIEW ) {
-	$template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-    $message = gettext("You're not allowed to do this (ACL rights)");
-    $template->param( MESSAGE => $message );	
-} elsif( $pgsql->get_status != Vhffs::Constants::ACTIVATED ) {
-    $template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-    $message = gettext("Please wait modification, creation or deletion");
-    $template->param( MESSAGE => $message );
+unless( defined $pgsql ) {
+	my $template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
+	$template->param( MESSAGE => gettext( 'Cannot get informations on this object') );
+} elsif( !$user->can_view( $pgsql ) ) {
+	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
+	$template->param( MESSAGE => gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' ) );	
 } else {
     if(defined($cgi->param('save_prefs_submit'))) {
         # save_prefs issues a redirect on success
@@ -121,7 +112,7 @@
 
 sub save_prefs {
     if(!$user->can_modify($pgsql)) {
-        $panel->add_error('You are not allowed to modify this PostgreSQL object (ACL rights)');
+        $panel->add_error( gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' ) );
         return 0;
     }
 

Modified: trunk/vhffs-panel/repository/delete.pl
===================================================================
--- trunk/vhffs-panel/repository/delete.pl	2007-12-05 22:18:15 UTC (rev 1106)
+++ trunk/vhffs-panel/repository/delete.pl	2007-12-05 23:52:49 UTC (rev 1107)
@@ -77,14 +77,10 @@
 {
 	$message = gettext( "Cannot retrieve informations about this Download repository" );
 }
-elsif( ( Vhffs::Acl::what_perm_for_user( $user , $repo , $vhffs ) < Vhffs::Constants::ACL_DELETE ) && ( $user->is_admin != 1 ) )
+elsif( !$user->can_delete( $repo ) )
 {
-	$message = gettext( "You're not allowed to do this (ACL rights)" );
+	$message = gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' );
 }
-elsif( $repo->get_status != Vhffs::Constants::ACTIVATED )
-{
-    $message = gettext( "This object is not functionnal yet. Please wait creation or moderation.");
-}
 elsif( $sure == 0 )
 {
 	$message = gettext( "This Download repository will NOT be deleted" );

Modified: trunk/vhffs-panel/repository/prefs.pl
===================================================================
--- trunk/vhffs-panel/repository/prefs.pl	2007-12-05 22:18:15 UTC (rev 1106)
+++ trunk/vhffs-panel/repository/prefs.pl	2007-12-05 23:52:49 UTC (rev 1107)
@@ -54,52 +54,34 @@
 exit 0 unless $session;
 
 my $vhffs = $panel->{'vhffs'};
-my $maintemplate = $panel->{'template'};
+my $cgi = $panel->{'cgi'};
 my $user = $panel->{'user'};
 my $group = $panel->{'group'};
-my $projectname = $session->param("project");
-my $cgi = $panel->{'cgi'};
-my $repo_name = $cgi->param("name");
-my $template;
+my $templatedir = $panel->{'templatedir'};
 
+my $repo_name = $cgi->param('name');
 my $repo = Vhffs::Services::Repository::get_by_reponame( $vhffs , $repo_name );
+my $template;
 
-my $message;
-
-my $templatedir = $vhffs->get_config->get_templatedir;
-
-if( ! defined $repo_name ) {
-	$template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-	$message = gettext( "CGI Error !");
-	$template->param( MESSAGE => $message );
+unless( defined $repo_name ) {
+	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
+	$template->param( MESSAGE => gettext('CGI Error !') );
 } elsif( ! defined $repo ) {
-	$template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-	$message = gettext( "Cannot get informations on this object");
-	$template->param( MESSAGE => $message );
+	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
+	$template->param( MESSAGE => gettext('Cannot get informations on this object') );
+} elsif( !$user->can_view( $repo ) ) {
+	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
+	$template->param( MESSAGE => gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' ) );
+} else {
 
-}
-elsif( ( Vhffs::Acl::what_perm_for_user( $user , $repo , $vhffs ) < Vhffs::Constants::ACL_VIEW ) && ( $user->is_admin != 1 ) )
-{
-	$template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-	$message = gettext( "You're not allowed to do this (ACL rights)");
-	$template->param( MESSAGE => $message );
-}
-elsif( ( $repo->get_status != Vhffs::Constants::ACTIVATED ) && ( $user->is_admin != 1 ) )
-{
-	$template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-    $message = gettext( "This object is not functionnal yet. Please wait creation, moderation or modification.");
-	$template->param( MESSAGE => $message );
-}
-else
-{
 	$template = new HTML::Template( filename => $templatedir."/panel/repository/prefs.tmpl" );
 
 	$panel->set_title( gettext('Admin Download repository') );
 	$template->param( TEXT_REPONAME => $repo->get_name );
 
-    $template->param( THEME => $panel->{theme} );
+	$template->param( THEME => $panel->{theme} );
 	$template->param( QUOTA_VALUE => sprintf( gettext("Quota (used/total) : %s/%s") , $repo->get_quota_used , $repo->get_quota ) );
-    $template->param( QUOTA_WIDTH => ( ($repo->get_quota_used / $repo->get_quota) * 300 ) );
+	$template->param( QUOTA_WIDTH => ( ($repo->get_quota_used / $repo->get_quota) * 300 ) );
 
 	$template->param( TEXT_DELETE_REPOSITORY => gettext("Delete this project") );
 	$template->param( TEXT_BEFORE_DELETE => gettext("This action is non-reversible. All services associated to this project will be DESTROYED.") );
@@ -108,10 +90,10 @@
 	$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 => $repo->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" );
+	$template->param( VALUE_OID => $repo->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 $adminpart = Vhffs::Panel::Object::admin_part( $panel, $repo );
 	$template->param( ADMIN_PART => $adminpart->output ) if( defined $adminpart );

Modified: trunk/vhffs-panel/svn/delete.pl
===================================================================
--- trunk/vhffs-panel/svn/delete.pl	2007-12-05 22:18:15 UTC (rev 1106)
+++ trunk/vhffs-panel/svn/delete.pl	2007-12-05 23:52:49 UTC (rev 1107)
@@ -76,14 +76,10 @@
 {
 	$message = gettext( "Cannot retrieve informations about this repository" );
 }
-elsif( ( Vhffs::Acl::what_perm_for_user( $user , $svn , $vhffs ) < Vhffs::Constants::ACL_DELETE ) && ( $user->is_admin != 1 ) )
+elsif( !$user->can_delete( $svn ) )
 {
-	$message = gettext( "You're not allowed to do this (ACL rights)" );
+	$message = gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' );
 }
-elsif( $svn->get_status != Vhffs::Constants::ACTIVATED )
-{
-    $message = gettext( "This object is not functionnal yet. Please wait creation or moderation.");
-}
 elsif( $sure == 0 )
 {
 	$message = gettext( "This subversion repository will NOT be deleted" );

Modified: trunk/vhffs-panel/svn/prefs.pl
===================================================================
--- trunk/vhffs-panel/svn/prefs.pl	2007-12-05 22:18:15 UTC (rev 1106)
+++ trunk/vhffs-panel/svn/prefs.pl	2007-12-05 23:52:49 UTC (rev 1107)
@@ -52,47 +52,29 @@
 exit 0 unless $session;
 
 my $vhffs = $panel->{'vhffs'};
-my $maintemplate = $panel->{'template'};
 my $user = $panel->{'user'};
-my $projectname = $session->param("project");
 my $cgi = $panel->{'cgi'};
+my $templatedir = $panel->{'templatedir'};
+
 my $repo_name = $cgi->param("name");
+my $svn = Vhffs::Services::Svn::get_by_reponame( $vhffs , $repo_name );
 my $template;
-my $output;
-my $subtemplate;
-my $svn;
-my $templatedir;
-my $message;
 
-$templatedir = $vhffs->get_config->get_templatedir;
-
-$svn = Vhffs::Services::Svn::get_by_reponame( $vhffs , $repo_name );
-
-if( ! defined $repo_name )
+unless( defined $repo_name )
 {
-    $template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-    $message = gettext( "CGI Error" );
-    $template->param( MESSAGE => $message );
+	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
+	$template->param( MESSAGE => gettext('CGI Error') );
 }
 elsif( !defined $svn )
 {
-    $template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-    $message = gettext( "Cannot get informations on this object");
-    $template->param( MESSAGE => $message );
-
+	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
+	$template->param( MESSAGE => gettext('Cannot get informations on this object') );
 }
-elsif( ( Vhffs::Acl::what_perm_for_user( $user , $svn , $vhffs ) < Vhffs::Constants::ACL_VIEW ) && ( $user->is_admin != 1 ) )
+elsif( !$user->can_view( $svn ) )
 {
-    $template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-    $message = gettext( "You're not allowed to do this (ACL rights)");
-    $template->param( MESSAGE => $message );
+	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
+	$template->param( MESSAGE => gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' ) );
 }
-elsif( ( $svn->get_status != Vhffs::Constants::ACTIVATED ) && ( $user->is_admin != 1 ) )
-{
-    $template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
-    $message = gettext( "This object is not functionnal yet. Please wait creation, moderation or modification.");
-    $template->param( MESSAGE => $message );
-}
 else
 {
     if(defined $cgi->param('prefs_save_submit')) {
@@ -149,7 +131,7 @@
     my $ml_name = $cgi->param('ml_name');
 
     if(!$user->can_modify($svn)) {
-        $panel->add_error( gettext('You are not allowed to modify this SVN Object (ACL Rights)') );
+        $panel->add_error( gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' ) );
         return 0;
     }
 

Modified: trunk/vhffs-panel/user/prefs.pl
===================================================================
--- trunk/vhffs-panel/user/prefs.pl	2007-12-05 22:18:15 UTC (rev 1106)
+++ trunk/vhffs-panel/user/prefs.pl	2007-12-05 23:52:49 UTC (rev 1107)
@@ -72,227 +72,228 @@
 	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
 	$template->param( MESSAGE => gettext('Cannot get informations on this object') );
 }
-elsif( $userp->get_status != Vhffs::Constants::ACTIVATED )
+elsif( !$user->can_view( $userp ) )
 {
 	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
-	$template->param( MESSAGE => gettext('This object is not functionnal yet. Please wait creation or moderation.') );
+	$template->param( MESSAGE => gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' ) );
 }
-elsif( ! $user->can_modify( $userp ) )
-{
-	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
-	$template->param( MESSAGE => gettext('You\'re not allowed to do this (ACL rights)') );
-}
 else
 {
-	if(defined $cgi->param('prefs_submit')) {
-		my $mail = $cgi->param( 'MAIL' );
-		my $firstname = Encode::decode_utf8( $cgi->param( 'FIRSTNAME' ) );
-		my $lastname = Encode::decode_utf8( $cgi->param( 'LASTNAME' ) );
-		my $city = Encode::decode_utf8( $cgi->param( 'CITY' ) );
-		my $zipcode = Encode::decode_utf8( $cgi->param( 'ZIPCODE' ) );
-		my $country = Encode::decode_utf8( $cgi->param( 'COUNTRY' ) );
-		my $address = Encode::decode_utf8( $cgi->param( 'ADDRESS' ) );
-		my $pass1 = $cgi->param( 'PASSWORD1' );
-		my $pass2 = $cgi->param( 'PASSWORD2' );
+	if( defined $cgi->param('prefs_submit') ) {
+		unless( $user->can_modify( $userp ) ) {
+			$panel->add_error( gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' ) );
+		} else {
+			my $mail = $cgi->param( 'MAIL' );
+			my $firstname = Encode::decode_utf8( $cgi->param( 'FIRSTNAME' ) );
+			my $lastname = Encode::decode_utf8( $cgi->param( 'LASTNAME' ) );
+			my $city = Encode::decode_utf8( $cgi->param( 'CITY' ) );
+			my $zipcode = Encode::decode_utf8( $cgi->param( 'ZIPCODE' ) );
+			my $country = Encode::decode_utf8( $cgi->param( 'COUNTRY' ) );
+			my $address = Encode::decode_utf8( $cgi->param( 'ADDRESS' ) );
+			my $pass1 = $cgi->param( 'PASSWORD1' );
+			my $pass2 = $cgi->param( 'PASSWORD2' );
 
-		my $theme = $cgi->param( 'THEME' );
-		my $lang = $cgi->param( 'LANG' );
-		my $shell = $cgi->param( 'SHELL' );
+			my $theme = $cgi->param( 'THEME' );
+			my $lang = $cgi->param( 'LANG' );
+			my $shell = $cgi->param( 'SHELL' );
 
-		my $pwd_change = 0;
-		my $mail_change = 0;
+			my $pwd_change = 0;
+			my $mail_change = 0;
 
-		if( $userp->{uid} == $user->{uid} )  {
-			# Checks data and perform requested modifications
-			$panel->add_cookie( CGI->cookie( -name=>'theme', -value=>$theme, -expires=>'+10y' ) );
-			Vhffs::Panel::User::set_theme( $user, $theme );
+			if( $userp->{uid} == $user->{uid} )  {
+				# Checks data and perform requested modifications
+				$panel->add_cookie( CGI->cookie( -name=>'theme', -value=>$theme, -expires=>'+10y' ) );
+				Vhffs::Panel::User::set_theme( $user, $theme );
 
-			$panel->add_cookie( CGI->cookie( -name=>'language', -value=>$lang, -expires=>'+10y' ) );
-			Vhffs::Panel::User::set_lang( $user, $lang );
-		}
+				$panel->add_cookie( CGI->cookie( -name=>'language', -value=>$lang, -expires=>'+10y' ) );
+				Vhffs::Panel::User::set_lang( $user, $lang );
+			}
 
-		# Commit all the changes for the current user
-		unless( defined $firstname && defined $lastname && defined $city && defined $mail && defined $zipcode && defined $country && defined $address && defined $shell )  {
-			$panel->add_error( gettext( 'CGI Error!' ) );
-		}
-		else {
-			# We don't really care about what user use as firstname, lastname, ... we just
-			# want it not to break everything
-			if( $firstname !~ /^[^<">]+$/ ) {
-				$panel->add_error( gettext( 'Firstname is not correct !') );
+			# Commit all the changes for the current user
+			unless( defined $firstname && defined $lastname && defined $city && defined $mail && defined $zipcode && defined $country && defined $address && defined $shell )  {
+				$panel->add_error( gettext( 'CGI Error!' ) );
 			}
-			if( $lastname !~ /^[^<">]+$/ ) {
-				$panel->add_error( gettext( 'Lastname is not correct !') );
-			}
-			if( $city !~ /^[^<">]+$/ ) {
-				$panel->add_error( gettext( 'City is not correct !') );
-			}
-			if( ! Vhffs::Functions::valid_mail($mail) ) {
-				$panel->add_error( gettext( 'Email is not correct !') );
-			}
-			if( ! ( $zipcode =~ /^[\w\d\s\-]+$/ ) ) {
-				$panel->add_error( gettext( "Zipcode is not correct !" ) );
-			}
-			if( $country !~ /^[^<">]+$/ ) {
-				$panel->add_error( gettext( 'Country is not correct !') );
-			}
-			if( $address !~ /^[^<">]+$/ ) {
-				$panel->add_error( gettext( 'Address is not correct !') );
-			}
-			if( $pass1 ne $pass2 ) {
-				$panel->add_error( gettext( "Passwords don't match" ) );
-			}
-			if( $userp->have_activegroups > 0 ) {
-				my $valid=0;
-				foreach( Vhffs::Panel::User::list_shells( $vhffs ) ) {
-					$valid = 1 if($shell eq $_);
+			else {
+				# We don't really care about what user use as firstname, lastname, ... we just
+				# want it not to break everything
+				if( $firstname !~ /^[^<">]+$/ ) {
+					$panel->add_error( gettext( 'Firstname is not correct !') );
 				}
-				unless( $valid ) {
-					$panel->add_error( gettext( 'Wanted shell is not in the shell list' ) );
+				if( $lastname !~ /^[^<">]+$/ ) {
+					$panel->add_error( gettext( 'Lastname is not correct !') );
 				}
-			}
-			else {
-				$shell = Vhffs::Panel::User::default_shell( $ vhffs );
-			}
+				if( $city !~ /^[^<">]+$/ ) {
+					$panel->add_error( gettext( 'City is not correct !') );
+				}
+				if( ! Vhffs::Functions::valid_mail($mail) ) {
+					$panel->add_error( gettext( 'Email is not correct !') );
+				}
+				if( ! ( $zipcode =~ /^[\w\d\s\-]+$/ ) ) {
+					$panel->add_error( gettext( "Zipcode is not correct !" ) );
+				}
+				if( $country !~ /^[^<">]+$/ ) {
+					$panel->add_error( gettext( 'Country is not correct !') );
+				}
+				if( $address !~ /^[^<">]+$/ ) {
+					$panel->add_error( gettext( 'Address is not correct !') );
+				}
+				if( $pass1 ne $pass2 ) {
+					$panel->add_error( gettext( "Passwords don't match" ) );
+				}
+				if( $userp->have_activegroups > 0 ) {
+					my $valid=0;
+					foreach( Vhffs::Panel::User::list_shells( $vhffs ) ) {
+						$valid = 1 if($shell eq $_);
+					}
+					unless( $valid ) {
+						$panel->add_error( gettext( 'Wanted shell is not in the shell list' ) );
+					}
+				}
+				else {
+					$shell = Vhffs::Panel::User::default_shell( $ vhffs );
+				}
 
-			if(! $panel->has_errors) {
-				$userp->set_firstname(  $firstname );
-				$userp->set_lastname(  $lastname );
-				$userp->set_city(  $city );
-				$userp->set_zipcode( $zipcode );
-				$userp->set_country( $country );
-				$userp->set_address( $address );
-				$userp->set_shell( $shell );
+				if(! $panel->has_errors) {
+					$userp->set_firstname(  $firstname );
+					$userp->set_lastname(  $lastname );
+					$userp->set_city(  $city );
+					$userp->set_zipcode( $zipcode );
+					$userp->set_country( $country );
+					$userp->set_address( $address );
+					$userp->set_shell( $shell );
 
-				if( ( length( $pass1 ) > 1 ) && ( $pass1 eq $pass2 ) ) { 
-					$pwd_change = 1;
-					$userp->set_password( $pass1 );
-					$panel->add_info( gettext('Password changed') );
+					if( ( length( $pass1 ) > 1 ) && ( $pass1 eq $pass2 ) ) { 
+						$pwd_change = 1;
+						$userp->set_password( $pass1 );
+						$panel->add_info( gettext('Password changed') );
 
-					my $mu = init Vhffs::Services::MailUser( $vhffs , $userp );
-					if( defined $mu  &&  $mu->exists_box) {
-						$mu->changepassword( $pass1 );
+						my $mu = init Vhffs::Services::MailUser( $vhffs , $userp );
+						if( defined $mu  &&  $mu->exists_box) {
+							$mu->changepassword( $pass1 );
+						}
 					}
-				}
 
-				my $prevmail = $userp->get_mail();
-				if( $prevmail ne $mail ) {
-					$mail_change = 1;
-					$userp->set_mail( $mail );
-					my $subject = gettext("Mailbox modified");
-					my $content = sprintf( gettext("Hello %s %s,\n\nYou changed your email, here are your new personal information :\n\nUser: %s\nMail: %s\n\nVHFFS administrators\n"), $userp->get_firstname, $userp->get_lastname, $userp->get_username, $userp->get_mail);
-					$userp->send_mail_user( $subject, $content );
-					$panel->add_info( gettext('Email address changed') );
-				}
+					my $prevmail = $userp->get_mail();
+					if( $prevmail ne $mail ) {
+						$mail_change = 1;
+						$userp->set_mail( $mail );
+						my $subject = gettext("Mailbox modified");
+						my $content = sprintf( gettext("Hello %s %s,\n\nYou changed your email, here are your new personal information :\n\nUser: %s\nMail: %s\n\nVHFFS administrators\n"), $userp->get_firstname, $userp->get_lastname, $userp->get_username, $userp->get_mail);
+						$userp->send_mail_user( $subject, $content );
+						$panel->add_info( gettext('Email address changed') );
+					}
 
-				if( $userp->commit < 0 ) {
-					$panel->clear_infos();
-					$panel->add_error( gettext('An error occured while updating the user account') );
-				}
+					if( $userp->commit < 0 ) {
+						$panel->clear_infos();
+						$panel->add_error( gettext('An error occured while updating the user account') );
+					}
 
-				# -- Mail User
-				my $mu = init Vhffs::Services::MailUser( $vhffs , $userp );
-				if( defined $mu )  {
+					# -- Mail User
+					my $mu = init Vhffs::Services::MailUser( $vhffs , $userp );
+					if( defined $mu )  {
 					
-					my $mail_activate = $cgi->param( "mail_activate" );
-					my $nospam = $cgi->param( "mail_nospam" );
-					my $novirus = $cgi->param( "mail_novirus" );
-					$nospam = (( defined $nospam ) && ( $nospam eq "on" ));
-					$novirus = ( ( defined $novirus ) && ( $novirus eq "on" ) );
+						my $mail_activate = $cgi->param( "mail_activate" );
+						my $nospam = $cgi->param( "mail_nospam" );
+						my $novirus = $cgi->param( "mail_novirus" );
+						$nospam = (( defined $nospam ) && ( $nospam eq "on" ));
+						$novirus = ( ( defined $novirus ) && ( $novirus eq "on" ) );
     
-					if( ( defined $mail_activate ) && ( $mail_activate eq "on" ) ) {
-						my $usage = $cgi->param( "mail_usage" );
-						if( ! defined $usage ) {
-							$panel->add_error( gettext("You must choose a method for your mail") );
-						}
-						elsif( $usage == 1 ) {
-							#Delete forward if necessary
-							#In this case, we treat for popable accounts
-							if( $mu->exists_box == 0 ) {
-								# Box doesn't exists, need a password
-								if( $pwd_change == 0 ) {
-									$panel->add_error( gettext("Error ! You MUST provide a password in your account when you create your popable account") );
-								} else  {
-									# Del forward if needed
-									$mu->delforward;
-									if( $mu->addbox($pass1 ) < 0 ) {
-										$panel->add_error( gettext("An error occured while adding the box") );
-									} elsif( $nospam && ( $mu->change_spam_status < 0 ) ) {
-										$panel->add_error( gettext("An error occured while adding the box (anti-spam adding)") );
-									} elsif( $novirus && ( $mu->change_virus_status < 0 ) ) {
-										$panel->add_error( gettext("An error occured while adding the box (anti-virus adding)") );
-									} else {
-										$panel->add_info( gettext("Mailbox successfully added") );
+						if( ( defined $mail_activate ) && ( $mail_activate eq "on" ) ) {
+							my $usage = $cgi->param( "mail_usage" );
+							if( ! defined $usage ) {
+								$panel->add_error( gettext("You must choose a method for your mail") );
+							}
+							elsif( $usage == 1 ) {
+								#Delete forward if necessary
+								#In this case, we treat for popable accounts
+								if( $mu->exists_box == 0 ) {
+									# Box doesn't exists, need a password
+									if( $pwd_change == 0 ) {
+										$panel->add_error( gettext("Error ! You MUST provide a password in your account when you create your popable account") );
+									} else  {
+										# Del forward if needed
+										$mu->delforward;
+										if( $mu->addbox($pass1 ) < 0 ) {
+											$panel->add_error( gettext("An error occured while adding the box") );
+										} elsif( $nospam && ( $mu->change_spam_status < 0 ) ) {
+											$panel->add_error( gettext("An error occured while adding the box (anti-spam adding)") );
+										} elsif( $novirus && ( $mu->change_virus_status < 0 ) ) {
+											$panel->add_error( gettext("An error occured while adding the box (anti-virus adding)") );
+										} else {
+											$panel->add_info( gettext("Mailbox successfully added") );
+										}
 									}
-								}
-							} else {
-								#Box already exists
-								# The user changed his password, we must update password for mail
-								if( $pwd_change ) {
-									$mu->changepassword( $pass1);
-								}
+								} else {
+									#Box already exists
+									# The user changed his password, we must update password for mail
+									if( $pwd_change ) {
+										$mu->changepassword( $pass1);
+									}
 
-								# We change the spam status. if the spam status changed
-								if( $vhffs->get_config->get_service('mail')->{'use_nospam'} eq 'yes' ) {
-									if( $nospam != $mu->use_nospam ) {
-										if( $mu->change_spam_status == 1 ) {
-											$panel->add_info( gettext( "Change spam protection status for your account\n" ) );
-										} else {
-											$panel->add_error( gettext( "Error for spam protection\n" ) );
+									# We change the spam status. if the spam status changed
+									if( $vhffs->get_config->get_service('mail')->{'use_nospam'} eq 'yes' ) {
+										if( $nospam != $mu->use_nospam ) {
+											if( $mu->change_spam_status == 1 ) {
+												$panel->add_info( gettext( "Change spam protection status for your account\n" ) );
+											} else {
+												$panel->add_error( gettext( "Error for spam protection\n" ) );
+											}
 										}
 									}
-								}
 
-								# As spam, the virus status changes only if the user changed values
-								if( $vhffs->get_config->get_service('mail')->{'use_novirus'} eq 'yes' ) {
-									if( $novirus != $mu->use_novirus ) {
-										if( $mu->change_virus_status == 1 ) {
-											$panel->add_info( gettext( "Changed anti-virus status for your account\n" ) );
-										} else {
-											$panel->add_error( gettext( "Error for virus protection\n" ) );
+									# As spam, the virus status changes only if the user changed values
+									if( $vhffs->get_config->get_service('mail')->{'use_novirus'} eq 'yes' ) {
+										if( $novirus != $mu->use_novirus ) {
+											if( $mu->change_virus_status == 1 ) {
+												$panel->add_info( gettext( "Changed anti-virus status for your account\n" ) );
+											} else {
+												$panel->add_error( gettext( "Error for virus protection\n" ) );
+											}
 										}
 									}
 								}
 							}
-						}
-						elsif( $usage == 2 ) {
-							#Here, we create the forward
-							my $ad = $userp->get_mail;
-							if( $mu->exists_forward == 0 ) {
-								if( ! defined $ad ) {
-									$panel->add_error( gettext("There is a problem with the address you filled in your profile, unable to add forwarding") );
-								} else {
-									# Delete the box if necessary
-									$mu->delbox;
-									if( $mu->addforward( $userp->get_mail ) < 0) {
-										$panel->add_error(  gettext("An error occured while adding the forwarding") );
+							elsif( $usage == 2 ) {
+								#Here, we create the forward
+								my $ad = $userp->get_mail;
+								if( $mu->exists_forward == 0 ) {
+									if( ! defined $ad ) {
+										$panel->add_error( gettext("There is a problem with the address you filled in your profile, unable to add forwarding") );
 									} else {
-										$panel->add_info( gettext('Forward added') );
+										# Delete the box if necessary
+										$mu->delbox;
+										if( $mu->addforward( $userp->get_mail ) < 0) {
+											$panel->add_error(  gettext("An error occured while adding the forwarding") );
+										} else {
+											$panel->add_info( gettext('Forward added') );
+										}
 									}
 								}
-							}
-							elsif( $mail_change == 1 ) {
-								$mu->delforward;
-								if( $mu->addforward( $mail ) < 0 ) {
-									$panel->add_error( gettext("An error occured while the forwarding") );
-								} else {
-									$panel->add_info( gettext('Forward updated') );
+								elsif( $mail_change == 1 ) {
+									$mu->delforward;
+									if( $mu->addforward( $mail ) < 0 ) {
+										$panel->add_error( gettext("An error occured while the forwarding") );
+									} else {
+										$panel->add_info( gettext('Forward updated') );
+									}
 								}
-							}
-						}	
-					} elsif($mu->exists_box || $mu->exists_forward) {
-						$panel->add_info( gettext('Mail deleted') );
-						# User doesn't want mail anymore
-						$mu->delbox;
-						$mu->delforward;
+							}	
+						} elsif($mu->exists_box || $mu->exists_forward) {
+							$panel->add_info( gettext('Mail deleted') );
+							# User doesn't want mail anymore
+							$mu->delbox;
+							$mu->delforward;
+						}
 					}
 				}
 			}
 		}
-	} elsif(defined $cgi->param('update_permissions_submit')) {
-        update_permissions();
-    }
+	}
 
+	elsif( defined $cgi->param('update_permissions_submit') ) {
+		update_permissions();
+	}
+
 	$panel->set_title( gettext("User Preferences") );
 
 	$template = new Vhffs::Panel::Template( filename => $templatedir."/panel/user/prefs.tmpl" );

Modified: trunk/vhffs-panel/web/delete.pl
===================================================================
--- trunk/vhffs-panel/web/delete.pl	2007-12-05 22:18:15 UTC (rev 1106)
+++ trunk/vhffs-panel/web/delete.pl	2007-12-05 23:52:49 UTC (rev 1107)
@@ -78,9 +78,9 @@
 {
     $message = gettext("This web area doesn't exist in VHFFS database");
 }
-elsif( ( Vhffs::Acl::what_perm_for_user( $user , $web , $vhffs ) < Vhffs::Constants::ACL_DELETE ) && ( $user->is_admin != 1 ) )
+elsif( !$user->can_delete( $web ) )
 {
-	$message = gettext("You're not allowed to do this (ACL rights)");
+	$message = gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' );
 }
 else
 {


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