[vhffs-dev] [523] Updated a bunch a examples.

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


Revision: 523
Author:   beuss
Date:     2007-03-22 22:06:52 +0000 (Thu, 22 Mar 2007)

Log Message:
-----------
Updated a bunch a examples. MailUser prefs are more user friendly, MailUser has been reworked

Modified Paths:
--------------
    branches/vhffs_4.1/vhffs-api/src/Vhffs/Constants.pm
    branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Mail.pm
    branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/MailUser.pm
    branches/vhffs_4.1/vhffs-api/src/examples/add_acl.pl
    branches/vhffs_4.1/vhffs-api/src/examples/add_acl_dns.pl
    branches/vhffs_4.1/vhffs-api/src/examples/create_box.pl
    branches/vhffs_4.1/vhffs-api/src/examples/create_forward.pl
    branches/vhffs_4.1/vhffs-api/src/examples/delbox.pl
    branches/vhffs_4.1/vhffs-api/src/examples/delete_acl.pl
    branches/vhffs_4.1/vhffs-api/src/examples/get_list.pl
    branches/vhffs_4.1/vhffs-api/src/examples/modify_acl.pl
    branches/vhffs_4.1/vhffs-api/src/examples/perm_for_user.pl
    branches/vhffs_4.1/vhffs-api/src/examples/print_domain.pl
    branches/vhffs_4.1/vhffs-api/src/examples/show_acl_per_object.pl
    branches/vhffs_4.1/vhffs-api/src/examples/show_members_from_list.pl
    branches/vhffs_4.1/vhffs-panel/templates/user/mailuser.tmpl
    branches/vhffs_4.1/vhffs-panel/templates/user/mailuserspam.tmpl
    branches/vhffs_4.1/vhffs-panel/templates/user/mailuservirus.tmpl
    branches/vhffs_4.1/vhffs-panel/templates/user/prefs_avatar.tmpl
    branches/vhffs_4.1/vhffs-panel/themes/vhffs/main.css
    branches/vhffs_4.1/vhffs-panel/themes/vhffs-ng/main.css
    branches/vhffs_4.1/vhffs-panel/user/prefs.pl


Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Constants.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Constants.pm	2007-03-22 07:09:18 UTC (rev 522)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Constants.pm	2007-03-22 22:06:52 UTC (rev 523)
@@ -7,7 +7,7 @@
 
 use constant
 {
-    VHFFS_VERSION => '4.1-alpha (Revision: 521)',
+    VHFFS_VERSION => '4.1-alpha (Revision: 522)',
     VHFFS_RELEASE_NAME => "hippocampus",
     
     WAITING_FOR_VALIDATION => 1,

Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Mail.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Mail.pm	2007-03-22 07:09:18 UTC (rev 522)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Mail.pm	2007-03-22 22:06:52 UTC (rev 523)
@@ -377,8 +377,16 @@
 	return 1;
 }
 
+=pod
 
+=head2 addforward
 
+    die("Unable to add forward $local_part\n") unless($mail->addforward($local_part, $remote_address) > 0);
+
+Add a forward from $local_part@$mail->get_domain to $remote_address.
+
+=cut
+
 sub addforward
 {
 	my $self = shift;
@@ -401,7 +409,16 @@
 	return 1;
 }
 
+=pod
 
+=head2 addbox
+
+    die("Unable to create box\n") unless($mail->addbox($local_part, $password));
+
+Add a new mailbox to the mail domain.
+
+=cut
+
 sub addbox
 {
 	my $self = shift;
@@ -622,6 +639,17 @@
 }
 
 
