[vhffs-dev] [402] Refactored Vhffs::Services::Httpd

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


Revision: 402
Author:   beuss
Date:     2007-01-18 14:51:18 +0000 (Thu, 18 Jan 2007)

Log Message:
-----------
Refactored Vhffs::Services::Httpd
If you are already using 4.1 please update your DB (UNIQUE (servername)) and set httpd_id_seq to the correct value.
Minor changes on modobot
Web areas admin allow to modify only fields that are effectively modified by the code...

Modified Paths:
--------------
    branches/vhffs_4.1/Makefile
    branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Web.pm
    branches/vhffs_4.1/vhffs-api/src/Vhffs/Robots/Web.pm
    branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Cvs.pm
    branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Httpd.pm
    branches/vhffs_4.1/vhffs-backend/src/pgsql/alter_from4.0_tocurrent.sql
    branches/vhffs_4.1/vhffs-backend/src/pgsql/initdb.sql
    branches/vhffs_4.1/vhffs-irc/modobot.pl
    branches/vhffs_4.1/vhffs-panel/acl/view.pl
    branches/vhffs_4.1/vhffs-panel/admin/web/edit.pl
    branches/vhffs_4.1/vhffs-panel/admin/web/edit_submit.pl
    branches/vhffs_4.1/vhffs-panel/admin/web/list.pl
    branches/vhffs_4.1/vhffs-panel/admin/web/show.pl
    branches/vhffs_4.1/vhffs-panel/templates/admin/web/edit.tmpl
    branches/vhffs_4.1/vhffs-panel/web/delete.pl
    branches/vhffs_4.1/vhffs-panel/web/prefs.pl
    branches/vhffs_4.1/vhffs-panel/web/prefs_save.pl
    branches/vhffs_4.1/vhffs-panel/web/web_submit.pl
    branches/vhffs_4.1/vhffs-tests/src/Stats.pl


Modified: branches/vhffs_4.1/Makefile
===================================================================
--- branches/vhffs_4.1/Makefile	2007-01-16 12:21:18 UTC (rev 401)
+++ branches/vhffs_4.1/Makefile	2007-01-18 14:51:18 UTC (rev 402)
@@ -302,4 +302,6 @@
 	@perl -I vhffs-tests/src/ -I vhffs-api/src/ -e 'use Test::Harness; Test::Harness::runtests("vhffs-tests/src/Stats.pl");'
 test-cvs:
 	@perl -I vhffs-tests/src/ -I vhffs-api/src/ -e 'use Test::Harness; Test::Harness::runtests("vhffs-tests/src/Services/Cvs.pl");'
