[vhffs-dev] [2090] renamed get_main to get_vhffs, renamed all meaningless $main variable to $vhffs

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


Revision: 2090
Author:   gradator
Date:     2012-03-02 20:58:58 +0100 (Fri, 02 Mar 2012)
Log Message:
-----------
renamed get_main to get_vhffs, renamed all meaningless $main variable to $vhffs

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Group.pm
    trunk/vhffs-api/src/Vhffs/Object.pm
    trunk/vhffs-api/src/Vhffs/Panel/Bazaar.pm
    trunk/vhffs-api/src/Vhffs/Panel/Broadcast.pm
    trunk/vhffs-api/src/Vhffs/Panel/Commons.pm
    trunk/vhffs-api/src/Vhffs/Panel/Cron.pm
    trunk/vhffs-api/src/Vhffs/Panel/Cvs.pm
    trunk/vhffs-api/src/Vhffs/Panel/DNS.pm
    trunk/vhffs-api/src/Vhffs/Panel/Git.pm
    trunk/vhffs-api/src/Vhffs/Panel/Group.pm
    trunk/vhffs-api/src/Vhffs/Panel/Mail.pm
    trunk/vhffs-api/src/Vhffs/Panel/MailingList.pm
    trunk/vhffs-api/src/Vhffs/Panel/Mercurial.pm
    trunk/vhffs-api/src/Vhffs/Panel/Mysql.pm
    trunk/vhffs-api/src/Vhffs/Panel/Object.pm
    trunk/vhffs-api/src/Vhffs/Panel/Pgsql.pm
    trunk/vhffs-api/src/Vhffs/Panel/Repository.pm
    trunk/vhffs-api/src/Vhffs/Panel/Svn.pm
    trunk/vhffs-api/src/Vhffs/Panel/Tag.pm
    trunk/vhffs-api/src/Vhffs/Panel/User.pm
    trunk/vhffs-api/src/Vhffs/Panel/Web.pm
    trunk/vhffs-api/src/Vhffs/Robots/Bazaar.pm
    trunk/vhffs-api/src/Vhffs/Robots/Cron.pm
    trunk/vhffs-api/src/Vhffs/Robots/Cvs.pm
    trunk/vhffs-api/src/Vhffs/Robots/DNS.pm
    trunk/vhffs-api/src/Vhffs/Robots/Git.pm
    trunk/vhffs-api/src/Vhffs/Robots/Group.pm
    trunk/vhffs-api/src/Vhffs/Robots/Mail.pm
    trunk/vhffs-api/src/Vhffs/Robots/MailingList.pm
    trunk/vhffs-api/src/Vhffs/Robots/Mercurial.pm
    trunk/vhffs-api/src/Vhffs/Robots/Mysql.pm
    trunk/vhffs-api/src/Vhffs/Robots/Pgsql.pm
    trunk/vhffs-api/src/Vhffs/Robots/Repository.pm
    trunk/vhffs-api/src/Vhffs/Robots/Svn.pm
    trunk/vhffs-api/src/Vhffs/Robots/User.pm
    trunk/vhffs-api/src/Vhffs/Robots/Web.pm
    trunk/vhffs-api/src/Vhffs/Robots.pm
    trunk/vhffs-api/src/Vhffs/Services/Bazaar.pm
    trunk/vhffs-api/src/Vhffs/Services/Cron.pm
    trunk/vhffs-api/src/Vhffs/Services/Cvs.pm
    trunk/vhffs-api/src/Vhffs/Services/DNS.pm
    trunk/vhffs-api/src/Vhffs/Services/Git.pm
    trunk/vhffs-api/src/Vhffs/Services/Mail.pm
    trunk/vhffs-api/src/Vhffs/Services/MailGroup.pm
    trunk/vhffs-api/src/Vhffs/Services/MailUser.pm
    trunk/vhffs-api/src/Vhffs/Services/MailingList.pm
    trunk/vhffs-api/src/Vhffs/Services/Mercurial.pm
    trunk/vhffs-api/src/Vhffs/Services/Mysql.pm
    trunk/vhffs-api/src/Vhffs/Services/Newsletter.pm
    trunk/vhffs-api/src/Vhffs/Services/Pgsql.pm
    trunk/vhffs-api/src/Vhffs/Services/Repository.pm
    trunk/vhffs-api/src/Vhffs/Services/Svn.pm
    trunk/vhffs-api/src/Vhffs/Services/Web.pm
    trunk/vhffs-api/src/Vhffs/Stats.pm
    trunk/vhffs-api/src/Vhffs/Tag/Category.pm
    trunk/vhffs-api/src/Vhffs/Tag/Request.pm
    trunk/vhffs-api/src/Vhffs/Tag.pm
    trunk/vhffs-api/src/Vhffs/User.pm
    trunk/vhffs-api/src/Vhffs/UserGroup.pm
    trunk/vhffs-tools/src/vhffs-webdir