+=pod
+
+=head2 get_by_mxdomain
+
+    my $mail = Vhffs::Services::get_by_mxdomain($main, $domain);
+    die("Mail domain $domain not found\n") unless(defined $mail);
+
+Fetches the mail services whose domainname is $domain.
+
+=cut
+
 sub get_by_mxdomain {
     my ($main, $domain) = @_;
 

Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/MailUser.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/MailUser.pm	2007-03-22 07:09:18 UTC (rev 522)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/MailUser.pm	2007-03-22 22:06:52 UTC (rev 523)
@@ -54,7 +54,6 @@
 
 package Vhffs::Services::MailUser;
 
-use base qw(Vhffs::Object);
 use strict;
 use DBI;
 use Vhffs::User;
@@ -69,60 +68,28 @@
 
 	my $this = {};
 
-	# Instance it as a main object to have links with the database
-	$this = $class->SUPER::new( $vhffs , 1 , '401' );	
+	my $config = $vhffs->get_config->get_service('mailuser');
+	return -1 unless( defined $config && (defined $config->{activate} && $config->{activate} eq 'yes' ) );
+    $this->{main} = $vhffs;
+    $this->{config} = $config;
 
-	my $config = $vhffs->get_config->get_service( "mailuser");
-	return -1 if( ! defined $config );
-	return -1 if( ( ! defined $config->{activate} ) || ( $config->{activate} ne "yes" ) );
+	return -1 unless( defined $user );
+    $this->{part} = $user->get_username;
 
-	if( ! defined $user )
-	{
-		return -1;
-	}
-	else
-	{
-		$this->{part} = $user->get_username;
-	}
+	return -2 unless( defined $config->{domain} );
+	$this->{domain} = $config->{domain};
 
-	if( defined $config->{domain} )
-	{
-		$this->{domain} = $config->{domain};
-	}
-	else
-	{
-		return -2;
-	}
+    # Fetches the owner of the mail domain
+	return -3 unless( defined $config->{user} );
+	my $wuser = Vhffs::User::get_by_username( $vhffs , $config->{user} );
+    return -4 unless( defined $wuser );
+    $this->{wuser} = $wuser;
 
-	if( defined $config->{user} )
-	{
-		my $wuser = Vhffs::User::get_by_username( $vhffs , $config->{user} );
-		if( defined $wuser )
-		{
-			$this->{wuser} = $wuser;
-		}
-		else
-		{
-			return -4;
-		}
-	}
-	else
-	{	
-		return -3;
-	}
+    # Fetches the mail domain defined in config
+    my $mail_service = Vhffs::Services::Mail::get_by_mxdomain($vhffs, $this->{domain});
+    return -5 unless(defined $mail_service);
+	$this->{mail_service} = $mail_service;
 
-	my $object = new Vhffs::Services::Mail( $vhffs, $this->{domain} , $this->{wuser} , undef );
-
-	if( $object->fetch < 0 )
-	{
-		return -5;
-	}
-	else
-	{
-		$this->{object} = $object;
-	}
-
-
     bless( $this , $class );
 
 	return $this;
@@ -131,57 +98,54 @@
 sub available
 {
 	my $self = shift;
-	my $config = $self->{main}->get_config->get_service( "mailuser");
 	my $user = Vhffs::User::get_by_username( $self->{main} , $self->{part} );
 	return 0 unless( defined $user );
-	return 1 if( ( ! defined $config->{groupneeded} ) || ( $config->{groupneeded} ne "yes" ) || ( $user->have_activegroups > 0 ) );
+	return 1 if( ( ! defined $self->{config}->{groupneeded} ) || ( $self->{config}->{groupneeded} ne "yes" ) || ( $user->have_activegroups > 0 ) );
 	return 0;
 }
 
 sub exists
 {
 	my $self = shift;
-	return $self->{object}->exists( $self->{part} );
+	return $self->{mail_service}->exists( $self->{part} );
 }
 
 sub exists_forward
 {
 	my $self = shift;
-	return $self->{object}->exists_forward( $self->{part} );
+	return $self->{mail_service}->exists_forward( $self->{part} );
 }
 
 
 sub exists_box
 {
 	my $self = shift;
-	return $self->{object}->exists_box( $self->{part} );
+	return $self->{mail_service}->exists_box( $self->{part} );
 }
 
 sub use_nospam
 {
 	my $self = shift;
-	return $self->{object}->use_nospam( $self->{part} );
+	return $self->{mail_service}->use_nospam( $self->{part} );
 }
 
 sub use_novirus
 {
 	my $self = shift;
-	return $self->{object}->use_novirus( $self->{part} );
+	return $self->{mail_service}->use_novirus( $self->{part} );
 }
 
 sub change_spam_status
 {
 	my $self = shift;
-	$self->{object}->change_spam_status( $self->{part} );
-	return -2 if( $self->{object}->commit < 0 );
+	$self->{mail_service}->change_spam_status( $self->{part} );
 	return 1;
 }
 
 sub change_virus_status
 {
 	my $self = shift;
-	$self->{object}->change_virus_status( $self->{part} );
-	return -2 if( $self->{object}->commit < 0 );
+	$self->{mail_service}->change_virus_status( $self->{part} );
 	return 1;
 }
 
@@ -193,24 +157,23 @@
 	
 	if( $self->exists_box == 1 )
 	{
-		$self->{object}->delbox( $self->{part} );
-		$self->{object}->fetch;
+		$self->{mail_service}->delbox( $self->{part} );
+		$self->{mail_service}->fetch;
 	}
 	
-	return -1 if ( $self->{object}->addforward( $self->{part} , $remote ) < 0);
-	return -2 if( $self->{object}->commit < 0 );
+	return -1 if ( $self->{mail_service}->addforward( $self->{part} , $remote ) < 0);
 }
 
 sub delforward
 {
 	my $self = shift;
-    $self->{object}->delforward( $self->{part} );
+    $self->{mail_service}->delforward( $self->{part} );
 }
 
 sub delbox
 {
 	my $self = shift;
-    $self->{object}->delbox( $self->{part} );
+    $self->{mail_service}->delbox( $self->{part} );
 }
 
 sub addbox
@@ -221,12 +184,11 @@
 
 	if( $self->exists_forward == 1 )
 	{
-		$self->{object}->delforward( $self->{part} );
-		$self->{object}->fetch;
+		$self->{mail_service}->delforward( $self->{part} );
+		$self->{mail_service}->fetch;
 	}
 
-	return -1 if( $self->{object}->addbox( $self->{part} , $password ) < 0);
-	return -2 if( $self->{object}->commit < 0 );
+	return -1 if( $self->{mail_service}->addbox( $self->{part} , $password ) < 0);
 }
 
 

