[vhffs-dev] [526] Updated examples to use new API version

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


Revision: 526
Author:   beuss
Date:     2007-03-24 15:54:41 +0000 (Sat, 24 Mar 2007)

Log Message:
-----------
Updated examples to use new API version

Modified Paths:
--------------
    branches/vhffs_4.1/vhffs-api/src/examples/create_cvs_panel.pl
    branches/vhffs_4.1/vhffs-api/src/examples/create_group_by_panel.pl
    branches/vhffs_4.1/vhffs-api/src/examples/create_mysql_panel.pl
    branches/vhffs_4.1/vhffs-api/src/examples/create_panel_mail.pl
    branches/vhffs_4.1/vhffs-api/src/examples/create_web.pl
    branches/vhffs_4.1/vhffs-api/src/examples/create_web_panel.pl
    branches/vhffs_4.1/vhffs-api/src/examples/generate_password.pl
    branches/vhffs_4.1/vhffs-api/src/examples/join_group.pl
    branches/vhffs_4.1/vhffs-api/src/examples/mailuser.pl
    branches/vhffs_4.1/vhffs-api/src/examples/mailuser_add_box.pl
    branches/vhffs_4.1/vhffs-api/src/examples/modify_user.pl
    branches/vhffs_4.1/vhffs-api/src/examples/show_dns_per_group.pl
    branches/vhffs_4.1/vhffs-api/src/examples/show_dns_per_user.pl
    branches/vhffs_4.1/vhffs-api/src/examples/show_dumper_group.pl
    branches/vhffs_4.1/vhffs-api/src/examples/show_dumper_object.pl
    branches/vhffs_4.1/vhffs-api/src/examples/show_dumper_user.pl
    branches/vhffs_4.1/vhffs-api/src/examples/show_groups_per_user.pl
    branches/vhffs_4.1/vhffs-api/src/examples/show_mail_per_group.pl
    branches/vhffs_4.1/vhffs-api/src/examples/stats.pl


Modified: branches/vhffs_4.1/vhffs-api/src/examples/create_cvs_panel.pl
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/examples/create_cvs_panel.pl	2007-03-24 15:52:48 UTC (rev 525)
+++ branches/vhffs_4.1/vhffs-api/src/examples/create_cvs_panel.pl	2007-03-24 15:54:41 UTC (rev 526)
@@ -3,50 +3,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::Panel::Cvs;
 
-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 cvsroot description owner_username owner_groupname\n") unless(@ARGV == 4);
 