Modified: trunk/vhffs-api/src/Vhffs/Group.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Group.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Group.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -86,8 +86,8 @@
 =cut
 sub _new {
 	no strict 'refs';
-	my ($class, $main, $gid, $oid, $owner_uid, $groupname, $realname, $passwd, $quota, $quota_used, $date_creation, $description, $state) = @_;
-	my $self = $class->SUPER::_new($main, $oid, $owner_uid, $gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_GROUP);
+	my ($class, $vhffs, $gid, $oid, $owner_uid, $groupname, $realname, $passwd, $quota, $quota_used, $date_creation, $description, $state) = @_;
+	my $self = $class->SUPER::_new($vhffs, $oid, $owner_uid, $gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_GROUP);
 	return undef unless defined $self;
 
 	$self->{gid} = $gid;
@@ -104,17 +104,17 @@
 
 =head2 create
 
-	my $group = Vhffs::Group::create($main, $groupname, $realname, $owner_uid, $gid, $description)
+	my $group = Vhffs::Group::create($vhffs, $groupname, $realname, $owner_uid, $gid, $description)
 
 Create in DB and return a fully functional group.
 
 =cut
 sub create {
-	my ($main, $groupname, $realname, $owner_uid, $gid, $description) = @_;
+	my ($vhffs, $groupname, $realname, $owner_uid, $gid, $description) = @_;
 	return undef unless check_groupname($groupname);
 	return undef unless defined($owner_uid);
 
-	my $groupconf = $main->get_config->get_groups;
+	my $groupconf = $vhffs->get_config->get_groups;
 	my $group;
 
 	open(my $badgroups, '<', $groupconf->{'bad_groupname_file'} );
@@ -131,7 +131,7 @@
 
 	$realname = $groupname unless defined $realname;
 
-	my $dbh = $main->get_db;
+	my $dbh = $vhffs->get_db;
 	local $dbh->{RaiseError} = 1;
 	local $dbh->{PrintError} = 0;
 
@@ -154,7 +154,7 @@
 		# to avoid updates (cf Vhffs::User::create)
 		($gid) = $dbh->selectrow_array('SELECT nextval(\'vhffs_groups_gid_seq\')') unless defined $gid;
 
-		my $parent = Vhffs::Object::create($main, $owner_uid, $gid, $description, undef, Vhffs::Constants::TYPE_GROUP);
+		my $parent = Vhffs::Object::create($vhffs, $owner_uid, $gid, $description, undef, Vhffs::Constants::TYPE_GROUP);
 		die('Unable to create parent object') unless(defined $parent);
 
 		my $quota = $groupconf->{default_quota} || 10;
@@ -164,7 +164,7 @@
 		$sth->execute($gid, $groupname, $realname, $quota, $parent->get_oid);
 
 		$dbh->commit if($transaction_started);
-		$group = get_by_gid($main, $gid);
+		$group = get_by_gid($vhffs, $gid);
 	};
 
 	if($transaction_started && $@) {
@@ -193,7 +193,7 @@
 
 =head2 getall
 
-	my @groups = Vhffs::User::getall( $main, $state, $name );
+	my @groups = Vhffs::User::getall( $vhffs, $state, $name );
 
 Returns an array of groups which matched $state and $name.
 
@@ -231,7 +231,7 @@
 
 =head2 getall_by_letter
 
-	my @groups = Vhffs::User::getall_by_letter( $main, $letter, $state );
+	my @groups = Vhffs::User::getall_by_letter( $vhffs, $letter, $state );
 
 Returns an array of all groups which starts by letter $letter and are having state $state.
 
@@ -267,7 +267,7 @@
 
 =head2 getall_quotalimit
 
-	my @groups = Vhffs::User::getall_quotalimit( $main, $limit );
+	my @groups = Vhffs::User::getall_quotalimit( $vhffs, $limit );
 
 Returns an array of groups which are using more than 90% of the disk quota applied
 
@@ -296,7 +296,7 @@
 
 =head2 get_by_gid
 
-	my $group = Vhffs::Group::get_by_gid($main, $gid);
+	my $group = Vhffs::Group::get_by_gid($vhffs, $gid);
 	die('Group not found') unless(defined $group);
 
 Fetches the group whose gid is $gid.
@@ -317,7 +317,7 @@
 
 =head2 get_by_groupname
 
-	my $group = Vhffs::Group::get_by_groupname($main, $groupname);
+	my $group = Vhffs::Group::get_by_groupname($vhffs, $groupname);
 	die('Group not found') unless(defined $group);
 
 Fetches the group whose name is $groupname.
@@ -426,7 +426,7 @@
 	my $self = shift;
 
 	require Vhffs::Services::MailGroup;
-	my $mg = new Vhffs::Services::MailGroup( $self->{'main'} , $self );
+	my $mg = new Vhffs::Services::MailGroup( $self->get_vhffs, $self );
 	if( defined $mg ) {
 		$mg->delbox;
 		$mg->delforward;
@@ -556,7 +556,7 @@
 =cut
 sub get_dir {
 	my $self = shift;
-	return $self->{'main'}->get_config->get_datadir.'/groups/'.substr($self->get_groupname, 0, 1).'/'.substr($self->get_groupname, 1, 1).'/'.$self->get_groupname;
+	return $self->get_vhffs->get_config->get_datadir.'/groups/'.substr($self->get_groupname, 0, 1).'/'.substr($self->get_groupname, 1, 1).'/'.$self->get_groupname;
 }
 
 =pod
@@ -576,7 +576,7 @@
 	my $request = $self->get_db->prepare( $query );
 	$request->execute($gid);
 	while( my ($uid) = $request->fetchrow_array ) {
-		my $user = Vhffs::User::get_by_uid( $self->{'main'} , $uid );
+		my $user = Vhffs::User::get_by_uid( $self->get_vhffs, $uid );
 		push( @users , $user ) if( defined $user );
 	}
 	return \@users;
@@ -619,7 +619,7 @@
 	my $rows = $request->fetchall_arrayref();
 
 	foreach (@$rows) {
-		push @objects , Vhffs::Object::get_by_oid( $self->get_main, @$_ );
+		push @objects , Vhffs::Object::get_by_oid( $self->get_vhffs, @$_ );
 	}
 	return \@objects;
 }

Modified: trunk/vhffs-api/src/Vhffs/Object.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Object.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Object.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -71,15 +71,15 @@
 
 =cut
 sub _new {
-	my ($class, $main, $oid, $owner_uid, $owner_gid, $date_creation, $description, $refuse_reason, $state, $type) = @_;
+	my ($class, $vhffs, $oid, $owner_uid, $owner_gid, $date_creation, $description, $refuse_reason, $state, $type) = @_;
 
 	my $self = {};
 
 	bless($self, $class);
 
-	return undef unless(defined $main);
+	return undef unless(defined $vhffs);
 
-	$self->{main} = $main;
+	$self->{vhffs} = $vhffs;
 	$self->{object_id} = $oid;
 	$self->{owner_uid} = $owner_uid;
 	$self->{owner_gid} = $owner_gid;
@@ -94,13 +94,13 @@
 
 =head2 create
 
-my $object = Vhffs::Object::create($main, [$owner_uid, $owner_gid, $description, $state, $type])
+my $object = Vhffs::Object::create($vhffs, [$owner_uid, $owner_gid, $description, $state, $type])
 
 Create (in database) and return a new object.
 
 =over 4
 
-=item C<$main>: C<Vhffs::Main> instance
+=item C<$vhffs>: C<Vhffs::Main> instance
 
 =item C<$owner_uid>: UID of the owner.
 
@@ -133,7 +133,7 @@
 
 =head2 get_by_oid
 
-my $obj = Vhffs::Object::get_by_oid($main, $oid);
+my $obj = Vhffs::Object::get_by_oid($vhffs, $oid);
 
 Fetches an object using its object ID. Returned object is
 fully functional.
@@ -283,15 +283,15 @@
 
 =pod
 
-=head2 get_main
+=head2 get_vhffs
 
 This method returns the Vhffs::Main object contained in this object.
 This method can be useful if you have an object and you need a Vhffs::Main instance.
 
 =cut
-sub get_main {
+sub get_vhffs {
 	my $self = shift;
-	return $self->{'main'};
+	return $self->{'vhffs'};
 }
 
 =pod
@@ -303,7 +303,7 @@
 =cut
 sub get_db {
 	my $self = shift;
-	return $self->{main}->get_db;
+	return $self->get_vhffs->get_db;
 }
 
 =pod
@@ -513,13 +513,13 @@
 
 =head2 add_history( $string )
 
-Add a message in the object's history. Don't forget to set current user through $main->set_current_user before.
+Add a message in the object's history. Don't forget to set current user through $vhffs->set_current_user before.
 
 =cut
 sub add_history {
 	my $self = shift;
 	my $message = shift;
-	my $user = $self->{main}->get_current_user->get_uid if defined $self->{main}->get_current_user;
+	my $user = $self->get_vhffs->get_current_user->get_uid if defined $self->get_vhffs->get_current_user;
 
 	my $query = 'INSERT INTO vhffs_history(object_id, date, message, source_uid) VALUES(?, ?, ?, ?)';
 	my $request = $self->get_db->prepare( $query );
@@ -588,7 +588,7 @@
 	my $self = shift;
 	my $comments = shift;
 
-	my $vhffs = $self->{main};
+	my $vhffs = $self->get_vhffs;
 	my $user = $self->get_owner;
 
 	$self->set_status( Vhffs::Constants::WAITING_FOR_CREATION );
@@ -655,7 +655,7 @@
 	my $self = shift;
 	my $reason = shift;
 
-	my $vhffs = $self->{main};
+	my $vhffs = $self->get_vhffs;
 	my $user = $self->get_owner;
 
 	$self->set_status( Vhffs::Constants::VALIDATION_REFUSED );
@@ -708,7 +708,7 @@
 sub delete_withmail {
 	my $self = shift;
 
-	my $vhffs = $self->{main};
+	my $vhffs = $self->get_vhffs;
 	my $user = $self->get_owner;
 
 	# TODO: write a beautiful module for INTL
@@ -777,7 +777,7 @@
 	my $self = shift;
 	return $self->{'group'} if defined $self->{'group'};
 	require Vhffs::Group;
-	$self->{'group'} = Vhffs::Group::get_by_gid( $self->{'main'} , $self->{'owner_gid'} );
+	$self->{'group'} = Vhffs::Group::get_by_gid( $self->get_vhffs, $self->{'owner_gid'} );
 	return $self->{'group'};
 }
 
@@ -794,7 +794,7 @@
 	my $self = shift;
 	return $self->{'user'} if defined $self->{'user'};
 	require Vhffs::User;
-	$self->{'user'} = Vhffs::User::get_by_uid( $self->{'main'} , $self->{'owner_uid'} );
+	$self->{'user'} = Vhffs::User::get_by_uid( $self->get_vhffs, $self->{'owner_uid'} );
 	return $self->{'user'};
 }
 

Modified: trunk/vhffs-api/src/Vhffs/Panel/Bazaar.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Bazaar.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Panel/Bazaar.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -55,9 +55,9 @@
 
 
 sub getall_per_group {
-	my ( $main, $gid ) = @_;
+	my ( $vhffs, $gid ) = @_;
 
-	my $dbh = $main->get_db;
+	my $dbh = $vhffs->get_db;
 	my $sql = 'SELECT s.object_id AS oid, s.reponame AS displayname, o.state FROM vhffs_bazaar s INNER JOIN vhffs_object o ON s.object_id = o.object_id WHERE o.owner_gid = ? ORDER BY s.reponame';
 	my $sth = $dbh->prepare($sql) or return -1;
 	$sth->execute($gid) or return -2;
@@ -72,17 +72,17 @@
 }
 
 sub get_repos_per_group {
-	my ($main, $gid, $public_only) = @_;
+	my ($vhffs, $gid, $public_only) = @_;
 	$public_only = 1 unless(defined $public_only);
 
-	my $dbh = $main->get_db;
+	my $dbh = $vhffs->get_db;
 	my $sql = 'SELECT g.reponame, o.description FROM vhffs_bazaar g INNER JOIN vhffs_object o ON o.object_id = g.object_id '.
 	  'WHERE '.($public_only ? 'public = 1 AND ' : '').'o.owner_gid = ? AND o.state = ?';
 	return $dbh->selectall_arrayref($sql, { Slice => {} }, $gid, Vhffs::Constants::ACTIVATED);
 }
 
 sub search_bazaar {
-	my ($main, $name) = @_;
+	my ($vhffs, $name) = @_;
 
 	my @params;
 	my $sql = 'SELECT bazaar.reponame as label, g.groupname as owner_group, o.state, u.username as owner_user '.
@@ -98,16 +98,16 @@
 
 	$sql .= 'ORDER BY bazaar.reponame';
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	return $dbh->selectall_arrayref($sql, { Slice => {} }, @params);
 }
 
 sub create_bazaar {
-	my ($main, $repo, $description, $user, $group) = @_;
+	my ($vhffs, $repo, $description, $user, $group) = @_;
 	return -1 unless defined $user;
 	return -2 unless defined $group;
 
-	my $bazaar = Vhffs::Services::Bazaar::create( $main, $repo, $description, $user, $group );
+	my $bazaar = Vhffs::Services::Bazaar::create( $vhffs, $repo, $description, $user, $group );
 	return -1 unless defined $bazaar;
 
 	return $bazaar;

Modified: trunk/vhffs-api/src/Vhffs/Panel/Broadcast.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Broadcast.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Panel/Broadcast.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -42,13 +42,13 @@
 use Vhffs::Broadcast;
 
 sub broadcast_list {
-	my ($main) = @_;
+	my ($vhffs) = @_;
 
 	my $sql = 'SELECT mailing_id as id, subject, message as body, date, state '.
 	  'FROM vhffs_mailings m '.
 	  'ORDER BY m.date DESC';
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	return $dbh->selectall_arrayref($sql, { Slice => {} });
 }
 

Modified: trunk/vhffs-api/src/Vhffs/Panel/Commons.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Commons.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Panel/Commons.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -123,14 +123,14 @@
 
 =head2
 
-	fetch_slice_and_count($main, $select, $conditions, $order, $start, $count, $params, $select_callback);
+	fetch_slice_and_count($vhffs, $select, $conditions, $order, $start, $count, $params, $select_callback);
 
 Helper function for pagination. Fetches a slice of result (using C<"LIMIT"> and C<"OFFSET"> clauses)
 and the total count of items (if there was no slice).
 
 =over 4
 
-=item C<$main>: Vhffs::Main instance;
+=item C<$vhffs>: Vhffs::Main instance;
 
 =item C<$select>: C<"SELECT"> clause of the query, will be replaced with C<"SELECT COUNT(*)"> to
 		get the total count;
@@ -147,18 +147,18 @@
 =item C<$params>: array ref containing parameters of the query when using placeholders;
 
 =item C<$select_callback>: optional sub reference which will be used to fetch results instead
-		of C<DBI::selectall_arrayref>. Its protorype must be ($main, $sql, @params).
+		of C<DBI::selectall_arrayref>. Its protorype must be ($vhffs, $sql, @params).
 =back
 
 =cut
 sub fetch_slice_and_count($$$$$$$;$) {
-	my ($main, $select, $conditions, $order, $start, $count, $params, $select_callback) = @_;
+	my ($vhffs, $select, $conditions, $order, $start, $count, $params, $select_callback) = @_;
 
-	my $dbh = $main->get_db;
+	my $dbh = $vhffs->get_db;
 	my $result = {};
 	my $sql = $select.$conditions.$order.' LIMIT '.$count.' OFFSET '.$start;
 	if(defined $select_callback) {
-		$result->{data} = $select_callback->($main, $sql, @{$params});
+		$result->{data} = $select_callback->($vhffs, $sql, @{$params});
 	} else {
 		$result->{data} = $dbh->selectall_arrayref($sql, { Slice => {} }, @{$params});
 	}

Modified: trunk/vhffs-api/src/Vhffs/Panel/Cron.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Cron.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Panel/Cron.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -52,9 +52,9 @@
 =cut
 
 sub getall_per_group {
-	my ( $main, $gid ) = @_;
+	my ( $vhffs, $gid ) = @_;
 
-	my $dbh = $main->get_db;
+	my $dbh = $vhffs->get_db;
 	my $sql = 'SELECT c.object_id AS oid, c.cronpath AS displayname, o.state FROM vhffs_cron c INNER JOIN vhffs_object o ON c.object_id = o.object_id WHERE o.owner_gid = ? ORDER BY c.cronpath';
 	my $sth = $dbh->prepare($sql) or return -1;
 	$sth->execute($gid) or return -2;
@@ -69,7 +69,7 @@
 }
 
 sub search_cron {
-	my ($main, $name) = @_;
+	my ($vhffs, $name) = @_;
 
 	my @params;
 	my $sql = 'SELECT cron.cronpath as label, g.groupname as owner_group, o.state, u.username as owner_user '.
@@ -85,14 +85,14 @@
 
 	$sql .= 'ORDER BY cron.cronpath';
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	return $dbh->selectall_arrayref($sql, { Slice => {} }, @params);
 }
 
 sub create_cron {
-	my( $main , $cronpath , $interval , $reportmail , $description , $user , $group ) = @_;
+	my( $vhffs , $cronpath , $interval , $reportmail , $description , $user , $group ) = @_;
 
-	my $cron = Vhffs::Services::Cron::create( $main , $cronpath , $interval , $reportmail , $description, $user , $group );
+	my $cron = Vhffs::Services::Cron::create( $vhffs , $cronpath , $interval , $reportmail , $description, $user , $group );
 	return undef unless defined $cron;
 
 

Modified: trunk/vhffs-api/src/Vhffs/Panel/Cvs.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Cvs.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Panel/Cvs.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -41,7 +41,7 @@
 use Vhffs::Constants;
 
 sub search_cvs {
-	my ($main, $name) = @_;
+	my ($vhffs, $name) = @_;
 
 	my @params;
 	my $sql = 'SELECT cvs.cvsroot as label, g.groupname as owner_group, o.state, u.username as owner_user '.
@@ -57,17 +57,17 @@
 
 	$sql .= 'ORDER BY cvs.cvsroot';
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	return $dbh->selectall_arrayref($sql, { Slice => {} }, @params);
 }
 
 
 sub create_cvs {
-	my( $main, $cvsroot, $description, $user, $group ) = @_;
+	my( $vhffs, $cvsroot, $description, $user, $group ) = @_;
 	return undef unless defined $user;
 	return undef unless defined $group;
 
-	my $cvs = Vhffs::Services::Cvs::create($main, $cvsroot, $description, $user, $group);
+	my $cvs = Vhffs::Services::Cvs::create($vhffs, $cvsroot, $description, $user, $group);
 	return undef unless defined $cvs;
 
 
@@ -87,9 +87,9 @@
 
 
 sub getall_per_group {
-	my ( $main, $gid ) = @_;
+	my ( $vhffs, $gid ) = @_;
 
-	my $dbh = $main->get_db;
+	my $dbh = $vhffs->get_db;
 	my $sql = 'SELECT c.object_id AS oid, c.cvsroot AS displayname, o.state FROM vhffs_cvs c INNER JOIN vhffs_object o ON c.object_id = o.object_id WHERE o.owner_gid = ? ORDER BY c.cvsroot';
 	my $sth = $dbh->prepare($sql) or return -1;
 	$sth->execute($gid) or return -2;
@@ -104,10 +104,10 @@
 }
 
 sub get_repos_per_group {
-	my ($main, $gid, $public_only) = @_;
+	my ($vhffs, $gid, $public_only) = @_;
 	$public_only = 1 unless(defined $public_only);
 
-	my $dbh = $main->get_db;
+	my $dbh = $vhffs->get_db;
 	my $sql = 'SELECT c.cvsroot, o.description FROM vhffs_cvs c INNER JOIN vhffs_object o ON o.object_id = c.object_id '.
 	  'WHERE '.($public_only ? 'c.public = true AND ' : '').'o.owner_gid = ? AND o.state = ?';
 	return $dbh->selectall_arrayref($sql, { Slice => {} }, $gid, Vhffs::Constants::ACTIVATED);

Modified: trunk/vhffs-api/src/Vhffs/Panel/DNS.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/DNS.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Panel/DNS.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -41,7 +41,7 @@
 
 
 sub search_dns {
-	my ($main, $name) = @_;
+	my ($vhffs, $name) = @_;
 
 	my @params;
 	my $sql = 'SELECT ns.domain as label, g.groupname as owner_group, o.state, u.username as owner_user '.
@@ -57,16 +57,16 @@
 
 	$sql .= 'ORDER BY ns.domain';
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	return $dbh->selectall_arrayref($sql, { Slice => {} }, @params);
 }
 
 sub create_dns {
-	my ( $main , $dns_name, $description , $user , $group ) = @_;
+	my ( $vhffs , $dns_name, $description , $user , $group ) = @_;
 	return undef unless defined $user;
 	return undef unless defined $group;
 
-	my $dns = Vhffs::Services::DNS::create( $main , $dns_name, $description, $user , $group );
+	my $dns = Vhffs::Services::DNS::create( $vhffs , $dns_name, $description, $user , $group );
 	return undef unless defined $dns;
 
 
@@ -76,13 +76,13 @@
 
 #Returns an array which contains | domain_name | object_id (from DNS)
 sub getall_dns_per_user {
-	my ( $user , $main ) = @_ ;
+	my ( $user , $vhffs ) = @_ ;
 
 	return undef if ( ! defined $user );
 
 	my $query = "SELECT ns.domain, ns.object_id FROM vhffs_dns ns, vhffs_acl acl ,vhffs_users WHERE vhffs_users.object_id=acl.oid_src AND acl.oid_dst=ns.object_id AND vhffs_users.username='".$user->{'username'}."'";
 
-	my $request = $main->get_db->prepare( $query ) or return -1;
+	my $request = $vhffs->get_db->prepare( $query ) or return -1;
 
 	return undef if ( $request->execute() <= 0);
 
@@ -100,9 +100,9 @@
 
 =cut
 sub getall_per_group {
-	my ( $main, $gid ) = @_;
+	my ( $vhffs, $gid ) = @_;
 
-	my $dbh = $main->get_db;
+	my $dbh = $vhffs->get_db;
 	my $sql = 'SELECT ns.object_id AS oid, ns.domain AS displayname, o.state FROM vhffs_dns ns INNER JOIN vhffs_object o ON ns.object_id = o.object_id WHERE o.owner_gid = ? ORDER BY ns.domain';
 	my $sth = $dbh->prepare($sql) or return -1;
 	$sth->execute($gid) or return -2;

Modified: trunk/vhffs-api/src/Vhffs/Panel/Git.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Git.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Panel/Git.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -56,9 +56,9 @@
 
 
 sub getall_per_group {
-	my ( $main, $gid ) = @_;
+	my ( $vhffs, $gid ) = @_;
 
-	my $dbh = $main->get_db;
+	my $dbh = $vhffs->get_db;
 	my $sql = 'SELECT s.object_id AS oid, s.reponame AS displayname, o.state FROM vhffs_git s INNER JOIN vhffs_object o ON s.object_id = o.object_id WHERE o.owner_gid = ? ORDER BY s.reponame';
 	my $sth = $dbh->prepare($sql) or return -1;
 	$sth->execute($gid) or return -2;
@@ -73,17 +73,17 @@
 }
 
 sub get_repos_per_group {
-	my ($main, $gid, $public_only) = @_;
+	my ($vhffs, $gid, $public_only) = @_;
 	$public_only = 1 unless(defined $public_only);
 
-	my $dbh = $main->get_db;
+	my $dbh = $vhffs->get_db;
 	my $sql = 'SELECT g.reponame, o.description FROM vhffs_git g INNER JOIN vhffs_object o ON o.object_id = g.object_id '.
 	  'WHERE '.($public_only ? 'public = 1 AND ' : '').'o.owner_gid = ? AND o.state = ?';
 	return $dbh->selectall_arrayref($sql, { Slice => {} }, $gid, Vhffs::Constants::ACTIVATED);
 }
 
 sub search_git {
-	my ($main, $name) = @_;
+	my ($vhffs, $name) = @_;
 
 	my @params;
 	my $sql = 'SELECT git.reponame as label, g.groupname as owner_group, o.state, u.username as owner_user '.
@@ -99,16 +99,16 @@
 
 	$sql .= 'ORDER BY git.reponame';
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	return $dbh->selectall_arrayref($sql, { Slice => {} }, @params);
 }
 
 sub create_git {
-	my ($main, $repo, $description, $user, $group) = @_;
+	my ($vhffs, $repo, $description, $user, $group) = @_;
 	return -1 unless defined $user;
 	return -2 unless defined $group;
 
-	my $git = Vhffs::Services::Git::create( $main, $repo, $description, $user, $group );
+	my $git = Vhffs::Services::Git::create( $vhffs, $repo, $description, $user, $group );
 	return -1 unless defined $git;
 
 

Modified: trunk/vhffs-api/src/Vhffs/Panel/Group.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Group.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Panel/Group.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -62,9 +62,9 @@
 
 =cut
 sub getall_users {
-	my ($main, $gid) = @_;
+	my ($vhffs, $gid) = @_;
 	my $sql = 'SELECT u.uid, u.username, u.firstname, u.lastname, u.mail, ug.state FROM vhffs_users u INNER JOIN vhffs_user_group ug ON ug.uid = u.uid WHERE ug.gid = ?';
-	my $dbh = $main->get_db;
+	my $dbh = $vhffs->get_db;
 	my $sth = $dbh->prepare($sql) or return -1;
 	$sth->execute($gid) or return -2;
 	my $users = [];
@@ -77,16 +77,16 @@
 }
 
 sub get_last_groups {
-	my $main = shift;
+	my $vhffs = shift;
 	my @groups;
 
 	my $sql = 'SELECT g.gid, g.groupname, g.realname, o.description, owner.username AS owner_name, o.object_id FROM vhffs_groups g LEFT OUTER JOIN vhffs_users u ON u.username=g.groupname INNER JOIN vhffs_object o ON o.object_id=g.object_id INNER JOIN vhffs_users owner ON owner.uid = o.owner_uid WHERE o.state=? AND u.username IS NULL ORDER BY o.date_creation DESC LIMIT 10';
 
-	 return fetch_groups_and_users($main, $sql, Vhffs::Constants::ACTIVATED);
+	 return fetch_groups_and_users($vhffs, $sql, Vhffs::Constants::ACTIVATED);
 }
 
 sub search_group {
-	my ($main, $name) = @_;
+	my ($vhffs, $name) = @_;
 
 	my @params;
 	my $sql = 'SELECT g.groupname, o.state, u.username as owner_user '.
@@ -103,13 +103,13 @@
 
 	$sql .= 'ORDER BY g.groupname';
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	return $dbh->selectall_arrayref($sql, { Slice => {} }, @params);
 }
 
 
 sub public_search {
-	my ($main, $groupname, $description, $included_tags, $excluded_tags, $start) = @_;
+	my ($vhffs, $groupname, $description, $included_tags, $excluded_tags, $start) = @_;
 
 	my $sql = ' FROM vhffs_groups g
 	  LEFT OUTER JOIN vhffs_users u ON u.username=g.groupname
@@ -148,9 +148,9 @@
 	$limit .= ' OFFSET '.($start * 10) if(defined $start);
 
 	my $select = 'SELECT g.gid, g.groupname, g.realname, o.description, owner.username AS owner_name, o.object_id'.$sql.' ORDER BY groupname '.$limit;
-	my $groups = fetch_groups_and_users($main, $select, @params);
+	my $groups = fetch_groups_and_users($vhffs, $select, @params);
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 
 	my $sth = $dbh->prepare('SELECT COUNT(*)'.$sql);
 	return undef unless ( $sth->execute(@params) );
@@ -161,20 +161,20 @@
 }
 
 sub getall_groups_per_user {
-	my ( $user , $main ) = @_;
+	my ( $user , $vhffs ) = @_;
 
 	return undef if ( ! defined $user );
 
 	my $query = "SELECT g.groupname , g.object_id, o.state  FROM vhffs_groups g, vhffs_user_group ug , vhffs_object o WHERE o.object_id=g.object_id AND ug.gid=g.gid AND ug.uid='".$user->{'uid'}."'";
 
-	my $request = $main->get_db->prepare( $query ) or return -1;
+	my $request = $vhffs->get_db->prepare( $query ) or return -1;
 	my @retour;
 
 	return undef if ( $request->execute() <= 0);
 	return ( $request->fetchall_hashref( 'groupname' ) );
 }
 
-=head2 create_group($groupname, $user, $main)
+=head2 create_group($groupname, $user, $vhffs)
 
 Create a new group with specified name and the
 specified user as owner. Owner if affected to
@@ -190,15 +190,15 @@
 =item $user: Vhffs::User owner of the group (must be registered
 in DB).
 
-=item $main: Vhffs::Main instance
+=item $vhffs: Vhffs::Main instance
 
 =cut
 
 sub create_group
 {
-	my( $groupname , $realname, $user , $main, $description ) = @_;
+	my( $groupname , $realname, $user , $vhffs, $description ) = @_;
 
-	my $group = Vhffs::Group::create($main, $groupname, $realname, $user->get_uid, undef, $description);
+	my $group = Vhffs::Group::create($vhffs, $groupname, $realname, $user->get_uid, undef, $description);
 
 	return undef unless( defined $group );
 
@@ -209,7 +209,7 @@
 }
 
 sub get_groups_starting_with {
-	my ($main, $letter, $starting, $count) = @_;
+	my ($vhffs, $letter, $starting, $count) = @_;
 	my @params;
 
 	my $select_clause = 'SELECT g.gid, g.groupname, g.realname, o.description, owner.username as owner_name, o.object_id';
@@ -225,15 +225,15 @@
 	}
 
 	my $order_clause = ' ORDER BY g.groupname LIMIT '.$count.' OFFSET '.$starting;
-	return Vhffs::Panel::Commons::fetch_slice_and_count($main, $select_clause, $sql, ' ORDER BY groupname', $starting, $count, \@params, \&Vhffs::Panel::Group::fetch_groups_and_users);
+	return Vhffs::Panel::Commons::fetch_slice_and_count($vhffs, $select_clause, $sql, ' ORDER BY groupname', $starting, $count, \@params, \&Vhffs::Panel::Group::fetch_groups_and_users);
 }
 
 sub fetch_groups_and_users {
-	my ($main, $sql, @params) = @_;
+	my ($vhffs, $sql, @params) = @_;
 	my @groups;
 
 
-	my $dbh = $main->get_db;
+	my $dbh = $vhffs->get_db;
 	my $sth = $dbh->prepare($sql);
 	$sql = 'SELECT u.username FROM vhffs_users u INNER JOIN vhffs_user_group ug ON ug.uid = u.uid WHERE ug.gid = ?';
 	my $usth = $dbh->prepare($sql);
@@ -257,8 +257,8 @@
 }
 
 sub get_used_letters {
-	my $main = shift;
-	my $dbh = $main->get_db;
+	my $vhffs = shift;
+	my $dbh = $vhffs->get_db;
 	my $sql = 'SELECT substr(g.groupname, 1, 1) AS letter, COUNT(*) AS count FROM vhffs_groups g LEFT OUTER JOIN vhffs_users u ON u.username = g.groupname INNER JOIN vhffs_object o ON o.object_id = g.object_id WHERE u.username IS NULL AND o.state = ? GROUP BY substr(g.groupname, 1, 1) ORDER BY substr(g.groupname, 1, 1)';
 	return $dbh->selectall_arrayref($sql, { Slice => {} }, Vhffs::Constants::ACTIVATED);
 }

Modified: trunk/vhffs-api/src/Vhffs/Panel/Mail.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Mail.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Panel/Mail.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -40,7 +40,7 @@
 use Vhffs::Services::Mail;
 
 sub search_mail {
-	my ($main, $name) = @_;
+	my ($vhffs, $name) = @_;
 
 	my @params;
 	my $sql = 'SELECT m.domain as label, g.groupname as owner_group, o.state, u.username as owner_user '.
@@ -56,7 +56,7 @@
 
 	$sql .= 'ORDER BY label';
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	return $dbh->selectall_arrayref($sql, { Slice => {} }, @params);
 }
 
@@ -71,9 +71,9 @@
 
 =cut
 sub getall_per_group {
-	my ( $main, $gid ) = @_;
+	my ( $vhffs, $gid ) = @_;
 
-	my $dbh = $main->get_db;
+	my $dbh = $vhffs->get_db;
 	my $sql = 'SELECT m.object_id AS oid, m.domain AS displayname, o.state FROM vhffs_mxdomain m INNER JOIN vhffs_object o ON m.object_id = o.object_id WHERE o.owner_gid = ? ORDER BY m.domain';
 	my $sth = $dbh->prepare($sql) or return -1;
 	$sth->execute($gid) or return -2;
@@ -99,9 +99,9 @@
 =cut
 
 sub is_owned_by_group($$$) {
-	my ($main, $domain, $gid) = @_;
+	my ($vhffs, $domain, $gid) = @_;
 
-	my $dbh = $main->get_db;
+	my $dbh = $vhffs->get_db;
 	my $sql = 'SELECT COUNT(*) FROM vhffs_mxdomain m INNER JOIN vhffs_object o ON o.object_id = m.object_id WHERE m.domain = ? AND o.owner_gid = ?';
 	my $sth = $dbh->prepare( $sql );
 	$sth->execute( $domain, $gid );
@@ -110,11 +110,11 @@
 }
 
 sub create_mail {
-	my( $main , $domain , $description, $user , $group ) = @_;
+	my( $vhffs , $domain , $description, $user , $group ) = @_;
 	return undef unless defined $user;
 	return undef unless defined $group;
 
-	my $mail = Vhffs::Services::Mail::create($main, $domain, $description, $user, $group);
+	my $mail = Vhffs::Services::Mail::create($vhffs, $domain, $description, $user, $group);
 	return undef unless defined $mail;
 
 

Modified: trunk/vhffs-api/src/Vhffs/Panel/MailingList.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/MailingList.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Panel/MailingList.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -42,7 +42,7 @@
 require Vhffs::Panel::Mail;
 
 sub search_mailinglist {
-	my ($main, $name) = @_;
+	my ($vhffs, $name) = @_;
 
 	my @params;
 	my $sql = 'SELECT m.local_part || \'@\' || m.domain as label, g.groupname as owner_group, o.state, u.username as owner_user '.
@@ -58,7 +58,7 @@
 
 	$sql .= 'ORDER BY m.domain, m.local_part';
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	return $dbh->selectall_arrayref($sql, { Slice => {} }, @params);
 }
 
@@ -73,9 +73,9 @@
 
 =cut
 sub getall_per_group {
-	my ( $main, $gid ) = @_;
+	my ( $vhffs, $gid ) = @_;
 
-	my $dbh = $main->get_db;
+	my $dbh = $vhffs->get_db;
 	my $sql = 'SELECT l.object_id AS oid, l.local_part || \'@\' || l.domain AS displayname, o.state FROM vhffs_ml l INNER JOIN vhffs_object o ON l.object_id = o.object_id WHERE o.owner_gid = ? ORDER BY l.local_part, l.domain';
 	my $sth = $dbh->prepare($sql) or return -1;
 	$sth->execute($gid) or return -2;
@@ -90,9 +90,9 @@
 }
 
 sub get_lists_per_group {
-	my ($main, $gid) = @_;
+	my ($vhffs, $gid) = @_;
 
-	my $dbh = $main->get_db;
+	my $dbh = $vhffs->get_db;
 	my $sql = 'SELECT l.local_part || \'@\' || l.domain AS listname, l.local_part, l.domain, l.open_archive, o.description FROM vhffs_ml l INNER JOIN vhffs_object o ON l.object_id = o.object_id WHERE o.owner_gid = ? AND o.state = ?';
 	return $dbh->selectall_arrayref($sql, { Slice => {} }, $gid, Vhffs::Constants::ACTIVATED);
 }
@@ -109,19 +109,19 @@
 =cut
 
 sub getall_mdomains_per_group($$) {
-	my ($main, $gid) = @_;
+	my ($vhffs, $gid) = @_;
 
-	my $dbh = $main->get_db;
+	my $dbh = $vhffs->get_db;
 	my $sql = q{ SELECT m.domain FROM vhffs_mxdomain m INNER JOIN vhffs_object o ON o.object_id = m.object_id WHERE o.owner_gid = ? AND o.state = ? ORDER BY m.domain };
 	return ($dbh->selectall_arrayref($sql, { Slice => {} }, $gid, Vhffs::Constants::ACTIVATED) );
 }
 
 sub create_list {
-	my ($main, $lpart, $domain, $description, $user, $group) = @_;
+	my ($vhffs, $lpart, $domain, $description, $user, $group) = @_;
 	return undef unless defined $user;
 	return undef unless defined $group;
 
-	my $list = Vhffs::Services::MailingList::create( $main , $lpart , $domain, $description, $user, $group );
+	my $list = Vhffs::Services::MailingList::create( $vhffs , $lpart , $domain, $description, $user, $group );
 	return undef unless defined $list;
 
 

Modified: trunk/vhffs-api/src/Vhffs/Panel/Mercurial.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Mercurial.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Panel/Mercurial.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -54,9 +54,9 @@
 
 =cut
 sub getall_per_group {
-	my ( $main, $gid ) = @_;
+	my ( $vhffs, $gid ) = @_;
 
-	my $dbh = $main->get_db;
+	my $dbh = $vhffs->get_db;
 	my $sql = 'SELECT s.object_id AS oid, s.reponame AS displayname, o.state FROM vhffs_mercurial s INNER JOIN vhffs_object o ON s.object_id = o.object_id WHERE o.owner_gid = ? ORDER BY s.reponame';
 	my $sth = $dbh->prepare($sql) or return -1;
 	$sth->execute($gid) or return -2;
@@ -71,10 +71,10 @@
 }
 
 sub get_repos_per_group {
-	my ($main, $gid, $public_only) = @_;
+	my ($vhffs, $gid, $public_only) = @_;
 	$public_only = 1 unless(defined $public_only);
 
-	my $dbh = $main->get_db;
+	my $dbh = $vhffs->get_db;
 	my $sql = 'SELECT g.reponame, o.description FROM vhffs_mercurial g INNER JOIN vhffs_object o ON o.object_id = g.object_id '.
 	  'WHERE '.($public_only ? 'public = 1 AND ' : '').'o.owner_gid = ? AND o.state = ?';
 	return $dbh->selectall_arrayref($sql, { Slice => {} }, $gid, Vhffs::Constants::ACTIVATED);
@@ -82,7 +82,7 @@
 
 
 sub search_mercurial {
-	my ($main, $name) = @_;
+	my ($vhffs, $name) = @_;
 
 	my @params;
 	my $sql = 'SELECT m.reponame as label, g.groupname as owner_group, o.state, u.username as owner_user '.
@@ -98,18 +98,18 @@
 
 	$sql .= 'ORDER BY m.reponame';
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	return $dbh->selectall_arrayref($sql, { Slice => {} }, @params);
 }
 
 
 
 sub create_mercurial {
-	my ($main, $repo, $description, $user, $group) = @_;
+	my ($vhffs, $repo, $description, $user, $group) = @_;
 	return -1 unless defined $user;
 	return -2 unless defined $group;
 
-	my $mercurial = Vhffs::Services::Mercurial::create( $main, $repo, $description, $user, $group );
+	my $mercurial = Vhffs::Services::Mercurial::create( $vhffs, $repo, $description, $user, $group );
 	return -1 unless defined $mercurial;
 
 

Modified: trunk/vhffs-api/src/Vhffs/Panel/Mysql.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Mysql.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Panel/Mysql.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -52,7 +52,7 @@
 
 
 sub search_mysql {
-	my ($main, $name) = @_;
+	my ($vhffs, $name) = @_;
 
 	my @params;
 	my $sql = 'SELECT m.dbname as label, g.groupname as owner_group, o.state, u.username as owner_user '.
@@ -68,15 +68,15 @@
 
 	$sql .= 'ORDER BY label';
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	return $dbh->selectall_arrayref($sql, { Slice => {} }, @params);
 }
 
 sub create_mysql($$$$$$$) {
-	my( $main , $dbname , $user , $group , $dbuser, $dbpass, $description ) = @_;
+	my( $vhffs , $dbname , $user , $group , $dbuser, $dbpass, $description ) = @_;
 	return undef unless defined $user and defined $group;
 
-	my $mysql = Vhffs::Services::Mysql::create($main, $dbname, $dbuser, $dbpass, $description, $user, $group);
+	my $mysql = Vhffs::Services::Mysql::create($vhffs, $dbname, $dbuser, $dbpass, $description, $user, $group);
 	return undef unless defined $mysql;
 
 
@@ -96,9 +96,9 @@
 
 
 sub getall_per_group {
-	my ( $main, $gid ) = @_;
+	my ( $vhffs, $gid ) = @_;
 
-	my $dbh = $main->get_db;
+	my $dbh = $vhffs->get_db;
 	my $sql = 'SELECT m.object_id AS oid, m.dbname AS displayname, o.state FROM vhffs_mysql m INNER JOIN vhffs_object o ON m.object_id = o.object_id WHERE o.owner_gid = ? ORDER BY m.dbname';
 	my $sth = $dbh->prepare($sql) or return -1;
 	$sth->execute($gid) or return -2;

Modified: trunk/vhffs-api/src/Vhffs/Panel/Object.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Object.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Panel/Object.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -39,7 +39,7 @@
 use Locale::gettext;
 
 sub search_object {
-	my ($main, $name) = @_;
+	my ($vhffs, $name) = @_;
 
 	my @params;
 	my $sql = 'SELECT o.object_id AS oid, u.username as owner_user, g.groupname as owner_group, o.type, o.state '.
@@ -54,7 +54,7 @@
 
 	$sql .= 'ORDER BY o.object_id';
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	return $dbh->selectall_arrayref($sql, { Slice => {} }, @params);
 }
 

Modified: trunk/vhffs-api/src/Vhffs/Panel/Pgsql.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Pgsql.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Panel/Pgsql.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -42,7 +42,7 @@
 
 
 sub search_pgsql {
-	my ($main, $name) = @_;
+	my ($vhffs, $name) = @_;
 
 	my @params;
 	my $sql = 'SELECT p.dbname as label, g.groupname as owner_group, o.state, u.username as owner_user '.
@@ -58,7 +58,7 @@
 
 	$sql .= 'ORDER BY label';
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	return $dbh->selectall_arrayref( $sql, { Slice => {} }, @params);
 }
 
@@ -76,9 +76,9 @@
 
 
 sub getall_per_group {
-	my ( $main, $gid ) = @_;
+	my ( $vhffs, $gid ) = @_;
 
-	my $dbh = $main->get_db;
+	my $dbh = $vhffs->get_db;
 	my $sql = 'SELECT p.object_id AS oid, p.dbname AS displayname, o.state FROM vhffs_pgsql p INNER JOIN vhffs_object o ON p.object_id = o.object_id WHERE o.owner_gid = ? ORDER BY p.dbname';
 	my $sth = $dbh->prepare($sql) or return -1;
 	$sth->execute($gid) or return -2;
@@ -93,11 +93,11 @@
 }
 
 sub create_pgsql {
-	my( $main , $dbname , $user , $group , $dbuser , $dbpass, $description ) = @_;
+	my( $vhffs , $dbname , $user , $group , $dbuser , $dbpass, $description ) = @_;
 	return -1 unless defined $user;
 	return -2 unless defined $group;
 
-	my $pgsql = Vhffs::Services::Pgsql::create($main, $dbname, $dbuser, $dbpass, $description, $user, $group);
+	my $pgsql = Vhffs::Services::Pgsql::create($vhffs, $dbname, $dbuser, $dbpass, $description, $user, $group);
 	return undef unless defined $pgsql;
 
 	return $pgsql;

Modified: trunk/vhffs-api/src/Vhffs/Panel/Repository.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Repository.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Panel/Repository.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -52,9 +52,9 @@
 =cut
 
 sub getall_per_group {
-	my ( $main, $gid ) = @_;
+	my ( $vhffs, $gid ) = @_;
 
-	my $dbh = $main->get_db;
+	my $dbh = $vhffs->get_db;
 	my $sql = 'SELECT r.object_id AS oid, r.name AS displayname, o.state FROM vhffs_repository r INNER JOIN vhffs_object o ON r.object_id = o.object_id WHERE o.owner_gid = ? ORDER BY r.name';
 	my $sth = $dbh->prepare($sql) or return -1;
 	$sth->execute($gid) or return -2;
@@ -69,7 +69,7 @@
 }
 
 sub search_repository {
-	my ($main, $name) = @_;
+	my ($vhffs, $name) = @_;
 
 	my @params;
 	my $sql = 'SELECT r.name as label, g.groupname as owner_group, o.state, u.username as owner_user '.
@@ -85,7 +85,7 @@
 
 	$sql .= 'ORDER BY label';
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	return $dbh->selectall_arrayref($sql, { Slice => {} }, @params);
 }
 
@@ -93,10 +93,10 @@
 
 sub create_repository
 {
-	my( $main , $name , $user , $group, $description ) = @_;
+	my( $vhffs , $name , $user , $group, $description ) = @_;
 	return undef unless defined $user and defined $group;
 
-	my $repo = Vhffs::Services::Repository::create( $main , $name , $description, $user , $group );
+	my $repo = Vhffs::Services::Repository::create( $vhffs , $name , $description, $user , $group );
 	return undef unless defined $repo;
 
 

Modified: trunk/vhffs-api/src/Vhffs/Panel/Svn.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Svn.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Panel/Svn.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -54,9 +54,9 @@
 
 =cut
 sub getall_per_group {
-	my ( $main, $gid ) = @_;
+	my ( $vhffs, $gid ) = @_;
 
-	my $dbh = $main->get_db;
+	my $dbh = $vhffs->get_db;
 	my $sql = 'SELECT s.object_id AS oid, s.reponame AS displayname, o.state FROM vhffs_svn s INNER JOIN vhffs_object o ON s.object_id = o.object_id WHERE o.owner_gid = ? ORDER BY s.reponame';
 	my $sth = $dbh->prepare($sql) or return -1;
 	$sth->execute($gid) or return -2;
@@ -71,17 +71,17 @@
 }
 
 sub get_repos_per_group {
-	my ($main, $gid, $public_only) = @_;
+	my ($vhffs, $gid, $public_only) = @_;
 	$public_only = 1 unless(defined $public_only);
 
-	my $dbh = $main->get_db;
+	my $dbh = $vhffs->get_db;
 	my $sql = 'SELECT s.reponame, o.description FROM vhffs_svn s INNER JOIN vhffs_object o ON o.object_id = s.object_id '.
 	  'WHERE '.($public_only ? 's.public = 1 AND ' : '').'o.owner_gid = ? AND o.state = ?';
 	return $dbh->selectall_arrayref($sql, { Slice => {} }, $gid, Vhffs::Constants::ACTIVATED);
 }
 
 sub search_svn {
-	my ($main, $name) = @_;
+	my ($vhffs, $name) = @_;
 
 	my @params;
 	my $svns = [];
@@ -98,17 +98,17 @@
 
 	$sql .= 'ORDER BY label';
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	return $dbh->selectall_arrayref($sql, { Slice => {} }, @params);
 }
 
 sub create_svn
 {
-	my ($main, $repo, $description, $user, $group) = @_;
+	my ($vhffs, $repo, $description, $user, $group) = @_;
 	return -1 unless defined $user;
 	return -2 unless defined $group;
 
-	my $svn = Vhffs::Services::Svn::create( $main, $repo, $description, $user, $group );
+	my $svn = Vhffs::Services::Svn::create( $vhffs, $repo, $description, $user, $group );
 	return -1 unless defined $svn;
 
 

Modified: trunk/vhffs-api/src/Vhffs/Panel/Tag.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Tag.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Panel/Tag.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -53,7 +53,7 @@
 
 =head2 get_groups
 
-	Vhffs::Panel::Tag::get_groups($main, $category_name, $tag_name, $start)
+	Vhffs::Panel::Tag::get_groups($vhffs, $category_name, $tag_name, $start)
 
 Fetches 10 groups associated to tag C<$tag_name> in (optional) category
 C<$category_name> starting at index C<$start>
@@ -61,7 +61,7 @@
 =cut
 
 sub get_groups {
-	my ($main, $category_name, $tag_name, $start) = @_;
+	my ($vhffs, $category_name, $tag_name, $start) = @_;
 
 	my $select =  'SELECT g.gid, g.groupname, g.realname, o.description, owner.username AS owner_name ';
 	my $restriction = ' FROM vhffs_groups g INNER JOIN vhffs_object o ON o.object_id=g.object_id '.
@@ -81,9 +81,9 @@
 	my $limit = ' LIMIT 10';
 	$limit .= ' OFFSET '.($start * 10) if(defined $start);
 
-	my $groups = Vhffs::Panel::Group::fetch_groups_and_users($main, $select.$restriction.' ORDER BY g.groupname '.$limit, @params);
+	my $groups = Vhffs::Panel::Group::fetch_groups_and_users($vhffs, $select.$restriction.' ORDER BY g.groupname '.$limit, @params);
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 
 	my $sth = $dbh->prepare('SELECT COUNT(*) '.$restriction);
 	return undef unless ( $sth->execute(@params) );
@@ -102,19 +102,19 @@
 =cut
 
 sub get_by_tag_ids {
-	my $main = shift;
+	my $vhffs = shift;
 	my @ids = @_;
-	return _get_by_tag_ids($main, 0, @ids);
+	return _get_by_tag_ids($vhffs, 0, @ids);
 }
 
 sub get_all_excluding {
-	my $main = shift;
+	my $vhffs = shift;
 	my @ids = @_;
-	return _get_by_tag_ids($main, 1, @ids);
+	return _get_by_tag_ids($vhffs, 1, @ids);
 }
 
 sub _get_by_tag_ids {
-	my $main = shift;
+	my $vhffs = shift;
 	my $exclude = shift;
 	my @ids = @_;
 
@@ -133,7 +133,7 @@
 		$sql .= ')';
 	}
 	$sql .= ' ORDER BY c.label, t.label';
-	my $dbh = $main->get_db;
+	my $dbh = $vhffs->get_db;
 	return $dbh->selectall_arrayref($sql, { Slice => {} }, @ids);
 }
 
@@ -166,7 +166,7 @@
 	my $category_id = $cgi->param('category_id');
 	my $label = $cgi->param('label');
 	my $description = $cgi->param('description');
-	my $main = $panel->{vhffs};
+	my $vhffs = $panel->{vhffs};
 
 	$vars->{label} = $label;
 	$vars->{description} = $description;
@@ -192,14 +192,14 @@
 		return 0;
 	}
 
-	my $category = Vhffs::Tag::Category::get_by_category_id($main, $category_id);
+	my $category = Vhffs::Tag::Category::get_by_category_id($vhffs, $category_id);
 
 	unless(defined $category) {
 		$panel->add_error( gettext('Category does not exists') );
 		return 0;
 	}
 
-	unless(defined Vhffs::Tag::create($main, $label, $description, $panel->{user}, $category)) {
+	unless(defined Vhffs::Tag::create($vhffs, $label, $description, $panel->{user}, $category)) {
 		$panel->add_error( gettext('Unable to create tag') );
 		return 0;
 	}

Modified: trunk/vhffs-api/src/Vhffs/Panel/User.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/User.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Panel/User.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -88,18 +88,18 @@
 
 sub get_last_users
 {
-	my ($main) = @_;
+	my ($vhffs) = @_;
 
 	my $sql = 'SELECT u.uid, u.username, u.firstname, u.lastname '.
 	  'FROM vhffs_users u '.
 	  'INNER JOIN vhffs_object o ON o.object_id=u.object_id '.
 	  'WHERE o.state=? ORDER BY o.date_creation DESC LIMIT 10';
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 
 	my $users = $dbh->selectall_hashref($sql, 'uid', undef, Vhffs::Constants::ACTIVATED);
 
-	fill_groups($main, $users);
+	fill_groups($vhffs, $users);
 
 	my @val = values(%$users);
 
@@ -107,7 +107,7 @@
 }
 
 sub search_user {
-	my ($main, $name) = @_;
+	my ($vhffs, $name) = @_;
 
 	my @params;
 	my $sql = 'SELECT u.uid, u.username, u.firstname || \' \' || u.lastname as realname, o.state '.
@@ -121,7 +121,7 @@
 
 	$sql .= 'ORDER BY u.username';
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	return $dbh->selectall_arrayref($sql, { Slice => {} }, @params);
 }
 
@@ -134,7 +134,7 @@
 =cut
 
 sub public_search {
-	my ($main, $username, $start) = @_;
+	my ($vhffs, $username, $start) = @_;
 	my $result = {};
 
 	my $select_clause = 'SELECT u.uid, u.username, u.firstname, u.lastname ';
@@ -154,13 +154,13 @@
 	my $limit = ' LIMIT 10';
 	$limit .= ' OFFSET '.($start * 10) if(defined $start);
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 
 	my $users = $dbh->selectall_hashref($select_clause.$sql.' ORDER BY u.username '.$limit, 'uid', undef, @params);
 
 	my ($count) = $dbh->selectrow_array('SELECT COUNT(*) '.$sql, undef, @params);
 
-	fill_groups($main, $users);
+	fill_groups($vhffs, $users);
 
 	my @val = values(%$users);
 
@@ -172,7 +172,7 @@
 
 =head2 fill_groups
 
-	Vhffs::Panel::User::fill_groups($main, $users);
+	Vhffs::Panel::User::fill_groups($vhffs, $users);
 
 C<$users> is a HASHREF indexed by uid containing at least
 the C<uid> field. It is modified inplace to add a field
@@ -181,9 +181,9 @@
 
 =cut
 sub fill_groups {
-	my ($main, $users) =@_;
+	my ($vhffs, $users) =@_;
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	my @uids = ();
 
 	foreach my $uid(keys(%$users)) {
@@ -207,10 +207,10 @@
 }
 
 sub fetch_users_and_groups {
-	my ($main, $sql, @params) = @_;
+	my ($vhffs, $sql, @params) = @_;
 	my @users;
 
-	my $dbh = $main->get_db;
+	my $dbh = $vhffs->get_db;
 	my $sth = $dbh->prepare($sql);
 	$sth->execute( @params );
 	$sql = 'SELECT g.groupname FROM vhffs_groups g INNER JOIN vhffs_user_group ug ON ug.gid = g.gid WHERE ug.uid = ? AND g.groupname != ?';
@@ -264,7 +264,7 @@
 	my $user = shift;
 	return -1 if( ! defined $user );
 	my $theme = $user->get_theme;
-	$theme = $user->get_main->get_config->get_panel->{'default_theme'} unless defined $theme;
+	$theme = $user->get_vhffs->get_config->get_panel->{'default_theme'} unless defined $theme;
 	return $theme;
 }
 

Modified: trunk/vhffs-api/src/Vhffs/Panel/Web.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Web.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Panel/Web.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -52,7 +52,7 @@
 
 =head2 get_all_per_group
 
-	my $areas = Vhffs::Panel::Web::getall_per_group($vhffs, $main);
+	my $areas = Vhffs::Panel::Web::getall_per_group($vhffs, $vhffs);
 
 Returns an array of hashrefs (oid, display, active, state) of all webareas owned by
 a given group.
@@ -60,9 +60,9 @@
 =cut
 
 sub getall_per_group {
-	my ($main, $gid) = @_;
+	my ($vhffs, $gid) = @_;
 
-	my $dbh = $main->get_db;
+	my $dbh = $vhffs->get_db;
 	my $sql = 'SELECT w.servername AS displayname, w.object_id AS oid, o.state FROM vhffs_httpd w INNER JOIN vhffs_object o ON o.object_id = w.object_id WHERE o.owner_gid = ? ORDER BY w.servername';
 	my $sth = $dbh->prepare($sql) or return -1;
 	$sth->execute($gid) or return -2;
@@ -84,15 +84,15 @@
 =cut
 
 sub get_websites_per_group {
-	my ($main, $gid) = @_;
+	my ($vhffs, $gid) = @_;
 
-	my $dbh = $main->get_db;
+	my $dbh = $vhffs->get_db;
 	my $sql = 'SELECT w.servername, o.description FROM vhffs_httpd w INNER JOIN vhffs_object o ON o.object_id = w.object_id WHERE o.owner_gid = ? AND o.state = ?';
 	return $dbh->selectall_arrayref($sql, { Slice => {} }, $gid, Vhffs::Constants::ACTIVATED);
 }
 
 sub search_web {
-	my ($main, $name) = @_;
+	my ($vhffs, $name) = @_;
 
 	my @params;
 	my $webs = [];
@@ -109,12 +109,12 @@
 
 	$sql .= 'ORDER BY label';
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	return $dbh->selectall_arrayref($sql, { Slice => {} }, @params);
 }
 
 sub public_search {
-	my ($main, $servername, $description, $start, $count) = @_;
+	my ($vhffs, $servername, $description, $start, $count) = @_;
 
 	my $select = 'SELECT w.servername, g.groupname, o.description';
 	my $from = ' FROM vhffs_httpd w INNER JOIN vhffs_object o ON o.object_id = w.object_id INNER JOIN vhffs_groups g ON g.gid = o.owner_gid WHERE o.state = ?';
@@ -130,17 +130,17 @@
 		push @params, '%'.$description.'%';
 	}
 
-	return Vhffs::Panel::Commons::fetch_slice_and_count($main, $select, $from, ' ORDER BY w.servername', $start, $count, \@params);
+	return Vhffs::Panel::Commons::fetch_slice_and_count($vhffs, $select, $from, ' ORDER BY w.servername', $start, $count, \@params);
 }
 
 
 sub create_web {
-	my( $main, $servername, $description, $user, $group ) = @_;
+	my( $vhffs, $servername, $description, $user, $group ) = @_;
 
 	return undef unless defined $user;
 	return undef unless defined $group;
 
-	my $web = Vhffs::Services::Web::create($main, $servername, $description, $user, $group);
+	my $web = Vhffs::Services::Web::create($vhffs, $servername, $description, $user, $group);
 	return undef unless defined $web;
 
 
@@ -171,9 +171,9 @@
 =cut
 
 sub get_used_letters {
-	my $main = shift;
+	my $vhffs = shift;
 	my $sql = 'SELECT substr(servername, 1, 1) as letter, COUNT(*) as count FROM vhffs_httpd h INNER JOIN vhffs_object o ON o.object_id = h.object_id WHERE state = ? GROUP BY substr(servername, 1, 1) ORDER BY substr(servername, 1, 1)';
-	my $dbh = $main->get_db;
+	my $dbh = $vhffs->get_db;
 	return $dbh->selectall_arrayref($sql, { Slice => {} }, Vhffs::Constants::ACTIVATED);
 }
 

Modified: trunk/vhffs-api/src/Vhffs/Robots/Bazaar.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Bazaar.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Robots/Bazaar.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -46,7 +46,7 @@
 	my $bazaar = shift;
 	return undef unless defined $bazaar and $bazaar->get_status == Vhffs::Constants::WAITING_FOR_CREATION;
 
-	my $vhffs = $bazaar->get_main;
+	my $vhffs = $bazaar->get_vhffs;
 	my $dir = $bazaar->get_dir;
 
 	if( -e $dir ) {
@@ -97,7 +97,7 @@
 	my $bazaar = shift;
 	return undef unless defined $bazaar and $bazaar->get_status == Vhffs::Constants::WAITING_FOR_DELETION;
 
-	my $vhffs = $bazaar->get_main;
+	my $vhffs = $bazaar->get_vhffs;
 	my $dir = $bazaar->get_dir;
 
 	Vhffs::Robots::archive_targz( $bazaar, $dir );
@@ -129,9 +129,9 @@
 	my $bazaar = shift;
 	return undef unless defined $bazaar and $bazaar->get_status == Vhffs::Constants::WAITING_FOR_MODIFICATION;
 
-	my $vhffs = $bazaar->get_main;
+	my $vhffs = $bazaar->get_vhffs;
 	my $dir = $bazaar->get_dir;
-	my $mail_from = $bazaar->get_main->get_config->get_service('bazaar')->{notify_from};
+	my $mail_from = $bazaar->get_vhffs->get_config->get_service('bazaar')->{notify_from};
 
 	if( $bazaar->get_ml_name !~ /^\s*$/ ) {
 		# TODO: Bazaar mail on commit

Modified: trunk/vhffs-api/src/Vhffs/Robots/Cron.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Cron.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Robots/Cron.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -40,32 +40,32 @@
 package Vhffs::Robots::Cron;
 
 sub get_runnable_jobs {
-	my $main = shift;
+	my $vhffs = shift;
 
 	my $sql = 'SELECT c.cron_id, c.cronpath, c.interval, c.reportmail, c.lastrundate, c.lastrunreturncode, c.nextrundate, c.running, o.owner_uid, o.owner_gid, o.object_id, o.date_creation, o.description, o.state FROM vhffs_cron c INNER JOIN vhffs_object o ON c.object_id=o.object_id WHERE o.state=? AND c.running=0 AND ( c.nextrundate IS NULL OR c.nextrundate<? )';
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	my $sth = $dbh->prepare($sql);
 	$sth->execute( Vhffs::Constants::ACTIVATED , time() ) or return undef;
 
 	my $repos = [];
 	while(my $r = $sth->fetchrow_arrayref()) {
-		push(@$repos, _new Vhffs::Services::Cron($main, @$r));
+		push(@$repos, _new Vhffs::Services::Cron($vhffs, @$r));
 	}
 	return $repos;
 }
 
 sub get_stalled_jobs {
-	my $main = shift;
+	my $vhffs = shift;
 	my $maxexectime = shift;
 
 	my $sql = 'SELECT c.cron_id, c.cronpath, c.interval, c.reportmail, c.lastrundate, c.lastrunreturncode, c.nextrundate, c.running, o.owner_uid, o.owner_gid, o.object_id, o.date_creation, o.description, o.state FROM vhffs_cron c INNER JOIN vhffs_object o ON c.object_id=o.object_id WHERE o.state=? AND c.running!=0 AND ( c.nextrundate IS NULL OR c.nextrundate<? )';
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	my $sth = $dbh->prepare($sql);
 	$sth->execute( Vhffs::Constants::ACTIVATED , time() - $maxexectime ) or return undef;
 
 	my $repos = [];
 	while(my $r = $sth->fetchrow_arrayref()) {
-		push(@$repos, _new Vhffs::Services::Cron($main, @$r));
+		push(@$repos, _new Vhffs::Services::Cron($vhffs, @$r));
 	}
 	return $repos;
 }
@@ -74,7 +74,7 @@
 	my $cron = shift;
 	return undef unless defined $cron and $cron->get_status == Vhffs::Constants::WAITING_FOR_CREATION;
 
-	my $vhffs = $cron->get_main;
+	my $vhffs = $cron->get_vhffs;
 
 	$cron->set_status( Vhffs::Constants::ACTIVATED );
 	$cron->commit;
@@ -87,7 +87,7 @@
 	my $cron = shift;
 	return undef unless defined $cron and $cron->get_status == Vhffs::Constants::WAITING_FOR_DELETION;
 
-	my $vhffs = $cron->get_main;
+	my $vhffs = $cron->get_vhffs;
 
 	if( $cron->delete ) {
 		Vhffs::Robots::vhffs_log( $vhffs, 'Deleted cron job '.$cron->get_cronpath );

Modified: trunk/vhffs-api/src/Vhffs/Robots/Cvs.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Cvs.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Robots/Cvs.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -46,7 +46,7 @@
 	my $cvs = shift;
 	return undef unless defined $cvs and $cvs->get_status == Vhffs::Constants::WAITING_FOR_CREATION;
 
-	my $vhffs = $cvs->get_main;
+	my $vhffs = $cvs->get_vhffs;
 	my $dir = $cvs->get_dir;
 
 	if( -e $dir ) {
@@ -93,7 +93,7 @@
 	my $cvs = shift;
 	return undef unless defined $cvs and $cvs->get_status == Vhffs::Constants::WAITING_FOR_DELETION;
 
-	my $vhffs = $cvs->get_main;
+	my $vhffs = $cvs->get_vhffs;
 	my $dir = $cvs->get_dir;
 
 	Vhffs::Robots::archive_targz( $cvs, $dir );
@@ -126,7 +126,7 @@
 	my $cvs = shift;
 	return undef unless defined $cvs and ( $cvs->get_status == Vhffs::Constants::WAITING_FOR_MODIFICATION or $cvs->get_status == Vhffs::Constants::WAITING_FOR_CREATION );
 
-	my $vhffs = $cvs->get_main;
+	my $vhffs = $cvs->get_vhffs;
 	my $dir = $cvs->get_dir;
 	my $readers_file = $dir.'/CVSROOT/readers';
 	my $passwd_file = $dir.'/CVSROOT/passwd';

Modified: trunk/vhffs-api/src/Vhffs/Robots/DNS.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/DNS.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Robots/DNS.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -43,7 +43,7 @@
 	my $dns = shift;
 	return undef unless defined $dns and $dns->get_status == Vhffs::Constants::WAITING_FOR_CREATION;
 
-	my $vhffs = $dns->get_main;
+	my $vhffs = $dns->get_vhffs;
 
 	$dns->set_status( Vhffs::Constants::ACTIVATED );
 	$dns->commit;
@@ -56,7 +56,7 @@
 	my $dns = shift;
 	return undef unless defined $dns and $dns->get_status == Vhffs::Constants::WAITING_FOR_DELETION;
 
-	my $vhffs = $dns->get_main;
+	my $vhffs = $dns->get_vhffs;
 
 	if( $dns->delete ) {
 		Vhffs::Robots::vhffs_log( $vhffs, 'Deleted DNS '.$dns->get_domain );

Modified: trunk/vhffs-api/src/Vhffs/Robots/Git.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Git.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Robots/Git.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -48,7 +48,7 @@
 	my $git = shift;
 	return undef unless defined $git and $git->get_status == Vhffs::Constants::WAITING_FOR_CREATION;
 
-	my $vhffs = $git->get_main;
+	my $vhffs = $git->get_vhffs;
 	my $dir = $git->get_dir;
 
 	if( -e $dir ) {
@@ -103,7 +103,7 @@
 	my $git = shift;
 	return undef unless defined $git and $git->get_status == Vhffs::Constants::WAITING_FOR_DELETION;
 
-	my $vhffs = $git->get_main;
+	my $vhffs = $git->get_vhffs;
 	my $dir = $git->get_dir;
 
 	Vhffs::Robots::archive_targz( $git, $dir );
@@ -135,7 +135,7 @@
 	my $git = shift;
 	return undef unless defined $git and ( $git->get_status == Vhffs::Constants::WAITING_FOR_MODIFICATION or $git->get_status == Vhffs::Constants::WAITING_FOR_CREATION );
 
-	my $vhffs = $git->get_main;
+	my $vhffs = $git->get_vhffs;
 	my $dir = $git->get_dir;
 
 	if( $git->is_public ) {
@@ -151,7 +151,7 @@
 		$git->add_history( 'Is now private');
 	}
 
-	my $mail_from = $git->get_main->get_config->get_service('git')->{'notify_from'};
+	my $mail_from = $git->get_vhffs->get_config->get_service('git')->{'notify_from'};
 
 	# Always unlink since git init create a dummy post-receive
 	unlink $dir.'/hooks/post-receive';

Modified: trunk/vhffs-api/src/Vhffs/Robots/Group.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Group.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Robots/Group.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -48,7 +48,7 @@
 	my $group = shift;
 	return undef unless defined $group and $group->get_status == Vhffs::Constants::WAITING_FOR_CREATION;
 
-	my $vhffs = $group->get_main;
+	my $vhffs = $group->get_vhffs;
 	my $dir = $group->get_dir;
 
 	if( -e $dir ) {
@@ -84,7 +84,7 @@
 	my $group = shift;
 	return undef unless defined $group and $group->get_status == Vhffs::Constants::WAITING_FOR_DELETION;
 
-	my $vhffs = $group->get_main;
+	my $vhffs = $group->get_vhffs;
 	my $dir = $group->get_dir;
 
 	Vhffs::Robots::archive_targz( $group, $dir );
@@ -146,7 +146,7 @@
 	my $group = shift;
 	return undef unless defined $group;
 
-	my $vhffs = $group->get_main;
+	my $vhffs = $group->get_vhffs;
 
 	my $dev = Quota::getqcarg($vhffs->get_config->get_datadir);
 
@@ -182,7 +182,7 @@
 	my $path = shift;
 	return undef unless defined $group and defined $path and -d $path;
 
-	my $vhffs = $group->get_main;
+	my $vhffs = $group->get_vhffs;
 
 	my $dev = Quota::getqcarg($path);
 

Modified: trunk/vhffs-api/src/Vhffs/Robots/Mail.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Mail.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Robots/Mail.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -61,7 +61,7 @@
 	my $mail = shift;
 	return undef unless defined $mail and $mail->get_status == Vhffs::Constants::WAITING_FOR_CREATION;
 
-	my $vhffs = $mail->get_main;
+	my $vhffs = $mail->get_vhffs;
 
 	$mail->set_status( Vhffs::Constants::ACTIVATED );
 	$mail->commit;
@@ -74,7 +74,7 @@
 	my $mail = shift;
 	return undef unless defined $mail and $mail->get_status == Vhffs::Constants::WAITING_FOR_DELETION;
 
-	my $vhffs = $mail->get_main;
+	my $vhffs = $mail->get_vhffs;
 	my $dir = $mail->get_dir();
 
 	require Vhffs::Services::MailingList;
@@ -138,7 +138,7 @@
 	my $localpart = shift;
 	return undef unless defined $mail and defined $localpart and $mail->get_box_status($localpart) == Vhffs::Constants::WAITING_FOR_CREATION;
 
-	my $vhffs = $mail->get_main;
+	my $vhffs = $mail->get_vhffs;
 	my $mailconf = $vhffs->get_config->get_service('mail');
 
 	my $dir = $mail->get_box_dir($localpart);
@@ -168,7 +168,7 @@
 	my $localpart = shift;
 	return undef unless defined $mail and defined $localpart and $mail->get_box_status($localpart) == Vhffs::Constants::WAITING_FOR_DELETION;
 
-	my $vhffs = $mail->get_main;
+	my $vhffs = $mail->get_vhffs;
 	my $dir = $mail->get_box_dir($localpart);
 
 	Vhffs::Robots::archive_targz( $mail, $dir, [ $localpart ] );

Modified: trunk/vhffs-api/src/Vhffs/Robots/MailingList.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/MailingList.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Robots/MailingList.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -43,7 +43,7 @@
 	my $ml = shift;
 	return undef unless defined $ml and $ml->get_status == Vhffs::Constants::WAITING_FOR_CREATION;
 
-	my $vhffs = $ml->get_main;
+	my $vhffs = $ml->get_vhffs;
 
 	$ml->set_status( Vhffs::Constants::ACTIVATED );
 	$ml->commit;
@@ -56,7 +56,7 @@
 	my $ml = shift;
 	return undef unless defined $ml and $ml->get_status == Vhffs::Constants::WAITING_FOR_DELETION;
 
-	my $vhffs = $ml->get_main;
+	my $vhffs = $ml->get_vhffs;
 
 	# TODO: Archives of archives, remove public archives
 
@@ -87,7 +87,7 @@
 	my $ml = shift;
 	return undef unless defined $ml;
 
-	my $vhffs = $ml->get_main;
+	my $vhffs = $ml->get_vhffs;
 	my $listengineconfig = $vhffs->get_config->get_listengine;
 	my $mhonarcconfig = '%VHFFS_BOTS_DIR%/misc/mhonarc.config';
 

Modified: trunk/vhffs-api/src/Vhffs/Robots/Mercurial.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Mercurial.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Robots/Mercurial.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -46,7 +46,7 @@
 	my $mercurial = shift;
 	return undef unless defined $mercurial and $mercurial->get_status == Vhffs::Constants::WAITING_FOR_CREATION;
 
-	my $vhffs = $mercurial->get_main;
+	my $vhffs = $mercurial->get_vhffs;
 	my $dir = $mercurial->get_dir;
 
 	if( -e $dir ) {
@@ -97,7 +97,7 @@
 	my $mercurial = shift;
 	return undef unless defined $mercurial and $mercurial->get_status == Vhffs::Constants::WAITING_FOR_DELETION;
 
-	my $vhffs = $mercurial->get_main;
+	my $vhffs = $mercurial->get_vhffs;
 	my $dir = $mercurial->get_dir;
 
 	Vhffs::Robots::archive_targz( $mercurial, $dir );
@@ -129,7 +129,7 @@
 	my $mercurial = shift;
 	return undef unless defined $mercurial and ( $mercurial->get_status == Vhffs::Constants::WAITING_FOR_MODIFICATION or $mercurial->get_status == Vhffs::Constants::WAITING_FOR_CREATION );
 
-	my $vhffs = $mercurial->get_main;
+	my $vhffs = $mercurial->get_vhffs;
 	my $dir = $mercurial->get_dir;
 
 	if( $mercurial->is_public ) {
@@ -145,7 +145,7 @@
 		$mercurial->add_history( 'Is now private');
 	}
 
-	my $mail_from = $mercurial->get_main->get_config->get_service('mercurial')->{notify_from};
+	my $mail_from = $mercurial->get_vhffs->get_config->get_service('mercurial')->{notify_from};
 	my $mladdress = $mercurial->{ml_name};
 
 	my $rcfileoutpath = $dir.'/.hg/hgrc';

Modified: trunk/vhffs-api/src/Vhffs/Robots/Mysql.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Mysql.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Robots/Mysql.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -57,7 +57,7 @@
 	my $mysql = shift;
 	return undef unless defined $mysql and $mysql->get_status == Vhffs::Constants::WAITING_FOR_CREATION;
 
-	my $vhffs = $mysql->get_main;
+	my $vhffs = $mysql->get_vhffs;
 
 	my $dbi = mysql_admin_db_connect( $vhffs );
 	return unless $dbi;
@@ -95,7 +95,7 @@
 	my $mysql = shift;
 	return undef unless defined $mysql and $mysql->get_status == Vhffs::Constants::WAITING_FOR_DELETION;
 
-	my $vhffs = $mysql->get_main;
+	my $vhffs = $mysql->get_vhffs;
 
 	my $dbi = mysql_admin_db_connect( $vhffs );
 	return unless $dbi;
@@ -147,7 +147,7 @@
 	my $mysql = shift;
 	return undef unless defined $mysql and $mysql->get_status == Vhffs::Constants::WAITING_FOR_MODIFICATION;
 
-	my $vhffs = $mysql->get_main;
+	my $vhffs = $mysql->get_vhffs;
 
 	my $dbi = mysql_admin_db_connect( $vhffs );
 	return unless $dbi;
@@ -174,10 +174,10 @@
 
 sub _dump {
 	my $mysql = shift;
-	my $mysqlconf = $mysql->{main}->get_config->get_service('mysql');
+	my $mysqlconf = $mysql->get_vhffs->get_config->get_service('mysql');
 	return undef unless defined $mysqlconf;
 
-	my ( $tmpfile, $tmppath ) = Vhffs::Robots::tmpfile( $mysql->{main} );
+	my ( $tmpfile, $tmppath ) = Vhffs::Robots::tmpfile( $mysql->get_vhffs );
 	return undef unless defined $tmpfile;
 
 	my $ret;

Modified: trunk/vhffs-api/src/Vhffs/Robots/Pgsql.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Pgsql.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Robots/Pgsql.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -62,7 +62,7 @@
 	my $pgsql = shift;
 	return undef unless defined $pgsql and $pgsql->get_status == Vhffs::Constants::WAITING_FOR_CREATION;
 
-	my $vhffs = $pgsql->get_main;
+	my $vhffs = $pgsql->get_vhffs;
 
 	my $dbi = pgsql_admin_db_connect( $vhffs );
 	return unless $dbi;
@@ -95,7 +95,7 @@
 	my $pgsql = shift;
 	return undef unless defined $pgsql and $pgsql->get_status == Vhffs::Constants::WAITING_FOR_DELETION;
 
-	my $vhffs = $pgsql->get_main;
+	my $vhffs = $pgsql->get_vhffs;
 	my $pgsqlconfig = $vhffs->get_config->get_service('pgsql');
 
 	my $dbi = pgsql_admin_db_connect( $vhffs );
@@ -149,7 +149,7 @@
 	my $pgsql = shift;
 	return undef unless defined $pgsql and $pgsql->get_status == Vhffs::Constants::WAITING_FOR_MODIFICATION;
 
-	my $vhffs = $pgsql->get_main;
+	my $vhffs = $pgsql->get_vhffs;
 
 	my $dbi = pgsql_admin_db_connect( $vhffs );
 	return unless $dbi;
@@ -175,17 +175,17 @@
 
 sub _dump {
 	my $pg = shift;
-	my $pgsqlconf = $pg->{main}->get_config->get_service('pgsql');
+	my $pgsqlconf = $pg->get_vhffs->get_config->get_service('pgsql');
 	return undef unless defined $pgsqlconf;
 
 	# create the postgres password file
-	my ( $pgpassfile, $pgpasspath ) = Vhffs::Robots::tmpfile( $pg->{main} );
+	my ( $pgpassfile, $pgpasspath ) = Vhffs::Robots::tmpfile( $pg->get_vhffs );
 	return undef unless defined $pgpassfile;
 	chmod( 0400, $pgpasspath );
 	print $pgpassfile '*:*:*:*:'.$pgsqlconf->{'password'}."\n";
 	close $pgpassfile;
 
-	my ( $tmpfile, $tmppath ) = Vhffs::Robots::tmpfile( $pg->{main} );
+	my ( $tmpfile, $tmppath ) = Vhffs::Robots::tmpfile( $pg->get_vhffs );
 	unless( defined $tmpfile ) {
 		unlink $pgpasspath;
 		return undef;

Modified: trunk/vhffs-api/src/Vhffs/Robots/Repository.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Repository.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Robots/Repository.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -47,7 +47,7 @@
 	my $repository = shift;
 	return undef unless defined $repository and $repository->get_status == Vhffs::Constants::WAITING_FOR_CREATION;
 
-	my $vhffs = $repository->get_main;
+	my $vhffs = $repository->get_vhffs;
 	my $dir = $repository->get_dir;
 
 	if( -e $dir ) {
@@ -86,7 +86,7 @@
 	my $repository = shift;
 	return undef unless defined $repository and $repository->get_status == Vhffs::Constants::WAITING_FOR_DELETION;
 
-	my $vhffs = $repository->get_main;
+	my $vhffs = $repository->get_vhffs;
 	my $dir = $repository->get_dir;
 
 	unless( Vhffs::Robots::unlink_from_group( $repository, $repository->get_name.'-repository' ) ) {
@@ -129,7 +129,7 @@
 	my $repository = shift;
 	return undef unless defined $repository;
 
-	my $vhffs = $repository->get_main;
+	my $vhffs = $repository->get_vhffs;
 
 	my $dev = Quota::getqcarg($vhffs->get_config->get_datadir.'/repository');
 

Modified: trunk/vhffs-api/src/Vhffs/Robots/Svn.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Svn.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Robots/Svn.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -46,7 +46,7 @@
 	my $svn = shift;
 	return undef unless defined $svn and $svn->get_status == Vhffs::Constants::WAITING_FOR_CREATION;
 
-	my $vhffs = $svn->get_main;
+	my $vhffs = $svn->get_vhffs;
 	my $dir = $svn->get_dir;
 
 	if( -e $dir ) {
@@ -97,7 +97,7 @@
 	my $svn = shift;
 	return undef unless defined $svn and $svn->get_status == Vhffs::Constants::WAITING_FOR_DELETION;
 
-	my $vhffs = $svn->get_main;
+	my $vhffs = $svn->get_vhffs;
 	my $dir = $svn->get_dir;
 
 	Vhffs::Robots::archive_targz( $svn, $dir );
@@ -131,7 +131,7 @@
 	my $svn = shift;
 	return undef unless defined $svn and ( $svn->get_status == Vhffs::Constants::WAITING_FOR_MODIFICATION or $svn->get_status == Vhffs::Constants::WAITING_FOR_CREATION );
 
-	my $vhffs = $svn->get_main;
+	my $vhffs = $svn->get_vhffs;
 	my $dir = $svn->get_dir;
 
 	my $confpath = $dir.'/conf/svnserve.conf';
@@ -188,7 +188,7 @@
 	}
 
 	# Commit mail
-	my $svnconf = $svn->{'main'}->get_config->get_service('svn');
+	my $svnconf = $svn->get_vhffs->get_config->get_service('svn');
 	my $mailfrom = $svnconf->{'notify_from'};
 	my $mailto = $svn->{ml_name};
 	if( defined $mailfrom and defined $mailto )  {

Modified: trunk/vhffs-api/src/Vhffs/Robots/User.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/User.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Robots/User.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -47,7 +47,7 @@
 	my $user = shift;
 	return undef unless defined $user and $user->get_status == Vhffs::Constants::WAITING_FOR_CREATION;
 
-	my $vhffs = $user->get_main;
+	my $vhffs = $user->get_vhffs;
 	my $dir = $user->get_home;
 
 	if( -e $dir ) {
@@ -85,7 +85,7 @@
 	my $user = shift;
 	return undef unless defined $user and $user->get_status == Vhffs::Constants::WAITING_FOR_DELETION;
 
-	my $vhffs = $user->get_main;
+	my $vhffs = $user->get_vhffs;
 	my $dir = $user->get_home;
 
 	if( @{$user->get_groups} ) {
@@ -134,7 +134,7 @@
 	my $user = shift;
 	return undef unless defined $user;
 
-	my $vhffs = $user->get_main;
+	my $vhffs = $user->get_vhffs;
 
 	my $dev = Quota::getqcarg($vhffs->get_config->get_datadir);
 
@@ -175,7 +175,7 @@
 	my $path = shift;
 	return undef unless defined $user and defined $path and -d $path;
 
-	my $vhffs = $user->get_main;
+	my $vhffs = $user->get_vhffs;
 
 	my $dev = Quota::getqcarg($path);
 

Modified: trunk/vhffs-api/src/Vhffs/Robots/Web.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Web.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Robots/Web.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -45,7 +45,7 @@
 	my $web = shift;
 	return undef unless defined $web and $web->get_status == Vhffs::Constants::WAITING_FOR_CREATION;
 
-	my $vhffs = $web->get_main;
+	my $vhffs = $web->get_vhffs;
 	my $dir = $web->get_dir;
 
 	if( -e $dir ) {
@@ -86,7 +86,7 @@
 	my $web = shift;
 	return undef unless defined $web and $web->get_status == Vhffs::Constants::WAITING_FOR_DELETION;
 
-	my $vhffs = $web->get_main;
+	my $vhffs = $web->get_vhffs;
 	my $dir = $web->get_dir;
 
 	unless( Vhffs::Robots::unlink_from_group( $web, $web->get_servername.'-web' ) ) {

Modified: trunk/vhffs-api/src/Vhffs/Robots.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Robots.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -156,7 +156,7 @@
 	my $dir = shift;
 	return undef unless defined $object and defined $linkname and defined $dir;
 
-	my $vhffs = $object->get_main;
+	my $vhffs = $object->get_vhffs;
 	return 1 if $vhffs->get_config->use_vhffsfs;
 
 	my $linkpath = $object->get_group->get_dir.'/'.$linkname;
@@ -185,7 +185,7 @@
 	my $linkname = shift;
 	return undef unless defined $object and defined $linkname;
 
-	my $vhffs = $object->get_main;
+	my $vhffs = $object->get_vhffs;
 	return 1 if $vhffs->get_config->use_vhffsfs;
 
 	my $linkpath = $object->get_group->get_dir.'/'.$linkname;
@@ -217,7 +217,7 @@
 
 	return undef unless defined $object and defined $dir and -d $dir;
 
-	my $robotconf = $object->{main}->get_config->get_robots;
+	my $robotconf = $object->get_vhffs->get_config->get_robots;
 	return undef unless defined $robotconf and $robotconf->{'archive_deleted'} and defined $robotconf->{'archive_deleted_path'} and -d $robotconf->{'archive_deleted_path'};
 
 	my $oldcwd = getcwd();

Modified: trunk/vhffs-api/src/Vhffs/Services/Bazaar.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Bazaar.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Services/Bazaar.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -51,9 +51,9 @@
 }
 
 sub _new {
-	my ($class, $main, $bazaar_id, $reponame, $owner_uid, $owner_gid, $public, $ml_name, $oid, $date_creation, $description, $state) = @_;
+	my ($class, $vhffs, $bazaar_id, $reponame, $owner_uid, $owner_gid, $public, $ml_name, $oid, $date_creation, $description, $state) = @_;
 
-	my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_BAZAAR);
+	my $self = $class->SUPER::_new($vhffs, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_BAZAAR);
 	return undef unless(defined $self);
 
 	$self->{bazaar_id} = $bazaar_id;
@@ -65,20 +65,20 @@
 }
 
 sub create {
-	my ($main, $rname, $description, $user, $group) = @_;
+	my ($vhffs, $rname, $description, $user, $group) = @_;
 
 	return undef unless(defined($user) && defined($group));
 	return undef unless(check_name($rname));
 
 	my $bazaar;
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	local $dbh->{RaiseError} = 1;
 	local $dbh->{PrintError} = 0;
 	$dbh->begin_work;
 
 	eval {
-		my $parent = Vhffs::Object::create($main, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_BAZAAR);
+		my $parent = Vhffs::Object::create($vhffs, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_BAZAAR);
 
 		die('Unable to create parent object') unless(defined $parent);
 
@@ -87,7 +87,7 @@
 		$sth->execute($rname, $parent->get_oid) or return undef;
 
 		$dbh->commit;
-		$bazaar = get_by_reponame($main, $rname);
+		$bazaar = get_by_reponame($vhffs, $rname);
 	};
 
 	if($@) {
@@ -144,17 +144,17 @@
 }
 
 sub get_by_reponame($$) {
-	my ($main, $reponame) = @_;
+	my ($vhffs, $reponame) = @_;
 	my @params;
 
 	my $sql = 'SELECT b.bazaar_id, b.reponame, o.owner_uid, o.owner_gid, b.public, b.ml_name, o.object_id, o.date_creation, o.description, o.state
 		FROM vhffs_bazaar b INNER JOIN vhffs_object o ON o.object_id = b.object_id WHERE b.reponame = ?';
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 
 	return undef unless(@params = $dbh->selectrow_array($sql, undef, $reponame));
 
-	return _new Vhffs::Services::Bazaar($main, @params);
+	return _new Vhffs::Services::Bazaar($vhffs, @params);
 }
 
 sub commit {
@@ -217,7 +217,7 @@
 =cut
 sub get_base_dir {
 	my $self = shift;
-	return $self->{'main'}->get_config->get_datadir.'/bazaar/bazaarroot';
+	return $self->get_vhffs->get_config->get_datadir.'/bazaar/bazaarroot';
 }
 
 1;

Modified: trunk/vhffs-api/src/Vhffs/Services/Cron.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Cron.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Services/Cron.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -61,9 +61,9 @@
 }
 
 sub _new {
-	my ($class, $main, $cron_id, $cronpath, $interval, $reportmail, $lastrundate, $lastrunreturncode, $nextrundate, $running, $owner_uid, $owner_gid, $oid, $date_creation, $description, $state) = @_;
+	my ($class, $vhffs, $cron_id, $cronpath, $interval, $reportmail, $lastrundate, $lastrunreturncode, $nextrundate, $running, $owner_uid, $owner_gid, $oid, $date_creation, $description, $state) = @_;
 
-	my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_CRON);
+	my $self = $class->SUPER::_new($vhffs, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_CRON);
 	return undef unless(defined $self);
 
 	$self->{cron_id} = $cron_id;
@@ -82,7 +82,7 @@
 
 =head2 create
 
-	my $cron = Vhffs::Services::Cron::create($main, $rname, $description, $user, $group);
+	my $cron = Vhffs::Services::Cron::create($vhffs, $rname, $description, $user, $group);
 	die('Unable to create cron') unless(defined $cron);
 
 Creates a new cron job in database and return the corresponding
@@ -90,23 +90,23 @@
 
 =cut
 sub create {
-	my ($main, $cronpath, $interval, $reportmail, $description, $user, $group, ) = @_;
+	my ($vhffs, $cronpath, $interval, $reportmail, $description, $user, $group, ) = @_;
 
 	return undef unless ( defined $cronpath && defined $interval && defined $reportmail && defined $user && defined $group );
 	return undef unless check_cronpath($cronpath);
 	return undef unless Vhffs::Functions::valid_mail($reportmail);
 
-	my $mininterval = $main->get_config->get_service('cron')->{'minimum_interval'}*60;
+	my $mininterval = $vhffs->get_config->get_service('cron')->{'minimum_interval'}*60;
 	$interval = $mininterval if( $interval < $mininterval );
 
 	my $cron;
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	local $dbh->{RaiseError} = 1;
 	local $dbh->{PrintError} = 0;
 	$dbh->begin_work;
 
 	eval {
-		my $parent = Vhffs::Object::create($main, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_CRON);
+		my $parent = Vhffs::Object::create($vhffs, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_CRON);
 		die('Unable to create parent object') unless(defined $parent);
 
 		my $sql = 'INSERT INTO vhffs_cron(cronpath, interval, reportmail, running, object_id) VALUES(?, ?, ?, 0, ?)';
@@ -114,7 +114,7 @@
 		$sth->execute($cronpath, $interval, $reportmail, $parent->get_oid);
 
 		$dbh->commit;
-		$cron = get_by_cronpath($main, $cronpath);
+		$cron = get_by_cronpath($vhffs, $cronpath);
 	};
 
 	if($@) {
@@ -173,24 +173,24 @@
 
 =head2 get_by_cronpath
 
-	my $repo = Vhffs::Services::Cron::get_by_cronpath($main, $path);
+	my $repo = Vhffs::Services::Cron::get_by_cronpath($vhffs, $path);
 	die('Cron not found') unless(defined $path);
 
 Fetches an existing cron job.
 
 =cut
 sub get_by_cronpath($$) {
-	my ($main, $path) = @_;
+	my ($vhffs, $path) = @_;
 
 	my @params;
 
 	my $sql = 'SELECT c.cron_id, c.cronpath, c.interval, c.reportmail, c.lastrundate, c.lastrunreturncode, c.nextrundate, c.running, o.owner_uid, o.owner_gid, o.object_id, o.date_creation, o.description, o.state FROM vhffs_cron c
 		INNER JOIN vhffs_object o ON o.object_id = c.object_id WHERE c.cronpath = ?';
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	return undef unless(@params = $dbh->selectrow_array($sql, undef, $path));
 
-	return _new Vhffs::Services::Cron($main, @params);
+	return _new Vhffs::Services::Cron($vhffs, @params);
 }
 
 sub commit {
@@ -232,7 +232,7 @@
 
 sub set_interval {
 	my ($self, $value) = @_;
-	my $mininterval = $self->get_main->get_config->get_service('cron')->{'minimum_interval'}*60;
+	my $mininterval = $self->get_vhffs->get_config->get_service('cron')->{'minimum_interval'}*60;
 	$value = $mininterval if( $value < $mininterval );
 	$self->{'interval'} = $value;
 	return 0;

Modified: trunk/vhffs-api/src/Vhffs/Services/Cvs.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Cvs.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Services/Cvs.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -71,9 +71,9 @@
 }
 
 sub _new {
-	my ($class, $main, $cvs_id, $cvsroot, $owner_uid, $owner_gid, $public, $oid, $date_creation, $description, $state) = @_;
+	my ($class, $vhffs, $cvs_id, $cvsroot, $owner_uid, $owner_gid, $public, $oid, $date_creation, $description, $state) = @_;
 
-	my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_CVS);
+	my $self = $class->SUPER::_new($vhffs, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_CVS);
 	return undef unless(defined $self);
 
 	$self->{cvsroot} = $cvsroot;
@@ -86,25 +86,25 @@
 
 =head2 create
 
-	my $cvs = Vhffs::Services::Cvs::create($main, $cvsroot, $description, $user, $group);
+	my $cvs = Vhffs::Services::Cvs::create($vhffs, $cvsroot, $description, $user, $group);
 	die("Unable to create cvs\n") unless($cvs);
 
 Creates a new CVS service in database and returns the corresponding fully functional object.
 
 =cut
 sub create {
-	my ($main, $cvsroot, $description, $user, $group) = @_;
+	my ($vhffs, $cvsroot, $description, $user, $group) = @_;
 	return undef unless(defined($user) && defined($group));
 	return undef unless(check_name($cvsroot));
 
 	my $cvs;
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	local $dbh->{RaiseError} = 1;
 	local $dbh->{PrintError} = 0;
 	$dbh->begin_work;
 	eval {
 
-		my $parent = Vhffs::Object::create($main, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_CVS);
+		my $parent = Vhffs::Object::create($vhffs, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_CVS);
 
 		die('Unable to create parent object') unless(defined($parent));
 
@@ -113,7 +113,7 @@
 		$sth->execute($cvsroot, $parent->get_oid);
 
 		$dbh->commit;
-		$cvs = get_by_reponame($main, $cvsroot);
+		$cvs = get_by_reponame($vhffs, $cvsroot);
 	};
 
 	if($@) {
@@ -170,14 +170,14 @@
 }
 
 sub get_by_reponame {
-	my($main, $cvsroot) = @_;
+	my($vhffs, $cvsroot) = @_;
 	my $sql = 'SELECT c.cvs_id, c.cvsroot, o.owner_uid, o.owner_gid, c.public, c.object_id, o.date_creation, o.description, o.state FROM vhffs_cvs c
 		INNER JOIN vhffs_object o ON c.object_id = o.object_id WHERE c.cvsroot = ?';
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	my @params;
 	return undef unless(@params = $dbh->selectrow_array($sql, undef, $cvsroot));
 
-	return _new Vhffs::Services::Cvs($main, @params);
+	return _new Vhffs::Services::Cvs($vhffs, @params);
 }
 
 sub commit {
@@ -245,7 +245,7 @@
 =cut
 sub get_base_dir {
 	my $self = shift;
-	return $self->{'main'}->get_config->get_datadir.'/cvs/cvsroot';
+	return $self->get_vhffs->get_config->get_datadir.'/cvs/cvsroot';
 }
 
 1;

Modified: trunk/vhffs-api/src/Vhffs/Services/DNS.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/DNS.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Services/DNS.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -57,9 +57,9 @@
 }
 
 sub _new {
-	my ($class, $main, $dns_id, $domain, $owner_gid, $ns, $mbox, $serial, $refresh, $retry, $expire, $minimum, $ttl, $oid, $owner_uid, $date_creation, $state, $description, $a, $nsr, $cname, $mx, $srv, $aaaa, $txt) = @_;
+	my ($class, $vhffs, $dns_id, $domain, $owner_gid, $ns, $mbox, $serial, $refresh, $retry, $expire, $minimum, $ttl, $oid, $owner_uid, $date_creation, $state, $description, $a, $nsr, $cname, $mx, $srv, $aaaa, $txt) = @_;
 
-	my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_DNS);
+	my $self = $class->SUPER::_new($vhffs, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_DNS);
 
 	$self->{dns_id} = $dns_id;
 	$self->{domain} = $domain;
@@ -86,7 +86,7 @@
 
 =head2 create
 
-	my $dns = Vhffs::Services::DNS::create($main, $domain, $description, $user, $group);
+	my $dns = Vhffs::Services::DNS::create($vhffs, $domain, $description, $user, $group);
 	die('Unable to create DNS') unless(defined $dns);
 
 Create a new DNS in database and returns the corresponding object.
@@ -94,16 +94,16 @@
 
 =cut
 sub create {
-	my($main, $domain, $description, $user, $group) = @_;
+	my($vhffs, $domain, $description, $user, $group) = @_;
 
-	my $conf = $main->get_config->get_service('dns');
+	my $conf = $vhffs->get_config->get_service('dns');
 	return undef unless defined $conf;
 
 
 	return undef unless(defined($user) && defined($group));
 	return undef unless(Vhffs::Functions::check_domain_name($domain));
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	local $dbh->{RaiseError} = 1;
 	local $dbh->{PrintError} = 0;
 	$dbh->begin_work;
@@ -111,7 +111,7 @@
 
 	eval {
 
-		my $parent = Vhffs::Object::create($main, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_DNS);
+		my $parent = Vhffs::Object::create($vhffs, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_DNS);
 
 		die('Unable to create parent object') unless(defined $parent);
 
@@ -126,7 +126,7 @@
 			$conf->{init}->{soa}->{refresh}, $conf->{init}->{soa}->{retry}, $conf->{init}->{soa}->{expire}, $conf->{init}->{soa}->{minimum}, $conf->{init}->{soa}->{ttl} );
 
 		$dbh->commit;
-		$self = get_by_domainname($main, $domain);
+		$self = get_by_domainname($vhffs, $domain);
 	};
 
 	# Something went wrong, let's cancel everything
@@ -301,7 +301,7 @@
 
 =head2 get_by_domainname
 
-	my $dns = Vhffs::Services::DNS::get_by_domainname($main, $domainname);
+	my $dns = Vhffs::Services::DNS::get_by_domainname($vhffs, $domainname);
 	die('Domain not found') unless(defined $dns);
 
 Fetches the DNS object whose domainname is $domainname. Returned object is fully
@@ -310,18 +310,18 @@
 
 =cut
 sub get_by_domainname($$) {
-	my ($main, $name) = @_;
+	my ($vhffs, $name) = @_;
 
 	my $sql = 'SELECT d.dns_id, d.domain, o.owner_gid, d.ns, d.mbox, d.serial, d.refresh, d.retry, d.expire, d.minimum, d.ttl, o.object_id, o.owner_uid, o.date_creation, o.state, o.description FROM vhffs_dns d INNER JOIN vhffs_object o ON o.object_id = d.object_id WHERE d.domain = ?';
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	my @params;
 	return undef unless(@params = $dbh->selectrow_array($sql, undef, $name));
 	my $dns_id = $params[0];
 
 	push @params, fetch_records($dbh, $dns_id);
 
-	return _new Vhffs::Services::DNS($main, @params);
+	return _new Vhffs::Services::DNS($vhffs, @params);
 }
 
 =pod
@@ -437,7 +437,7 @@
 	return -2 if ( $self->name_exists( $name, 'A', 'CNAME' ) != 0 );
 
 	unless( defined $ip ) {
-		my $dnsconfig = $self->{'main'}->get_config->get_service('dns');
+		my $dnsconfig = $self->get_vhffs->get_config->get_service('dns');
 		if( defined $dnsconfig->{'default_a'} ) {
 		    $ip = $dnsconfig->{'default_a'};
 		} else {
@@ -649,7 +649,7 @@
 	return -2 if ( $self->name_exists( $name, 'CNAME', 'AAAA' ) != 0 );
 
 	unless( defined $ip ) {
-		my $dnsconfig = $self->{'main'}->get_config->get_service('dns');
+		my $dnsconfig = $self->get_vhffs->get_config->get_service('dns');
 		if( defined $dnsconfig->{'default_aaaa'} ) {
 		    $ip = $dnsconfig->{'default_aaaa'};
 		} else {
@@ -839,7 +839,7 @@
 	my $self = shift;
 	return -1 unless ( defined $self && defined $self->{'dns_id'} );
 
-	my $conf = $self->{'main'}->get_config->get_service('dns');
+	my $conf = $self->get_vhffs->get_config->get_service('dns');
 	return -1 unless defined $conf;
 
 	#Update the serial to refresh the domain

Modified: trunk/vhffs-api/src/Vhffs/Services/Git.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Git.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Services/Git.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -52,9 +52,9 @@
 }
 
 sub _new {
-	my ($class, $main, $git_id, $reponame, $owner_uid, $owner_gid, $public, $ml_name, $oid, $date_creation, $description, $state) = @_;
+	my ($class, $vhffs, $git_id, $reponame, $owner_uid, $owner_gid, $public, $ml_name, $oid, $date_creation, $description, $state) = @_;
 
-	my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_GIT);
+	my $self = $class->SUPER::_new($vhffs, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_GIT);
 	return undef unless(defined $self);
 
 	$self->{git_id} = $git_id;
@@ -66,20 +66,20 @@
 }
 
 sub create {
-	my ($main, $rname, $description, $user, $group) = @_;
+	my ($vhffs, $rname, $description, $user, $group) = @_;
 
 	return undef unless(defined($user) && defined($group));
 	return undef unless(check_name($rname));
 
 	my $git;
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	local $dbh->{RaiseError} = 1;
 	local $dbh->{PrintError} = 0;
 	$dbh->begin_work;
 
 	eval {
-		my $parent = Vhffs::Object::create($main, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_GIT);
+		my $parent = Vhffs::Object::create($vhffs, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_GIT);
 
 		die('Unable to create parent object') unless(defined $parent);
 
@@ -88,7 +88,7 @@
 		$sth->execute($rname, $parent->get_oid) or return undef;
 
 		$dbh->commit;
-		$git = get_by_reponame($main, $rname);
+		$git = get_by_reponame($vhffs, $rname);
 	};
 
 	if($@) {
@@ -146,17 +146,17 @@
 }
 
 sub get_by_reponame($$) {
-	my ($main, $reponame) = @_;
+	my ($vhffs, $reponame) = @_;
 	my @params;
 
 	my $sql = 'SELECT g.git_id, g.reponame, o.owner_uid, o.owner_gid, g.public, g.ml_name, o.object_id, o.date_creation, o.description, o.state FROM vhffs_git g
 		INNER JOIN vhffs_object o ON o.object_id = g.object_id WHERE g.reponame = ?';
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 
 	return undef unless(@params = $dbh->selectrow_array($sql, undef, $reponame));
 
-	return _new Vhffs::Services::Git($main, @params);
+	return _new Vhffs::Services::Git($vhffs, @params);
 }
 
 sub commit {
@@ -219,7 +219,7 @@
 =cut
 sub get_base_dir {
 	my $self = shift;
-	return $self->{'main'}->get_config->get_datadir.'/git/gitroot';
+	return $self->get_vhffs->get_config->get_datadir.'/git/gitroot';
 }
 
 1;

Modified: trunk/vhffs-api/src/Vhffs/Services/Mail.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Mail.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Services/Mail.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -87,8 +87,8 @@
 }
 
 sub _new {
-	my ($class, $main, $mxdomain_id, $owner_gid, $domain, $boxes_path, $catchall, $oid, $owner_uid, $date_creation, $state, $description, $boxes, $forwards) = @_;
-	my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_MAIL);
+	my ($class, $vhffs, $mxdomain_id, $owner_gid, $domain, $boxes_path, $catchall, $oid, $owner_uid, $date_creation, $state, $description, $boxes, $forwards) = @_;
+	my $self = $class->SUPER::_new($vhffs, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_MAIL);
 	return undef unless defined($self);
 
 	$self->{mxdomain_id} = $mxdomain_id;
@@ -105,24 +105,24 @@
 
 =head2 create
 
-	my $mail = Vhffs::Services::Mail::create($main, $domain, $description, $user, $group);
+	my $mail = Vhffs::Services::Mail::create($vhffs, $domain, $description, $user, $group);
 
 Create a new domain mail in database and return corresponding object.
 
 =cut
 sub create {
-	my ($main, $domain, $description, $user, $group) = @_;
+	my ($vhffs, $domain, $description, $user, $group) = @_;
 	return undef unless(defined($user) && defined($group));
 	return undef unless(Vhffs::Functions::check_domain_name($domain));
 
 	my $mail;
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	local $dbh->{RaiseError} = 1;
 	local $dbh->{PrintError} = 0;
 	$dbh->begin_work;
 
 	eval {
-		my $parent = Vhffs::Object::create($main, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_MAIL);
+		my $parent = Vhffs::Object::create($vhffs, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_MAIL);
 
 		die('Unable to create parent object') unless(defined $parent);
 
@@ -132,7 +132,7 @@
 		$sth->execute($domain, $domain_hash, $parent->get_oid);
 
 		$dbh->commit;
-		$mail = get_by_mxdomain($main, $domain);
+		$mail = get_by_mxdomain($vhffs, $domain);
 	};
 
 	if($@) {
@@ -197,17 +197,17 @@
 
 =head2 get_by_mxdomain
 
-	my $mail = Vhffs::Services::get_by_mxdomain($main, $domain);
+	my $mail = Vhffs::Services::get_by_mxdomain($vhffs, $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) = @_;
+	my ($vhffs, $domain) = @_;
 
 	my $sql = 'SELECT m.mxdomain_id, o.owner_gid, m.domain, m.boxes_path, m.catchall, o.object_id, o.owner_uid, o.date_creation, o.state, o.description FROM vhffs_mxdomain m INNER JOIN vhffs_object o ON o.object_id = m.object_id WHERE domain = ?';
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	my @params;
 	return undef unless(@params = $dbh->selectrow_array($sql, undef, $domain));
 
@@ -215,7 +215,7 @@
 	my $boxes = fetch_boxes($dbh, $domain);
 	my $forwards = fetch_forwards($dbh, $domain);
 
-	return _new Vhffs::Services::Mail($main, @params, $boxes, $forwards);
+	return _new Vhffs::Services::Mail($vhffs, @params, $boxes, $forwards);
 }
 
 =head2 fetch_boxes
@@ -274,7 +274,7 @@
 	my $self = shift;
 
 	return undef unless defined $self;
-	return( $self->{'main'}->get_config->get_datadir . '/mail/boxes/' . $self->{'boxes_path'} );
+	return( $self->get_vhffs->get_config->get_datadir . '/mail/boxes/' . $self->{'boxes_path'} );
 }
 
 sub change_forward {
@@ -472,7 +472,7 @@
 	my $local_part = shift;
 	return undef unless defined $self and defined $local_part and defined $self->{'boxes'}{$local_part};
 
-	return( $self->{'main'}->get_config->get_datadir . '/mail/boxes/' . $self->{'boxes_path'} . '/' . $self->{'boxes'}{$local_part}{'mbox_name'} );
+	return( $self->get_vhffs->get_config->get_datadir . '/mail/boxes/' . $self->{'boxes_path'} . '/' . $self->{'boxes'}{$local_part}{'mbox_name'} );
 }
 
 =pod
@@ -492,7 +492,7 @@
 	return -1 unless(defined($name) && defined($remote) && $name =~ /^[a-z0-9\_\-\.]+$/ && Vhffs::Functions::valid_mail( $remote ) );
 	return -2 if( defined $self->{'forward'}{$name}
 		||  ( defined $self->{'boxes'}{$name}  &&  $self->{'boxes'}{$name}{'state'} != Vhffs::Constants::WAITING_FOR_DELETION )
-		||  Vhffs::Services::MailingList::address_exists($self->get_main, $name, $self->{domain}) );
+		||  Vhffs::Services::MailingList::address_exists($self->get_vhffs, $name, $self->{domain}) );
 
 	my $sql = 'INSERT INTO vhffs_forward(domain, local_part, remote_name, password) VALUES(?, ?, ?, \'x\')';
 	my $dbh = $self->get_db;
@@ -524,7 +524,7 @@
 
 	return -1 unless( defined($password)  &&  defined($name)  &&  $name =~ /^[a-z0-9\_\-\.]+$/ );
 	return -2 if( ( defined ( $self->{'boxes'}{$name} ) ) || ( defined( $self->{'forward'}{$name} ) )
-		|| Vhffs::Services::MailingList::address_exists($self->get_main, $name, $self->{domain}) );
+		|| Vhffs::Services::MailingList::address_exists($self->get_vhffs, $name, $self->{domain}) );
 
 	$password = crypt_pwd( $password );
 	my $domainhash = $self->{boxes_path};

Modified: trunk/vhffs-api/src/Vhffs/Services/MailGroup.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/MailGroup.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Services/MailGroup.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -62,7 +62,7 @@
 	return undef unless defined $mail_service;
 
 	my $this = {};
-	$this->{main} = $vhffs;
+	$this->{vhffs} = $vhffs;
 	$this->{config} = $config;
 	$this->{group} = $group;
 	$this->{localpart} = $group->get_groupname;

Modified: trunk/vhffs-api/src/Vhffs/Services/MailUser.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/MailUser.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Services/MailUser.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -64,7 +64,7 @@
 	return undef unless( not $config->{groupneeded} or $user->have_activegroups > 0 or $mail_service->exists($user->get_username) );
 
 	my $this = {};
-	$this->{main} = $vhffs;
+	$this->{vhffs} = $vhffs;
 	$this->{config} = $config;
 	$this->{user} = $user;
 	$this->{localpart} = $user->get_username;

Modified: trunk/vhffs-api/src/Vhffs/Services/MailingList.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/MailingList.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Services/MailingList.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -56,9 +56,9 @@
 use DBI;
 
 sub _new {
-	my ($class, $main, $ml_id, $local_part, $domain, $prefix, $owner_gid, $open_archive, $reply_to, $sub_ctrl, $post_ctrl, $signature, $oid, $owner_uid, $date_creation, $state, $description, $subs) = @_;
+	my ($class, $vhffs, $ml_id, $local_part, $domain, $prefix, $owner_gid, $open_archive, $reply_to, $sub_ctrl, $post_ctrl, $signature, $oid, $owner_uid, $date_creation, $state, $description, $subs) = @_;
 
-	my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_ML);
+	my $self = $class->SUPER::_new($vhffs, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_ML);
 	return undef unless defined($self);
 
 	$self->{ml_id} = $ml_id;
@@ -88,16 +88,16 @@
 
 =cut
 sub create {
-	my ($main, $local, $domain, $description, $user, $group) = @_;
+	my ($vhffs, $local, $domain, $description, $user, $group) = @_;
 
 	return undef unless(defined $user && defined $group);
 	return undef unless($local =~ /^[a-z0-9\_\-]+$/);
 	return undef unless(Vhffs::Functions::check_domain_name($domain));
-	return undef if(Vhffs::Services::Mail::address_exists($main, $local, $domain));
+	return undef if(Vhffs::Services::Mail::address_exists($vhffs, $local, $domain));
 
 	my $ml;
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	local $dbh->{RaiseError} = 1;
 	local $dbh->{PrintError} = 0;
 	$dbh->begin_work;
@@ -105,10 +105,10 @@
 	eval {
 		# Group must be the mail domain owner or use default mail domain.
 		my $sql = 'SELECT mxdomain_id FROM vhffs_mxdomain m INNER JOIN vhffs_object o ON o.object_id = m.object_id WHERE m.domain = ? AND o.owner_gid = ?';
-		die('Mail domain not found') unless($domain eq $main->get_config()->get_service('mailinglist')->{'default_domain'} ||
+		die('Mail domain not found') unless($domain eq $vhffs->get_config()->get_service('mailinglist')->{'default_domain'} ||
 			$dbh->do($sql, undef, $domain, $group->get_gid) > 0);
 
-		my $parent = Vhffs::Object::create($main, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_ML);
+		my $parent = Vhffs::Object::create($vhffs, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_ML);
 		die('Unable to create parent object') unless(defined $parent);
 
 	# open sub, post members only
@@ -116,7 +116,7 @@
 		my $sth = $dbh->prepare($sql);
 		$sth->execute($local, $domain, $local, $parent->get_oid, Vhffs::Constants::ML_SUBSCRIBE_NO_APPROVAL_REQUIRED, Vhffs::Constants::ML_POSTING_MEMBERS_ONLY);
 		$dbh->commit;
-		$ml = get_by_mladdress($main, $local, $domain);
+		$ml = get_by_mladdress($vhffs, $local, $domain);
 	};
 
 	if($@) {
@@ -184,23 +184,23 @@
 
 =head2 get_by_mladdress
 
-	my $ml = Vhffs::Services::MailingList::get_by_mladdress($main, $local_part, $domain);
+	my $ml = Vhffs::Services::MailingList::get_by_mladdress($vhffs, $local_part, $domain);
 	die("Mailing list $localpart\@$domain not found\n") unless(defined $ml);
 
 Fetches the mailing list $local_part@$domain.
 
 =cut
 sub get_by_mladdress {
-	my ($main, $local, $domain) = @_;
+	my ($vhffs, $local, $domain) = @_;
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	my $sql = 'SELECT ml.ml_id, ml.local_part, ml.domain, ml.prefix, o.owner_gid, ml.open_archive, ml.reply_to, ml.sub_ctrl, ml.post_ctrl, ml.signature, o.object_id, o.owner_uid, o.date_creation, o.state, o.description FROM vhffs_ml ml INNER JOIN vhffs_object o ON o.object_id = ml.object_id WHERE domain = ? and local_part = ?';
 	my $sth = $dbh->prepare($sql);
 	return undef unless ($sth->execute($domain, $local) > 0);
 	my @params = $sth->fetchrow_array;
 
 	push @params, fetch_subs($dbh, $params[0]);
-	return _new Vhffs::Services::MailingList($main, @params);
+	return _new Vhffs::Services::MailingList($vhffs, @params);
 }
 
 =head2 fetch_subs
@@ -372,19 +372,19 @@
 }
 
 sub get_language_for_sub {
-	my ($main, $sub) = @_;
+	my ($vhffs, $sub) = @_;
 
 	my $sql = 'SELECT language FROM vhffs_ml_subscribers WHERE member = ?';
-	my $lang = $main->get_db->selectrow_array($sql, undef, $sub);
+	my $lang = $vhffs->get_db->selectrow_array($sql, undef, $sub);
 	return $lang;
 }
 
 sub set_language_for_sub {
-	my ($main, $sub, $language) = @_;
+	my ($vhffs, $sub, $language) = @_;
 
 	$language = 'en_US' unless( $language =~ /^\w+$/ );
 	my $sql = 'UPDATE vhffs_ml_subscribers SET language = ? WHERE member = ?';
-	$main->get_db->do($sql, undef, $language, $sub) or return -1;
+	$vhffs->get_db->do($sql, undef, $language, $sub) or return -1;
 }
 
 sub get_localpart {

Modified: trunk/vhffs-api/src/Vhffs/Services/Mercurial.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Mercurial.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Services/Mercurial.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -51,9 +51,9 @@
 }
 
 sub _new {
-	my ($class, $main, $mercurial_id, $reponame, $owner_uid, $owner_gid, $public, $ml_name, $oid, $date_creation, $description, $state) = @_;
+	my ($class, $vhffs, $mercurial_id, $reponame, $owner_uid, $owner_gid, $public, $ml_name, $oid, $date_creation, $description, $state) = @_;
 
-	my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_MERCURIAL);
+	my $self = $class->SUPER::_new($vhffs, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_MERCURIAL);
 	return undef unless(defined $self);
 
 	$self->{mercurial_id} = $mercurial_id;
@@ -65,20 +65,20 @@
 }
 
 sub create {
-	my ($main, $rname, $description, $user, $group) = @_;
+	my ($vhffs, $rname, $description, $user, $group) = @_;
 
 	return undef unless(defined($user) && defined($group));
 	return undef unless(check_name($rname));
 
 	my $mercurial;
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	local $dbh->{RaiseError} = 1;
 	local $dbh->{PrintError} = 0;
 	$dbh->begin_work;
 
 	eval {
-		my $parent = Vhffs::Object::create($main, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_MERCURIAL);
+		my $parent = Vhffs::Object::create($vhffs, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_MERCURIAL);
 
 		die('Unable to create parent object') unless(defined $parent);
 
@@ -87,7 +87,7 @@
 		$sth->execute($rname, $parent->get_oid) or return undef;
 
 		$dbh->commit;
-		$mercurial = get_by_reponame($main, $rname);
+		$mercurial = get_by_reponame($vhffs, $rname);
 	};
 
 	if($@) {
@@ -145,17 +145,17 @@
 }
 
 sub get_by_reponame($$) {
-	my ($main, $reponame) = @_;
+	my ($vhffs, $reponame) = @_;
 	my @params;
 
 	my $sql = 'SELECT m.mercurial_id, m.reponame, o.owner_uid, o.owner_gid, m.public, m.ml_name, o.object_id, o.date_creation, o.description, o.state FROM vhffs_mercurial m
 		INNER JOIN vhffs_object o ON o.object_id = m.object_id WHERE m.reponame = ?';
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 
 	return undef unless(@params = $dbh->selectrow_array($sql, undef, $reponame));
 
-	return _new Vhffs::Services::Mercurial($main, @params);
+	return _new Vhffs::Services::Mercurial($vhffs, @params);
 }
 
 sub commit {
@@ -218,7 +218,7 @@
 =cut
 sub get_base_dir {
 	my $self = shift;
-	return $self->{'main'}->get_config->get_datadir.'/mercurial/mercurialroot';
+	return $self->get_vhffs->get_config->get_datadir.'/mercurial/mercurialroot';
 }
 
 1;

Modified: trunk/vhffs-api/src/Vhffs/Services/Mysql.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Mysql.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Services/Mysql.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -95,8 +95,8 @@
 }
 
 sub _new {
-	my ($class, $main, $mysql_id, $owner_gid, $dbname, $dbuser, $dbpass, $oid, $owner_uid, $date_creation, $state, $description) = @_;
-	my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_MYSQL);
+	my ($class, $vhffs, $mysql_id, $owner_gid, $dbname, $dbuser, $dbpass, $oid, $owner_uid, $date_creation, $state, $description) = @_;
+	my $self = $class->SUPER::_new($vhffs, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_MYSQL);
 	return undef unless(defined $self);
 
 	$self->{mysql_id} = $mysql_id;
@@ -110,33 +110,33 @@
 
 =head2 create
 
-	my $mysql = Vhffs::Services::Mysql::create($main, $dbname, $dbuser, $dbpass, $description, $user, $group);
+	my $mysql = Vhffs::Services::Mysql::create($vhffs, $dbname, $dbuser, $dbpass, $description, $user, $group);
 	die("Unable to create MySQL service $dbname\n") unless(defined $mysql);
 
 Creates a new MySQL service in VHFFS database and returns the fully functional object.
 
 =cut
 sub create {
-	my ($main, $dbname, $dbuser, $dbpass, $description, $user, $group) = @_;
+	my ($vhffs, $dbname, $dbuser, $dbpass, $description, $user, $group) = @_;
 	return undef unless(defined($user) && defined($group));
 	return undef unless(check_dbname($dbname) && check_dbpass($dbpass) && check_dbuser($dbuser));
 
 	my $mysql;
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	local $dbh->{RaiseError} = 1;
 	local $dbh->{PrintError} = 0;
 	$dbh->begin_work;
 
 	eval {
 
-		my $parent = Vhffs::Object::create($main, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_MYSQL);
+		my $parent = Vhffs::Object::create($vhffs, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_MYSQL);
 		die('Unable to create parent object') unless defined ($parent);
 
 		my $sth = $dbh->prepare( 'INSERT INTO vhffs_mysql(dbname, dbuser, dbpass, object_id) VALUES(?, ?, ?, ?)' );
 		$sth->execute($dbname, $dbuser, $dbpass, $parent->get_oid);
 
 		$dbh->commit;
-		$mysql = get_by_dbname($main, $dbname);
+		$mysql = get_by_dbname($vhffs, $dbname);
 	};
 
 	if($@) {
@@ -197,7 +197,7 @@
 
 =head2 get_by_dbname
 
-	my $mysql = Vhffs::Services::Mysql::get_by_dbname($main, $dbname);
+	my $mysql = Vhffs::Services::Mysql::get_by_dbname($vhffs, $dbname);
 	die("MySQL service $dbname not found\n") unless(defined $mysql);
 
 Fetches the MySQL service $dbname.

Modified: trunk/vhffs-api/src/Vhffs/Services/Newsletter.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Newsletter.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Services/Newsletter.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -68,7 +68,7 @@
 	return undef unless defined $mailinglist_service;
 
 	my $this = {};
-	$this->{main} = $vhffs;
+	$this->{vhffs} = $vhffs;
 	$this->{config} = $config;
 	$this->{user} = $user;
 	$this->{collectmode} = ACTIVE_OPTIN;

Modified: trunk/vhffs-api/src/Vhffs/Services/Pgsql.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Pgsql.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Services/Pgsql.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -98,8 +98,8 @@
 }
 
 sub _new {
-	my ($class, $main, $pgsql_id, $owner_gid, $dbname, $dbuser, $dbpass, $oid, $owner_uid, $date_creation, $state, $description) = @_;
-	my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_PGSQL);
+	my ($class, $vhffs, $pgsql_id, $owner_gid, $dbname, $dbuser, $dbpass, $oid, $owner_uid, $date_creation, $state, $description) = @_;
+	my $self = $class->SUPER::_new($vhffs, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_PGSQL);
 	return undef unless(defined $self);
 
 	$self->{pgsql_id} = $pgsql_id;
@@ -113,26 +113,26 @@
 
 =head2 create
 
-	my $psql = Vhffs::Services::Pgsql::create($main, $dbname, $dbuser, $dbpass, $description, $user, $group);
+	my $psql = Vhffs::Services::Pgsql::create($vhffs, $dbname, $dbuser, $dbpass, $description, $user, $group);
 	die("Unable to create Postgre Service\n") unless(defined $psql);
 
 Create a new Postgres services and return the corresponding fully functional object.
 
 =cut
 sub create {
-	my ($main, $dbname, $dbuser, $dbpass, $description, $user, $group) = @_;
+	my ($vhffs, $dbname, $dbuser, $dbpass, $description, $user, $group) = @_;
 	return undef unless(defined($user) && defined($group));
 	return undef unless(check_dbname($dbname) && check_dbpass($dbpass) && check_dbuser($dbuser));
 
 	my $pg;
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	local $dbh->{RaiseError} = 1;
 	local $dbh->{PrintError} = 0;
 	$dbh->begin_work;
 
 	eval {
 
-		my $parent = Vhffs::Object::create($main, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_PGSQL);
+		my $parent = Vhffs::Object::create($vhffs, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_PGSQL);
 		die('Unable to create parent object') unless defined ($parent);
 
 		my $sql = 'INSERT INTO vhffs_pgsql(dbname, dbuser, dbpass, object_id) VALUES(?, ?, ?, ?)';
@@ -140,7 +140,7 @@
 		$sth->execute($dbname, $dbuser, $dbpass, $parent->get_oid);
 
 		$dbh->commit;
-		$pg = get_by_dbname($main, $dbname);
+		$pg = get_by_dbname($vhffs, $dbname);
 	};
 
 	if($@) {
@@ -201,7 +201,7 @@
 
 =head2 get_by_dbname
 
-	my $pg = Vhffs::Services::Pgsql::get_by_dbname($main, $dbname);
+	my $pg = Vhffs::Services::Pgsql::get_by_dbname($vhffs, $dbname);
 	die("No database with this name") unless(defined $pg);
 
 Fetches the pg database whose name is C<$dbname>.

Modified: trunk/vhffs-api/src/Vhffs/Services/Repository.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Repository.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Services/Repository.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -61,9 +61,9 @@
 }
 
 sub _new {
-	my ($class, $main, $repository_id, $name, $owner_uid, $owner_gid, $quota, $quota_used, $oid, $date_creation, $description, $state) = @_;
+	my ($class, $vhffs, $repository_id, $name, $owner_uid, $owner_gid, $quota, $quota_used, $oid, $date_creation, $description, $state) = @_;
 
-	my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_REPOSITORY);
+	my $self = $class->SUPER::_new($vhffs, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_REPOSITORY);
 	return undef unless defined $self;
 
 	$self->{repository_id} = $repository_id;
@@ -78,7 +78,7 @@
 
 =head2 create
 
-	my $repo = Vhffs::Services::Repository::create($main, $rname, $description, $user, $group);
+	my $repo = Vhffs::Services::Repository::create($vhffs, $rname, $description, $user, $group);
 	die('Unable to create repository) unless(defined $repo);
 
 Creates a new download repository in database and return the corresponding
@@ -86,24 +86,24 @@
 
 =cut
 sub create {
-	my ($main, $rname, $description, $user, $group) = @_;
+	my ($vhffs, $rname, $description, $user, $group) = @_;
 	return undef unless defined $user and defined $group;
 	return undef unless check_name($rname);
 
 	my $repo;
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	local $dbh->{RaiseError} = 1;
 	local $dbh->{PrintError} = 0;
 	$dbh->begin_work;
 
 	eval {
-		my $parent = Vhffs::Object::create($main, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_REPOSITORY);
+		my $parent = Vhffs::Object::create($vhffs, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_REPOSITORY);
 		die('Unable to create parent object') unless(defined $parent);
 
 		my $sql = 'INSERT INTO vhffs_repository(name, quota, quota_used, object_id) VALUES(?, ?, 0, ?)';
 
 		#Quota
-		my $config = $main->get_config()->get_service('repository');
+		my $config = $vhffs->get_config()->get_service('repository');
 		my $quota = $config->{'default_quota'} if defined($config);
 		$quota = 100 unless defined $quota;
 
@@ -111,7 +111,7 @@
 		$sth->execute($rname, $quota, $parent->get_oid);
 
 		$dbh->commit;
-		$repo =  get_by_reponame($main, $rname);
+		$repo =  get_by_reponame($vhffs, $rname);
 	};
 
 	if($@) {
@@ -171,23 +171,23 @@
 
 =head2 get_by_reponame
 
-	my $repo = Vhffs::Services::Repository::get_by_reponame($main, $name);
+	my $repo = Vhffs::Services::Repository::get_by_reponame($vhffs, $name);
 	die('Repository not found') unless(defined $repo);
 
 Fetches an existing repository.
 
 =cut
 sub get_by_reponame($$) {
-	my ($main, $name) = @_;
+	my ($vhffs, $name) = @_;
 
 	my @params;
 
 	my $sql = 'SELECT r.repository_id, r.name, o.owner_uid, o.owner_gid, r.quota, r.quota_used, o.object_id, o.date_creation, o.description, o.state FROM vhffs_repository r INNER JOIN vhffs_object o ON o.object_id = r.object_id WHERE r.name = ?';
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	return undef unless(@params = $dbh->selectrow_array($sql, undef, $name));
 
-	return _new Vhffs::Services::Repository($main, @params);
+	return _new Vhffs::Services::Repository($vhffs, @params);
 }
 
 sub commit {
@@ -232,7 +232,7 @@
 
 sub get_dir {
 	my $self = shift;
-	return $self->{'main'}->get_config->get_datadir.'/repository/'.$self->get_name;
+	return $self->get_vhffs->get_config->get_datadir.'/repository/'.$self->get_name;
 }
 
 1;

Modified: trunk/vhffs-api/src/Vhffs/Services/Svn.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Svn.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Services/Svn.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -53,9 +53,9 @@
 }
 
 sub _new {
-	my ($class, $main, $svn_id, $reponame, $owner_uid, $owner_gid, $public, $ml_name, $oid, $date_creation, $description, $state) = @_;
+	my ($class, $vhffs, $svn_id, $reponame, $owner_uid, $owner_gid, $public, $ml_name, $oid, $date_creation, $description, $state) = @_;
 
-	my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_SVN);
+	my $self = $class->SUPER::_new($vhffs, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_SVN);
 	return undef unless(defined $self);
 
 	$self->{svn_id} = $svn_id;
@@ -67,20 +67,20 @@
 }
 
 sub create {
-	my ($main, $rname, $description, $user, $group) = @_;
+	my ($vhffs, $rname, $description, $user, $group) = @_;
 
 	return undef unless(defined($user) && defined($group));
 	return undef unless(check_name($rname));
 
 	my $svn;
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	local $dbh->{RaiseError} = 1;
 	local $dbh->{PrintError} = 0;
 	$dbh->begin_work;
 
 	eval {
-		my $parent = Vhffs::Object::create($main, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_SVN);
+		my $parent = Vhffs::Object::create($vhffs, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_SVN);
 
 		die('Unable to create parent object') unless(defined $parent);
 
@@ -89,7 +89,7 @@
 		$sth->execute($rname, $parent->get_oid) or return undef;
 
 		$dbh->commit;
-		$svn = get_by_reponame($main, $rname);
+		$svn = get_by_reponame($vhffs, $rname);
 	};
 
 	if($@) {
@@ -147,17 +147,17 @@
 }
 
 sub get_by_reponame($$) {
-	my ($main, $reponame) = @_;
+	my ($vhffs, $reponame) = @_;
 	my @params;
 
 	my $sql = 'SELECT s.svn_id, s.reponame, o.owner_uid, o.owner_gid, s.public, s.ml_name, o.object_id, o.date_creation, o.description, o.state FROM vhffs_svn s
 		INNER JOIN vhffs_object o ON o.object_id = s.object_id WHERE s.reponame = ?';
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 
 	return undef unless(@params = $dbh->selectrow_array($sql, undef, $reponame));
 
-	return _new Vhffs::Services::Svn($main, @params);
+	return _new Vhffs::Services::Svn($vhffs, @params);
 }
 
 sub commit {
@@ -228,7 +228,7 @@
 =cut
 sub get_base_dir {
 	my $self = shift;
-	return $self->{main}->get_config->get_datadir.'/svn/svnroot';
+	return $self->get_vhffs->get_config->get_datadir.'/svn/svnroot';
 }
 
 1;

Modified: trunk/vhffs-api/src/Vhffs/Services/Web.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Web.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Services/Web.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -58,9 +58,9 @@
 use DBI;
 
 sub _new {
-	my ($class, $main, $httpd_id, $servername, $owner_uid, $owner_gid, $oid, $date_creation, $description, $state) = @_;
+	my ($class, $vhffs, $httpd_id, $servername, $owner_uid, $owner_gid, $oid, $date_creation, $description, $state) = @_;
 
-	my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_WEB);
+	my $self = $class->SUPER::_new($vhffs, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_WEB);
 	return undef unless(defined($self));
 
 	$self->{http_id} = $httpd_id;
@@ -73,25 +73,25 @@
 
 =head2 create
 
-	my $httpd = Vhffs::Services::Web::create($main, $servername, $description, $user, $group);
+	my $httpd = Vhffs::Services::Web::create($vhffs, $servername, $description, $user, $group);
 	die("Unable to create webarea $servername\n") unless(defined $httpd);
 
 Creates a new webarea in database and returns the corresponding fully functional object.
 
 =cut
 sub create {
-	my ($main, $servername, $description, $user, $group) = @_;
+	my ($vhffs, $servername, $description, $user, $group) = @_;
 	return undef unless defined $user and defined $group;
 	return undef unless Vhffs::Functions::check_domain_name($servername);
 
 	my $web;
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	local $dbh->{RaiseError} = 1;
 	local $dbh->{PrintError} = 0;
 	$dbh->begin_work;
 
 	eval {
-		my $parent =  Vhffs::Object::create($main, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_WEB);
+		my $parent =  Vhffs::Object::create($vhffs, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_WEB);
 
 		die('Unable to create parent object') unless(defined($parent));
 
@@ -101,7 +101,7 @@
 		$sth->execute($servername, $parent->get_oid);
 
 		$dbh->commit;
-		$web = get_by_servername($main, $servername);
+		$web = get_by_servername($vhffs, $servername);
 	};
 
 	if($@) {
@@ -158,22 +158,22 @@
 
 =head2 get_by_servername
 
-	my $httpd = Vhffs::Services::Web::get_by_servername($main, $servername);
+	my $httpd = Vhffs::Services::Web::get_by_servername($vhffs, $servername);
 	die("Webarea $servername not found\n") unless(defined $httpd);
 
 Fetches the webarea whose address is C<$servername>.
 
 =cut
 sub get_by_servername {
-	my ($main, $servername) = @_;
+	my ($vhffs, $servername) = @_;
 	my $sql = 'SELECT h.httpd_id, h.servername, o.owner_uid, o.owner_gid, h.object_id, o.date_creation, o.description, o.state
 		FROM vhffs_httpd h INNER JOIN vhffs_object o ON o.object_id = h.object_id WHERE h.servername = ?';
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 	my @params;
 	return undef unless(@params = $dbh->selectrow_array($sql, undef, $servername));
 
-	return _new Vhffs::Services::Web($main, @params);
+	return _new Vhffs::Services::Web($vhffs, @params);
 }
 
 =pod
@@ -211,7 +211,7 @@
 	my $self = shift;
 	require Digest::MD5;
 	my $hash = Digest::MD5::md5_hex( $self->{'servername'} );
-	return $self->{main}->get_config->get_datadir.'/web/'.$self->get_hash();
+	return $self->get_vhffs->get_config->get_datadir.'/web/'.$self->get_hash();
 }
 
 =head2 get_hash

Modified: trunk/vhffs-api/src/Vhffs/Stats.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Stats.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Stats.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -37,9 +37,9 @@
 
 =head1 SYNOPSIS
 
-	my $main = init Vhffs::Main(...);
+	my $vhffs = init Vhffs::Main(...);
 
-	my $stats = new Vhffs::Stats($main);
+	my $stats = new Vhffs::Stats($vhffs);
 	my $lstcount = $stats->get_lists_in_moderation;
 	my $count = $stats->get_...
 
@@ -63,16 +63,16 @@
 
 =head2 new
 
-	my $stats = new Vhffs::Stats($main);
+	my $stats = new Vhffs::Stats($vhffs);
 
-Creates a new Vhffs::Stats instance. C<$main> is the C<Vhffs::Main> instance used to get database connection.
+Creates a new Vhffs::Stats instance. C<$vhffs> is the C<Vhffs::Main> instance used to get database connection.
 
 =cut
 sub new {
-	my ( $class, $main ) = @_;
+	my ( $class, $vhffs ) = @_;
 
 	my $this = {};
-	$this->{main} = $main;
+	$this->{vhffs} = $vhffs;
 	$this->{flushed} = time();
 	bless( $this, $class );
 }
@@ -112,7 +112,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{lists}->{totalsubs}) {
 		my $sql = 'SELECT COUNT(*) FROM vhffs_ml_subscribers';
-		($self->{stats}->{lists}->{totalsubs}) = @{$self->{main}->get_db->selectrow_arrayref( $sql )};
+		($self->{stats}->{lists}->{totalsubs}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql )};
 	}
 	return $self->{stats}->{lists}->{totalsubs};
 }
@@ -130,7 +130,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{lists}->{awaiting_validation}) {
 		my $sql = 'SELECT COUNT(*) FROM vhffs_ml ml, vhffs_object o WHERE o.object_id=ml.object_id AND o.state='.Vhffs::Constants::WAITING_FOR_VALIDATION;
-		($self->{stats}->{lists}->{awaiting_validation}) = @{$self->{main}->get_db->selectrow_arrayref( $sql )};
+		($self->{stats}->{lists}->{awaiting_validation}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql )};
 	}
 	return $self->{stats}->{lists}->{awaiting_validation};
 }
@@ -148,7 +148,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{lists}->{activated}) {
 		my $sql = 'SELECT COUNT(*) FROM vhffs_ml ml, vhffs_object o WHERE o.object_id=ml.object_id AND o.state = ?';
-		($self->{stats}->{lists}->{activated}) = @{$self->{main}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::ACTIVATED )};
+		($self->{stats}->{lists}->{activated}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::ACTIVATED )};
 	}
 	return $self->{stats}->{lists}->{activated};
 }
@@ -166,7 +166,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{lists}->{total}) {
 		my $sql = 'SELECT COUNT(*) FROM vhffs_ml';
-		($self->{stats}->{lists}->{total}) = @{$self->{main}->get_db->selectrow_arrayref( $sql )};
+		($self->{stats}->{lists}->{total}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql )};
 	}
 	return $self->{stats}->{lists}->{total};
 }
@@ -184,7 +184,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{web}->{awaiting_validation}) {
 		my $sql = 'SELECT COUNT(*) FROM vhffs_httpd w INNER JOIN vhffs_object o ON o.object_id=w.object_id WHERE o.state = ?';
-		($self->{stats}->{web}->{awaiting_validation}) = @{$self->{main}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::WAITING_FOR_VALIDATION )};
+		($self->{stats}->{web}->{awaiting_validation}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::WAITING_FOR_VALIDATION )};
 	}
 	return $self->{stats}->{web}->{awaiting_validation};
 }
@@ -202,7 +202,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{web}->{activated}) {
 		my $sql = 'SELECT COUNT(*) FROM vhffs_httpd w INNER JOIN vhffs_object o ON o.object_id=w.object_id WHERE o.state = ?';
-		($self->{stats}->{web}->{activated}) = @{$self->{main}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::ACTIVATED )};
+		($self->{stats}->{web}->{activated}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::ACTIVATED )};
 	}
 	return $self->{stats}->{web}->{activated};
 }
@@ -220,7 +220,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{users}->{total}) {
 		my $sql = 'SELECT COUNT(*) FROM vhffs_users';
-		($self->{stats}->{users}->{total}) = @{$self->{main}->get_db->selectrow_arrayref( $sql )};
+		($self->{stats}->{users}->{total}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql )};
 	}
 	return $self->{stats}->{users}->{total};
 }
@@ -238,7 +238,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{users}->{total_admin}) {
 		my $sql = 'SELECT COUNT(*) FROM vhffs_users WHERE admin=?';
-		($self->{stats}->{users}->{total_admin}) = @{$self->{main}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::USER_ADMIN )};
+		($self->{stats}->{users}->{total_admin}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::USER_ADMIN )};
 	}
 	return $self->{stats}->{users}->{total_admin};
 }
@@ -256,7 +256,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{users}->{total_moderator}) {
 		my $sql = 'SELECT COUNT(*) FROM vhffs_users WHERE admin=?';
-		($self->{stats}->{users}->{total_moderator}) = @{$self->{main}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::USER_MODERATOR )};
+		($self->{stats}->{users}->{total_moderator}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::USER_MODERATOR )};
 	}
 	return $self->{stats}->{users}->{total_moderator};
 }
@@ -275,7 +275,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{dns}->{awaiting_validation}) {
 		my $sql = 'SELECT COUNT(*) FROM vhffs_dns w INNER JOIN vhffs_object o ON o.object_id=w.object_id WHERE o.state=?';
-		($self->{stats}->{dns}->{awaiting_validation}) = @{$self->{main}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::WAITING_FOR_VALIDATION )};
+		($self->{stats}->{dns}->{awaiting_validation}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::WAITING_FOR_VALIDATION )};
 	}
 	return $self->{stats}->{dns}->{awaiting_validation};
 }
@@ -293,7 +293,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{dns}->{activated}) {
 		my $sql = 'SELECT COUNT(*) FROM vhffs_dns w INNER JOIN vhffs_object o ON o.object_id=w.object_id WHERE o.state=?';
-		($self->{stats}->{dns}->{activated}) = @{$self->{main}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::ACTIVATED )};
+		($self->{stats}->{dns}->{activated}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::ACTIVATED )};
 	}
 	return $self->{stats}->{dns}->{activated};
 }
@@ -311,7 +311,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{mail}->{awaiting_validation}) {
 		my $sql = 'SELECT COUNT(*) FROM vhffs_mxdomain w INNER JOIN vhffs_object o ON o.object_id=w.object_id WHERE o.state = ?';
-		($self->{stats}->{mail}->{awaiting_validation}) = @{$self->{main}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::WAITING_FOR_VALIDATION )};
+		($self->{stats}->{mail}->{awaiting_validation}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::WAITING_FOR_VALIDATION )};
 	}
 	return $self->{stats}->{mail}->{awaiting_validation};
 }
@@ -329,7 +329,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{mail}->{activated}) {
 		my $sql = 'SELECT COUNT(*) FROM vhffs_mxdomain w INNER JOIN vhffs_object o ON o.object_id=w.object_id WHERE o.state = ?';
-		($self->{stats}->{mail}->{activated}) = @{$self->{main}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::ACTIVATED )};
+		($self->{stats}->{mail}->{activated}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::ACTIVATED )};
 	}
 	return $self->{stats}->{mail}->{activated};
 }
@@ -347,7 +347,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{mail}->{total_boxes}) {
 		my $sql = 'SELECT COUNT(*) FROM vhffs_boxes';
-		($self->{stats}->{mail}->{total_boxes}) = @{$self->{main}->get_db->selectrow_arrayref( $sql )};
+		($self->{stats}->{mail}->{total_boxes}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql )};
 	}
 	return $self->{stats}->{mail}->{total_boxes};
 }
@@ -365,7 +365,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{mail}->{total_forwards}) {
 		my $sql = 'SELECT COUNT(*) FROM vhffs_forward';
-		($self->{stats}->{mail}->{total_forwards}) = @{$self->{main}->get_db->selectrow_arrayref( $sql )};
+		($self->{stats}->{mail}->{total_forwards}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql )};
 	}
 	return $self->{stats}->{mail}->{total_forwards};
 }
@@ -383,7 +383,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{cvs}->{awaiting_validation}) {
 		my $sql = 'SELECT COUNT(*) FROM vhffs_cvs w INNER JOIN vhffs_object o ON o.object_id=w.object_id WHERE o.state=?';
-		($self->{stats}->{cvs}->{awaiting_validation}) = @{$self->{main}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::WAITING_FOR_VALIDATION )};
+		($self->{stats}->{cvs}->{awaiting_validation}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::WAITING_FOR_VALIDATION )};
 	}
 	return $self->{stats}->{cvs}->{awaiting_validation};
 }