Modified: branches/vhffs_4.1/vhffs-api/src/examples/add_acl.pl
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/examples/add_acl.pl	2007-03-22 07:09:18 UTC (rev 522)
+++ branches/vhffs_4.1/vhffs-api/src/examples/add_acl.pl	2007-03-22 22:06:52 UTC (rev 523)
@@ -3,32 +3,23 @@
 
 use strict;
 
-use Data::Dumper;
 use lib "/usr/share/vhffs/api/";
-use Vhffs::Conf;
 use Vhffs::User;
-use Vhffs::Group;
 use Vhffs::Main;
-use Vhffs::Object;
 use Vhffs::Services::Httpd;
 use Vhffs::Acl;
 
-my $config;
-my $mysql_config;
-my $services_config;
-my $user;
-my $dbh;
-my $backend;
-my %infos;
-
 my $princ = init Vhffs::Main;
 
-$config = $princ->get_config;
+die("Usage: $0 servername username level\n") if(@ARGV != 3);
 
+my ($servername, $username, $level) = @ARGV;
 
-$user = new Vhffs::User( $princ , "soda" , 401) ;
+my $user = Vhffs::User::get_by_username($princ, $username);
+die("User $username not found\n") unless(defined $user);
 
-my $httpd = new Vhffs::Services::Httpd( $princ , "proutlol2.com" , $user );
+my $httpd = Vhffs::Services::Httpd::get_by_servername($princ, $servername);
+die("Webarea $servername not found\n") unless(defined $httpd);
 
-Vhffs::Acl::add_acl( $user , $httpd , 3 , $princ );
+Vhffs::Acl::add_acl( $user, $httpd, $level, $princ );
 

Modified: branches/vhffs_4.1/vhffs-api/src/examples/add_acl_dns.pl
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/examples/add_acl_dns.pl	2007-03-22 07:09:18 UTC (rev 522)
+++ branches/vhffs_4.1/vhffs-api/src/examples/add_acl_dns.pl	2007-03-22 22:06:52 UTC (rev 523)
@@ -5,32 +5,23 @@
 
 use Data::Dumper;
 use lib "/usr/share/vhffs/api/";
-use Vhffs::Conf;
 use Vhffs::User;
-use Vhffs::Group;
 use Vhffs::Main;
-use Vhffs::Object;
 use Vhffs::Services::DNS;
 use Vhffs::Acl;
 
-my $config;
-my $mysql_config;
-my $services_config;
-my $user;
-my $group;
-my $dbh;
-my $backend;
-my %infos;
-
 my $princ = init Vhffs::Main;
 
-$config = $princ->get_config;
+die("Usage: $0 domain user level\n") unless(@ARGV == 3);
 
+my ($domain, $username, $level) = @ARGV;
 
-$user = new Vhffs::User( $princ , "sodalol" , 401) ;
-$group = new Vhffs::Group( $princ , "sodalol" , 401) ;
+my $dns = Vhffs::Services::DNS::get_by_domainname($princ , $domain);
+die("Domain $domain not found\n") unless(defined $dns);
 
-my $httpd = new Vhffs::Services::DNS ($princ , "prout.com" , $user , $group);
+my $user = Vhffs::User::get_by_username($princ, $username);
+die("User $username not found\n") unless(defined $user);
 
-Vhffs::Acl::add_acl( $user , $httpd , 3 , $princ->get_db_object );
+Vhffs::Acl::add_acl($user, $dns, $level, $princ);
 
+print "User $username has now access level $level domain $domain\n";

Modified: branches/vhffs_4.1/vhffs-api/src/examples/create_box.pl
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/examples/create_box.pl	2007-03-22 07:09:18 UTC (rev 522)
+++ branches/vhffs_4.1/vhffs-api/src/examples/create_box.pl	2007-03-22 22:06:52 UTC (rev 523)
@@ -5,66 +5,17 @@
 
 use Data::Dumper;
 use lib "/usr/share/vhffs/api/";
-use Vhffs::Conf;
-use Vhffs::User;
-use Vhffs::Group;
 use Vhffs::Main;
-use Vhffs::Object;
 use Vhffs::Services::Mail;
 
-my $config;
-my $mysql_config;
-my $services_config;
-my $user;
-my $dbh;
-my $backend;
-my %infos;
-
 my $princ = init Vhffs::Main;
 
-$config = $princ->get_config;
+die("Usage: $0 mail_domain local_part password\n") unless(@ARGV == 3);
 
+my ($domain, $local, $pass) = @ARGV;
 
-$user = new Vhffs::User( $princ , "soda" , 401) ;
-my $group = new Vhffs::Group( $princ , "soda" , 401) ;
+my $mail = Vhffs::Services::Mail::get_by_mxdomain($princ, $domain);
+die("Mail domain $domain not found\n") unless(defined $mail);
 
-my $mail = new Vhffs::Services::Mail( $princ , $ARGV[0] , $user , $group);
-
-if( defined $mail )
-{
-	print "object created\n";
-}
-else
-{
-	print "object error\n";
-	exit;
-}
-
-
-if( $mail->fetch < 0 )
-{
-	print "can't fetch mail object";
-	exit 0;
-}
-
-if( $mail->addbox("soda" , "prout") < 0 )
-{
-	print "can't add this part to the mail object";
-	exit 0;
-}
-
-
-my $retour = $mail->commit;
-
-if( $retour < 0 )
-{
-	print "ERROR while create box, returns $retour \n";
-}
-else
-{
-	print "Successfully create box : $retour \n";
-}
-
-
-use Data::Dumper;
-
+die("Unable to create box $local\@$domain\n") if( $mail->addbox($local, $pass) < 0 );
+print "Box $local\@$domain successfully created\n";

