[vhffs-dev] [527] Removed all old API methods. |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 527
Author: beuss
Date: 2007-03-24 16:09:48 +0000 (Sat, 24 Mar 2007)
Log Message:
-----------
Removed all old API methods.
Modified Paths:
--------------
branches/vhffs_4.1/vhffs-api/src/Vhffs/Group.pm
branches/vhffs_4.1/vhffs-api/src/Vhffs/Object.pm
branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Cvs.pm
branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Mail.pm
branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Mysql.pm
branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Web.pm
branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Cvs.pm
branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/DNS.pm
branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Httpd.pm
branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Mail.pm
branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/MailUser.pm
branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Mailing.pm
branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Mysql.pm
branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Postgres.pm
branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Repository.pm
branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Svn.pm
branches/vhffs_4.1/vhffs-api/src/Vhffs/User.pm
Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Group.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Group.pm 2007-03-24 15:54:41 UTC (rev 526)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Group.pm 2007-03-24 16:09:48 UTC (rev 527)
@@ -52,115 +52,6 @@
=cut
-sub new
-{
- my $groupname;
- my $owner;
- my $this;
- my $class;
- my $self;
- my $princ;
- my $user;
- my $gid;
-
- $class = shift;
- $princ = shift;
- $groupname = shift;
- $owner = shift;
- $gid = shift;
-
- $this={};
-
- $groupname = get_name_by_gid( $princ , $gid ) if( ( defined $gid ) && ( $gid =~ /[\d]+/ ) );
-
- return undef unless check_groupname($groupname);
-
- $this = $class->SUPER::new( $princ , 0 , $owner );
-
-
- $this->{'groupname'} = $groupname if ( defined $groupname );
- $this->{'gid'} = $gid;
-
- bless( $this , $class );
-
-}
-
-
-
-
-
-
-# Simply get a unix group. In other words, only the gid and the groupname are fetched
-# fetch_unix is not used any more
-sub fetch_unix
-{
- my $request;
- my $result;
- my $self;
- my $query;
-
- $self = shift;
-
- return -1 unless( defined $self->{'groupname'} );
- $request = 'SELECT * FROM vhffs_groups where groupname = ?';
-# $request = "SELECT * FROM vhffs_groups where gid='$self->{'gid'}'" if ( defined $self->{'gid'} );
-
- $result = $self->{'db'}->prepare($request) or return -1;
- $result->execute( $self->{'groupname'} ) or return -1;
-
- return -1 if ( $result->rows != 1 );
-
- foreach ( keys %{$result} )
- {
- $self->{$_} = $result->{$_};
- }
-
- return 1;
-}
-
-
-
-# Simply get a complete group with intos
-sub fetch
-{
- my $groupname;
- my $request;
- my $result;
- my $request2;
- my $result2;
- my $self;
- my $query;
- my $hash;
-
- $self = shift;
-
-
- $request = 'SELECT * FROM vhffs_groups where groupname=?';
-
- $result = $self->{'db'}->prepare($request) or return -1;
- my $rows = $result->execute($self->{'groupname'}) or return -1;
-
- return -1 if ( $rows == 0 );
-
-
- $hash = $result->fetchrow_hashref();
-
- foreach ( keys %{$hash} )
- {
- $self->{$_} = $hash->{$_};
- }
-
- return -2 if( $self->SUPER::fetch < 0 );
-
- return 1;
-}
-
-
-
-
-
-
-
# get all unix groups and return it as an hashref
#THIS IS NOT A METHOD IT'S JUST A FUNCTION
sub get_all_unix
@@ -193,7 +84,6 @@
=cut
sub create {
- return old_create(@_) if($_[0]->isa('Vhffs::Group'));
my ($main, $groupname, $owner_uid, $gid, $description) = @_;
return undef unless check_groupname($groupname);
return undef unless defined($owner_uid);
@@ -223,74 +113,6 @@
return get_by_gid($main, $gid);
}
-#create a new group with the name given in parameter
-sub old_create
-{
- my $self;
- my $config;
- my $conf;
- my $result;
- my $request;
- my $gid;
- my $owneruid;
- my $query;
- my $badgroups;
- my $oid;
- my $rows;
- my $quota;
-
-
- $self = shift;
-
-
- $conf = $self->{'main'}->get_config->get_users;
-
- return -1 if ( ! defined $self->{'groupname'} );
-
- $self->{'groupname'} =~ tr/A-Z/a-z/;
-
- $badgroups = $self->{'main'}->get_config->get_bad_groupname;
- if( defined $badgroups )
- {
-
- foreach ( @{$badgroups} )
- {
- return -10 if ( $_ eq $self->{"groupname"} );
- }
- }
-
-
-
- #Create the related object
- $oid = $self->SUPER::create;
-
- return -1 if ( $oid < 0 );
-
-
-
- #Quota initialization
- #One day, god decide that : "10Mb ? It will be enough for everyone"
- # "God smoke too much herb"
- $quota = 10;
- $quota = $conf->{'default_quota'} if( ( defined $conf ) && ( defined $conf->{'default_quota'} ) );
- $self->{'quota'} = $quota;
- $self->{'quota_used'} = 0;
-
-
-
- #finally, create the group
- $query = 'INSERT INTO vhffs_groups(groupname, passwd, quota, quota_used, owner_uid, uid_mod, object_id) VALUES(?, NULL, ?, ?, ?, ?, ?)';
- $request = $self->{'db'}->prepare( $query ) or return -2;
- $request->execute($self->{'groupname'}, $self->{'quota'}, $self->{'quota_used'}, $self->{'owner_uid'}, $self->{'owner_uid'}, $oid) or return -3;
- $self->{'gid'} = $self->{'db'}->last_insert_id(undef, undef, 'vhffs_groups', undef);
-
- $self->commit;
-
- $self->fetch;
- return $self->{'gid'};
-}
-
-
sub remove_user
{
use Vhffs::Constants;
@@ -442,9 +264,6 @@
$self = shift;
- return 2 if ( $self->fetch < 0 );
-
-
$request = $self->{'db'}->prepare('DELETE FROM vhffs_groups WHERE gid=?');
$request->execute($self->{'gid'}) or return -1;
@@ -619,10 +438,7 @@
while( my ($gid) = $request->fetchrow_array )
{
my $group = Vhffs::Group::get_by_gid( $vhffs , $gid );
- if( $group->fetch > 0 )
- {
- push @groups , $group;
- }
+ push @groups , $group;
}
return \@groups;
}
@@ -633,7 +449,6 @@
use Vhffs::User;
my $self = shift;
- return undef if( $self->fetch < 0 );
my @users;
my $gid = $self->get_gid;
my $query = 'SELECT ug.uid FROM vhffs_user_group ug WHERE ug.gid = ?';
@@ -653,8 +468,7 @@
if( ! defined $self->{'user'} )
{
- $self->{'user'} = new Vhffs::User( $self->{'main'} , undef , $self->{'owner_uid'} );
- $self->{'user'}->fetch if( defined $self->{'user'} );
+ $self->{'user'} = Vhffs::User::get_by_uid( $self->{'main'}, $self->{'owner_uid'} );
}
return( $self->{'user'} );
Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Object.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Object.pm 2007-03-24 15:54:41 UTC (rev 526)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Object.pm 2007-03-24 16:09:48 UTC (rev 527)
@@ -180,12 +180,7 @@
=cut
sub create {
- if($_[0]->isa('Vhffs::Object')) {
- my ($package, $file, $line) = caller();
- warn "Using deprecated form of Vhffs::Object::create from $package ($file:$line).\n";
- return old_create(@_);
- }
- my ($vhffs, $owner_uid, $description, $state, $type) = @_;
+ my ($vhffs, $owner_uid, $description, $state, $type) = @_;
$description = '' unless (defined $description);
$state = ($vhffs->get_config->get_moderation ? Vhffs::Constants::WAITING_FOR_VALIDATION : Vhffs::Constants::WAITING_FOR_CREATION) unless defined $state;
my $sth = $vhffs->get_db_object->prepare('INSERT INTO vhffs_object(owner_uid, date_creation, state, description, type) VALUES ( ?, NOW(), ?, ?, ?)');
@@ -198,75 +193,6 @@
return $res;
}
-sub old_create
-{
- my $query;
- my $request;
- my $id;
- my ( $self ) = @_;
-
-
- $self->{'owner_uid'} = $user->get_uid if( defined $user );
- $self->{'owner_gid'} = $group->get_gid if( defined $group );
-
- # NO! IF YOU DO THAT, YOU ADD AN HISTORY ENTRY FOR A NON EXISTENT OBJECT !!!!
- #$self->set_default_state;
-
-
- $self->{'state'} =( $self->{'main'}->get_config->get_moderation == 1 ? Vhffs::Constants::WAITING_FOR_VALIDATION : Vhffs::Constants::WAITING_FOR_CREATION);
-
- $request = $self->{'db'}->prepare('INSERT INTO vhffs_object(owner_uid, date_creation, state, description) VALUES ( ? , NOW(), ? , ? )');
-
- $request->execute( $self->{'owner_uid'} , $self->{'state'} , $self->{'description'} ) or return -2;
- $self->{'object_id'} = $self->{'db'}->last_insert_id(undef, undef, 'vhffs_object', undef);
-
- $self->add_history( "Object created" );
-
- # Fill in DB defined params (eg. creation date)
- $self->fetch;
-
- return $self->{'object_id'};
-}
-
-
-
-sub fetch
-{
- my ($package, $file, $line) = caller();
- warn "Using deprecated method Vhffs::Object::fetch from $package ($file:$line).\n";
-
- my $self;
- my $request;
- my $result;
-
- $self = shift;
-
- my $query = 'SELECT * FROM vhffs_object WHERE object_id =?';
- $request = $self->{'db'}->prepare( $query );
- my $rows = $request->execute( $self->{'object_id'} );
-
- return -1 if( $rows != 1);
-
- $result = $request->fetchrow_hashref;
-
- foreach ( keys %{$result} )
- {
- $self->{"$_"} = $result->{"$_"}
- }
-
- #Fix encofing of description
- $self->{'description'} =~ s/\\//g;
-
-
- return 1;
-}
-
-sub fetch_object
-{
- my $self = shift;
- $self->fetch();
-}
-
sub get_owner_uid
{
my $self = shift;
Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Cvs.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Cvs.pm 2007-03-24 15:54:41 UTC (rev 526)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Cvs.pm 2007-03-24 16:09:48 UTC (rev 527)
@@ -89,8 +89,8 @@
{
my( $main, $cvsroot, $description, $user, $group ) = @_;
- return -1 if( ! defined $user );
- return -2 if( ! defined $group );
+ return undef if( ! defined $user );
+ return undef if( ! defined $group );
my $cvs = Vhffs::Services::Cvs::create($main, $cvsroot, $description, $user, $group);
Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Mail.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Mail.pm 2007-03-24 15:54:41 UTC (rev 526)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Mail.pm 2007-03-24 16:09:48 UTC (rev 527)
@@ -117,8 +117,8 @@
{
my( $main , $domain , $description, $user , $group ) = @_;
- return -1 if( ! defined $user );
- return -2 if( ! defined $group );
+ return undef if( ! defined $user );
+ return undef if( ! defined $group );
my $mail = Vhffs::Services::Mail::create($main, $domain, $description, $user, $group);
Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Mysql.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Mysql.pm 2007-03-24 15:54:41 UTC (rev 526)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Mysql.pm 2007-03-24 16:09:48 UTC (rev 527)
@@ -93,8 +93,8 @@
{
my( $main , $dbname , $user , $group , $dbuser, $dbpass, $description ) = @_;
- return -1 if( ! defined $user );
- return -2 if( ! defined $group );
+ return undef if( ! defined $user );
+ return undef if( ! defined $group );
my $mysql = Vhffs::Services::Mysql::create($main, $dbname, $dbuser, $dbpass, $description, $user, $group);
Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Web.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Web.pm 2007-03-24 15:54:41 UTC (rev 526)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Web.pm 2007-03-24 16:09:48 UTC (rev 527)
@@ -106,8 +106,8 @@
{
my( $main, $servername, $description, $user, $group ) = @_;
- return -1 if( !defined $user );
- return -2 if( !defined $group );
+ return undef if( !defined $user );
+ return undef if( !defined $group );
my $web = Vhffs::Services::Httpd::create($main, $servername, $description, $user, $group);
return undef if( ! defined $web );
Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Cvs.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Cvs.pm 2007-03-24 15:54:41 UTC (rev 526)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Cvs.pm 2007-03-24 16:09:48 UTC (rev 527)
@@ -29,13 +29,20 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
+=pod
+=head1 NAME
-# This file is a part of VHFFS4 Hosting Platform
-# Please respect the licence of this file and the whole software
+Vhffs::Services::Cvs - Handle CVS service in VHFFS
-# Author: soda < dieu at gunnm dot org>
+=head1 SYNOPSIS
+TODO
+
+=head1 METHODS
+
+=cut
+
package Vhffs::Services::Cvs;
use base qw(Vhffs::Object);
@@ -43,47 +50,24 @@
use strict;
use DBI;
+=pod
+=head2 check_cvsroot
-sub new
-{
- my $main;
- my $cvsroot;
- my $this;
- my $self;
- my $class;
- my $user;
- my $group;
-
- #( $class , $main , $cvsroot , $user , $group ) = @_;
-
- $class = shift;
- $main = shift;
- $cvsroot = shift;
- $user = shift;
- $group = shift;
-
- $this = {};
-
- $this = $class->SUPER::new( $main , 1 , '401' );
-
- #We return an undefined value if the user or the CVSROOT are not correct
- return undef if( ! defined ( $cvsroot ) );
- return undef if( ! ( $cvsroot =~ /[a-z0-9]+/) );
-
- $this->{'cvsroot'} = $cvsroot;
- $this->{'user'} = $user if( defined $user );
- $this->{'group'} = $group if( defined $group );
-
- bless( $this , $class );
+ die("Invalid CVS root\n") unless(Vhffs::Services::Cvs::check_cvsroot($cvsroot));
- return $this;
+Checks whether a cvsroot is valid or not.
+
+=cut
+
+sub check_cvsroot($) {
+ my $cvsroot = shift;
+ return (defined($cvsroot) && ($cvsroot =~ /^[a-z0-9]+$/));
}
sub delete
{
my $self = shift;
- $self->fetch;
my $query = "DELETE FROM vhffs_cvs WHERE object_id='".$self->{'object_id'}."'";
my $request = $self->{'db'}->prepare($query);
@@ -93,14 +77,22 @@
return 1;
}
+=pod
+
+=head2 create
+
+ my $cvs = Vhffs::Services::Cvs::create($main, $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
{
- # Compatibility stuff, will be deleted before 4.1 release
- return old_create(@_) if($_[0]->isa('Vhffs::Services::Cvs'));
-
my ($main, $cvsroot, $description, $user, $group) = @_;
return undef unless(defined($user) && defined($group));
- return undef unless(defined($cvsroot) && ($cvsroot =~ /^[a-z0-9]+$/));
+ return undef unless(check_cvsroot($cvsroot));
my $parent = Vhffs::Object::create($main, $user->get_uid, $description, undef, Vhffs::Constants::TYPE_CVS);
@@ -114,77 +106,6 @@
}
-sub old_create
-{
- my $self = shift;
-
- return -2 if ( $self->{'user'}->fetch < 0 );
- return -3 if ( $self->{'group'}->fetch < 0 );
-
- $self->{'owner_uid'} = $self->{'user'}->get_uid;
- $self->{'owner_gid'} = $self->{'group'}->get_gid;
-
- my $request = $self->{'db'}->prepare("SELECT * FROM vhffs_cvs WHERE cvsroot='" . $self->{'cvsroot'} . "'");
- my $rows = $request->execute;
- return -1 if ( $rows != 0 );
-
- my $oid = $self->SUPER::create();
- if ( $oid lt 0 )
- {
- return( -1 );
- }
- else
- {
- $self->{'object_id'} = $oid;
- }
-
-
- #Get the max cvs_id and compute the new cvs_id
- my $cvs_id = 1;
- my $resultuid = $self->{'db'}->selectall_arrayref("SELECT MAX(cvs_id) FROM vhffs_cvs");
- $cvs_id = $resultuid->[0][0] if ( defined $resultuid->[0][0] );
- $cvs_id++;
-
-
- #Finally, create the object
- my $text = "INSERT INTO vhffs_cvs VALUES( '".$cvs_id."' , '".$self->{'cvsroot'} . "','".$self->{'user'}->get_uid."','".$self->{'group'}->get_gid."' , 'TRUE' , '".$self->{'object_id'}."' )";
- $request = $self->{'db'}->prepare( $text );
- $request->execute or return -2;
-
- return $cvs_id;
-}
-
-
-sub fetch
-{
- my $self = shift;
-
- my $request = $self->{'db'}->prepare("SELECT * FROM vhffs_cvs where cvsroot='".$self->{'cvsroot'}."'") or return -1;
-
- my $rows = $request->execute() or return -3;
-
- return -1 if( $rows <= 0 );
-
- my $result = $request->fetchrow_hashref();
-
-
- foreach ( keys %{$result} )
- {
- $self->{$_} = $result->{$_}
- }
-
-
- $self->{'group'} = Vhffs::Group::get_by_gid( $self->{'main'} , $self->{'owner_gid'} );
- return -1 unless( defined $self->{'group'} );
-
-
- $self->SUPER::fetch;
-
- return 1;
-}
-
-
-
sub commit
{
my $self = shift;
@@ -227,8 +148,6 @@
}
}
-
-
sub set_user
{
my ( $self , $user ) = @_;
@@ -368,7 +287,10 @@
}
+1;
+__END__
+=head1 AUTHORS
+soda < dieu at gunnm dot org>
-
-1;
+Sebastien Le Ray < beuss at tuxfamily dot org >
Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/DNS.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/DNS.pm 2007-03-24 15:54:41 UTC (rev 526)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/DNS.pm 2007-03-24 16:09:48 UTC (rev 527)
@@ -50,37 +50,6 @@
use strict;
use DBI;
-sub new
-{
- my $this;
- my $self;
-
- my $class = shift;
- my $main = shift;
- my $domain = shift;
- my $user = shift;
- my $group = shift;
-
- $this = {};
-
- return undef if( ! ($domain =~ /^([a-z0-9\-]+\.)+[a-z]{2,4}$/ ) );
-
- $this = $class->SUPER::new( $main , 1 , '401' );
-
- $this->{'domain'} = $domain if ( defined $domain );
- $this->{'owner_uid'} = $user->get_uid if ( defined $user );
- $this->{'owner_gid'} = $group->get_gid if ( defined $group );
- $this->{'user'} = $user;
- $this->{'group'} = $group;
-
-
- bless( $this , $class );
-
- return $this;
-}
-
-
-
# Returns an array with ALL the DNS
# If ionly a ref of a Vhffs::Main instance if given, it returns ALL DNS objects
# If a state (of Vhffs::Constants) is given more, it returns all DNS objects which have this state
@@ -129,12 +98,6 @@
sub create
{
- if($_[0]->isa('Vhffs::Services::DNS')) {
- my ($package, $file, $line) = caller();
- warn "Using deprecated form of method Vhffs::DNS::Repository::create from $package ($file:$line)\n";
- return old_create(@_);
- }
-
my($main, $domain, $description, $user, $group) = @_;
my $conf = $main->get_config->get_service("dns");
@@ -196,94 +159,6 @@
return $self;
}
-#Create the object in VHFFS database
-sub old_create
-{
- my $self = shift;
- my $conf = $self->{'main'}->get_config->get_service("dns");
-
- return -1 if ( ! defined $conf );
-
-
- #Check if the DNS object already exists
- my $request = $self->{'db'}->prepare("SELECT * FROM vhffs_dns WHERE domain='" . $self->{'domain'} . "'");
- my $rows = $request->execute;
- return -1 if ( $rows != 0 );
-
- my $oid = $self->SUPER::create();
- return -1 if ( $oid lt 0 );
-
-
- #Exit is the no user and no group are linked to this object
- return -3 if ( ( $self->{'user'}->fetch < 0 ) || ( $self->{'group'}->fetch < 0 ) );
-
-
- #Get the max dns_id and compute the new dns_id
- my $dns_id = 1;
- $request = $self->{'db'}->prepare("SELECT * FROM vhffs_dns where domain='".$self->{'domain'}."'") or return -1;
- my $resultuid = $self->{'db'}->selectall_arrayref("SELECT MAX(dns_id) FROM vhffs_dns");
- $dns_id = $resultuid->[0][0] if ( defined $resultuid->[0][0] );
- $dns_id++;
- $self->{'dns_id'} = $dns_id;
-
- #Finally, create the object
- my $text = "INSERT INTO vhffs_dns VALUES( '".$dns_id."' , '".$self->{'domain'}."', '".$self->{'group'}->get_gid."' , '".$self->{'user'}->get_uid."' , '".$oid."' , '".$conf->{default_ns1}."' , '".$conf->{default_mbox}."' , '".$conf->{default_serial}."' , '".$conf->{default_refresh}."' , '".$conf->{default_retry}."' , '".$conf->{default_expire}."' , '".$conf->{default_minimum}."' )";
- $request = $self->{'db'}->prepare( $text );
- $request->execute or return -2;
- $self->commit;
-
-
- # Final, create some defaults values defined in the conf file
- # Those values are defined in the config file in the <services> <dns> .... </dns> </services>
- my $ip;
- my $name;
- my $prio;
-
- if( defined $conf->{init} )
- {
- my $init = $conf->{init};
- if( defined $init->{a} )
- {
- foreach( keys %{$init->{a}} )
- {
- $name = $_;
- $ip = $init->{a}{$_};
- if( $name eq "default" )
- {
- $self->add_a( "" , $ip );
- }
- else
- {
- $self->add_a( $name , $ip );
- }
- }
- }
- if( defined $init->{mx} )
- {
- foreach( keys %{$init->{mx}} )
- {
- $prio = $_;
- $ip = $init->{mx}{$_};
- $self->add_mx( $ip , $prio );
- }
- }
-
- if( defined $init->{ns} )
- {
- foreach( keys %{$init->{ns}} )
- {
- $name = $_;
- $self->add_ns( $name );
- }
- }
-
- }
-
- return $dns_id;
-}
-
-
-
# Delete this object from VHFFS database
sub delete
{
@@ -291,8 +166,6 @@
my $query;
my $request;
- return -1 if( $self->fetch < 0);
-
# Destroy the RR part (A, NS, PTR, ...)
$query = "DELETE FROM vhffs_dns_rr WHERE zone='".$self->{'dns_id'}."'";
$request = $self->{'db'}->prepare($query);
@@ -389,104 +262,6 @@
return $self;
}
-#Get all data about this httpd object in the databse
-sub fetch
-{
- my $self = shift;
- my $name;
- my $key;
-
-
- #First, get informations in the dns database, in dns_global
- my $request = $self->{'db'}->prepare("SELECT * FROM vhffs_dns where domain='".$self->{'domain'}."'") or return -1;
- my $rows = $request->execute() or return -3;
- return -1 if ( $rows == 0 );
-
-
- my $result = $request->fetchrow_hashref();
-
- foreach ( keys %{$result} )
- {
- $self->{$_} = $result->{$_}
- }
-
- #Get the A TYPE
- $request = $self->{'db'}->prepare("SELECT * FROM vhffs_dns_rr where zone='".$self->{'dns_id'}."' AND type='A'") or return -1;
- $request->execute() or return -3;
- while( $result = $request->fetchrow_hashref())
- {
- if( $result->{name} eq "" )
- {
- $name = "default";
- }
- else
- {
- $name = $result->{name};
- }
-
- foreach( keys %{$result} )
- {
- $self->{A}->{$name}->{$_} = $result->{$_} if ( $_ ne "name" );
- }
- }
-
-
-
- #Get the NS ZONE
- $request = $self->{'db'}->prepare("SELECT * FROM vhffs_dns_rr where zone='".$self->{'dns_id'}."' AND type='NS'") or return -1;
- $request->execute() or return -3;
- while( $result = $request->fetchrow_hashref())
- {
- $key = $result->{data};
-
- foreach( keys %{$result} )
- {
- $self->{NS}->{$key}->{$_} = $result->{$_};
- }
- }
-
-
-
-
- #Get the CNAME TYPE
- $request = $self->{'db'}->prepare("SELECT * FROM vhffs_dns_rr where zone='".$self->{'dns_id'}."' AND type='CNAME'") or return -1;
- $request->execute() or return -3;
- while( $result = $request->fetchrow_hashref())
- {
- if( $result->{name} eq "" )
- {
- $name = "default";
- }
- else
- {
- $name = $result->{name};
- }
-
- foreach( keys %{$result} )
- {
- $self->{CNAME}->{$name}->{$_} = $result->{$_} if ( $_ ne "name" );
- }
- }
-
-
-
-
- #Get the MX TYPE
- $request = $self->{'db'}->prepare("SELECT * FROM vhffs_dns_rr where zone='".$self->{'dns_id'}."' AND type='MX'") or return -1;
- $self->{MX} = undef if ( $request->execute() <= 0 );
- while( $result = $request->fetchrow_hashref())
- {
- $key = $result->{aux};
-
- foreach( keys %{$result} )
- {
- $self->{MX}->{$key}->{$_} = $result->{$_} if ( $_ ne "aux" );
- }
- }
-
- $self->SUPER::fetch;
-}
-
# This function returns -1 if a name already exists.
# For example, if soda.gunnm.org already exists in the dns_rr table, we return -1. Otherwise, 0.
sub name_exists
Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Httpd.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Httpd.pm 2007-03-24 15:54:41 UTC (rev 526)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Httpd.pm 2007-03-24 16:09:48 UTC (rev 527)
@@ -55,50 +55,6 @@
use strict;
use DBI;
-
-
-sub new
-{
- my $main;
- my $servername;
- my $this;
- my $self;
- my $class;
- my $user;
- my $group;
-
- ( $class , $main , $servername , $user , $group ) = @_;
-
- return undef unless(Vhffs::Functions::check_domain_name($servername));
-
- $this = {};
-
- $this = $class->SUPER::new( $main , 1 , '401' );
-
-
- $this->{'servername'} = $servername if ( defined $servername );
-
- # $this->{'owner_uid'} = $user->{'uid'} if ( defined $user->{'uid'} );
- $this->{'user'} = $user;
- $this->{'group'} = $group;
-
- bless( $this , $class );
-
- return $this;
-}
-
-sub delete
-{
- my $self = shift;
- my $query = "DELETE FROM vhffs_httpd WHERE object_id='".$self->{'object_id'}."'";
- my $request = $self->{'db'}->prepare($query);
- $request->execute or return -1;
-
- return -2 if( $self->SUPER::delete < 0 );
-
- return 1;
-}
-
=pod
=head2 create
@@ -131,69 +87,6 @@
return get_by_servername($main, $servername);
}
-sub old_create
-{
- my $self = shift;
-
- return -1 if( $self->{'user'}->fetch < 0 );
- return -1 if( $self->{'group'}->fetch < 0 );
-
- $self->{'owner_uid'} = $self->{'user'}->get_uid;
- $self->{'owner_gid'} = $self->{'group'}->get_gid;
-
-
- my $request = $self->{'db'}->prepare("SELECT * FROM vhffs_httpd WHERE servername='" . $self->{'servername'} . "'");
- my $rows = $request->execute;
- return -2 if ( $rows != 0 );
-
- my $oid = $self->SUPER::create();
- return -3 if ( $oid lt 0 );
-
- #Get the mac httpd_id and compute the new httpd_id
- my $httpd_id = 1;
- my $resultuid = $self->{'db'}->selectall_arrayref("SELECT MAX(httpd_id) FROM vhffs_httpd");
- $httpd_id = $resultuid->[0][0] if ( defined $resultuid->[0][0] );
- $httpd_id++;
-
-
- #Finally, create the object
- my $query = "INSERT INTO vhffs_httpd VALUES( '".$httpd_id."' , '".$self->{'servername'} . "', '1' , '".$self->{'owner_uid'}."' , '".$self->{'owner_uid'}."' , '".$self->{'owner_uid'}."' , '".$self->{'group'}->get_gid."', '0' , '0' , '0' , $oid )";
- $request = $self->{'db'}->prepare( $query );
- $request->execute or return -2;
-
- return $httpd_id;
-}
-
-
-#Get all data about this httpd object in the databse
-sub fetch
-{
- my $self = shift;
- my $request = $self->{'db'}->prepare("SELECT * FROM vhffs_httpd where servername='".$self->{'servername'}."'") or return -1;
-
- my $rows = $request->execute() or return -3;
-
- return -1 if( $rows <= 0 );
-
- my $result = $request->fetchrow_hashref();
-
-
- foreach ( keys %{$result} )
- {
- $self->{$_} = $result->{$_}
- }
-
- $self->SUPER::fetch;
-
- $self->{'group'} = Vhffs::Group::get_by_gid( $self->{'main'} , $self->{'owner_gid'} );
- return -1 if( $self->{'group'}->fetch < 0 );
-
- $self->{'user'} = new Vhffs::User( $self->{'main'} , undef , $self->{'owner_uid'} );
- return -1 if( $self->{'user'}->fetch < 0 );
-
- return 1;
-}
-
sub commit
{
my $self = shift;
Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Mail.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Mail.pm 2007-03-24 15:54:41 UTC (rev 526)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Mail.pm 2007-03-24 16:09:48 UTC (rev 527)
@@ -51,43 +51,6 @@
use strict;
use DBI;
-
-# Create a new instance of the current class
-sub new
-{
- my $main;
- my $domain;
- my $this;
- my $self;
- my $class;
- my $user;
- my $group;
-
- ( $class , $main , $domain , $user , $group ) = @_;
-
- $this = {};
-
- #If the domain is not specified by argument, return an undef instance
- return undef if ( ! defined $domain );
-
- $this = $class->SUPER::new( $main , 1 , '401' );
-
- return undef if( ! ( $domain =~ /^[a-zA-Z0-9\-\.]+$/) );
- return undef if( length( $domain ) < 5 );
-
- $this->{'domain'} = $domain if ( defined $domain );
-
- # $this->{'owner_uid'} = $user->{'uid'} if ( defined $user->{'uid'} );
- $this->{'user'} = $user;
- $this->{'group'} = $group;
-
- $this->{'boxes'} = {};
-
- bless( $this , $class );
-
- return $this;
-}
-
sub delete
{
my $self = shift;
@@ -127,12 +90,6 @@
=cut
sub create {
- if($_[0]->isa('Vhffs::Services::Mail')) {
- my ($package, $file, $line) = caller();
- warn "Using deprecated form of Vhffs::Services::Mail::create from $package ($file:$line).\n";
- return old_create(@_);
- }
-
my ($main, $domain, $description, $user, $group) = @_;
return undef unless(defined($user) && defined($group));
return undef unless(Vhffs::Functions::check_domain_name($domain));
@@ -150,123 +107,6 @@
return get_by_mxdomain($main, $domain);
}
-# Create the object in the database
-sub old_create
-{
- my $self = shift;
-
- # If user or group^does not exists in the VHFFS database, we return -1, the object is not created
- return -1 if( $self->{'user'}->fetch < 0 );
- return -1 if( $self->{'group'}->fetch < 0 );
-
- $self->{'owner_uid'} = $self->{'user'}->get_uid();
-
- my $request = $self->{'db'}->prepare("SELECT * FROM vhffs_mxdomain WHERE domain='" . $self->{'domain'} . "'");
- my $rows = $request->execute;
- return -2 if ( $rows != 0 );
-
- my $oid = $self->SUPER::create();
- return -3 if ( $oid lt 0 );
-
- #Get the max mx_id and compute the new mx_id
- my $mx_id = 1;
- my $resultuid = $self->{'db'}->selectall_arrayref("SELECT MAX(mxdomain_id) FROM vhffs_mxdomain");
- $mx_id = $resultuid->[0][0] if ( defined $resultuid->[0][0] );
- $mx_id++;
-
- my $domainhash = Vhffs::Functions::hash_mxdomain( $self->{'domain'} );
-
- #Finally, create the object in the database
- my $query = "INSERT INTO vhffs_mxdomain VALUES( '".$mx_id."' , '".$self->{'domain'} . "', 'exim' , '".$domainhash."' , '0' , '' , '".$self->{'user'}->get_uid."' , '".$self->{'group'}->get_gid."', '$oid' )";
- $request = $self->{'db'}->prepare( $query );
- $request->execute or return -2;
-
- return $mx_id;
-}
-
-
-# Get all data about this mail object in the databse
-# Informations about the mail domain is stored in $ref->
-# Inforations about forwards are stored in $ref->{'forward'}
-# Informations about mailboxes are stored in $ref->{'boxes'}
-sub fetch
-{
- my ($package, $file, $line) = caller();
- warn "Using deprecated method Vhffs::Services::Mail::fetch from $package ($file:$line).\n";
-
- my $self = shift;
-
- my ($request , $result , $name , $request2 , $result2 , $names);
-
- $request = $self->{'db'}->prepare("SELECT * FROM vhffs_mxdomain where domain='".$self->{'domain'}."'") or return -1;
- return -3 if( $request->execute() <= 0 );
- $result = $request->fetchrow_hashref();
-
- foreach ( keys %{$result} )
- {
- $self->{$_} = $result->{$_}
- }
-
- #Fetch the object part( SUPER class)
- return -2 if ($self->SUPER::fetch < 0 );
-
- ###########################
- #Get all Boxes
- ###########################
- #So, we will have :
- # - $ref->{'boxes'}{$local_part}{'domain'}
- # - $ref->{'boxes'}{$local_part}{'local_part'}
- # - $ref->{'boxes'}{$local_part}{'domain_hash'}
- # - $ref->{'boxes'}{$local_part}{'password_hash'}
- # - $ref->{'boxes'}{$local_part}{'mbox_name'}
- # - $ref->{'boxes'}{$local_part}{'password'}
- $request = $self->{'db'}->prepare("SELECT * FROM vhffs_boxes where domain='".$self->{'domain'}."'") or return -1;
- $request->execute() or return -3;
- $result = $request->fetchall_hashref('local_part');
-
- $self->{'boxes'} = {};
- foreach $name ( keys %{$result} )
- {
- foreach( keys %{$result->{$name}} )
- {
- $self->{'boxes'}{$name}{$_} = $result->{$name}{$_};
- }
- $self->{'boxes'}{$name}{'password'} = $self->{'boxes'}{$name}{'password_hash'};
- $self->{'boxes'}{$name}{'nospam'} = 1 if( $self->{'boxes'}{$name}{'nospam'} eq 't' );
- $self->{'boxes'}{$name}{'novirus'} = 1 if( $self->{'boxes'}{$name}{'novirus'} eq 't' );
-
- }
- ######### End of boxes fetching ########
-
-
-
-
- ######################
- #Get All forwarders
- ######################
- #So, we will have :
- # - $ref->{'forward'}{$local_part}{'domain'}
- # - $ref->{'forward'}{$local_part}{'local_part'}
- # - $ref->{'forward'}{$local_part}{'remote_name'}
- # - $ref->{'forward'}{$local_part}{'password'}
- $request = $self->{'db'}->prepare("SELECT * FROM vhffs_forward where domain='".$self->{'domain'}."'") or return -1;
- $request->execute() or return -3;
- $result = $request->fetchall_hashref('local_part');
-
- $self->{'forward'} = {};
- foreach $name ( keys %{$result} )
- {
- foreach( keys %{$result->{$name}} )
- {
- $self->{'forward'}{$name}{$_} = $result->{$name}{$_};
- }
- }
- ######### End of forward fetching ######
-
- return 1;
-}
-
-
# Commit all changes of the current instance in the database
sub commit
{
Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/MailUser.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/MailUser.pm 2007-03-24 15:54:41 UTC (rev 526)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/MailUser.pm 2007-03-24 16:09:48 UTC (rev 527)
@@ -158,7 +158,6 @@
if( $self->exists_box == 1 )
{
$self->{mail_service}->delbox( $self->{part} );
- $self->{mail_service}->fetch;
}
return -1 if ( $self->{mail_service}->addforward( $self->{part} , $remote ) < 0);
@@ -185,7 +184,6 @@
if( $self->exists_forward == 1 )
{
$self->{mail_service}->delforward( $self->{part} );
- $self->{mail_service}->fetch;
}
return -1 if( $self->{mail_service}->addbox( $self->{part} , $password ) < 0);
Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Mailing.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Mailing.pm 2007-03-24 15:54:41 UTC (rev 526)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Mailing.pm 2007-03-24 16:09:48 UTC (rev 527)
@@ -53,51 +53,6 @@
use strict;
use DBI;
-
-# Create a new instance of the current class
-sub new
-{
- my $main;
- my $domain;
- my $this;
- my $self;
- my $class;
- my $user;
- my $group;
- my $local;
-
- #( $class , $main , $domain , $user , $group ) = @_;
-
- $class = shift;
- $main = shift;
- $local = shift;
- $domain = shift;
- $user = shift;
- $group = shift;
-
- $this = {};
-
- #If the domain is not specified by argument, return an undef instance
- return undef if ( ! defined $domain );
- return undef if ( ! defined $local );
-
- $this = $class->SUPER::new( $main , 1 , '401' );
-
-
- return undef if( ! ( $local =~ /^[a-zA-Z0-9\-\.]+$/ ) );
- return undef if( ! ( $domain =~ /^[a-zA-Z0-9\-\.]+$/ ) );
- $this->{'domain'} = $domain if ( defined $domain );
- $this->{'local_part'} = $local if ( defined $local );
-
-
- $this->{'user'} = $user if( defined $user );
- $this->{'group'} = $group if( defined $group);
-
- bless( $this , $class );
-
- return $this;
-}
-
=pod
=head2 create
@@ -110,12 +65,6 @@
=cut
sub create
{
- if($_[0]->isa('Vhffs::Services::Mailing')) {
- my ($package, $file, $line) = caller();
- warn "Using deprecated form of Vhffs::Services::Mailing::create from $package ($file:$line).\n";
- return old_create(@_);
- }
-
my ($main, $local, $domain, $admin, $description, $user, $group) = @_;
return undef unless(defined $user && defined $group);
@@ -137,53 +86,6 @@
return get_by_mladdress($main, $local, $domain);
}
-# Create the object in the database
-sub old_create
-{
- my $self = shift;
- my $query;
- my $request;
- my $rows;
-
- $self->{'admin'} = "nobody\@nobody.com" if( ! defined $self->{admin} );
-
- return -1 if( ! defined $self->{'user'} );
- return -1 if( ! defined $self->{'group'} );
-
- $query = "SELECT * FROM vhffs_ml where domain='".$self->{'domain'}."' AND local_part='".$self->{'local_part'}."'";
- $request = $self->{'db'}->prepare( $query ) or return -1;
- $rows = $request->execute() or return -3;
- return -1 if( $rows >= 1 );
-
- $self->{'owner_uid'} = $self->{'user'}->get_uid;
- $self->{'owner_gid'} = $self->{'group'}->get_gid;
-
- if( $self->{'domain'} ne $self->{'main'}->get_config->get_service("mailing")->{'default_domain'} )
- {
- $query = "SELECT * FROM vhffs_mxdomain WHERE domain='".$self->{domain}."' AND owner_gid='".$self->{'group'}->get_gid."'";
- $request = $self->{'db'}->prepare( $query );
- $rows = $request->execute;
- return -4 if ( $rows != 1 );
- }
-
- my $oid = $self->SUPER::create();
- return -3 if ( $oid lt 0 );
-
- #Get the max mx_id and compute the new mx_id
- my $ml_id = 1;
- my $resultuid = $self->{'db'}->selectall_arrayref("SELECT MAX(ml_id) FROM vhffs_ml");
- $ml_id = $resultuid->[0][0] if ( defined $resultuid->[0][0] );
- $ml_id++;
-
- #Finally, create the object in the database
- $query = "INSERT INTO vhffs_ml VALUES( '".$ml_id."' , '".$self->{'local_part'} . "', '".$self->{'domain'}."' , '".$self->{'local_part'} . "' , '".$self->{'user'}->get_uid."' , '".$self->{'group'}->get_gid."', '".$oid."' , '".$self->{'admin'} . "' , 'f' , 'f' , 't' , 't' , 'f' , '' )";
- $request = $self->{'db'}->prepare( $query );
- $request->execute or return -2;
-
- return $ml_id;
-}
-
-
=pod
=head2 get_by_mladdress
@@ -235,46 +137,6 @@
return $self;
}
-sub fetch
-{
- my ($package, $file, $line) = caller();
- warn "Using deprecated method Vhffs::Mailing::fetch from $package ($file:$line).\n";
-
- my $self = shift;
-
- my ($request , $result , $request2 , $result2 , $query );
- my $rows;
- $query = "SELECT * FROM vhffs_ml where domain='".$self->{'domain'}."' AND local_part='".$self->{'local_part'}."'";
- $request = $self->{'db'}->prepare( $query ) or return -1;
- $rows = $request->execute() or return -3;
- return -1 if( $rows == 0 );
- $result = $request->fetchrow_hashref();
-
- foreach ( keys %{$result} )
- {
- $self->{$_} = $result->{$_}
- }
-
- #Fetch the object part( SUPER class)
- return -2 if ($self->SUPER::fetch < 0 );
-
- $query = "SELECT * FROM vhffs_ml_subscribers where ml_id='".$self->{'ml_id'}."'";
- $request = $self->{'db'}->prepare( $query ) or return -1;
- $request->execute() or return -3;
- $result = $request->fetchall_hashref('member');
- my $v;
- foreach ( keys %{$result} )
- {
- foreach $v ( keys %{$result->{$_}} )
- {
- $self->{subs}{$_}{$v} = $result->{$_}{$v};
- }
- }
-
- return 1;
-}
-
-
# Commit all changes of the current instance in the database
sub commit
{
Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Mysql.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Mysql.pm 2007-03-24 15:54:41 UTC (rev 526)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Mysql.pm 2007-03-24 16:09:48 UTC (rev 527)
@@ -53,37 +53,6 @@
use strict;
use DBI;
-
-sub new
-{
- my $main;
- my $dbname;
- my $this;
- my $self;
- my $class;
- my $user;
- my $group;
-
- ( $class , $main , $dbname , $user , $group ) = @_;
-
- $this = {};
-
-
- $this = $class->SUPER::new( $main , 1 , '401' );
-
- return undef unless(check_dbname($dbname));
-
- $this->{'dbname'} = $dbname if ( defined $dbname );
- $this->{'dbuser'} = $dbname if ( defined $dbname );
- $this->{'user'} = $user if ( defined $user );
- $this->{'group'} = $group if (defined $group );
-
-
- bless( $this , $class );
-
- return $this;
-}
-
sub check_dbname($) {
my $dbname = shift;
return ($dbname =~ /^[a-z0-9][a-z0-9\_]{1,30}[a-z0-9]$/ );
@@ -124,11 +93,6 @@
=cut
sub create {
- if($_[0]->isa('Vhffs::Services::Mysql')) {
- my ($package, $file, $line) = caller();
- warn "Using deprecated form of Vhffs::Services::Mysql::create from $package ($file:$line).\n";
- return old_create(@_);
- }
my ($main, $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));
@@ -144,65 +108,7 @@
return get_by_dbname($main, $dbname);
}
-sub old_create
-{
- my $self = shift;
- return -1 if ( $self->{'user'}->fetch < 0 );
- return -1 if ( $self->{'group'}->fetch < 0 );
-
- $self->{'owner_uid'} = $self->{'user'}->get_uid;
-
- my $request = $self->{'db'}->prepare("SELECT * FROM vhffs_mysql WHERE dbname='" . $self->{'dbname'} . "'");
- my $rows = $request->execute;
- return -1 if ( $rows != 0 );
-
- my $oid = $self->SUPER::create();
- return -1 if ( $oid lt 0 );
-
- $self->{'object_id'} = $oid;
-
-# return -2 if ( ( ! defined $self->{'dbuser'} ) || ( ! defined $self->{'dbpass'} ) );
- return -2 if ( ( ! defined $self->{'dbpass'} ) );
-
- #Get the mac httpd_id and compute the new httpd_id
- my $mysql_id = 1;
- my $resultuid = $self->{'db'}->selectall_arrayref("SELECT MAX(mysql_id) FROM vhffs_mysql");
- $mysql_id = $resultuid->[0][0] if ( defined $resultuid->[0][0] );
- $mysql_id++;
-
- #Finally, create the object
- my $query = "INSERT INTO vhffs_mysql VALUES( '".$mysql_id."' , '".$self->{'dbname'}."', '".$self->{'dbuser'}."' , '".$self->{'owner_uid'}."' , '".$self->{'group'}->get_gid."' , '".$self->{'dbpass'}."' , '$oid' )";
- $request = $self->{'db'}->prepare( $query );
- $request->execute or return -2;
-
- return $mysql_id;
-}
-
-
-#Get all data about this httpd object in the databse
-sub fetch
-{
- my $self = shift;
-
- my $request = $self->{'db'}->prepare("SELECT * FROM vhffs_mysql where dbname='".$self->{'dbname'}."'") or return -1;
- my $rows = $request->execute();
-
- return -1 if( $rows != 1 );
-
- my $result = $request->fetchrow_hashref();
-
-
- foreach ( keys %{$result} )
- {
- $self->{$_} = $result->{$_}
- }
-
- $self->SUPER::fetch;
-}
-
-
-
sub commit
{
my $self = shift;
Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Postgres.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Postgres.pm 2007-03-24 15:54:41 UTC (rev 526)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Postgres.pm 2007-03-24 16:09:48 UTC (rev 527)
@@ -52,42 +52,6 @@
use strict;
use DBI;
-
-
-sub new
-{
- my $main;
- my $dbname;
- my $this;
- my $self;
- my $class;
- my $user;
- my $group;
-
- #( $class , $main , $dbname , $user ) = @_;
-
- $class = shift;
- $main = shift;
- $dbname = shift;
- $user = shift;
- $group = shift;
-
- $this = {};
-
- return undef unless(check_dbname($dbname));
-
- $this = $class->SUPER::new( $main , 1 , '401' );
-
- $this->{'dbname'} = $dbname if ( defined $dbname );
- $this->{'dbuser'} = "";
- $this->{'user'} = $user if ( defined $user );
- $this->{'group'} = $group if ( defined $group );
-
- bless( $this , $class );
-
- return $this;
-}
-
=pod
=head2 check_dbname
@@ -161,12 +125,6 @@
=cut
sub create {
- if($_[0]->isa('Vhffs::Services::Postgres')) {
- my ($package, $file, $line) = caller();
- warn "Using deprecated form of method Vhffs::Services::Postgres::create from $package ($file:$line)\n";
- return old_create(@_);
- }
-
my ($main, $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));
@@ -183,68 +141,6 @@
}
-
-sub old_create
-{
- my $self = shift;
-
- return -1 if( $self->{'user'}->fetch < 0 );
- return -1 if ( $self->{'group'}->fetch < 0 );
- $self->{'owner_gid'} = $self->{'group'}->get_gid;
- $self->{'owner_uid'} = $self->{'user'}->get_uid;
-
-
- my $request = $self->{'db'}->prepare("SELECT * FROM vhffs_pgsql WHERE dbname='" . $self->{'dbname'} . "'");
- my $rows = $request->execute;
- return -1 if ( $rows != 0 );
-
- my $oid = $self->SUPER::create();
- return -1 if ( $oid lt 0 );
-
-
- $self->{'object_id'} = $oid;
-
- return -2 if ( ( ! defined $self->{'dbuser'} ) || ( ! defined $self->{'dbpass'} ) );
-
- #Get the mac httpd_id and compute the new httpd_id
- my $pgsql_id = 1;
- my $resultuid = $self->{'db'}->selectall_arrayref("SELECT MAX(pgsql_id) FROM vhffs_pgsql");
- $pgsql_id = $resultuid->[0][0] if ( defined $resultuid->[0][0] );
- $pgsql_id++;
-
-
- #Finally, create the object
- my $query = "INSERT INTO vhffs_pgsql VALUES( '".$pgsql_id."' , '".$self->{'dbname'} . "', '".$self->{'dbuser'}."' , '".$self->{'dbpass'}."' , '".$self->{'owner_uid'}."', '".$self->{'owner_gid'}."' , '$oid' )";
- $request = $self->{'db'}->prepare( $query );
- $request->execute or return -2;
-
- return $pgsql_id;
-}
-
-
-#Get all data about this httpd object in the databse
-sub fetch
-{
- my $self = shift;
-
- my $request = $self->{'db'}->prepare("SELECT * FROM vhffs_pgsql where dbname='".$self->{'dbname'}."'") or return -1;
- my $rows = $request->execute();
-
- return -1 if( $rows != 1 );
-
- my $result = $request->fetchrow_hashref();
-
-
- foreach ( keys %{$result} )
- {
- $self->{$_} = $result->{$_}
- }
-
- $self->SUPER::fetch;
-}
-
-
-
sub commit
{
my $self = shift;
@@ -263,16 +159,12 @@
return $self->{'owner_gid'};
}
-
sub get_owneruid
{
my $self = shift;
return $self->{'owner_uid'};
}
-
-
-
sub get_dbusername
{
my $self = shift;
@@ -285,7 +177,6 @@
return $self->{'dbname'};
}
-
sub get_title
{
my $self = shift;
@@ -298,8 +189,6 @@
return $self->{'dbpass'};
}
-
-
sub set_dbusername
{
my ($self , $value) = @_;
Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Repository.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Repository.pm 2007-03-24 15:54:41 UTC (rev 526)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Repository.pm 2007-03-24 16:09:48 UTC (rev 527)
@@ -54,41 +54,6 @@
use strict;
use DBI;
-
-
-sub new
-{
- my $main;
- my $name;
- my $this;
- my $self;
- my $class;
- my $user;
- my $group;
-
- $class = shift;
- $main = shift;
- $name = shift;
- $user = shift;
- $group = shift;
-
- $this = {};
-
- $this = $class->SUPER::new( $main , 1 , '401' );
-
- #We return an undefined value if the user or the NAME are not correct
- return undef if( ! defined ( $name ) );
- return undef if( ! ( $name =~ /[a-z0-9]+/) );
-
- $this->{'name'} = $name;
- $this->{'user'} = $user if( defined $user );
- $this->{'group'} = $group if( defined $group );
-
- bless( $this , $class );
-
- return $this;
-}
-
sub check_name($)
{
my $name = shift;
@@ -122,12 +87,6 @@
sub create
{
- if($_[0]->isa('Vhffs::Services::Repository')) {
- my ($package, $file, $line) = caller();
- warn "Using deprecated form of method Vhffs::Services::Repository::create from $package ($file:$line)\n";
- return old_create(@_);
- }
-
my ($main, $rname, $description, $user, $group) = @_;
return undef unless(defined($user) && defined($group));
@@ -153,80 +112,6 @@
return get_by_reponame($main, $rname);
}
-sub old_create
-{
- my $self = shift;
- my $conf;
- my $quota;
-
- return -2 if ( $self->{'user'}->fetch < 0 );
- return -3 if ( $self->{'group'}->fetch < 0 );
-
- $self->{'owner_uid'} = $self->{'user'}->get_uid;
- $self->{'owner_gid'} = $self->{'group'}->get_gid;
-
- my $request = $self->{'db'}->prepare("SELECT * FROM vhffs_repository WHERE name='" . $self->{'name'} . "'");
- my $rows = $request->execute;
- return -1 if ( $rows != 0 );
-
- my $oid = $self->SUPER::create();
- if ( $oid lt 0 )
- {
- return( -1 );
- }
- else
- {
- $self->{'object_id'} = $oid;
- }
-
-
- #Get the max repository_id and compute the new repository_id
- my $repository_id = 1;
- my $resultuid = $self->{'db'}->selectall_arrayref("SELECT MAX(repository_id) FROM vhffs_repository");
- $repository_id = $resultuid->[0][0] if ( defined $resultuid->[0][0] );
- $repository_id++;
-
- #Quota
- $conf = $self->{'main'}->get_config->get_service("repository");
- $quota = 100;
- $quota = $conf->{'default_quota'} if( ( defined $conf ) && ( defined $conf->{'default_quota'} ) );
-
- #Finally, create the object
- my $text = "INSERT INTO vhffs_repository VALUES( '".$repository_id."' , '".$self->{'name'} . "','".$self->{'user'}->get_uid."','".$self->{'group'}->get_gid."' , '".$quota."' , '0' , '".$self->{'object_id'}."' )";
- $request = $self->{'db'}->prepare( $text );
- $request->execute or return -2;
-
- return $repository_id;
-}
-
-
-sub fetch
-{
- my $self = shift;
-
- my $request = $self->{'db'}->prepare("SELECT * FROM vhffs_repository where name='".$self->{'name'}."'") or return -1;
-
- my $rows = $request->execute() or return -3;
-
- return -1 if( $rows <= 0 );
-
- my $result = $request->fetchrow_hashref();
-
-
- foreach ( keys %{$result} )
- {
- $self->{$_} = $result->{$_}
- }
-
- $self->{'group'} = Vhffs::Group::get_by_gid( $self->{'main'} , $self->{'owner_gid'} );
- return -1 unless( defined $self->{'group'} );
-
-
- $self->SUPER::fetch;
-
- return 1;
-}
-
=pod
=head2 get_by_reponame
Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Svn.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Svn.pm 2007-03-24 15:54:41 UTC (rev 526)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Svn.pm 2007-03-24 16:09:48 UTC (rev 527)
@@ -43,44 +43,6 @@
use strict;
use DBI;
-
-
-sub new
-{
- my $main;
- my $reponame;
- my $this;
- my $self;
- my $class;
- my $user;
- my $group;
-
- $class = shift;
- $main = shift;
- $reponame = shift;
- $user = shift;
- $group = shift;
-
- $this = {};
-
- $this = $class->SUPER::new( $main , 1 , '401' );
-
- #We return an undefined value if the user or the SVNROOT are not correct
- return undef if( ! defined ( $reponame ) );
- return undef if( length( $reponame ) < 3 );
- return undef if( ! ( $reponame =~ /^[a-z0-9]+$/ ) );
-
-
- $this->{'user'} = $user;
- $this->{'group'} = $group;
- $this->{'reponame'} = $reponame;
- $this->{'public'} = 1;
-
- bless( $this , $class );
-
- return $this;
-}
-
sub check_name($) {
my $name = shift;
return ($name =~ /^[a-z0-9]{3,64}$/);
@@ -99,16 +61,9 @@
return -1 if( $self->SUPER::delete < 0 );
}
-
-
sub create
{
- if($_[0]->isa('Vhffs::Services::Svn')) {
- my ($package, $file, $line) = caller();
- warn "Using deprecated form of method Vhffs::Svn::create from $package ($file:$line)\n";
- return old_create(@_);
- }
- my ($main, $rname, $description, $user, $group) = @_;
+ my ($main, $rname, $description, $user, $group) = @_;
return undef unless(defined($user) && defined($group));
return undef unless(check_name($rname));
@@ -128,78 +83,6 @@
return get_by_reponame($main, $rname);
}
-sub old_create
-{
- my $self = shift;
-
-
- return -2 if ( !defined $self->{'user'} );
- return -3 if ( !defined $self->{'group'} );
-
-
- my $request = $self->{'db'}->prepare("SELECT * FROM vhffs_svn WHERE reponame='" . $self->{'reponame'} ."' AND owner_gid='".$self->{'group'}->get_gid."'");
- my $rows = $request->execute;
- return -1 if ( $rows != 0 );
-
-
- $self->{'owner_uid'} = $self->{'user'}->get_uid;
-
- my $oid = $self->SUPER::create();
- if ( $oid lt 0 )
- {
- return( -1 );
- }
- else
- {
- $self->{'object_id'} = $oid;
- }
-
-
- #Finally, create the object
- my $text = "INSERT INTO vhffs_svn (reponame,owner_uid,owner_gid,public,object_id) VALUES( '".$self->{'reponame'} . "','".$self->{'user'}->get_uid."','".$self->{'group'}->get_gid."' , '1' , '".$self->{'object_id'}."' )";
- $request = $self->{'db'}->prepare( $text );
- $request->execute or return -2;
-
- return 1;
-}
-
-
-sub fetch
-{
- my ($package, $file, $line) = caller();
- warn "Using deprecated method Vhffs::Svn::fetch from $package ($file:$line).\n";
-
- my $self = shift;
-
-
- my $query = "SELECT * FROM vhffs_svn where reponame='".$self->{'reponame'}."' AND owner_gid='".$self->get_group->get_gid."'";
- my $request = $self->{'db'}->prepare( $query ) or return -1;
-
- my $rows = $request->execute() or return -3;
-
- return -2 if( $rows <= 0 );
-
- my $result = $request->fetchrow_hashref();
-
-
- foreach ( keys %{$result} )
- {
- $self->{$_} = $result->{$_}
- }
-
-
- $self->{'group'} = Vhffs::Group::get_by_gid( $self->{'main'} , $self->{'owner_gid'} );
- return -1 unless( defined $self->{'group'} );
-
- $self->{'user'} = Vhffs::User::get_by_uid( $self->{'main'} , $self->{'owner_uid'} );
- return -1 unless( defined $self->{'user'} );
-
-
- $self->SUPER::fetch;
-
- return 1;
-}
-
sub get_by_reponame($$) {
my ($main, $reponame) = @_;
my @params;
Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/User.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/User.pm 2007-03-24 15:54:41 UTC (rev 526)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/User.pm 2007-03-24 16:09:48 UTC (rev 527)
@@ -86,39 +86,6 @@
use Vhffs::Group;
use Vhffs::Functions;
-
-
-sub new
-{
- my $main;
- my $uid;
- my $name;
- my $this;
- my $self;
- my $class;
-
- $class = shift;
- $main = shift;
- $name = shift;
- $uid = shift;
-
- $this = {};
-
- if( ! defined( $name ) )
- {
- $name = get_name_by_uid( $main , $uid );
- }
- return undef unless (check_username($name));
-
- $this = $class->SUPER::new( $main , 1 , $uid );
- $this->{'username'} = $name;
- $this->{'uid'} = $uid if ( defined $uid );
- $this->{'group'} = new Vhffs::Group( $main , $name , $uid );
- $this->{'admin'} = 0;
-
- bless( $this , $class );
-}
-
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, $date_creation, $description, $state) = @_;
my $self = $class->SUPER::_new($main, $oid, $uid, $date_creation, $description, $state, Vhffs::Constants::TYPE_USER);
@@ -161,60 +128,6 @@
return ($main->get_db_object()->do('SELECT uid FROM vhffs_users WHERE username = ?', undef, $username) > 0);
}
-
-
-# get unix informations for a user : uid, gid, username, status, homedir, ...
-sub fetch_unix
-{
- my $request;
- my $result;
- my $query;
- my $gid;
- my $self;
- my %hash;
- my $rows;
-
- $self = shift;
-
- $query = 'SELECT * FROM vhffs_users WHERE username=?';
-
- $request = $self->{'db'}->prepare( $query ) or return -2;
-
- $rows = $request->execute($self->{'username'}) or return -2;
-
- if ( $rows > 0 )
- {
- $result = $request->fetchrow_hashref();
-
-
- foreach ( keys %{$result} )
- {
- $self->{"$_"} = $result->{$_}
- }
- return 1;
- }
- else
- {
- return -1;
- }
-
- $self->{group}->fetch();
- $self->SUPER::fetch();
- return 1;
-
-}
-
-
-# get a complete user
-# it fetch informations in the vhffs_users table
-sub fetch
-{
- my ($package, $file, $line) = caller();
- warn "Using deprecated method Vhffs::User::fetch from $package ($file:$line).\n";
- return fetch_unix(@_);
-}
-
-
#add a user to a group
sub add_group
{
@@ -225,7 +138,7 @@
$self = shift;
$group = shift;
- return -1 if ( $group->fetch < 0 ) ;
+ return -1 if ( !defined $group ) ;
$request = $self->{'db'}->prepare('INSERT INTO vhffs_user_group VALUES( ?, ? )') or return -2;
@@ -264,13 +177,6 @@
=cut
sub create {
- # for compatibility until complete refactoring
- if($_[0]->isa('Vhffs::User')) {
- my ($package, $file, $line) = caller();
- warn "Using deprecated form of Vhffs::User::create from $package ($file:$line).\n";
- return old_create(@_);
- }
-
my ( $main, $username, $password, $admin, $mail, $firstname, $lastname, $city, $zipcode, $country, $address, $gpg_key ) = @_;
return undef unless check_username($username);
@@ -334,93 +240,6 @@
return $user;
}
-#create a new user with username and password
-# !!! DEPRECATED !!!
-sub old_create
-{
- my $self;
- my $config;
- my $conf;
- my $group;
- my $resultuid;
- my $uid;
- my $gid;
- my $request;
- my $query;
- my $rows;
- my $badusers;
- my $homedir;
-
- ( $self ) = @_ ;
-
- $conf = $self->{'main'}->get_config->get_users;
- $badusers = $self->{'main'}->get_config->get_bad_username;
-
- if( defined $badusers )
- {
-
- foreach ( @{$badusers} )
- {
- return -10 if ( $_ eq $self->{"username"} );
- }
- }
-
-
- $self->{'username'} =~ tr/A-Z/a-z/;
-
- $self->{'db'}->begin_work;
- # Localize RaiseError so it get restored after we finish
- # With this enabled, DBI automagically call die if a
- # query goes wrong.
- local $self->{'db'}->{'RaiseError'} = 1;
-
- eval {
-
- # First we create the object corresponding to this user
- my $oid = $self->SUPER::create();
- die if ( $oid lt 0 ); # Creation failed
-
- $self->{'admin'} = 0 if ( ! defined $self->{'admin'} );
-
- $homedir = Vhffs::Functions::hash_homename( $self->{'username'} , $self->{'main'} );
-
- $request = $self->{'db'}->prepare('INSERT INTO vhffs_users (gid, username, shell, passwd, homedir, admin, date_creation, object_id) VALUES(?, ?, ?, ?, ?, ?, now(), ?)');
-
- $request->execute(3 , $self->{'username'}, $conf->{'shell'}, '' , $homedir, $self->{'admin'}, $oid);
-
- $self->{'uid'} = $self->{'db'}->last_insert_id(undef, undef, 'vhffs_users', undef);
- $self->SUPER::set_owner($self->{'uid'});
- $self->SUPER::commit();
-
- #Now, create the GID
-
- $self->{'group'} = Vhffs::Group::create( $self->{'main'} , $self->{'username'} , $self->{'uid'} );
- die unless defined( $self->{group} );
- $self->{'group'}->set_status( Vhffs::Constants::ACTIVATED );
- $self->{'group'}->commit;
- $self->{'gid'} = $gid;
-
- $request = $self->{'db'}->prepare('UPDATE vhffs_users SET gid = ? WHERE username=?');
- $request->execute($self->{'gid'}, $self->{'username'});
-
- # Fill User's informations
- $self->commit;
- # If we are here all was fine so make changes permanent
- $self->{'db'}->commit;
- $self->fetch;
- };
-
- if($@) {
- # An error occured => cancel transaction
- $self->{'db'}->rollback;
- return -1;
- }
- return $self->{'uid'};
-}
-
-
-
-
#modify a user
#use as this : modify_user($db , username , field , value);
#Example : modify_user($db , "soda" , "shell" , "/bin/bash");
@@ -497,7 +316,6 @@
$self = shift;
- return -1 if ($self->fetch < 0 );
return -1 if ( ! defined $self->{'username'} );
return -1 if ( ! defined $self->{'uid'} );
return -2 if ( $self->{'group'}->delete < 0 );
@@ -961,7 +779,6 @@
{
my $self = shift;
- return -1 if( $self->fetch < 0 );
my $uid = $self->get_uid;
my $query = 'SELECT COUNT(g.groupname) FROM vhffs_groups g, vhffs_user_group ug, vhffs_object o WHERE ug.uid=? AND g.gid=ug.gid AND o.object_id=g.object_id AND o.state='.Vhffs::Constants::ACTIVATED;