@@ -401,7 +401,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{cvs}->{activated}) {
 		my $sql = 'SELECT COUNT(*) FROM vhffs_cvs w INNER JOIN vhffs_object o ON o.object_id=w.object_id WHERE o.state=?';
-		($self->{stats}->{cvs}->{activated}) = @{$self->{main}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::ACTIVATED )};
+		($self->{stats}->{cvs}->{activated}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::ACTIVATED )};
 	}
 	return $self->{stats}->{cvs}->{activated};
 }
@@ -419,7 +419,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{svn}->{awaiting_validation}) {
 		my $sql = 'SELECT COUNT(*) FROM vhffs_svn w INNER JOIN vhffs_object o ON o.object_id=w.object_id WHERE o.state = ?';
-		($self->{stats}->{svn}->{awaiting_validation}) = @{$self->{main}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::WAITING_FOR_VALIDATION )};
+		($self->{stats}->{svn}->{awaiting_validation}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::WAITING_FOR_VALIDATION )};
 
 	}
 	return $self->{stats}->{svn}->{awaiting_validation};
@@ -438,7 +438,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{svn}->{activated}) {
 		my $sql = 'SELECT COUNT(*) FROM vhffs_svn w INNER JOIN vhffs_object o ON o.object_id=w.object_id WHERE o.state='.Vhffs::Constants::ACTIVATED;
-		($self->{stats}->{svn}->{activated}) = @{$self->{main}->get_db->selectrow_arrayref( $sql )};
+		($self->{stats}->{svn}->{activated}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql )};
 	}
 	return $self->{stats}->{svn}->{activated};
 }