Modified: branches/vhffs_4.1/vhffs-api/src/examples/create_forward.pl
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/examples/create_forward.pl	2007-03-22 07:09:18 UTC (rev 522)
+++ branches/vhffs_4.1/vhffs-api/src/examples/create_forward.pl	2007-03-22 22:06:52 UTC (rev 523)
@@ -5,66 +5,23 @@
 
 use Data::Dumper;
 use lib "/usr/share/vhffs/api/";
-use Vhffs::Conf;
-use Vhffs::User;
-use Vhffs::Group;
 use Vhffs::Main;
-use Vhffs::Object;
 use Vhffs::Services::Mail;
 
-my $config;
-my $mysql_config;
-my $services_config;
-my $user;
-my $dbh;
-my $backend;
-my %infos;
-
 my $princ = init Vhffs::Main;
 
-$config = $princ->get_config;
+die("Usage: $0 mxdomain localpart remote_address\n") unless(@ARGV == 3);
 
+my ($domain, $local, $remote) = @ARGV;
 
-$user = new Vhffs::User( $princ , "soda" , 401) ;
-my $group = new Vhffs::Group( $princ , "soda" , 401) ;
+my $mail = Vhffs::Services::Mail::get_by_mxdomain($princ, $domain);
 
-my $mail = new Vhffs::Services::Mail( $princ , $ARGV[0] , $user , $group);
+die("Mail domain $domain not found\n") unless(defined $mail);
 
-if( defined $mail )
-{
-	print "object created\n";
-}
-else
-{
-	print "object error\n";
-	exit;
-}
 
-
-if( $mail->fetch < 0 )
+if( $mail->addforward($local, $remote) < 0 )
 {
-	print "can't fetch mail object";
-	exit 0;
+    die "Unable to add forward $local\@". $mail->get_domain ." -> $remote\n";
 }
 
-if( $mail->addforward("soda2" , "prout" , "julien\@gunnm.org") < 0 )
-{
-	print "can't add this part to the mail object";
-	exit 0;
-}
-
-
-my $retour = $mail->commit;
-
-if( $retour < 0 )
-{
-	print "ERROR while create box, returns $retour \n";
-}
-else
-{
-	print "Successfully create box : $retour \n";
-}
-
-
-use Data::Dumper;
-
+print "Forward created\n";

Modified: branches/vhffs_4.1/vhffs-api/src/examples/delbox.pl
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/examples/delbox.pl	2007-03-22 07:09:18 UTC (rev 522)
+++ branches/vhffs_4.1/vhffs-api/src/examples/delbox.pl	2007-03-22 22:06:52 UTC (rev 523)
@@ -2,59 +2,24 @@
 
 
 use strict;
-
-use Data::Dumper;
 use lib "/usr/share/vhffs/api/";
+
 use Vhffs::Conf;
-use Vhffs::User;
-use Vhffs::Group;
 use Vhffs::Main;
-use Vhffs::Object;
 use Vhffs::Services::Mail;
 
-my $config;
-my $mysql_config;
-my $services_config;
-my $user;
-my $dbh;
-my $backend;
-my %infos;
-
 my $princ = init Vhffs::Main;
 
-$config = $princ->get_config;
+die("Usage: $0 mail_domain box\n") unless(@ARGV == 2);
 
+my ($domain, $box) = @ARGV;
 
-$user = new Vhffs::User( $princ , "soda" , 401) ;
-my $group = new Vhffs::Group( $princ , "soda" , 401) ;
+my $mail = Vhffs::Services::Mail::get_by_mxdomain($princ , $domain);
 
-my $mail = new Vhffs::Services::Mail( $princ , $ARGV[0] , $user , $group);
+die("Domain $domain not found\n") unless(defined $mail);
 
-if( defined $mail )
-{
-	print "object created\n";
-}
-else
-{
-	print "object error\n";
-	exit;
-}
+die("Unable to delete box $box\@".$mail->get_domain."\n") if( $mail->delbox($box) < 0 );
 
+print "Box $box\@".$mail->get_domain." deleted\n";
 
-if( $mail->fetch < 0 )
-{
-	print "can't fetch mail object";
-	exit 0;
-}
 
-if( $mail->delbox("soda") < 0 )
-{
-	print "can't del this part to the mail object";
-	exit 0;
-}
-else
-{
-	print "sucessfull delete";
-}
-
-

Modified: branches/vhffs_4.1/vhffs-api/src/examples/delete_acl.pl
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/examples/delete_acl.pl	2007-03-22 07:09:18 UTC (rev 522)
+++ branches/vhffs_4.1/vhffs-api/src/examples/delete_acl.pl	2007-03-22 22:06:52 UTC (rev 523)
@@ -13,22 +13,18 @@
 use Vhffs::Services::Httpd;
 use Vhffs::Acl;
 