+test-web:
+	@perl -I vhffs-tests/src/ -I vhffs-api/src/ -e 'use Test::Harness; Test::Harness::runtests("vhffs-tests/src/Services/Httpd.pl");'
 

Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Web.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Web.pm	2007-01-16 12:21:18 UTC (rev 401)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Panel/Web.pm	2007-01-18 14:51:18 UTC (rev 402)
@@ -99,18 +99,14 @@
 
 sub create_web
 {
-        my( $main , $servername , $user , $group ) = @_;
+        my( $main, $servername, $description, $user, $group ) = @_;
 
         return -1 if( !defined $user );
-        return -2 if( $group->fetch < 0 );
+        return -2 if( !defined $group );
 
-        my $web = new Vhffs::Services::Httpd( $main , $servername , $user , $group );
+        my $web = Vhffs::Services::Httpd::create($main, $servername, $description, $user, $group);
 		return undef if( ! defined $web );
-		$web->set_user( $user );
-		$web->set_group( $group );
 
-        return undef if ( $web->create < 0 );
-
         return undef if ( Vhffs::Acl::add_acl( $user , $web , Vhffs::Constants::ACL_DELETE , $main ) < 0 );
         return undef if( Vhffs::Acl::add_acl( $group , $web , Vhffs::Constants::ACL_VIEW , $main ) < 0 );
 

Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Robots/Web.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Robots/Web.pm	2007-01-16 12:21:18 UTC (rev 401)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Robots/Web.pm	2007-01-18 14:51:18 UTC (rev 402)
@@ -71,7 +71,7 @@
 	my $main = shift;
 	my $web = shift;
 
-	if( ( defined $web ) && ( $web->fetch > 0 ) ) 
+	if( defined $web ) 
 	{
 		$web->add_history( "Ok, the robot take the creation of this object. Web directory will be created");
 		my $webdir = $main->get_config->get_datadir . "/" . Vhffs::Constants::WEBDIR . "/" . Vhffs::Functions::hash_webdir( $web->get_servername );
@@ -114,7 +114,7 @@
 
 
 	my $dir;	
-	if( $web->fetch > 0 )
+	if(defined $web)
 	{
 		$web->add_history( "Ok, the robot will delete this object. Web directory will be removed");
 		my $hash = Vhffs::Functions::hash_webdir( $web->get_servername );

Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Cvs.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Cvs.pm	2007-01-16 12:21:18 UTC (rev 401)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Cvs.pm	2007-01-18 14:51:18 UTC (rev 402)
@@ -232,13 +232,13 @@
 sub set_user
 {
 	my ( $self , $user ) = @_;
-	$self->{'user'} = $user;
+	$self->{'owner_uid'} = $user->get_uid() if(defined $user && defined $self);
 }
 
 sub set_group
 {
 	my ( $self , $group ) = @_;
-	$self->{'group'} = $group;
+	$self->{'owner_gid'} = $group->get_gid() if(defined $group && defined $self);
 }
 
 sub get_cvsroot

Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Httpd.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Httpd.pm	2007-01-16 12:21:18 UTC (rev 401)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Httpd.pm	2007-01-18 14:51:18 UTC (rev 402)
@@ -57,12 +57,12 @@
 
     ( $class , $main , $servername , $user , $group ) = @_;
 				    
+    return undef unless(check_servername($servername));
+    
     $this = {};
 
     $this = $class->SUPER::new( $main , 1 , '401' );
-   
-   return undef if( ! ($servername =~ /^[a-z0-9](([a-z0-9]\-{0,1})+\.)+[a-z]{2,4}$/ ) );
-   return undef if( $servername =~ /\.\./ );
+
 	
 	$this->{'servername'} = $servername if ( defined $servername );
 
@@ -75,6 +75,11 @@
 	return $this;
 }
 
+sub check_servername($) {
+    my $servername = shift;
+    return ( (defined($servername)) && ($servername =~ /^[a-z0-9](([a-z0-9]\-{0,1})+\.)+[a-z]{2,4}$/ ) && ($servername !~ /\.\./) );
+}
+
 sub delete
 {
     my $self = shift;
@@ -87,9 +92,29 @@
 	return 1;
 }
 
-
 sub create
 {
+    return old_create(@_) if($_[0]->isa('Vhffs::Services::Httpd'));
+    my ($main, $servername, $description, $user, $group) = @_;
+    return undef unless(defined($user) && defined($group));
+    return undef unless(check_servername($servername));
+
+    my $parent =  Vhffs::Object::create($main, $user->get_uid, $description);
+    
+    return undef unless(defined($parent));
+
+    my $sql = 'INSERT INTO vhffs_httpd(servername, crawl, owner_http, owner_rev, owner_uid, owner_gid, trafic, alert_state, alert_limit, object_id) VALUES(?, 1, ?, ?, ?, ?, 0, 0, 0, ?)';
+
+    my $dbh = $main->get_db_object();
+
+    my $sth = $dbh->prepare($sql);
+    $sth->execute($servername, $user->get_uid, $user->get_uid, $user->get_uid, $group->get_gid, $parent->get_oid) or return undef;
+
+    return get_by_servername($main, $servername);
+}
+
+sub old_create
+{
 	my $self = shift;
 
 	return -1 if( $self->{'user'}->fetch < 0 );
@@ -151,20 +176,13 @@
 	return 1;
 }
 
-
-
 sub commit
 {
-	my $self = shift;	
+	my $self = shift;
 
-	$self->{'crawl'} = 0 if( ! defined $self->{'crawl'} );
-	$self->{'trafic'} = 1 if( ! defined $self->{'trafic'} );
+    my $sql = 'UPDATE vhffs_httpd SET crawl = ?, trafic = ?, alert_limit = ? WHERE servername = ?';
+    $self->{'db'}->do($sql, undef, $self->{crawl}, $self->{trafic}, $self->{alert_limit}, $self->{servername});
 
-	my $query = "UPDATE vhffs_httpd SET crawl='".$self->{'crawl'}."', trafic= '".$self->{'trafic'}."' WHERE servername='".$self->{'servername'}."'";
-	my $request = $self->{'db'}->prepare( $query );
-	$request->execute;
-
-
 	$self->SUPER::commit;
 }
 
@@ -261,72 +279,75 @@
 
 sub getall
 {
-    my $vhffs = shift;
-    my $state = shift;
-    my $name = shift;
-    my $group = shift;
+    my ($vhffs, $state, $name, $group) = @_;
 
-    my $query;
-    my $request;
+    my $sql;
+    my @params;
+    my $sth;
 
     my $objs;
     my $result;
     my $tmp;
 
-	$query = "SELECT w.servername, w.object_id FROM  vhffs_httpd w, vhffs_object o WHERE w.object_id = o.object_id";
-    $query .= " AND o.state='".$state."'" if( defined $state );
-    $query .= " AND w.servername LIKE '%".$name."%'" if( defined $name );
-    $query .= " AND w.owner_gid='".$group->get_gid."'" if( defined $group );
+    $sql = 'SELECT  h.httpd_id, h.servername, h.crawl, h.owner_http, h.owner_rev, h.owner_uid, h.owner_gid, h.trafic, h.alert_state, h.alert_limit, 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';
+    if(defined $state) {
+        $sql .= ' AND o.state = ?';
+        push(@params, $state);
+    }
+    if(defined($name)) {
+        $sql .= ' AND h.servername LIKE ?';
+        push(@params, '%'.$name.'%');
+    }
+    if(defined($group)) {
+        $sql .= ' AND h.owner_gid = ?';
+        push(@params, $group->get_gid);
+    }
+	$sql .= " ORDER BY servername";
+    $sth = $vhffs->get_db_object->prepare( $sql );
+    my $rows = $sth->execute(@params);
     
-	
-	$query .= " ORDER BY servername";
-    $request = $vhffs->{'db'}->prepare( $query );
-    return undef if ( ! $request->execute );
+    return undef unless($rows);
 
-    while( $result = $request->fetchrow_hashref )
+    while( $result = $sth->fetchrow_arrayref )
     {
-        $tmp = new Vhffs::Services::Httpd( $vhffs , $result->{'servername'} );
-        if( ( defined ( $tmp ) ) && ( $tmp->fetch > 0 ) )
-        {
-            push @{$objs} , $tmp;
-        }
+        push @{$objs}, _new Vhffs::Services::Httpd($vhffs, @{$result});
     }
     return $objs;
 }
 
 sub getall_by_letter
 {
-    my $vhffs = shift;
-    my $letter = shift;
-    my $state = shift;
+    my ($vhffs, $letter, $state) = @_;
 
     return getall($vhffs, $state) if ( ! defined $letter );
 
     $letter .= '%';
 
-    my $query;
-    my $request;
+    my $sql;
+    my @params;
+    my $sth;
 
     my $objs = [];
     my $result;
-    my $tmp;
 
-    $query = "SELECT w.servername, w.object_id FROM  vhffs_httpd w, vhffs_object o WHERE w.object_id = o.object_id";
-    $query .= " AND o.state='".$state."'" if( defined $state );
-    $query .= " AND w.servername LIKE ?";
-    $query .= " ORDER BY servername";
+    $sql = 'SELECT  h.httpd_id, h.servername, h.crawl, h.owner_http, h.owner_rev, h.owner_uid, h.owner_gid, h.trafic, h.alert_state, h.alert_limit, 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 LIKE ?';
 
-    $request = $vhffs->{'db'}->prepare( $query );
-    return undef if ( ! $request->execute($letter) );
+    push(@params, $letter);
 
+    if(defined $state) {
+        $sql .= 'AND o.state = ?';
+        push(@params, $state);
+    }
+    $sql .= 'ORDER BY servername';
 
-    while( $result = $request->fetchrow_hashref )
+    $sth = $vhffs->get_db_object->prepare( $sql );
+    my $rows = $sth->execute(@params);
+
+    return undef unless($rows);
+
+    while( $result = $sth->fetchrow_arrayref )
     {
-        $tmp = new Vhffs::Services::Httpd( $vhffs , $result->{'servername'} );
-        if( ( defined ( $tmp ) ) && ( $tmp->fetch > 0 ) )
-        {
-            push @{$objs} , $tmp;
-        }
+        push @{$objs}, _new Vhffs::Services::Httpd($vhffs, @{$result});
     }
     return $objs;
 }
@@ -334,39 +355,34 @@
 
 sub search
 {
-    my $vhffs = shift;
-    my $state = shift;
-    my $name = shift;
-    my $query;
-    my $request;
+    my ($vhffs, $state, $name) = @_;
 
+    my $sql;
+    my $sth;
+    my @params;
+
     my $objs;
     my $result;
-    my $tmp;
 
-    if( ( defined $state ) && ( $state < Vhffs::Constants::TO_DELETE ) )
-    {
-        $query = "SELECT w.servername, w.object_id FROM  vhffs_httpd w, vhffs_object o WHERE o.state='".$state."' AND w.object_id = o.object_id AND ( o.description LIKE '%$name%' OR w.servername LIKE '%name%' )";
+    $sql = 'SELECT h.httpd_id, h.servername, h.crawl, h.owner_http, h.owner_rev, h.owner_uid, h.owner_gid, h.trafic, h.alert_state, h.alert_limit, 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';
+
+    if( ( defined $state ) && ( $state < Vhffs::Constants::TO_DELETE ) ) {
+        $sql .= 'WHERE o.state= ? AND ( o.description LIKE ? OR w.servername LIKE ? )';
+        push(@params, $state);
+        push(@params, '%'.$name.'%');
+        push(@params, '%'.$name.'%');
     }
-    else
-    {
-        $query = "SELECT w.servername, w.object_id FROM  vhffs_httpd w, vhffs_object o WHERE w.object_id = o.object_id";
-    }
-    $query .= " ORDER BY servername";
-    $request = $vhffs->{'db'}->prepare( $query );
-    my $rows = $request->execute;
+    
+    $sql .= " ORDER BY servername";
+    $sth = $vhffs->get_db_object()->prepare( $sql );
 
-    return undef if( $rows == 0);
+    my $rows = $sth->execute(@params);
 
-#    $result = $request->fetchall_hashref( 'servername' );
+    return undef unless($rows);
 
-    while( $result = $request->fetchrow_hashref )
+    while( $result = $sth->fetchrow_arrayref )
     {
-        $tmp = new Vhffs::Services::Httpd( $vhffs , $result->{'servername'} );
-        if( ( defined ( $tmp ) ) && ( $tmp->fetch > 0 ) )
-        {
-            push @{$objs} , $tmp;
-        }
+        push @{$objs}, _new Vhffs::Services::Httpd($vhffs, @{$result});
     }
     return $objs;
 }
@@ -374,38 +390,54 @@
 
 sub getall_by_group
 {
-    my $vhffs = shift;
-    my $group = shift;
+    my ($vhffs, $group) = @_;
 
-    my $query;
-    my $request;
+    my $sql;
+    my $sth;
 
     my $objs;
     my $result;
     my $tmp;
 
-     
-    $query = "SELECT w.servername, w.object_id FROM  vhffs_httpd w, vhffs_object o WHERE w.object_id = o.object_id AND w.owner_gid='".$group->get_gid."'";
     
-    $request = $vhffs->{'db'}->prepare( $query );
-    my $rows = $request->execute;
+    $sql = 'SELECT h.httpd_id, h.servername, h.crawl, h.owner_http, h.owner_rev, h.owner_uid, h.owner_gid, h.trafic, h.alert_state, h.alert_limit, 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 AND h.owner_gid = ? ORDER BY servername';
 
-    return undef if( $rows == 0);
 
-    $result = $request->fetchall_hashref( 'servername' );
+    $sth = $vhffs->get_db_object()->prepare( $sql );
 
-    foreach( keys %{$result} )
+    my $rows = $sth->execute($group->get_gid());
+
+    return undef unless($rows);
+
+    while( $result = $sth->fetchrow_arrayref )
     {
-        $tmp = new Vhffs::Services::Httpd( $vhffs , $_ );
-        if( ( defined ( $tmp ) ) && ( $tmp->fetch > 0 ) )
-        {
-            push @{$objs} , $tmp;
-        }
+        push @{$objs}, _new Vhffs::Services::Httpd($vhffs, @{$result});
     }
     return $objs;
 }
 
+sub get_by_servername {
+    my ($main, $servername) = @_;
+    my $sql = 'SELECT h.httpd_id, h.servername, h.crawl, h.owner_http, h.owner_rev, h.owner_uid, h.owner_gid, h.trafic, h.alert_state, h.alert_limit, 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_object();
+    my @params = $dbh->selectrow_array($sql, undef, $servername);
 
+    return _new Vhffs::Services::Httpd($main, @params);
+}
 
+sub _new {
+    my ($class, $main, $httpd_id, $servername, $crawl, $owner_http, $owner_rev, $owner_uid, $owner_gid, $trafic, $alert_state, $alert_limit, $oid, $date_creation, $description, $state) = @_;
 
+    my $self = $class->SUPER::_new($main, $oid, $owner_uid, $date_creation, $description, $state);
+    return undef unless(defined($self));
+
+    foreach (qw(httpd_id servername crawl owner_http owner_rev owner_gid trafic alert_state alert_limit)) {
+        no strict 'refs';
+        eval '$self->{$_} = $'.$_;
+    }
+    return $self;
+}
+
+
 1;

Modified: branches/vhffs_4.1/vhffs-backend/src/pgsql/alter_from4.0_tocurrent.sql
===================================================================
--- branches/vhffs_4.1/vhffs-backend/src/pgsql/alter_from4.0_tocurrent.sql	2007-01-16 12:21:18 UTC (rev 401)
+++ branches/vhffs_4.1/vhffs-backend/src/pgsql/alter_from4.0_tocurrent.sql	2007-01-18 14:51:18 UTC (rev 402)
@@ -28,6 +28,8 @@
 ALTER TABLE vhffs_users ADD CONSTRAINT vhffs_users_unique_username UNIQUE (username);
 ALTER TABLE vhffs_groups ADD CONSTRAINT vhffs_groups_unique_groupname UNIQUE (groupname);
 ALTER TABLE vhffs_cvs ADD CONSTRAINT vhffs_cvs_unique_cvsroot UNIQUE (cvsroot);
+ALTER TABLE vhffs_httpd ADD CONSTRAINT vhffs_httpd_unique_servername UNIQUE (servername);
 
+
 ALTER TABLE vhffs_object ALTER owner_uid DROP NOT NULL;
 ALTER TABLE vhffs_users ALTER gid DROP NOT NULL;

Modified: branches/vhffs_4.1/vhffs-backend/src/pgsql/initdb.sql
===================================================================
--- branches/vhffs_4.1/vhffs-backend/src/pgsql/initdb.sql	2007-01-16 12:21:18 UTC (rev 401)
+++ branches/vhffs_4.1/vhffs-backend/src/pgsql/initdb.sql	2007-01-18 14:51:18 UTC (rev 402)
@@ -369,6 +369,7 @@
 ALTER TABLE vhffs_users ADD CONSTRAINT vhffs_users_unique_username UNIQUE (username);
 ALTER TABLE vhffs_groups ADD CONSTRAINT vhffs_groups_unique_groupname UNIQUE (groupname);
 ALTER TABLE vhffs_cvs ADD CONSTRAINT vhffs_cvs_unique_cvsroot UNIQUE (cvsroot);
+ALTER TABLE vhffs_httpd ADD CONSTRAINT vhffs_httpd_unique_servername UNIQUE (servername);
 
 
 /****** Non primary key constraints.

Modified: branches/vhffs_4.1/vhffs-irc/modobot.pl
===================================================================
--- branches/vhffs_4.1/vhffs-irc/modobot.pl	2007-01-16 12:21:18 UTC (rev 401)
+++ branches/vhffs_4.1/vhffs-irc/modobot.pl	2007-01-18 14:51:18 UTC (rev 402)
@@ -489,7 +489,7 @@
 {
     my $name = shift;
     my $web;
-    if ((! defined ($web = new Vhffs::Services::Httpd( $vhffs , $name, $name ) ) ) || ( $web->fetch < 0 ))
+    if (! defined ($web = Vhffs::Services::Httpd::get_by_servername( $vhffs , $name)))
    {
        irc_msg ("$name : No such website");
    }
@@ -504,16 +504,14 @@
 {
   my $groupname = shift;
   my $group;
-  if ((! defined ($group = new Vhffs::Group( $vhffs , $groupname,'401' ) ) ) || ( $group->fetch < 0 ))
+  if (! defined ($group = Vhffs::Group::get_by_groupname( $vhffs , $groupname)))
   {
     irc_msg ("$groupname : No such groupname");
   }
   else
   {
-    my $user = new Vhffs::User($vhffs,$group->get_owner_username,401);
-    my $ret;
-    $ret = $user->fetch;
-    if ( $ret >= 0 )
+    my $user = Vhffs::User::get_by_uid($vhffs, $group->get_owneruid);
+    if ( defined $user )
     {
       irc_msg ($groupname." owned by ". $user->get_username ." (". $user->get_firstname ." ". $user->get_lastname ." [". $user->get_mail ."] )");
     }

Modified: branches/vhffs_4.1/vhffs-panel/acl/view.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/acl/view.pl	2007-01-16 12:21:18 UTC (rev 401)
+++ branches/vhffs_4.1/vhffs-panel/acl/view.pl	2007-01-18 14:51:18 UTC (rev 402)
@@ -75,7 +75,7 @@
 #First, we instanciate an Object, according to the variable $type
 if( $type eq "web" )
 {
-	$object = new Vhffs::Services::Httpd( $vhffs , $name , $user , $group );
+	$object = Vhffs::Services::Httpd::get_by_servername( $vhffs , $name );
 }
 elsif( $type eq "dns" )
 {

Modified: branches/vhffs_4.1/vhffs-panel/admin/web/edit.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/admin/web/edit.pl	2007-01-16 12:21:18 UTC (rev 401)
+++ branches/vhffs_4.1/vhffs-panel/admin/web/edit.pl	2007-01-18 14:51:18 UTC (rev 402)
@@ -78,7 +78,7 @@
 	my $message = gettext( "CGI ERROR !");
 	$template->param( MESSAGE => $message );
 }
-elsif( ( ! defined ( $object = new Vhffs::Services::Httpd( $vhffs , $webname , '401' ) ) ) || ( $object->fetch < 0 ) )
+elsif( ! defined ( $object = Vhffs::Services::Httpd::get_by_servername( $vhffs , $webname ) ) )
 {
 	$template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );
 	my $message = gettext( "Cannot fetch object");

Modified: branches/vhffs_4.1/vhffs-panel/admin/web/edit_submit.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/admin/web/edit_submit.pl	2007-01-16 12:21:18 UTC (rev 401)
+++ branches/vhffs_4.1/vhffs-panel/admin/web/edit_submit.pl	2007-01-18 14:51:18 UTC (rev 402)
@@ -78,7 +78,7 @@
 	my $message = gettext( "CGI ERROR !");
 	$template->param( MESSAGE => $message );
 }
-elsif( ( ! defined ( $object = new Vhffs::Services::Httpd( $vhffs , $servername , '401' ) ) ) || ( $object->fetch < 0 ) )
+elsif( ! defined ( $object = Vhffs::Services::Httpd::get_by_servername( $vhffs , $servername ) ) )
 {
 	$template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );
 	my $message = gettext( "Cannot fetch object");
@@ -91,6 +91,7 @@
 
 	$object->set_status( $cgi->param( "STATUS" ) );
 	$object->set_crawl( $cgi->param( "CRAWL" ) );
+    $object->set_alertlimit( $cgi->param( "TEXT_ALERT") );
 
 
 	if( $object->commit < 0 )

Modified: branches/vhffs_4.1/vhffs-panel/admin/web/list.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/admin/web/list.pl	2007-01-16 12:21:18 UTC (rev 401)
+++ branches/vhffs_4.1/vhffs-panel/admin/web/list.pl	2007-01-18 14:51:18 UTC (rev 402)
@@ -93,7 +93,6 @@
 		foreach $web ( @{$webs} )
 		{
 			my $subtemplate;
-			next if( $web->fetch < 0 );
 
 			if( $user->is_admin == 1 )  {
 				$subtemplate = new HTML::Template( filename => $templatedir."/admin/web/part.tmpl" );

Modified: branches/vhffs_4.1/vhffs-panel/admin/web/show.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/admin/web/show.pl	2007-01-16 12:21:18 UTC (rev 401)
+++ branches/vhffs_4.1/vhffs-panel/admin/web/show.pl	2007-01-18 14:51:18 UTC (rev 402)
@@ -78,7 +78,7 @@
 	my $message = gettext( "CGI ERROR !");
 	$template->param( MESSAGE => $message );
 }
-elsif( ( ! defined ( $object = new Vhffs::Services::Httpd( $vhffs , $webname , '401' ) ) ) || ( $object->fetch < 0 ) )
+elsif( ! defined ( $object = Vhffs::Services::Httpd::get_by_servername( $vhffs , $webname ) ) )
 {
 	$template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );
 	my $message = gettext( "Cannot fetch object");

Modified: branches/vhffs_4.1/vhffs-panel/templates/admin/web/edit.tmpl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/templates/admin/web/edit.tmpl	2007-01-16 12:21:18 UTC (rev 401)
+++ branches/vhffs_4.1/vhffs-panel/templates/admin/web/edit.tmpl	2007-01-18 14:51:18 UTC (rev 402)
@@ -2,10 +2,10 @@
 
 <form method="post" action="edit_submit.pl">
 	<p>
-		<label for="SERVERNAME">		
+		<label>		
 			<TMPL_VAR NAME="TEXT_SERVERNAME">
 		</label>
-		<input type="text" name="SERVERNAME" id="SERVERNAME" value="<TMPL_VAR NAME="VALUE_SERVERNAME">" />
+		<TMPL_VAR NAME="VALUE_SERVERNAME">
 	</p>
 	<p>
 		<label for="CRAWL">		
@@ -17,28 +17,28 @@
 		</select>
 	</p>
 	<p>
-		<label for="TEXT_GROUP">		
+		<label>
 			<TMPL_VAR NAME="TEXT_GROUP">
 		</label>
-		<input type="text" name="TEXT_GROUP"  id="TEXT_GROUP" value="<TMPL_VAR NAME="VALUE_GROUP">" />
+		<TMPL_VAR NAME="VALUE_GROUP">
 	</p>
 	<p>
-		<label for="OWNER">		
+		<label>
 			<TMPL_VAR NAME="TEXT_OWNER">
 		</label>
-		<input type="text" name="OWNER"  id="OWNER" value="<TMPL_VAR NAME="VALUE_OWNER">" />
+		<TMPL_VAR NAME="VALUE_OWNER">
 	</p>
 	<p>
-		<label for="TEXT_ALERT">		
+		<label for="TEXT_ALERT">
 			<TMPL_VAR NAME="TEXT_ALERT">
 		</label>
-		<input type="text" name="TEXT_ALERT" id="TEXT_ALERT"  value="<TMPL_VAR NAME="VALUE_ALERT">" />
+		<input type="text" name="TEXT_ALERT" id="TEXT_ALERT" VALUE="<TMPL_VAR NAME="VALUE_ALERT">"/>
 	</p>
 	<p>
-		<label for="ALERT_STATE">		
+		<label>
 			<TMPL_VAR NAME="TEXT_ALERT_STATE">
 		</label>
-		<input type="text" name="ALERT_STATE" id="ALERT_STATE"  value="<TMPL_VAR NAME="VALUE_ALERT_STATE">" />
+		<TMPL_VAR NAME="VALUE_ALERT_STATE">
 	</p>
 	<p>
 		<label for="STATUS">		

Modified: branches/vhffs_4.1/vhffs-panel/web/delete.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/web/delete.pl	2007-01-16 12:21:18 UTC (rev 401)
+++ branches/vhffs_4.1/vhffs-panel/web/delete.pl	2007-01-18 14:51:18 UTC (rev 402)
@@ -70,10 +70,10 @@
 
 my $servername = $cgi->param("name");
 
-my $web = new Vhffs::Services::Httpd( $vhffs , $servername , $user , $group );
+my $web = Vhffs::Services::Httpd::get_by_servername( $vhffs , $servername );
 
 
-if( ( ! defined( $web ) )  || ( $web->fetch < 0 ) )
+if( ! defined( $web ) ) 
 {
     $message = gettext("This web area doesn't exist in VHFFS database");
 }

Modified: branches/vhffs_4.1/vhffs-panel/web/prefs.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/web/prefs.pl	2007-01-16 12:21:18 UTC (rev 401)
+++ branches/vhffs_4.1/vhffs-panel/web/prefs.pl	2007-01-18 14:51:18 UTC (rev 402)
@@ -62,9 +62,9 @@
 my $template;
 my $templatedir = $vhffs->get_config->get_templatedir;
 
-my $web = new Vhffs::Services::Httpd( $vhffs , $servername , $user , $group );
+my $web = Vhffs::Services::Httpd::get_by_servername( $vhffs , $servername );
 
-if( $web->fetch < 0 )
+if( ! defined($web) )
 {
 
 	$template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );

Modified: branches/vhffs_4.1/vhffs-panel/web/prefs_save.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/web/prefs_save.pl	2007-01-16 12:21:18 UTC (rev 401)
+++ branches/vhffs_4.1/vhffs-panel/web/prefs_save.pl	2007-01-18 14:51:18 UTC (rev 402)
@@ -70,9 +70,9 @@
 
 
 
-my $web = new Vhffs::Services::Httpd( $vhffs , $servername , $user , $group );
+my $web = Vhffs::Services::Httpd::get_by_servername( $vhffs , $servername );
 
-if( ( ! defined( $web ) )  || ( $web->fetch < 0 ) )
+if( ! defined( $web ) )
 {
     $message = gettext("This web area doesn't exist in VHFFS database");
 }

Modified: branches/vhffs_4.1/vhffs-panel/web/web_submit.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/web/web_submit.pl	2007-01-16 12:21:18 UTC (rev 401)
+++ branches/vhffs_4.1/vhffs-panel/web/web_submit.pl	2007-01-18 14:51:18 UTC (rev 402)
@@ -78,12 +78,10 @@
 else
 {
 
-	my $web = Vhffs::Panel::Web::create_web( $vhffs , $servername , $user , $group );
+	my $web = Vhffs::Panel::Web::create_web( $vhffs, $servername, $description, $user, $group );
 	
 	if( defined $web )
 	{
-		$web->set_description( $description );
-		$web->commit;
 		$message = gettext("Web area successfully created !");
 	}
 	else

Modified: branches/vhffs_4.1/vhffs-tests/src/Stats.pl
===================================================================
--- branches/vhffs_4.1/vhffs-tests/src/Stats.pl	2007-01-16 12:21:18 UTC (rev 401)
+++ branches/vhffs_4.1/vhffs-tests/src/Stats.pl	2007-01-18 14:51:18 UTC (rev 402)
@@ -95,15 +95,13 @@
     $group->fetch;
     $user->fetch;
     # Httpd servername must end with a 2-4 letters suffix
-    $svc = new Vhffs::Services::Httpd($main, "httpd0$i.test.com", $user, $group);
-    $svc->create;
+    $svc = Vhffs::Services::Httpd::create($main, "httpd0$i.test.com", '', $user, $group);
 }
 
 $stats->fetch;
 is($stats->get_web_in_moderation, 9, 'All httpd services waiting for moderation');
 for(my $i = 1 ; $i < 10 ; ++$i) {
-    $svc = new Vhffs::Services::Httpd($main, "httpd0$i.test.com");
-    $svc->fetch;
+    $svc = Vhffs::Services::Httpd::get_by_servername($main, "httpd0$i.test.com");
     $svc->set_status(Vhffs::Constants::WAITING_FOR_CREATION);
     $svc->commit;
     $stats->fetch;
@@ -112,8 +110,7 @@
 }
 
 for(my $i = 1 ; $i < 10 ; ++$i) {
-    $svc = new Vhffs::Services::Httpd($main, "httpd0$i.test.com");
-    $svc->fetch;
+    $svc = Vhffs::Services::Httpd::get_by_servername($main, "httpd0$i.test.com");
     $svc->set_status(Vhffs::Constants::ACTIVATED);
     $svc->commit;
     $stats->fetch;


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