@@ -456,7 +456,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{git}->{awaiting_validation}) {
 		my $sql = 'SELECT COUNT(*) FROM vhffs_git w INNER JOIN vhffs_object o ON o.object_id=w.object_id WHERE o.state = ?';
-		($self->{stats}->{git}->{awaiting_validation}) = @{$self->{main}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::WAITING_FOR_VALIDATION )};
+		($self->{stats}->{git}->{awaiting_validation}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::WAITING_FOR_VALIDATION )};
 
 	}
 	return $self->{stats}->{git}->{awaiting_validation};
@@ -475,7 +475,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{git}->{activated}) {
 		my $sql = 'SELECT COUNT(*) FROM vhffs_git w INNER JOIN vhffs_object o ON o.object_id=w.object_id WHERE o.state='.Vhffs::Constants::ACTIVATED;
-		($self->{stats}->{git}->{activated}) = @{$self->{main}->get_db->selectrow_arrayref( $sql )};
+		($self->{stats}->{git}->{activated}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql )};
 	}
 	return $self->{stats}->{git}->{activated};
 }
@@ -493,7 +493,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{mercurial}->{awaiting_validation}) {
 		my $sql = 'SELECT COUNT(*) FROM vhffs_mercurial w INNER JOIN vhffs_object o ON o.object_id=w.object_id WHERE o.state = ?';
-		($self->{stats}->{mercurial}->{awaiting_validation}) = @{$self->{main}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::WAITING_FOR_VALIDATION )};
+		($self->{stats}->{mercurial}->{awaiting_validation}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::WAITING_FOR_VALIDATION )};
 
 	}
 	return $self->{stats}->{mercurial}->{awaiting_validation};