-my $config;
-my $mysql_config;
-my $services_config;
-my $user;
-my $dbh;
-my $backend;
-my %infos;
-
 my $princ = init Vhffs::Main;
 
-$config = $princ->get_config;
+die("Usage: $0 servername username\n") if(@ARGV != 2);
 
+my ($servername, $username) = @ARGV;
 
-$user = new Vhffs::User( $princ , "sodalol" , 401) ;
+my $user = Vhffs::User::get_by_username($princ, $username);
+die("User $username not found\n") unless(defined $user);
 
-my $httpd = new Vhffs::Services::Httpd( $princ , "proutlol2.com" , $user );
+my $httpd = Vhffs::Services::Httpd::get_by_servername($princ, $servername);
+die("Webarea $servername not found\n") unless(defined $httpd);
 
-Vhffs::Acl::del_acl( $user , $httpd , $princ->get_db_object );
+die("Unable to delete ACL\n") unless(Vhffs::Acl::del_acl( $user , $httpd , $princ) > 0);
+print "User $username has no longer access to webarea $servername\n";
 

Modified: branches/vhffs_4.1/vhffs-api/src/examples/get_list.pl
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/examples/get_list.pl	2007-03-22 07:09:18 UTC (rev 522)
+++ branches/vhffs_4.1/vhffs-api/src/examples/get_list.pl	2007-03-22 22:06:52 UTC (rev 523)
@@ -3,50 +3,22 @@
 
 use strict;
 
-use Data::Dumper;
 use lib "/usr/share/vhffs/api/";
-use Vhffs::Conf;
-use Vhffs::User;
-use Vhffs::Group;
+use Data::Dumper;
 use Vhffs::Main;
-use Vhffs::Object;
-use Vhffs::Services::Mail;
 use Vhffs::Services::Mailing;
 
-my $config;
-my $mysql_config;
-my $services_config;
-my $user;
-my $dbh;
-my $backend;
-my %infos;
-
 my $princ = init Vhffs::Main;
 
-$config = $princ->get_config;
+die("Usage: $0 mladdress\n") unless(@ARGV == 1);
 
+my ($address) = @ARGV;
 
-$user = new Vhffs::User( $princ , "soda" , 401) ;
-my $group = new Vhffs::Group( $princ , "prout" , 401) ;
+my ($local, $domain) = split(/@/, $address);
+die("$address is not a valid email address\n") unless(defined $local && defined $domain);
 
-my $mail = new Vhffs::Services::Mailing( $princ , "bli4" , "prout.com" , $user , $group);
+my $ml = Vhffs::Services::Mailing::get_by_mladdress($princ, $local, $domain);
+die("Mailing list $address not found\n") unless(defined $ml);
 
-if( defined $mail )
-{
-	print "object created\n";
-}
-else
-{
-	print "object error\n";
-	exit;
-}
+print Dumper $ml;
 
-
-if( $mail->fetch < 0 )
-{
-	print "error while fetching\n";
-}
-
-use Data::Dumper;
-print Dumper $mail;
-

Modified: branches/vhffs_4.1/vhffs-api/src/examples/modify_acl.pl
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/examples/modify_acl.pl	2007-03-22 07:09:18 UTC (rev 522)
+++ branches/vhffs_4.1/vhffs-api/src/examples/modify_acl.pl	2007-03-22 22:06:52 UTC (rev 523)
@@ -3,32 +3,23 @@
 
 use strict;
 
-use Data::Dumper;
 use lib "/usr/share/vhffs/api/";
-use Vhffs::Conf;
 use Vhffs::User;
-use Vhffs::Group;
 use Vhffs::Main;
-use Vhffs::Object;
 use Vhffs::Services::Httpd;
 use Vhffs::Acl;
 
-my $config;
-my $mysql_config;
-my $services_config;
-my $user;
-my $dbh;
-my $backend;
-my %infos;
-
 my $princ = init Vhffs::Main;
 
-$config = $princ->get_config;
+die("Usage: $0 servername username newlevel\n") unless(@ARGV == 3);
 
+my ($servername, $username, $level) = @ARGV;
 
-$user = new Vhffs::User( $princ , "sodalol" , 401) ;
+my $user = Vhffs::User::get_by_username($princ, $username);
+die("User $username not found\n") unless(defined $user);
 
-my $httpd = new Vhffs::Services::Httpd( $princ , "proutlol2.com" , $user );
+my $httpd = Vhffs::Services::Httpd::get_by_servername($princ, $servername);
+die("Webarea $servername not found\n") unless(defined $httpd);
 
-Vhffs::Acl::add_acl( $user , $httpd , 2 , $princ->get_db_object );
+Vhffs::Acl::add_acl($user, $httpd , $level, $princ);
 

Modified: branches/vhffs_4.1/vhffs-api/src/examples/perm_for_user.pl
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/examples/perm_for_user.pl	2007-03-22 07:09:18 UTC (rev 522)
+++ branches/vhffs_4.1/vhffs-api/src/examples/perm_for_user.pl	2007-03-22 22:06:52 UTC (rev 523)
@@ -2,7 +2,6 @@
 
 use Data::Dumper;
 use lib "/usr/share/vhffs/api/";
-use Vhffs::Conf;
 use Vhffs::User;
 use Vhffs::Group;
 use Vhffs::Main;