-if( $#ARGV != 0 )
-{
-         print "Error ! Exec this script as it : create_cvs cvsroot";
-         print "Example : create_cvs moncvs";
-		 exit( 0 );
-}
+my ($cvsroot, $description, $username, $groupname) = @ARGV;
 
+my $user = Vhffs::User::get_by_username($princ, $username);
+die("User not found\n") unless(defined $user);
+my $group = Vhffs::Group::get_by_groupname($princ, $groupname);
+die("Group not found\n") unless(defined $group);
 
-$user = new Vhffs::User( $princ , "soda" , 401) ;
-$group = new Vhffs::Group( $princ , "soda" , 401) ;
+my $cvs = Vhffs::Panel::Cvs::create_cvs( $princ, $cvsroot, $description, $user, $group );
 
-
-my $cvs = Vhffs::Panel::Cvs::create_cvs( $princ , "$ARGV[0]" , $user , $group );
-
-
-if( $cvs > 0)
-{
-	print "Successfully create cvs object in the database\n";
-}
-else
-{
-	print "ERROR while create cvs object in the database\n";
-	exit( 0 );
-}
-
+die("Unable to create cvs $cvsroot\n") unless(defined $cvs);
+print "CVS $cvsroot created\n";

Modified: branches/vhffs_4.1/vhffs-api/src/examples/create_group_by_panel.pl
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/examples/create_group_by_panel.pl	2007-03-24 15:52:48 UTC (rev 525)
+++ branches/vhffs_4.1/vhffs-api/src/examples/create_group_by_panel.pl	2007-03-24 15:54:41 UTC (rev 526)
@@ -4,49 +4,22 @@
 use strict;
 
 use lib "/usr/share/vhffs/api/";
-use Vhffs::Conf;
 use Vhffs::User;
-use Vhffs::Group;
 use Vhffs::Main;
-use Vhffs::Object;
 use Vhffs::Panel::Group;
 
-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 groupname owner_username decription\n") unless(@ARGV == 3);
 
-if( $#ARGV != 0 )
-{
-	print "Error ! Create a new group with : create_group groupname";
-	print "Example : create_group soda";
-}
+my ($groupname, $username, $description) = @ARGV;
 
+my $user = Vhffs::User::get_by_username($princ, $username);
+die("User $username not found\n") unless(defined $user);
 
-print "Creation du group $ARGV[0]\n";
-$user = new Vhffs::User( $princ , "sodalol" , 401) ;
 
-
 #add this group in database
-my $retour = Vhffs::Panel::Group::create_group( $ARGV[0] , $user , $princ );
-if( $retour lt 0 )
-{
-	print "Impossible de creer ce groupe\n";
-	exit 0;
-}
-else
-{
+my $group = Vhffs::Panel::Group::create_group( $groupname, $user , $princ, $description );
+die("Unable to create group $groupname\n") unless(defined $group);
 
-	print "Groupe cree !\n";
-}
-
-
-
-exit;
+print("Group $groupname created\n");

Modified: branches/vhffs_4.1/vhffs-api/src/examples/create_mysql_panel.pl
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/examples/create_mysql_panel.pl	2007-03-24 15:52:48 UTC (rev 525)
+++ branches/vhffs_4.1/vhffs-api/src/examples/create_mysql_panel.pl	2007-03-24 15:54:41 UTC (rev 526)
@@ -3,47 +3,25 @@
 
 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::Mysql;
 use Vhffs::Panel::Mysql;
 
-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;
 
-if( $#ARGV != 2 )
-{
-         print "Error ! Exec this script as it : create_mysql base user pass";
-         print "Example : create_mysql soda prout";
-}
+die("Usage: $0 dbname dbuser dbpass description owner_username owner_groupname\n") unless(@ARGV == 6);
 
+my ($dbname, $dbuser, $dbpass, $description, $username, $groupname) = @ARGV;
 
-$user = new Vhffs::User( $princ , "soda" , 401) ;
-my $group = new Vhffs::Group( $princ , "soda" , 401) ;
+my $user = Vhffs::User::get_by_username($princ, $username);
+die("User not found\n") unless(defined $user);
+my $group = Vhffs::Group::get_by_groupname($princ, $groupname);
+die("Group not found\n") unless(defined $group);
 
+my $mysql = Vhffs::Panel::Mysql::create_mysql( $princ, $dbname, $user, $group, $dbuser, $dbpass, $description );
 
-my $sql = Vhffs::Panel::Mysql::create_mysql( $princ , "$ARGV[0]" , $user,$group,$ARGV[1],$ARGV[2]);
-
-if( defined $sql )
-{
-	print "object created\n";
-}
-else
-{
-	print "object error\n";
-	exit;
-}
+die("Unable to create mysql service $dbname\n") unless(defined $mysql);
+print("MySQL service created\n");

Modified: branches/vhffs_4.1/vhffs-api/src/examples/create_panel_mail.pl
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/examples/create_panel_mail.pl	2007-03-24 15:52:48 UTC (rev 525)
+++ branches/vhffs_4.1/vhffs-api/src/examples/create_panel_mail.pl	2007-03-24 15:54:41 UTC (rev 526)
@@ -5,44 +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;
 use Vhffs::Panel::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 domain description owner_username owner_groupname\n") unless(@ARGV == 4);
 
+my ($domain, $description, $username, $groupname) = @ARGV;
 
-$user = new Vhffs::User( $princ , "soda" , 401) ;
-my $group = new Vhffs::Group( $princ , "soda" , 401) ;
+my $user = Vhffs::User::get_by_username($princ, $username);
+die("User not found\n") unless(defined $user);
+my $group = Vhffs::Group::get_by_groupname($princ, $groupname);
+die("Group not found\n") unless(defined $group);
 
-my $mail = Vhffs::Panel::Mail::create_mail( $princ , $ARGV[0] , $user , $group);
+my $mail = Vhffs::Panel::Mail::create_mail( $princ, $domain, $description, $user, $group);
 
-if( defined $mail )
-{
-	print "object created\n";
-}
-else
-{
-	print "object error\n";
-	exit;
-}
-
-
-use Data::Dumper;
-
-print $mail;
-
+die("Unable to create mail domain $domain\n") unless(defined $mail);
+print("Mail domain $domain created\n");

Modified: branches/vhffs_4.1/vhffs-api/src/examples/create_web.pl
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/examples/create_web.pl	2007-03-24 15:52:48 UTC (rev 525)
+++ branches/vhffs_4.1/vhffs-api/src/examples/create_web.pl	2007-03-24 15:54:41 UTC (rev 526)
@@ -16,7 +16,7 @@
 
 die("Usage: $0 servername description owner_username owner_groupname\n") unless(@ARGV == 4);
 
-my($servername, $description, $username, $groupname) = @_;
+my($servername, $description, $username, $groupname) = @ARGV;
 
 my $user = Vhffs::User::get_by_username($princ, $username);
 die("User not found\n") unless(defined $user);

Modified: branches/vhffs_4.1/vhffs-api/src/examples/create_web_panel.pl
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/examples/create_web_panel.pl	2007-03-24 15:52:48 UTC (rev 525)
+++ branches/vhffs_4.1/vhffs-api/src/examples/create_web_panel.pl	2007-03-24 15:54:41 UTC (rev 526)
@@ -3,44 +3,22 @@
 
 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::Panel::Web;
 
-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 description owner_username owner_groupname\n") unless(@ARGV == 4);
 
+my ($servername, $description, $username, $groupname) = @ARGV;
 
-$user = new Vhffs::User( $princ , "soda" , 401) ;
-my $group = new Vhffs::Group( $princ , "soda" , 401) ;
+my $user = Vhffs::User::get_by_username($princ, $username);
+die("User not found\n") unless(defined $user);
+my $group = Vhffs::Group::get_by_groupname($princ, $groupname);
+die("Group not found\n") unless(defined $group);
 
-my $retour = Vhffs::Panel::Web::create_web( $princ , $ARGV[0] , $user , $group);
-
-
-if( (!defined $retour ) || ( $retour < 0 ) )
-{
-	print "ERROR while create httpd object in the database, returns $retour \n";
-}
-else
-{
-	print "Successfully create httpd object in the database\n";
-}
-
-
-use Data::Dumper;
-
+die("Unable to create webarea $servername\n") unless(defined Vhffs::Panel::Web::create_web($princ, $servername, $description, $user, $group));
+print("Webarea $servername created\n");

Modified: branches/vhffs_4.1/vhffs-api/src/examples/generate_password.pl
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/examples/generate_password.pl	2007-03-24 15:52:48 UTC (rev 525)
+++ branches/vhffs_4.1/vhffs-api/src/examples/generate_password.pl	2007-03-24 15:54:41 UTC (rev 526)
@@ -4,43 +4,17 @@
 use strict;
 
 use lib "/usr/share/vhffs/api/";
-use Vhffs::Conf;
 use Vhffs::User;
-use Vhffs::Group;
 use Vhffs::Main;
-use Vhffs::Object;
 
-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 username\n") unless(@ARGV == 1);
 
-if( $#ARGV != 0 )
-{
-	print "Error ! Change the password with  : generate_password username";
-	print "Example : generate_password soda";
-}
+my ($username) = @ARGV;
 
+my $user = Vhffs::User::get_by_username($princ, $username);
+die("User $username not found\n") unless(defined $user);
 
-print "changement du pass pour le user  $ARGV[0]\n";
-$user = new Vhffs::User( $princ , "$ARGV[0]" , 401) ;
-
-
-#on fetche l'utilisateur
-my $retour;
-$retour = $user->fetch;
-if ( $retour > 0  )
-{
-
-	$user->generate_password;
-	exit 0;
-}
-
-exit;
+my $pwd = $user->generate_password;
+print "New password for $username : $pwd\n";

Modified: branches/vhffs_4.1/vhffs-api/src/examples/join_group.pl
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/examples/join_group.pl	2007-03-24 15:52:48 UTC (rev 525)
+++ branches/vhffs_4.1/vhffs-api/src/examples/join_group.pl	2007-03-24 15:54:41 UTC (rev 526)
@@ -4,46 +4,19 @@
 use strict;
 
 use lib "/usr/share/vhffs/api/";
-use Vhffs::Conf;
 use Vhffs::User;
 use Vhffs::Group;
 use Vhffs::Main;
-use Vhffs::Object;
-use Vhffs::Panel::Group;
 
-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 username groupname\n") unless(@ARGV == 2);
 
-if( $#ARGV != 0 )
-{
-	print "Error !  Join a group with  : join_group groupname";
-	print "Example : join_group group";
-}
+my ($username, $groupname) = @ARGV;
 
+my $user = Vhffs::User::get_by_username($princ, $username);
+die("User not found\n") unless(defined $user);
+my $group = Vhffs::Group::get_by_groupname($princ, $groupname);
+die("Group not found\n") unless(defined $group);
 
-$user = new Vhffs::User( $princ , "sodalol" , 401) ;
-
-my $group = Vhffs::Panel::Group::create_group( $ARGV[0] , $user , $princ );
-
-if( ! defined $group)
-{
-	print "can't add to this group";
-}
-else
-{
-	$group->set_description( "blablabla" );
-	$group->commit;
-	print "Sucessfully add to this group";
-}
-
-
-exit;
+die("Unable to add $username to group $groupname\n") unless($group->add_user($user) > 0);

Modified: branches/vhffs_4.1/vhffs-api/src/examples/mailuser.pl
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/examples/mailuser.pl	2007-03-24 15:52:48 UTC (rev 525)
+++ branches/vhffs_4.1/vhffs-api/src/examples/mailuser.pl	2007-03-24 15:54:41 UTC (rev 526)
@@ -14,39 +14,27 @@
 use Vhffs::Services::MailUser;
 use Vhffs::Panel::Mail;
 
-my $config;
-my $mysql_config;
-my $services_config;
-my $group;
-my $dbh;
-my $backend;
-my %infos;
-
 my $princ = init Vhffs::Main;
 
-$config = $princ->get_config;
+die("Usage: $0 username\n") unless(@ARGV == 1);
 
-my $user = new Vhffs::User( $princ , "gradator" , '401' );
+my ($username) = @ARGV;
+
+my $user = Vhffs::User::get_by_username($princ, $username);
+die("User not found\n") unless(defined $user);
+
 my $mu = init Vhffs::Services::MailUser( $princ , $user );
+die("Configuration error\n") if(!ref($mu));
 
-if( $mu->exists_forward == 1 )
-{
-	print "Cet utilisateur a un forward sur le domaine\n";
+if( $mu->exists_forward == 1 ) {
+	print "User has a forward on this domain\n";
+} else {
+	print "User doesn't have forward\n";
 }
-else
-{
-	print "Cet utilisateur n'a aucun forward\n";
-}
 
-if( $mu->exists_box == 1 )
-{
-	print "Cet utilisateur a une box\n";
+if( $mu->exists_box == 1 ) {
+	print "User has a box\n";
+} else {
+	print "User doesn't have a box\n";
 }
-else
-{
-	print "Cet utilisateur n'a pas de box\n";
-}
 
-
-
-#print Dumper $mu->{object};

Modified: branches/vhffs_4.1/vhffs-api/src/examples/mailuser_add_box.pl
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/examples/mailuser_add_box.pl	2007-03-24 15:52:48 UTC (rev 525)
+++ branches/vhffs_4.1/vhffs-api/src/examples/mailuser_add_box.pl	2007-03-24 15:54:41 UTC (rev 526)
@@ -14,29 +14,16 @@
 use Vhffs::Services::MailUser;
 use Vhffs::Panel::Mail;
 
-my $config;
-my $mysql_config;
-my $services_config;
-my $group;
-my $dbh;
-my $backend;
-my %infos;
-
 my $princ = init Vhffs::Main;
 
-$config = $princ->get_config;
+die("Usage: $0 username password\n") unless(@ARGV == 2);
 
-my $user = new Vhffs::User( $princ , "gradator" , '401' );
-my $mu = init Vhffs::Services::MailUser( $princ , $user );
+my ($username, $password) = @ARGV;
 
-if( ( my $retour = $mu->addforward( "soda\@free.fr" ) ) < 0 )
-{
-	print "erreur $retour";
-}
-else
-{
-	print "success\n";
-}
+my $user = Vhffs::User::get_by_username($princ, $username);
+die("User not found\n") unless(defined $user);
 
+my $mu = init Vhffs::Services::MailUser( $princ , $user );
 
-#print Dumper $mu;
+die("Unable to create box $username\@".$mu->{domain}."\n") unless($mu->addbox( $password ) > 0);
+print "Box $username\@".$mu->{domain}." created\n";

Modified: branches/vhffs_4.1/vhffs-api/src/examples/modify_user.pl
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/examples/modify_user.pl	2007-03-24 15:52:48 UTC (rev 525)
+++ branches/vhffs_4.1/vhffs-api/src/examples/modify_user.pl	2007-03-24 15:54:41 UTC (rev 526)
@@ -6,44 +6,18 @@
 use lib "/usr/share/vhffs/api/";
 use Vhffs::Conf;
 use Vhffs::User;
-use Vhffs::Group;
 use Vhffs::Main;
-use Vhffs::Object;
 
-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 username new_firstname\n") unless(@ARGV == 2);
 
+my ($username, $firstname) = @ARGV;
 
-$user = new Vhffs::User( $princ , "sod" , 401) ;
+my $user = Vhffs::User::get_by_username($princ, $username);
+die("User not found\n") unless(defined $user);
 
+$user->set_firstname($firstname);
+die("Unable to change firstname for user $username\n") unless($user->commit > 0);
+print("User updated\n");
 
-#on fetche l'utilisateur
-my $retour;
-$retour = $user->fetch;
-if ( $retour > 0  )
-{
-	print "Cet utilisateur existe bien\n";
-}
-
-
-#on le cree dans la base
-$user->set_firstname("prout");
-
-if( $user->commit < 0 )
-{
-	print "unchanged";
-}
-else
-{
-	print "unchanged";
-}
-

Modified: branches/vhffs_4.1/vhffs-api/src/examples/show_dns_per_group.pl
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/examples/show_dns_per_group.pl	2007-03-24 15:52:48 UTC (rev 525)
+++ branches/vhffs_4.1/vhffs-api/src/examples/show_dns_per_group.pl	2007-03-24 15:54:41 UTC (rev 526)
@@ -5,33 +5,18 @@
 
 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::Panel::DNS;
 
-my $config;
-my $mysql_config;
-my $services_config;
-my $group;
-my $dbh;
-my $backend;
-my %infos;
-
 my $princ = init Vhffs::Main;
 
-$config = $princ->get_config;
+die("Usage: $0 groupname\n") unless(@ARGV == 1);
 
+my ($groupname) = @ARGV;
 
-$group = new Vhffs::Group( $princ , "sodaproject" , 401) ;
+my $group = Vhffs::Group::get_by_groupname($princ, $groupname);
+die("Group $groupname not found\n") unless(defined $group);
 
-my $lol = Vhffs::Panel::DNS::getall_dns_per_group( $group , $princ );
+print Dumper(Vhffs::Panel::DNS::getall_dns_per_group( $group , $princ ));
 
-foreach( keys ( %{$lol} ) )
-{
-	print $_ ."etat :". $lol->{$_}{'state'};
-}

Modified: branches/vhffs_4.1/vhffs-api/src/examples/show_dns_per_user.pl
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/examples/show_dns_per_user.pl	2007-03-24 15:52:48 UTC (rev 525)
+++ branches/vhffs_4.1/vhffs-api/src/examples/show_dns_per_user.pl	2007-03-24 15:54:41 UTC (rev 526)
@@ -5,28 +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::Httpd;
-use Vhffs::Acl;
 use Vhffs::Panel::DNS;
 
-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 username\n") unless(@ARGV == 1);
 
+my ($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);
 
-print Dumper Vhffs::Panel::DNS::getall_dns_per_user( $user , $princ );
+print Dumper( Vhffs::Panel::DNS::getall_dns_per_user( $user , $princ ));

Modified: branches/vhffs_4.1/vhffs-api/src/examples/show_dumper_group.pl
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/examples/show_dumper_group.pl	2007-03-24 15:52:48 UTC (rev 525)
+++ branches/vhffs_4.1/vhffs-api/src/examples/show_dumper_group.pl	2007-03-24 15:54:41 UTC (rev 526)
@@ -5,33 +5,16 @@
 
 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::Panel::Group;
 
-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 groupname\n") unless(@ARGV == 1);
 
+my ($groupname) = @ARGV;
 
-my $group = new Vhffs::Group( $princ , $ARGV[0] , 401) ;
+my $group = Vhffs::Group::get_by_groupname($princ, $groupname);
+die("Group $groupname not found\n") unless(defined $group);
 
-$group->Vhffs::Group::fetch;
-
-print Dumper $group;
-
-print $group->get_description;
-
+print Dumper($group);

Modified: branches/vhffs_4.1/vhffs-api/src/examples/show_dumper_object.pl
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/examples/show_dumper_object.pl	2007-03-24 15:52:48 UTC (rev 525)
+++ branches/vhffs_4.1/vhffs-api/src/examples/show_dumper_object.pl	2007-03-24 15:54:41 UTC (rev 526)
@@ -14,24 +14,13 @@
 use Vhffs::Services::Httpd;
 use Vhffs::Panel::Group;
 
-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 objectID\n") unless(@ARGV == 1);
 
+my ($oid) = @ARGV;
 
-my $obj = new Vhffs::Object( $princ , $ARGV[0] , 401) ;
+my $obj = Vhffs::Object::get_by_oid($princ, $oid);
+die("Object #$oid not found\n") unless(defined $obj);
 
-$obj->fetch;
-
 print Dumper $obj;
-
-print $obj->get_description;
-

Modified: branches/vhffs_4.1/vhffs-api/src/examples/show_dumper_user.pl
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/examples/show_dumper_user.pl	2007-03-24 15:52:48 UTC (rev 525)
+++ branches/vhffs_4.1/vhffs-api/src/examples/show_dumper_user.pl	2007-03-24 15:54:41 UTC (rev 526)
@@ -5,33 +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::Acl;
-use Vhffs::Services::Httpd;
-use Vhffs::Panel::Group;
 
-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 username\n") unless(@ARGV == 1);
 
+my ($username) = @ARGV;
 
-$user = new Vhffs::User( $princ , $ARGV[0] , 401) ;
+my $user = Vhffs::User::get_by_username( $princ, $username );
+die("User $username not found\n") unless(defined $user);
 
-$user->fetch;
-
 print Dumper $user;
 
-print $user->get_description;
-

Modified: branches/vhffs_4.1/vhffs-api/src/examples/show_groups_per_user.pl
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/examples/show_groups_per_user.pl	2007-03-24 15:52:48 UTC (rev 525)
+++ branches/vhffs_4.1/vhffs-api/src/examples/show_groups_per_user.pl	2007-03-24 15:54:41 UTC (rev 526)
@@ -5,33 +5,20 @@
 
 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::Panel::Group;
 
-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 username\n") unless(@ARGV == 1);
 
+my ($username) = @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 $lol = Vhffs::Panel::Group::getall_groups_per_user( $user , $princ );
+my $groups = Vhffs::Panel::Group::getall_groups_per_user( $user , $princ );
 
-foreach( keys ( %{$lol} ) )
-{
-	print $_;
-}
+print Dumper($groups);
+

Modified: branches/vhffs_4.1/vhffs-api/src/examples/show_mail_per_group.pl
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/examples/show_mail_per_group.pl	2007-03-24 15:52:48 UTC (rev 525)
+++ branches/vhffs_4.1/vhffs-api/src/examples/show_mail_per_group.pl	2007-03-24 15:54:41 UTC (rev 526)
@@ -5,31 +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::Acl;
-use Vhffs::Services::Httpd;
 use Vhffs::Panel::Mail;
 
-my $config;
-my $mysql_config;
-my $services_config;
-my $group;
-my $dbh;
-my $backend;
-my %infos;
-
 my $princ = init Vhffs::Main;
 
-$config = $princ->get_config;
+die("Usage: $0 groupname\n") unless(@ARGV == 1);
 
+my ($groupname) = @ARGV;
 
-$group = new Vhffs::Group( $princ , "sodaproject" , 401) ;
+my $group = Vhffs::Group::get_by_groupname($princ, $groupname);
+die("Group $groupname not found\n") unless(defined $group);
 
-my $lol = Vhffs::Panel::Mail::getall_mail_per_group( $group , $princ );
-
-
-print Dumper $lol;
+print Dumper(Vhffs::Panel::Mail::getall_mail_per_group( $group , $princ ));

Modified: branches/vhffs_4.1/vhffs-api/src/examples/stats.pl
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/examples/stats.pl	2007-03-24 15:52:48 UTC (rev 525)
+++ branches/vhffs_4.1/vhffs-api/src/examples/stats.pl	2007-03-24 15:54:41 UTC (rev 526)
@@ -7,9 +7,6 @@
 my $vhffs = init Vhffs::Main;
 my $stats = new Vhffs::Stats( $vhffs );
 
-
-$stats->fetch;
-
 print "Users total : ";
 print $stats->get_user_total;
 print "\n";


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