@@ -512,7 +512,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{mercurial}->{activated}) {
 		my $sql = 'SELECT COUNT(*) FROM vhffs_mercurial w INNER JOIN vhffs_object o ON o.object_id=w.object_id WHERE o.state='.Vhffs::Constants::ACTIVATED;
-		($self->{stats}->{mercurial}->{activated}) = @{$self->{main}->get_db->selectrow_arrayref( $sql )};
+		($self->{stats}->{mercurial}->{activated}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql )};
 	}
 	return $self->{stats}->{mercurial}->{activated};
 }
@@ -530,7 +530,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{bazaar}->{awaiting_validation}) {
 		my $sql = 'SELECT COUNT(*) FROM vhffs_bazaar w INNER JOIN vhffs_object o ON o.object_id=w.object_id WHERE o.state = ?';
-		($self->{stats}->{bazaar}->{awaiting_validation}) = @{$self->{main}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::WAITING_FOR_VALIDATION )};
+		($self->{stats}->{bazaar}->{awaiting_validation}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::WAITING_FOR_VALIDATION )};
 
 	}
 	return $self->{stats}->{bazaar}->{awaiting_validation};
@@ -549,7 +549,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{bazaar}->{activated}) {
 		my $sql = 'SELECT COUNT(*) FROM vhffs_bazaar w INNER JOIN vhffs_object o ON o.object_id=w.object_id WHERE o.state='.Vhffs::Constants::ACTIVATED;
-		($self->{stats}->{bazaar}->{activated}) = @{$self->{main}->get_db->selectrow_arrayref( $sql )};
+		($self->{stats}->{bazaar}->{activated}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql )};
 	}
 	return $self->{stats}->{bazaar}->{activated};
 }