@@ -11,27 +10,18 @@
 use Vhffs::Services::Httpd;
 use Vhffs::Acl;
 
-my $config;
-my $mysql_config;
-my $services_config;
-my $user;
-my $dbh;
-my $backend;
-my %infos;
-
 my $princ = init Vhffs::Main;
 
-$config = $princ->get_config;
+die("Usage: $0 servername username\n") unless(@ARGV == 2);
 
+my ($servername, $username) = @ARGV;
 
+my $user = Vhffs::User::get_by_username($princ, $username);
+die("User $username not found\n") unless(defined $user);
 
-$user = new Vhffs::User( $princ , $ARGV[0] , 401) ;
+my $httpd = Vhffs::Services::Httpd::get_by_servername($princ, $servername);
+die("Webarea $servername not found\n") unless(defined $httpd);
 
-my $sql = new Vhffs::Services::Httpd( $princ , "prout.com", $user );
-
-print "Error while fetching mysql object" if( $sql->fetch < 0 );
-print "Error while fetching user object" if( $user->fetch < 0 );
-
-print "permission";
-print Vhffs::Acl::what_perm_for_user($user , $sql , $princ);
+print "Permission: ";
+print Vhffs::Acl::what_perm_for_user($user, $httpd, $princ);
 print "\n";

Modified: branches/vhffs_4.1/vhffs-api/src/examples/print_domain.pl
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/examples/print_domain.pl	2007-03-22 07:09:18 UTC (rev 522)
+++ branches/vhffs_4.1/vhffs-api/src/examples/print_domain.pl	2007-03-22 22:06:52 UTC (rev 523)
@@ -5,47 +5,17 @@
 
 use Data::Dumper;
 use lib "/usr/share/vhffs/api/";
-use Vhffs::Conf;
-use Vhffs::User;
-use Vhffs::Group;
 use Vhffs::Main;
-use Vhffs::Object;
 use Vhffs::Services::DNS;
 
-my $config;
-my $mysql_config;
-my $services_config;
-my $user;
-my $dbh;
-my $backend;
-my %infos;
-my $group;
-
 my $princ = init Vhffs::Main;
 
-$config = $princ->get_config;
+die("Usage: $0 domainname\n") unless(@ARGV == 1);
 
+my ($domainname) = @ARGV;
 
+my $dns = Vhffs::Services::DNS::get_by_domainname($princ, $domainname);
 
-if( $#ARGV != 0 )
-{
-        print "Error ! Exec this script as it : print_domain domain";
-        print "Example : print_domain prout.com";
-}
+die("Domain name not found\n") unless(defined $dns);
 
-$user = new Vhffs::User( $princ , "sodalol" , 401) ;
-$group = new Vhffs::Group( $princ , "sodalol" , 401) ;
-
-my $dns = new Vhffs::Services::DNS( $princ , $ARGV[0] , $user , $group );
-
-if( ! defined $dns )
-{
-	print "Error while creating the object";
-	exit 0;
-}
-
-$dns->fetch;
-
-use Data::Dumper;
-
 print Dumper $dns;

Modified: branches/vhffs_4.1/vhffs-api/src/examples/show_acl_per_object.pl
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/examples/show_acl_per_object.pl	2007-03-22 07:09:18 UTC (rev 522)
+++ branches/vhffs_4.1/vhffs-api/src/examples/show_acl_per_object.pl	2007-03-22 22:06:52 UTC (rev 523)
@@ -1,41 +1,28 @@
-#!/usr/bin/perl -w -I/vhffs/vhffs-api/src/
+#!/usr/bin/perl  -I/vhffs/vhffs-api/src/
 
 
 use strict;
 
 use Data::Dumper;
 use lib "/usr/share/vhffs/api/";
-use Vhffs::Conf;
-use Vhffs::User;
-use Vhffs::Group;
 use Vhffs::Main;
-use Vhffs::Object;
 use Vhffs::Acl;
-use Vhffs::Services::Httpd;
 use Vhffs::Services::Mysql;
-use Vhffs::Panel::DNS;
 
-my $config;
-my $mysql_config;
-my $services_config;
-my $group;
-my $user;
-my $dbh;
-my $backend;
-my %infos;
-
 my $princ = init Vhffs::Main;
 
+die("Usage: $0 dbname\n\tShows ACL for MySQL service dbname\n") unless(@ARGV == 1);
 
-$user = new Vhffs::User( $princ , "soda" , 401) ;
-$group = new Vhffs::Group( $princ , "sodaproject" , 401) ;
+my ($dbname) = @ARGV;
 
-my $sql = new Vhffs::Services::Mysql( $princ , $ARGV[0] , $user , $group );
+my $sql = Vhffs::Services::Mysql::get_by_dbname($princ, $dbname);
 
-my $lol = Vhffs::Acl::getall_acl_for_user_per_object( $sql , $princ );
+die("MySQL service $dbname not found\n") unless(defined $sql);
 
-print Dumper $lol;
+my $acl = Vhffs::Acl::getall_acl_for_user_per_object( $sql , $princ );
 
-$lol = Vhffs::Acl::getall_acl_for_group_per_object( $sql , $princ );
+print Dumper $acl;
 
-print Dumper $lol;
+$acl = Vhffs::Acl::getall_acl_for_group_per_object( $sql , $princ );
+
+print Dumper $acl;

Modified: branches/vhffs_4.1/vhffs-api/src/examples/show_members_from_list.pl
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/examples/show_members_from_list.pl	2007-03-22 07:09:18 UTC (rev 522)
+++ branches/vhffs_4.1/vhffs-api/src/examples/show_members_from_list.pl	2007-03-22 22:06:52 UTC (rev 523)
@@ -5,57 +5,21 @@
 
 use Data::Dumper;
 use lib "/usr/share/vhffs/api/";
-use Vhffs::Conf;
-use Vhffs::User;
-use Vhffs::Group;
 use Vhffs::Main;
-use Vhffs::Object;
-use Vhffs::Services::Mail;
 use Vhffs::Services::Mailing;
 
-my $config;
-my $mysql_config;
-my $services_config;
-my $user;
-my $dbh;
-my $backend;
-my %infos;
-
 my $princ = init Vhffs::Main;
 
-$config = $princ->get_config;
+die("Usage: $0 mladdress\n") unless(@ARGV == 1);
 
+my ($address) = @ARGV;
 
-$user = new Vhffs::User( $princ , "soda" , 401) ;
-my $group = new Vhffs::Group( $princ , "prout" , 401) ;
+my ($local, $domain) = split(/@/, $address);
+die("$address is not a valid email address\n") unless(defined $local && defined $domain);
 
-my $mail = new Vhffs::Services::Mailing( $princ , "maliste" , "prout.com" , $user , $group);
+my $ml = Vhffs::Services::Mailing::get_by_mladdress($princ, $local, $domain);
+die("Mailing list $address not found\n") unless(defined $ml);
 
-if( defined $mail )
-{
-	print "object created\n";
-}
-else
-{
-	print "object error\n";
-	exit;
-}
+my $subs = $ml->get_members;
 
-my $retour = $mail->fetch;
-
-if( $retour < 0 )
-{
-	print "fetch error";
-}
-else
-{
-	print "fetch success";
-}
-
-my $subs = $mail->get_members;
-
-
-
-use Data::Dumper;
-
 print Dumper $subs;

Modified: branches/vhffs_4.1/vhffs-panel/templates/user/mailuser.tmpl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/templates/user/mailuser.tmpl	2007-03-22 07:09:18 UTC (rev 522)
+++ branches/vhffs_4.1/vhffs-panel/templates/user/mailuser.tmpl	2007-03-22 22:06:52 UTC (rev 523)
@@ -4,9 +4,11 @@
 					</legend>
 					
 					<p>
-						<input name="mail_activate" id="mail_activate" type="checkbox" <tmpl_var name="ACTIV_CHECKED">/> <label for="mail_activate"><tmpl_var name="TEXT_MAILACTIV"></label>
+						<input name="mail_activate" id="mail_activate" type="checkbox"
+                            <tmpl_if name="ACTIV_CHECKED">checked="checked"</tmpl_if>
+                            onchange="javascript:toggle('mail_prefs');"/> <label for="mail_activate"><tmpl_var name="TEXT_MAILACTIV"></label>
 					</p>
-
+                    <div id="mail_prefs"<tmpl_unless name="ACTIV_CHECKED">style="display:none"</tmpl_unless>>
 					<p>
 						<label for="mail_usage">
 							<tmpl_var name="TEXT_MAILINFO2">
@@ -14,18 +16,21 @@
 					</p>
 					
 					<p>
-						<input name="mail_usage" id="mail_usage_box" value="1" type="radio" <tmpl_var name="POP_CHECKED">/>
+						<input name="mail_usage" id="mail_usage_box" value="1" type="radio" <tmpl_if name="POP_CHECKED">checked="checked"</tmpl_if> onchange="javascript:document.getElementById('mbox_options').style.display='';"/>
 						<label for="mail_usage_box" ><tmpl_var name="TEXT_MAILBOX"></label>
 						
 					</p>
-					<p>
+					<div id="mbox_options" <tmpl_unless name="POP_CHECKED">style="display:none"</tmpl_unless>>
 <tmpl_var name="MAILUSER_OPTIONS">
-					</p>
+					</div>
 					<p>
-						<input name="mail_usage" id="mail_usage_foward" value="2" type="radio" <tmpl_var name="FWD_CHECKED">/>
+						<input name="mail_usage" 
+                            id="mail_usage_foward" value="2" 
+                            type="radio" <tmpl_if name="FWD_CHECKED">checked="checked"</tmpl_if>
+                            onchange="javascript:document.getElementById('mbox_options').style.display='none';" />
 						<label for="mail_usage_foward"><tmpl_var name="TEXT_MAILFORWARD"></label>
 					</p>
-					
+					</div>
 				</fieldset>
 
 

Modified: branches/vhffs_4.1/vhffs-panel/templates/user/mailuserspam.tmpl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/templates/user/mailuserspam.tmpl	2007-03-22 07:09:18 UTC (rev 522)
+++ branches/vhffs_4.1/vhffs-panel/templates/user/mailuserspam.tmpl	2007-03-22 22:06:52 UTC (rev 523)
@@ -1,2 +1,2 @@
-<br/>
-<input name="mail_nospam" id="mail_activate" type="checkbox" <tmpl_var name="ACTIV_CHECKED">/><tmpl_var name="TEXT_NOSPAM">
+<p><input name="mail_nospam" id="mail_nospam" type="checkbox" <tmpl_var name="ACTIV_CHECKED">/>
+    <label for="mail_nospam"><tmpl_var name="TEXT_NOSPAM"></label><p>

Modified: branches/vhffs_4.1/vhffs-panel/templates/user/mailuservirus.tmpl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/templates/user/mailuservirus.tmpl	2007-03-22 07:09:18 UTC (rev 522)
+++ branches/vhffs_4.1/vhffs-panel/templates/user/mailuservirus.tmpl	2007-03-22 22:06:52 UTC (rev 523)
@@ -1,2 +1,2 @@
-<br/>
-<input name="mail_novirus" id="mail_activate" type="checkbox" <tmpl_var name="ACTIV_CHECKED">/><tmpl_var name="TEXT_VIRUS">
+<p><input name="mail_novirus" id="mail_novirus" type="checkbox" <tmpl_var name="ACTIV_CHECKED">/>
+    <label for="mail_novirus"><tmpl_var name="TEXT_VIRUS"></label></p>

Modified: branches/vhffs_4.1/vhffs-panel/templates/user/prefs_avatar.tmpl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/templates/user/prefs_avatar.tmpl	2007-03-22 07:09:18 UTC (rev 522)
+++ branches/vhffs_4.1/vhffs-panel/templates/user/prefs_avatar.tmpl	2007-03-22 22:06:52 UTC (rev 523)
@@ -1,10 +1,8 @@
 			<h2><tmpl_var name="TEXT_AVATAR"></h2>
 			<form method="post" action="../object/upavatar.pl" enctype="multipart/form-data">
+				<h3><tmpl_var name="CURRENT_AVATAR"></h3>
+				<img alt="avatar for your user" src="/getavatar.pl?oid=<tmpl_var name="VALUE_OID">"/>
 				<p>
-					<h3><tmpl_var name="CURRENT_AVATAR"></h3>
-					<img alt="avatar for your user" src="/getavatar.pl?oid=<tmpl_var name="VALUE_OID">"/>
-				</p>
-				<p>
 				<tmpl_var name="EXPLAIN_AVATAR">
 				</p>
 		        <input type="hidden" name="OID" value="<tmpl_var name="VALUE_OID">"/>

Modified: branches/vhffs_4.1/vhffs-panel/themes/vhffs/main.css
===================================================================
--- branches/vhffs_4.1/vhffs-panel/themes/vhffs/main.css	2007-03-22 07:09:18 UTC (rev 522)
+++ branches/vhffs_4.1/vhffs-panel/themes/vhffs/main.css	2007-03-22 22:06:52 UTC (rev 523)
@@ -836,3 +836,8 @@
 	padding-right: 5em;
 }
 