@@ -567,7 +567,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{mysql}->{awaiting_validation}) {
 		my $sql = 'SELECT COUNT(*) FROM vhffs_mysql w INNER JOIN vhffs_object o ON o.object_id=w.object_id WHERE o.state = ?';
-		($self->{stats}->{mysql}->{awaiting_validation}) = @{$self->{main}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::WAITING_FOR_VALIDATION )};
+		($self->{stats}->{mysql}->{awaiting_validation}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::WAITING_FOR_VALIDATION )};
 	}
 	return $self->{stats}->{mysql}->{awaiting_validation};
 }
@@ -585,7 +585,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{mysql}->{activated}) {
 		my $sql = 'SELECT COUNT(*) FROM vhffs_mysql w INNER JOIN vhffs_object o ON o.object_id=w.object_id WHERE o.state = ?';
-		($self->{stats}->{mysql}->{activated}) = @{$self->{main}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::ACTIVATED )};
+		($self->{stats}->{mysql}->{activated}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::ACTIVATED )};
 	}
 	return $self->{stats}->{mysql}->{activated};
 }
@@ -603,7 +603,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{pgsql}->{awaiting_validation}) {
 		my $sql = 'SELECT COUNT(*) FROM vhffs_pgsql w INNER JOIN vhffs_object o ON o.object_id=w.object_id WHERE o.state = ?';
-		($self->{stats}->{pgsql}->{awaiting_validation}) = @{$self->{main}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::WAITING_FOR_VALIDATION )};
+		($self->{stats}->{pgsql}->{awaiting_validation}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::WAITING_FOR_VALIDATION )};
 
 	}
 	return $self->{stats}->{pgsql}->{awaiting_validation};
@@ -622,7 +622,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{pgsql}->{activated}) {
 		my $sql = 'SELECT COUNT(*) FROM vhffs_pgsql w INNER JOIN vhffs_object o ON o.object_id=w.object_id WHERE o.state = ?';
-		($self->{stats}->{pgsql}->{activated}) = @{$self->{main}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::ACTIVATED )};
+		($self->{stats}->{pgsql}->{activated}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::ACTIVATED )};
 	}
 	return $self->{stats}->{pgsql}->{activated};
 }
@@ -640,7 +640,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{groups}->{awaiting_moderation}) {
 		my $sql = 'SELECT COUNT(*) FROM vhffs_groups g INNER JOIN vhffs_object o ON o.object_id=g.object_id LEFT JOIN vhffs_users u ON u.username = g.groupname WHERE o.state = ? AND u.username IS NULL';
-		($self->{stats}->{groups}->{awaiting_moderation}) = @{$self->{main}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::WAITING_FOR_VALIDATION )};
+		($self->{stats}->{groups}->{awaiting_moderation}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql, undef, Vhffs::Constants::WAITING_FOR_VALIDATION )};
 	}
 	return $self->{stats}->{groups}->{awaiting_moderation};
 }
@@ -658,7 +658,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{groups}->{activated}) {
 		my $sql = 'SELECT COUNT(*) FROM vhffs_groups g INNER JOIN vhffs_object o ON o.object_id=g.object_id LEFT JOIN vhffs_users u ON u.username = g.groupname WHERE o.state='.Vhffs::Constants::ACTIVATED.' AND u.username IS NULL';
-		($self->{stats}->{groups}->{activated}) = @{$self->{main}->get_db->selectrow_arrayref( $sql )};
+		($self->{stats}->{groups}->{activated}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql )};
 	}
 	return $self->{stats}->{groups}->{activated};
 }
@@ -676,7 +676,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{groups}->{total}) {
 		my $sql = 'SELECT COUNT(*) FROM vhffs_groups g LEFT JOIN vhffs_users u ON u.username = g.groupname WHERE u.username IS NULL';
-		($self->{stats}->{groups}->{total}) = @{$self->{main}->get_db->selectrow_arrayref( $sql )};
+		($self->{stats}->{groups}->{total}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql )};
 	}
 	return $self->{stats}->{groups}->{total};
 }
@@ -694,7 +694,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{tags_categories}->{total}) {
 		my $sql = 'SELECT COUNT(*) FROM vhffs_tag_category';
-		($self->{stats}->{tags_categories}->{total}) = @{$self->{main}->get_db->selectrow_arrayref( $sql )};
+		($self->{stats}->{tags_categories}->{total}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql )};
 	}
 	return $self->{stats}->{tags_categories}->{total};
 }
@@ -712,7 +712,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{tags}->{total}) {
 		my $sql = 'SELECT COUNT(*) FROM vhffs_tag';
-		($self->{stats}->{tags}->{total}) = @{$self->{main}->get_db->selectrow_arrayref( $sql )};
+		($self->{stats}->{tags}->{total}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql )};
 	}
 	return $self->{stats}->{tags}->{total};
 }
@@ -730,7 +730,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{tags_used}->{total}) {
 		my $sql = 'SELECT COUNT(distinct tag_id) FROM vhffs_object_tag';
-		($self->{stats}->{tags_used}->{total}) = @{$self->{main}->get_db->selectrow_arrayref( $sql )};
+		($self->{stats}->{tags_used}->{total}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql )};
 	}
 	return $self->{stats}->{tags_used}->{total};
 }
@@ -748,7 +748,7 @@
 	my $self = shift;
 	unless(defined $self->{stats}->{tags_groups}->{total}) {
 		my $sql = 'SELECT COUNT(distinct object_id) FROM vhffs_object_tag';
-		($self->{stats}->{tags_groups}->{total}) = @{$self->{main}->get_db->selectrow_arrayref( $sql )};
+		($self->{stats}->{tags_groups}->{total}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql )};
 	}
 	return $self->{stats}->{tags_groups}->{total};
 }
@@ -771,7 +771,7 @@
 	        WHERE vhffs_tag.category_id=vhffs_tag_category.tag_category_id
 	          AND vhffs_object_tag.tag_id=vhffs_tag.tag_id
 	        GROUP BY category,tag_label ORDER BY nb_groups DESC LIMIT 10';
-	my $sth = $self->{main}->get_db->prepare($sql);
+	my $sth = $self->{vhffs}->get_db->prepare($sql);
 	$sth->execute() or return undef;
 	while( (my $t = $sth->fetchrow_hashref() )  ) {
 		push @$tags, $t;
@@ -793,7 +793,7 @@
 
 	unless(defined $self->{stats}->{tags_groups}->{max}) {
 		my $sql = 'SELECT MAX(count_tag_id) FROM (select COUNT(tag_id) as count_tag_id, object_id FROM vhffs_object_tag GROUP BY object_id) AS count_tags_groups';
-		($self->{stats}->{tags_groups}->{max}) = @{$self->{main}->get_db->selectrow_arrayref( $sql )};
+		($self->{stats}->{tags_groups}->{max}) = @{$self->{vhffs}->get_db->selectrow_arrayref( $sql )};
 	}
 	return $self->{stats}->{tags_groups}->{max};
 }

Modified: trunk/vhffs-api/src/Vhffs/Tag/Category.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Tag/Category.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Tag/Category.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -49,22 +49,22 @@
 $VISIBILITY_STRING[Vhffs::Constants::TAG_VISIBILITY_ADMINS] = 'Administrators';
 
 sub create {
-	my ($main, $label, $description, $visibility, $creator, $updated) = @_;
+	my ($vhffs, $label, $description, $visibility, $creator, $updated) = @_;
 	$updated = time() unless(defined $updated);
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 
 	my $sql = q{INSERT INTO vhffs_tag_category(label, description, visibility, updated, updater_id) VALUES (?, ?, ?, ?, ?)};
 	$dbh->do($sql, undef, $label, $description, $visibility, $updated, $creator->get_uid);
 
 	my $category_id = $dbh->last_insert_id(undef, undef, 'vhffs_tag_category', undef);
-	return get_by_category_id($main, $category_id);
+	return get_by_category_id($vhffs, $category_id);
 }
 
 sub get_by_category_id {
-	my ($main, $category_id) = @_;
+	my ($vhffs, $category_id) = @_;
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 
 	my $sql = q{SELECT tag_category_id, label, description, visibility, updated, updater_id
 		FROM vhffs_tag_category WHERE tag_category_id = ?};
@@ -74,15 +74,15 @@
 	my @results = $sth->fetchrow_array();
 	return undef unless @results;
 
-	my $category = _new Vhffs::Tag::Category($main, @results);
+	my $category = _new Vhffs::Tag::Category($vhffs, @results);
 
 	return $category;
 }
 
 sub get_by_label {
-	my ($main, $label) = @_;
+	my ($vhffs, $label) = @_;
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 
 	my $sql = q{SELECT tag_category_id, label, description, visibility, updated, updater_id
 		FROM vhffs_tag_category WHERE label = ?};
@@ -92,13 +92,13 @@
 	my @results = $sth->fetchrow_array();
 	return undef unless @results;
 
-	my $category = _new Vhffs::Tag::Category($main, @results);
+	my $category = _new Vhffs::Tag::Category($vhffs, @results);
 
 	return $category;
 }
 
 sub get_all {
-	my ($main, $visibility) = @_;
+	my ($vhffs, $visibility) = @_;
 
 	my @params = ();
 	my $cats = [];
@@ -111,26 +111,26 @@
 	}
 	$sql .= q{ ORDER BY label};
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 
 	my $sth = $dbh->prepare($sql);
 	$sth->execute(@params) or return undef;
 
 	while(my $c = $sth->fetchrow_arrayref()) {
-		push @$cats, _new Vhffs::Tag::Category($main, @$c);
+		push @$cats, _new Vhffs::Tag::Category($vhffs, @$c);
 	}
 
 	return $cats;
 }
 
 sub _new {
-	my($class, $main, $category_id, $label, $description, $visibility, $updated, $updater_id) = @_;
+	my($class, $vhffs, $category_id, $label, $description, $visibility, $updated, $updater_id) = @_;
 
 	my $self = {};
 
 	bless($self, $class);
 
-	$self->{main} = $main;
+	$self->{vhffs} = $vhffs;
 	$self->{category_id} = $category_id;
 	$self->{label} = $label;
 	$self->{description} = $description;
@@ -144,14 +144,14 @@
 sub save {
 	my ($self) = @_;
 	my $sql = q{UPDATE vhffs_tag_category SET label = ?, description = ?, visibility = ?, updated = ?, updater_id = ? WHERE tag_category_id = ?};
-	my $dbh = $self->{main}->get_db();
+	my $dbh = $self->{vhffs}->get_db();
 	return $dbh->do($sql, undef, $self->{label}, $self->{description}, $self->{visibility}, $self->{updated}, $self->{updater_id}, $self->{category_id});
 }
 
 sub delete {
 	my ($self) = @_;
 	my $sql = q{DELETE FROM vhffs_tag_category WHERE tag_category_id = ?};
-	my $dbh = $self->{main}->get_db();
+	my $dbh = $self->{vhffs}->get_db();
 	return $dbh->do($sql, undef, $self->{category_id});
 }
 
@@ -159,7 +159,7 @@
 	my ($self) = @_;
 
 	unless( defined $self->{updater} ) {
-		$self->{updater} = Vhffs::User::get_by_uid($self->{main}, $self->{updater_id});
+		$self->{updater} = Vhffs::User::get_by_uid($self->{vhffs}, $self->{updater_id});
 	}
 	return $self->{updater};
 }

Modified: trunk/vhffs-api/src/Vhffs/Tag/Request.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Tag/Request.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Tag/Request.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -43,26 +43,26 @@
 use Vhffs::ObjectFactory;
 
 sub create {
-	my ($main, $category, $tag, $requester, $tagged) = @_;
+	my ($vhffs, $category, $tag, $requester, $tagged) = @_;
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 
 	my $sql = q{INSERT INTO vhffs_tag_request(category_label, tag_label, created, requester_id, tagged_id) VALUES (?, ?, ?, ?, ?)};
 	$dbh->do($sql, undef, $category, $tag, time(), $requester->get_uid, $tagged->get_oid);
 
 	my $request_id = $dbh->last_insert_id(undef, undef, 'vhffs_tag_request', undef);
 
-	return get_by_request_id($main, $request_id);
+	return get_by_request_id($vhffs, $request_id);
 }
 
 sub _new {
-	my($class, $main, $request_id, $category_label, $tag_label, $created, $requester_id, $tagged_id) = @_;
+	my($class, $vhffs, $request_id, $category_label, $tag_label, $created, $requester_id, $tagged_id) = @_;
 
 	my $self = {};
 
 	bless($self, $class);
 
-	$self->{main} = $main;
+	$self->{vhffs} = $vhffs;
 	$self->{request_id} = $request_id;
 	$self->{category_label} = $category_label;
 	$self->{tag_label} = $tag_label;
@@ -74,9 +74,9 @@
 }
 
 sub get_by_request_id {
-	my ($main, $request_id) = @_;
+	my ($vhffs, $request_id) = @_;
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 
 	my $sql = q{SELECT tag_request_id, category_label, tag_label, created, requester_id, tagged_id
 		FROM vhffs_tag_request WHERE tag_request_id = ?};
@@ -86,26 +86,26 @@
 	my @results = $sth->fetchrow_array();
 	return undef unless @results;
 
-	my $request = _new Vhffs::Tag::Request($main, @results);
+	my $request = _new Vhffs::Tag::Request($vhffs, @results);
 
 	return $request;
 }
 
 sub get_all {
-	my ($main) = @_;
+	my ($vhffs) = @_;
 
 	my $requests = [];
 
 	my $sql = q{SELECT tag_request_id, category_label, tag_label, created, requester_id, tagged_id
 		FROM vhffs_tag_request ORDER BY created};
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 
 	my $sth = $dbh->prepare($sql);
 	$sth->execute() or return undef;
 
 	while(my $c = $sth->fetchrow_arrayref()) {
-		push @$requests, _new Vhffs::Tag::Request($main, @$c);
+		push @$requests, _new Vhffs::Tag::Request($vhffs, @$c);
 	}
 
 	return $requests;
@@ -115,7 +115,7 @@
 	my ($self) = @_;
 
 	unless( defined $self->{requester} ) {
-		$self->{requester} = Vhffs::User::get_by_uid($self->{main}, $self->{requester_id});
+		$self->{requester} = Vhffs::User::get_by_uid($self->{vhffs}, $self->{requester_id});
 	}
 	return $self->{requester};
 }
@@ -124,7 +124,7 @@
 	my ($self) = @_;
 
 	unless( defined $self->{tagged} ) {
-		$self->{tagged} = Vhffs::ObjectFactory::fetch_object($self->{main}, $self->{tagged_id});
+		$self->{tagged} = Vhffs::ObjectFactory::fetch_object($self->{vhffs}, $self->{tagged_id});
 	}
 	return $self->{tagged};
 }