+div#mbox_options
+{
+    padding-left:2em;
+}
+

Modified: branches/vhffs_4.1/vhffs-panel/themes/vhffs-ng/main.css
===================================================================
--- branches/vhffs_4.1/vhffs-panel/themes/vhffs-ng/main.css	2007-03-22 07:09:18 UTC (rev 522)
+++ branches/vhffs_4.1/vhffs-panel/themes/vhffs-ng/main.css	2007-03-22 22:06:52 UTC (rev 523)
@@ -306,7 +306,7 @@
 }
 form input[type="checkbox"], form input[type="radio"]
 {
-	width:20px;
+	width:auto;
 
 }
 
@@ -630,3 +630,8 @@
 	padding-right: 5em;
 }
 
+
+div#mbox_options
+{
+    padding-left:2em;
+}

Modified: branches/vhffs_4.1/vhffs-panel/user/prefs.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/user/prefs.pl	2007-03-22 07:09:18 UTC (rev 522)
+++ branches/vhffs_4.1/vhffs-panel/user/prefs.pl	2007-03-22 22:06:52 UTC (rev 523)
@@ -169,9 +169,9 @@
 	if( defined $mu  &&  $mu >= 0  &&  $mu->available > 0 )
 	{
     
-    $subtemplate->param( ACTIV_CHECKED => "checked" ) if( $mu->exists == 1         );
-    $subtemplate->param( POP_CHECKED => "checked" )   if( $mu->exists_box == 1     );
-    $subtemplate->param( FWD_CHECKED => "checked" )   if( $mu->exists_forward == 1 );   
+    $subtemplate->param( ACTIV_CHECKED => 1 ) if( $mu->exists == 1         );
+    $subtemplate->param( POP_CHECKED => 1 )   if( $mu->exists_box == 1     );
+    $subtemplate->param( FWD_CHECKED => 1 )   if( $mu->exists_forward == 1 );   
     $subtemplate->param( TEXT_MAILACTIV => sprintf( gettext("Activate %s\@%s email"), $username, $config->{domain}) );
     $subtemplate->param( TEXT_MAILINFO1 => sprintf( gettext("We offer you the possibility to have one email box on the domain %s") , $config->{domain}) );
     $subtemplate->param( TEXT_MAILINFO2 => gettext("There is two possible usages :") );


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