@@ -133,7 +133,7 @@
 	my ($self) = @_;
 
 	my $sql = q{DELETE FROM vhffs_tag_request WHERE tag_request_id = ?};
-	my $dbh = $self->{main}->get_db();
+	my $dbh = $self->{vhffs}->get_db;
 	return $dbh->do($sql, undef, $self->{request_id});
 }
 
@@ -153,7 +153,7 @@
 	$sth->execute($self->get_oid()) or return undef;
 
 	while(my $c = $sth->fetchrow_arrayref()) {
-		push @$requests, _new Vhffs::Tag::Request($self->get_main(), @$c);
+		push @$requests, _new Vhffs::Tag::Request($self->get_vhffs(), @$c);
 	}
 
 	return $requests;

Modified: trunk/vhffs-api/src/Vhffs/Tag.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Tag.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/Tag.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -56,13 +56,13 @@
 
 =cut
 sub _new {
-	my ($class, $main, $tag_id, $label, $description, $updated, $updater_id, $category_id) = @_;
+	my ($class, $vhffs, $tag_id, $label, $description, $updated, $updater_id, $category_id) = @_;
 
 	my $self = {};
 
 	bless($self, $class);
 
-	$self->{main} = $main;
+	$self->{vhffs} = $vhffs;
 	$self->{tag_id} = $tag_id;
 	$self->{label} = $label;
 	$self->{description} = $description;
@@ -75,13 +75,13 @@
 
 =head2 create
 
-my $tag = Vhffs::Tag::create($main, $label, $description, $creator, $category, $created)
+my $tag = Vhffs::Tag::create($vhffs, $label, $description, $creator, $category, $created)
 
 Create (in database) and return a new object.
 
 =over 4
 
-=item C<$main>: C<Vhffs::Main> instance
+=item C<$vhffs>: C<Vhffs::Main> instance
 
 =item C<$label>: Tag label.
 
@@ -97,40 +97,40 @@
 
 =cut
 sub create {
-	my ($main, $label, $description, $creator, $category, $created) = @_;
+	my ($vhffs, $label, $description, $creator, $category, $created) = @_;
 	$created = time() unless(defined $created);
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 
 	my $sql = q{INSERT INTO vhffs_tag(label, description, updated, category_id, updater_id) VALUES(?, ?, ?, ?, ?)};
 	my $sth = $dbh->prepare($sql);
 	$sth->execute($label, $description, $created, $category->{category_id}, $creator->get_uid);
 
 	my $tag_id = $dbh->last_insert_id(undef, undef, 'vhffs_tag', undef);
-	return get_by_tag_id($main, $tag_id);
+	return get_by_tag_id($vhffs, $tag_id);
 }
 
 =cut
 
 =head2 Vhffs::Tag::get_by_tag_id
 
-my $tag = Vhffs::Tag::get_by_tag_id( $main, $tag_id );
+my $tag = Vhffs::Tag::get_by_tag_id( $vhffs, $tag_id );
 
 Fetches a tag by tag ID.
 
 =cut
 sub get_by_tag_id {
-	my($main, $tag_id) = @_;
+	my($vhffs, $tag_id) = @_;
 
 	my $sql = q{SELECT tag_id, label, description, updated, updater_id, category_id FROM vhffs_tag WHERE tag_id = ?};
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 
 	my $sth = $dbh->prepare($sql);
 	$sth->execute($tag_id) or return undef;
 	my @results = $sth->fetchrow_array();
 	return undef unless @results;
 
-	my $tag = _new Vhffs::Tag($main, @results);
+	my $tag = _new Vhffs::Tag($vhffs, @results);
 
 	return $tag;
 }
@@ -139,15 +139,15 @@
 
 =head2 Vhffs::Tag::get_all
 
-my $tags = Vhffs::Tag::get_all( $main );
+my $tags = Vhffs::Tag::get_all( $vhffs );
 
 Fetches all tags.
 
 =cut
 sub get_all {
-	my ($main) = @_;
+	my ($vhffs) = @_;
 
-	return _fetch_tags($main, q{SELECT tag_id, label, description, updated, updater_id, category_id
+	return _fetch_tags($vhffs, q{SELECT tag_id, label, description, updated, updater_id, category_id
 		FROM vhffs_tag ORDER BY label});
 }
 
@@ -155,15 +155,15 @@
 
 =head2 Vhffs::Tag::get_by_category_id
 
-my $tags = Vhffs::Tag::get_all( $main, $category_id );
+my $tags = Vhffs::Tag::get_all( $vhffs, $category_id );
 
 Fetches all tags from a category.
 
 =cut
 sub get_by_category_id {
-	my ($main, $category_id) = @_;
+	my ($vhffs, $category_id) = @_;
 
-	return _fetch_tags($main, q{SELECT tag_id, label, description, updated, updater_id, category_id
+	return _fetch_tags($vhffs, q{SELECT tag_id, label, description, updated, updater_id, category_id
 		FROM vhffs_tag WHERE category_id = ? ORDER BY label}, $category_id);
 }
 
@@ -171,7 +171,7 @@
 
 =head2 Vhffs::Tag::get_most_popular_tags
 
-my $tags = Vhffs::Tag::get_most_popular_tags( $main, $visibility );
+my $tags = Vhffs::Tag::get_most_popular_tags( $vhffs, $visibility );
 
 Fetches popular tags.
 
@@ -187,11 +187,11 @@
 sub get_most_popular_tags {
 	use POSIX;	# ceil
 
-	my ($main, $visibility) = @_;
+	my ($vhffs, $visibility) = @_;
 	$visibility = Vhffs::Constants::TAG_VISIBILITY_PUBLIC unless(defined $visibility);
 	my $tags = [];
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 
 	my $sql = q{SELECT MAX(c) AS max_count FROM
 		(SELECT COUNT(*) AS c
@@ -213,7 +213,7 @@
 		GROUP BY t.tag_id, t.label, t.description, c.tag_category_id, c.label, c.description
 		ORDER BY object_count DESC
 		LIMIT 10};
-	$sth = $main->get_db->prepare($sql);
+	$sth = $vhffs->get_db->prepare($sql);
 	$sth->execute($visibility) or return undef;
 	while( (my $t = $sth->fetchrow_hashref() )  ) {
 		$t->{weight} = ceil($t->{object_count} * 10 / $max_count);
@@ -226,7 +226,7 @@
 
 =head2 Vhffs::Tag::get_random_tags
 
-my $tags = Vhffs::Tag::get_random_tags( $main, $visibility );
+my $tags = Vhffs::Tag::get_random_tags( $vhffs, $visibility );
 
 Fetches ten random tags.
 
@@ -242,11 +242,11 @@
 sub get_random_tags {
 	use POSIX;	# ceil
 
-	my ($main, $visibility) = @_;
+	my ($vhffs, $visibility) = @_;
 	$visibility = Vhffs::Constants::TAG_VISIBILITY_PUBLIC unless(defined $visibility);
 	my $tags = [];
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 
 	my $sql = q{SELECT MAX(c) AS max_count FROM
 		(SELECT COUNT(*) AS c
@@ -268,7 +268,7 @@
 		GROUP BY t.tag_id, t.label, t.description, c.tag_category_id, c.label, c.description
 		ORDER BY RANDOM()
 		LIMIT 10};
-	$sth = $main->get_db->prepare($sql);
+	$sth = $vhffs->get_db->prepare($sql);
 	$sth->execute($visibility) or return undef;
 	while( (my $t = $sth->fetchrow_hashref() )  ) {
 		$t->{weight} = ceil($t->{object_count} * 10 / $max_count);
@@ -280,7 +280,7 @@
 =cut
 
 =head2
-	Vhffs::Tag::_fetch_tags($main, $sql, @params)
+	Vhffs::Tag::_fetch_tags($vhffs, $sql, @params)
 
 Fetches a tag list using C<$sql> and C<@params>.
 C<$sql> is a query having the following format
@@ -288,17 +288,17 @@
 
 =cut
 sub _fetch_tags {
-	my ($main, $sql, @params) = @_;
+	my ($vhffs, $sql, @params) = @_;
 
 	my $tags = [];
 
-	my $dbh = $main->get_db();
+	my $dbh = $vhffs->get_db();
 
 	my $sth = $dbh->prepare($sql);
 	$sth->execute(@params) or return undef;
 
 	while(my $t = $sth->fetchrow_arrayref()) {
-		push @$tags, _new Vhffs::Tag($main, @$t);
+		push @$tags, _new Vhffs::Tag($vhffs, @$t);
 	}
 
 	return $tags;
@@ -321,7 +321,7 @@
 	my ($self) = @_;
 
 	unless( defined $self->{updater} ) {
-		$self->{updater} = Vhffs::User::get_by_uid($self->{main}, $self->{updater_id});
+		$self->{updater} = Vhffs::User::get_by_uid($self->{vhffs}, $self->{updater_id});
 	}
 	return $self->{updater};
 }
@@ -339,7 +339,7 @@
 	my ($self) = @_;
 
 	unless( defined $self->{category} ) {
-		$self->{category} = Vhffs::Tag::Category::get_by_category_id($self->{main}, $self->{category_id});
+		$self->{category} = Vhffs::Tag::Category::get_by_category_id($self->{vhffs}, $self->{category_id});
 	}
 
 	return $self->{category}
@@ -358,7 +358,7 @@
 	my ($self) = @_;
 
 	my $sql = q{DELETE FROM vhffs_tag WHERE tag_id = ?};
-	my $dbh = $self->{main}->get_db();
+	my $dbh = $self->{vhffs}->get_db;
 	return $dbh->do($sql, undef, $self->{tag_id});
 }
 
@@ -375,7 +375,7 @@
 	my ($self) = @_;
 
 	my $sql = q{UPDATE vhffs_tag SET category_id = ?,  label = ?, description = ?, updated = ?, updater_id = ? WHERE tag_id = ?};
-	my $dbh = $self->{main}->get_db();
+	my $dbh = $self->{vhffs}->get_db;
 	return $dbh->do($sql, undef, $self->{category_id}, $self->{label}, $self->{description}, $self->{updated}, $self->{updater_id}, $self->{tag_id});
 }
 

Modified: trunk/vhffs-api/src/Vhffs/User.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/User.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/User.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -88,8 +88,8 @@
 
 =cut
 sub _new {
-	my ($class, $main, $uid, $gid, $oid, $username, $passwd, $homedir, $shell, $admin, $firstname, $lastname, $address, $zipcode, $city, $country, $mail, $gpg_key, $note, $language, $theme, $lastloginpanel, $ircnick, $date_creation, $description, $state) = @_;
-	my $self = $class->SUPER::_new($main, $oid, $uid, $gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_USER);
+	my ($class, $vhffs, $uid, $gid, $oid, $username, $passwd, $homedir, $shell, $admin, $firstname, $lastname, $address, $zipcode, $city, $country, $mail, $gpg_key, $note, $language, $theme, $lastloginpanel, $ircnick, $date_creation, $description, $state) = @_;
+	my $self = $class->SUPER::_new($vhffs, $oid, $uid, $gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_USER);
 	return undef unless(defined $self);
 	$self->{uid} = $uid;
 	$self->{gid} = $gid;
@@ -118,7 +118,7 @@
 
 =head2 create
 
-	my $user = Vhffs::User::create($main, $username, $password, $admin,
+	my $user = Vhffs::User::create($vhffs, $username, $password, $admin,
 		$mail, $firstname, $lastname, $city, $zipcode,
 		$country, $address, $gpg_key);
 
@@ -126,10 +126,10 @@
 
 =cut
 sub create {
-	my ( $main, $username, $password, $admin, $mail, $firstname, $lastname, $city, $zipcode, $country, $address, $gpg_key ) = @_;
+	my ( $vhffs, $username, $password, $admin, $mail, $firstname, $lastname, $city, $zipcode, $country, $address, $gpg_key ) = @_;
 	return undef unless check_username($username);
 
-	my $userconf = $main->get_config->get_users;
+	my $userconf = $vhffs->get_config->get_users;
 	my $user;
 
 	open(my $badusers, '<', $userconf->{'bad_username_file'} );
@@ -144,7 +144,7 @@
 		close $badusers;
 	}
 
-	my $dbh = $main->get_db;
+	my $dbh = $vhffs->get_db;
 	# Localize RaiseError so it get restored after we finish
 	# With this enabled, DBI automagically call die if a
 	# query goes wrong.
@@ -161,25 +161,25 @@
 
 		# Create corresponding object
 		# -- TODO, user moderation (easy to do now)
-		my $parent = Vhffs::Object::create($main, $uid, $gid, '', Vhffs::Constants::WAITING_FOR_CREATION, Vhffs::Constants::TYPE_USER);
+		my $parent = Vhffs::Object::create($vhffs, $uid, $gid, '', Vhffs::Constants::WAITING_FOR_CREATION, Vhffs::Constants::TYPE_USER);
 		die('Error creating parent') unless (defined $parent);
 
 		# Insert base information
 		$admin = 0 unless (defined $admin);
 		$password = Vhffs::Functions::generate_random_password() if( not defined $password or $password eq '' );
-		my $homedir = $main->get_config->get_datadir.'/home/'.substr( $username, 0, 1 ).'/'.substr( $username, 1, 1 ).'/'.$username;
+		my $homedir = $vhffs->get_config->get_datadir.'/home/'.substr( $username, 0, 1 ).'/'.substr( $username, 1, 1 ).'/'.$username;
 
 		my $sth = $dbh->prepare('INSERT INTO vhffs_users (uid, gid, username, shell, passwd, homedir, admin, firstname, lastname, address, zipcode, city, country, mail, gpg_key, note, language, theme, lastloginpanel, object_id) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, ?, NULL, NULL, ?)');
-		$sth->execute($uid, $gid, $username, $userconf->{'default_shell'}, Vhffs::Functions::password_encrypt($password), $homedir, $admin, $firstname, $lastname, $address, $zipcode, $city, $country, $mail, $gpg_key, $main->get_config->get_default_language, $parent->get_oid);
+		$sth->execute($uid, $gid, $username, $userconf->{'default_shell'}, Vhffs::Functions::password_encrypt($password), $homedir, $admin, $firstname, $lastname, $address, $zipcode, $city, $country, $mail, $gpg_key, $vhffs->get_config->get_default_language, $parent->get_oid);
 
-		my $group = Vhffs::Group::create($main, $username, undef, $uid, $gid);
+		my $group = Vhffs::Group::create($vhffs, $username, undef, $uid, $gid);
 		die('Error creating group') unless (defined $group);
 		$group->set_status(Vhffs::Constants::ACTIVATED);
 		$group->set_quota( $userconf->{'default_quota'} || 1 );
 		$group->commit;
 
 		$dbh->commit;
-		$user = get_by_uid($main, $uid);
+		$user = get_by_uid($vhffs, $uid);
 	};
 
 	if($@) {
@@ -188,8 +188,8 @@
 		undef $user;
 	}
 	else {
-		my $subject = sprintf("Welcome on %s", $main->get_config->get_host_name );
-		my $content = sprintf("Hello %s %s, Welcome on %s\n\nHere are your login information :\nUser: %s\nPassword: %s\n\nYour account is NOT created yet, you cannot login on the panel now, you\nare going to receive another mail in a few minutes upon account creation.\n\n%s Administrators\n", $user->get_firstname, $user->get_lastname, $main->get_config->get_host_name, $user->get_username, $password , $main->get_config->get_host_name );
+		my $subject = sprintf("Welcome on %s", $vhffs->get_config->get_host_name );
+		my $content = sprintf("Hello %s %s, Welcome on %s\n\nHere are your login information :\nUser: %s\nPassword: %s\n\nYour account is NOT created yet, you cannot login on the panel now, you\nare going to receive another mail in a few minutes upon account creation.\n\n%s Administrators\n", $user->get_firstname, $user->get_lastname, $vhffs->get_config->get_host_name, $user->get_username, $password , $vhffs->get_config->get_host_name );
 		$user->send_mail_user( $subject, $content );
 	}
 
@@ -216,7 +216,7 @@
 
 =head2 getall
 
-	my @users = Vhffs::User::getall( $main, $state, $name );
+	my @users = Vhffs::User::getall( $vhffs, $state, $name );
 
 Returns an array of users who matched $state and $name.
 
@@ -254,7 +254,7 @@
 
 =head2 get_unused_accounts
 
-	my @users = Vhffs::User::get_unused_accounts( $main, $age );
+	my @users = Vhffs::User::get_unused_accounts( $vhffs, $age );
 
 Returns an array of users who seem to be left unused for at least $age seconds long.
 
@@ -285,55 +285,55 @@
 
 =head2 get_by_uid
 
-	my $user = Vhffs::User::get_by_uid($main, $uid);
+	my $user = Vhffs::User::get_by_uid($vhffs, $uid);
 	die('User not found') unless defined($user);
 
 Fetches an user using its UID. Returned user is fully functional.
 
 =cut
 sub get_by_uid {
-	my ($main, $uid) = @_;
+	my ($vhffs, $uid) = @_;
 	my $query = 'SELECT u.uid, u.gid, u.object_id, u.username, u.passwd, u.homedir, u.shell, u.admin, u.firstname, u.lastname, u.address, u.zipcode, u.city, u.country, u.mail, u.gpg_key, u.note, u.language, u.theme, u.lastloginpanel, u.ircnick, o.date_creation, o.description, o.state FROM vhffs_users u INNER JOIN vhffs_object o ON o.object_id = u.object_id WHERE u.uid = ?';
-	my $dbh = $main->get_db;
+	my $dbh = $vhffs->get_db;
 	my @params = $dbh->selectrow_array($query, undef, $uid);
 	return undef unless(@params);
-	return _new Vhffs::User($main, @params);
+	return _new Vhffs::User($vhffs, @params);
 }
 
 =pod
 
 =head2 get_by_username
 
-	my $user = Vhffs::User::get_by_username($main, $username);
+	my $user = Vhffs::User::get_by_username($vhffs, $username);
 	die('User not found') unless defined($user);
 
 Fetches an user using its username. Returned user is fully functional.
 
 =cut
 sub get_by_username {
-	my ($main, $username) = @_;
+	my ($vhffs, $username) = @_;
 	my $query = 'SELECT u.uid, u.gid, u.object_id, u.username, u.passwd, u.homedir, u.shell, u.admin, u.firstname, u.lastname, u.address, u.zipcode, u.city, u.country, u.mail, u.gpg_key, u.note, u.language, u.theme, u.lastloginpanel, u.ircnick, o.date_creation, o.description, o.state FROM vhffs_users u INNER JOIN vhffs_object o ON o.object_id = u.object_id WHERE u.username = ?';
-	my $dbh = $main->get_db;
+	my $dbh = $vhffs->get_db;
 	my @params = $dbh->selectrow_array($query, undef, $username);
 	return undef unless(@params);
-	return _new Vhffs::User($main, @params);
+	return _new Vhffs::User($vhffs, @params);
 }
 
 =head2 get_by_ircnick
 
-	my $user = Vhffs::User::get_by_ircnick($main, $ircnick);
+	my $user = Vhffs::User::get_by_ircnick($vhffs, $ircnick);
 	die('User not found') unless defined($user);
 
 Fetches an user using its IRC nick. Returned user is fully functional.
 
 =cut
 sub get_by_ircnick {
-	my ($main, $ircnick) = @_;
+	my ($vhffs, $ircnick) = @_;
 	my $query = 'SELECT u.uid, u.gid, u.object_id, u.username, u.passwd, u.homedir, u.shell, u.admin, u.firstname, u.lastname, u.address, u.zipcode, u.city, u.country, u.mail, u.gpg_key, u.note, u.language, u.theme, u.lastloginpanel, u.ircnick, o.date_creation, o.description, o.state FROM vhffs_users u INNER JOIN vhffs_object o ON o.object_id = u.object_id WHERE u.ircnick = ?';
-	my $dbh = $main->get_db;
+	my $dbh = $vhffs->get_db;
 	my @params = $dbh->selectrow_array($query, undef, $ircnick);
 	return undef unless(@params);
-	return _new Vhffs::User($main, @params);
+	return _new Vhffs::User($vhffs, @params);
 }
 
 =pod
@@ -352,7 +352,7 @@
 sub commit {
 	my $self = shift;
 
-	$self->{'shell'} = $self->{'main'}->get_config->get_users->{'default_shell'} unless defined $self->{'shell'};
+	$self->{'shell'} = $self->get_vhffs->get_config->get_users->{'default_shell'} unless defined $self->{'shell'};
 	$self->{'admin'} = 0 unless defined $self->{'admin'};
 
 	return -1 unless defined $self->{'passwd'} and $self->{'passwd'} ne '';
@@ -390,7 +390,7 @@
 
 	# delete mail user if mail_user is enabled
 	use Vhffs::Services::MailUser;
-	my $mu = new Vhffs::Services::MailUser( $self->{'main'} , $self );
+	my $mu = new Vhffs::Services::MailUser( $self->get_vhffs, $self );
 	if( defined $mu ) {
 		$mu->delbox;
 		$mu->delforward;
@@ -398,7 +398,7 @@
 
 	# remove subscription from newsletter
 	use Vhffs::Services::Newsletter;
-	my $newsletter = new Vhffs::Services::Newsletter( $self->{'main'} , $self );
+	my $newsletter = new Vhffs::Services::Newsletter( $self->get_vhffs, $self );
 	$newsletter->del if defined $newsletter;
 
 	# User references corresponding object with an ON DELETE cascade foreign key
@@ -419,7 +419,7 @@
 sub pendingdeletion_withmail {
 	my $self = shift;
 
-	my $vhffs = $self->{main};
+	my $vhffs = $self->get_vhffs;
 
 	# TODO: write a beautiful module for INTL
 	bindtextdomain('vhffs', '%localedir%');
@@ -486,7 +486,7 @@
 	use Vhffs::Functions;
 	my ( $user, $subject, $content ) = @_;
 
-	my $vhffs = $user->{'main'};
+	my $vhffs = $user->get_vhffs;
 
 	my $from = $vhffs->get_config->get_master_mail;
 	return undef unless defined $from;
@@ -1065,7 +1065,7 @@
 	my $request = $self->get_db->prepare( $query );
 	return undef unless $request->execute($self->get_uid);
 	while( my ($groupname) = $request->fetchrow_array ) {
-		my $group = Vhffs::Group::get_by_groupname( $self->get_main, $groupname );
+		my $group = Vhffs::Group::get_by_groupname( $self->get_vhffs, $groupname );
 		push( @$groups, $group ) if defined $group;
 	}
 	return $groups;

Modified: trunk/vhffs-api/src/Vhffs/UserGroup.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/UserGroup.pm	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-api/src/Vhffs/UserGroup.pm	2012-03-02 19:58:58 UTC (rev 2090)
@@ -89,7 +89,7 @@
 
 =head2 getall
 
-	my $usergroups = Vhffs::UserGroup::getall( $main, $state ;
+	my $usergroups = Vhffs::UserGroup::getall( $vhffs, $state ;
 
 Returns an array of usergroups who matched $state.
 

Modified: trunk/vhffs-tools/src/vhffs-webdir
===================================================================
--- trunk/vhffs-tools/src/vhffs-webdir	2012-03-02 19:31:09 UTC (rev 2089)
+++ trunk/vhffs-tools/src/vhffs-webdir	2012-03-02 19:58:58 UTC (rev 2090)
@@ -16,10 +16,10 @@
 	exit( -1 );
 }
 
-my $main = init Vhffs::Main;
-exit 1 unless defined $main;
+my $vhffs = init Vhffs::Main;
+exit 1 unless defined $vhffs;
 
-my $web = Vhffs::Services::Web::get_by_servername( $main, $ARGV[0] );
+my $web = Vhffs::Services::Web::get_by_servername( $vhffs, $ARGV[0] );
 unless( defined $web ) {
 	print 'No such website'."\n";
 	exit 1;


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