[vhffs-dev] [1190] Added cron module, everything is done except the scheduler

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


Revision: 1190
Author:   gradator
Date:     2008-05-03 01:34:30 +0200 (Sat, 03 May 2008)

Log Message:
-----------
Added cron module, everything is done except the scheduler

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Constants.pm
    trunk/vhffs-api/src/Vhffs/Functions.pm
    trunk/vhffs-api/src/Vhffs/Makefile.am
    trunk/vhffs-api/src/Vhffs/ObjectFactory.pm
    trunk/vhffs-api/src/Vhffs/Panel/Admin.pm
    trunk/vhffs-api/src/Vhffs/Panel/Main.pm
    trunk/vhffs-api/src/Vhffs/Panel/Menu.pm
    trunk/vhffs-api/src/Vhffs/Services.pm
    trunk/vhffs-backend/conf/vhffs.conf.dist.in
    trunk/vhffs-backend/src/pgsql/initdb.sql.in
    trunk/vhffs-compat/4.1.sql
    trunk/vhffs-panel/Makefile.am
    trunk/vhffs-panel/templates/Makefile.am
    trunk/vhffs-robots/Makefile.am
    trunk/vhffs-themes/Makefile.am
    trunk/vhffs-themes/vhffs/main.css

Added Paths:
-----------
    trunk/vhffs-api/src/Vhffs/Panel/Cron.pm
    trunk/vhffs-api/src/Vhffs/Services/Cron.pm
    trunk/vhffs-panel/admin/cron/
    trunk/vhffs-panel/admin/cron/index.pl
    trunk/vhffs-panel/admin/cron/list.pl
    trunk/vhffs-panel/admin/cron/search.pl
    trunk/vhffs-panel/cron/
    trunk/vhffs-panel/cron/create.pl
    trunk/vhffs-panel/cron/delete.pl
    trunk/vhffs-panel/cron/index.pl
    trunk/vhffs-panel/cron/prefs.pl
    trunk/vhffs-panel/templates/admin/cron/
    trunk/vhffs-panel/templates/admin/cron/part.tmpl
    trunk/vhffs-panel/templates/admin/cron/search.tmpl
    trunk/vhffs-panel/templates/cron/
    trunk/vhffs-panel/templates/cron/create.tmpl
    trunk/vhffs-panel/templates/cron/prefs.tmpl
    trunk/vhffs-robots/src/cron_create.pl
    trunk/vhffs-robots/src/cron_delete.pl
    trunk/vhffs-themes/vhffs/images/cronentry.png


Modified: trunk/vhffs-api/src/Vhffs/Constants.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Constants.pm	2008-04-19 21:57:22 UTC (rev 1189)
+++ trunk/vhffs-api/src/Vhffs/Constants.pm	2008-05-02 23:34:30 UTC (rev 1190)
@@ -75,6 +75,7 @@
     TYPE_DNS => 50,
     TYPE_MAIL => 60,
     TYPE_ML => 61,
+    TYPE_CRON => 70,
     
 # Tags visibility
 	TAG_VISIBILITY_PUBLIC		=> 1,

Modified: trunk/vhffs-api/src/Vhffs/Functions.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Functions.pm	2008-04-19 21:57:22 UTC (rev 1189)
+++ trunk/vhffs-api/src/Vhffs/Functions.pm	2008-05-02 23:34:30 UTC (rev 1190)
@@ -84,6 +84,7 @@
 $TYPES_STRINGS[Vhffs::Constants::TYPE_DNS] = 'Domain Name';
 $TYPES_STRINGS[Vhffs::Constants::TYPE_MAIL] = 'Mail Domain';
 $TYPES_STRINGS[Vhffs::Constants::TYPE_ML] = 'Mailing List';
+$TYPES_STRINGS[Vhffs::Constants::TYPE_CRON] = 'Cron job';
 
 
 # Return 1 if string is either 'yes', 'on', '1', 'y', else return 0

Modified: trunk/vhffs-api/src/Vhffs/Makefile.am
===================================================================
--- trunk/vhffs-api/src/Vhffs/Makefile.am	2008-04-19 21:57:22 UTC (rev 1189)
+++ trunk/vhffs-api/src/Vhffs/Makefile.am	2008-05-02 23:34:30 UTC (rev 1190)
@@ -39,6 +39,7 @@
 	Panel/User.pm \
 	Panel/Web.pm \
 	Panel/Template.pm \
+	Panel/Cron.pm \
 	Robots/Cvs.pm \
 	Robots/Group.pm \
 	Robots/Mail.pm \
@@ -62,6 +63,7 @@
 	Services/Repository.pm \
 	Services/Svn.pm \
 	Services/Git.pm \
+	Services/Cron.pm \
 	Tag/Category.pm
 
 # Define the substitution we need to point perl script at correct location

Modified: trunk/vhffs-api/src/Vhffs/ObjectFactory.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/ObjectFactory.pm	2008-04-19 21:57:22 UTC (rev 1189)
+++ trunk/vhffs-api/src/Vhffs/ObjectFactory.pm	2008-05-02 23:34:30 UTC (rev 1190)
@@ -66,6 +66,7 @@
 $OBJECTS_BY_TYPE[Vhffs::Constants::TYPE_DNS] = 'Vhffs::Services::DNS';
 $OBJECTS_BY_TYPE[Vhffs::Constants::TYPE_MAIL] = 'Vhffs::Services::Mail';
 $OBJECTS_BY_TYPE[Vhffs::Constants::TYPE_ML] = 'Vhffs::Services::MailingList';
+$OBJECTS_BY_TYPE[Vhffs::Constants::TYPE_CRON] = 'Vhffs::Services::Cron';
 
 =head2 fetch_object
 

Modified: trunk/vhffs-api/src/Vhffs/Panel/Admin.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Admin.pm	2008-04-19 21:57:22 UTC (rev 1189)
+++ trunk/vhffs-api/src/Vhffs/Panel/Admin.pm	2008-05-02 23:34:30 UTC (rev 1190)
@@ -331,7 +331,23 @@
     return { CATNAME => gettext( 'Download repositories Admin' ),    ITEMS => $items, CATTYPE => 'repository'  };
 }
 
+=head2 get_cron_category
 
+    Vhffs::Panel::Admin::get_cron_category;
+
+Returns a hashref (CATNAME, ITEM) containing cron jobs administration
+items.
+
+=cut
+
+sub get_cron_category {
+    my $items = [
+        { LINK => '/admin/cron/list.pl',        LABEL => gettext( 'List all cron jobs' ) },
+        { LINK => '/admin/cron/search.pl',      LABEL => gettext( 'Search for a cron job' ) }
+    ];
+    return { CATNAME => gettext( 'Crons Admin' ),    ITEMS => $items, CATTYPE => 'cron'  };
+}
+
 =head2 get_all_admin_categories
 
     Vhffs::Panel::Admin::get_all_admin_categories($vhffs);
@@ -359,6 +375,7 @@
     push @$categories, get_mail_category    if($config->get_service_availability('mail'));
     push @$categories, get_mailing_category if($config->get_service_availability('mailinglist'));
     push @$categories, get_repo_category    if($config->get_service_availability('repository'));
+    push @$categories, get_cron_category    if($config->get_service_availability('cron'));
     push @$categories, get_tag_category;
 
     return $categories;
@@ -392,6 +409,7 @@
     push @$categories, get_mail_category    if($config->get_service_availability('mail'));
     push @$categories, get_mailing_category if($config->get_service_availability('mailinglist'));
     push @$categories, get_repo_category    if($config->get_service_availability('repository'));
+    push @$categories, get_cron_category    if($config->get_service_availability('cron'));
 
     return $categories;
 }

Added: trunk/vhffs-api/src/Vhffs/Panel/Cron.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Cron.pm	                        (rev 0)
+++ trunk/vhffs-api/src/Vhffs/Panel/Cron.pm	2008-05-02 23:34:30 UTC (rev 1190)
@@ -0,0 +1,121 @@
+#!%PERL%
+# Copyright (c) vhffs project and its contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright 
+#   notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in 
+#   the documentation and/or other materials provided with the 
+#   distribution.
+#3. Neither the name of vhffs nor the names of its contributors 
+#   may be used to endorse or promote products derived from this 
+#   software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+# POSSIBILITY OF SUCH DAMAGE.
+
+use strict;
+use utf8;
+
+package Vhffs::Panel::Cron;
+
+use DBI;
+use POSIX qw(locale_h);
+use HTML::Template;
+use locale;
+use Locale::gettext;
+use CGI;
+use CGI::Session;
+use Vhffs::User;
+use Vhffs::Main;
+use Vhffs::Acl;
+use Vhffs::Services::Cron;
+use Vhffs::Panel::Main;
+use Vhffs::Constants;
+
+=pod
+
+=head2 getall_per_group
+
+	$cron = Vhffs::Panel::Cron::getall_per_group($vhffs, $gid);
+
+Returns an array of hashrefs (oid, displayname, active, state (localized string)) of all download
+repositories owned by a given group.
+
+=cut
+
+sub getall_per_group
+{
+	my ( $main, $gid ) = @_;
+
+	my $dbh = $main->get_db_object;
+	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;
+	my $crons = [];
+	while(my $m = $sth->fetchrow_hashref) {
+		$m->{active} = ($m->{state} == Vhffs::Constants::ACTIVATED);
+		$m->{refused} = ($m->{state} == Vhffs::Constants::VALIDATION_REFUSED);
+		$m->{state} = Vhffs::Functions::status_string_from_status_id($m->{state});
+		push @$crons, $m;
+	}
+	return $crons;
+}
+
+sub search {
+	my ($main, $name) = @_;
+
+	my $sql;
+	my @params;
+	my $reps = [];
+
+	if( defined $name ) {
+		$sql = 'SELECT c.cronpath, g.groupname, o.state FROM vhffs_cron c INNER JOIN vhffs_object o ON o.object_id=c.object_id INNER JOIN vhffs_groups g ON g.gid = o.owner_gid WHERE c.cronpath LIKE ?';
+		push(@params, '%'.$name.'%');
+	} else {
+		$sql = 'SELECT c.cronpath, g.groupname, o.state FROM vhffs_cron c INNER JOIN vhffs_object o ON o.object_id=c.object_id INNER JOIN vhffs_groups g ON g.gid = o.owner_gid';
+	}
+
+	my $dbh = $main->get_db_object();
+	my $sth = $dbh->prepare($sql) or return undef;
+
+	return undef unless($sth->execute(@params));
+
+	while(my $r = $sth->fetchrow_hashref('NAME_lc')) {
+		$r->{state} = Vhffs::Functions::status_string_from_status_id($r->{state});
+		push(@$reps, $r);
+	}
+
+	return $reps;
+}
+
+
+sub create_cron
+{
+	my( $main , $cronpath , $interval , $reportmail , $description , $user , $group ) = @_;
+
+	my $cron = Vhffs::Services::Cron::create( $main , $cronpath , $interval , $reportmail , $description, $user , $group );
+	return undef unless defined $cron;
+
+	return undef if( Vhffs::Acl::add_acl( $user , $cron , Vhffs::Constants::ACL_DELETE , $main ) < 0 );
+	return undef if( Vhffs::Acl::add_acl( $group , $cron , Vhffs::Constants::ACL_VIEW , $main ) < 0 );
+
+	return $cron;
+}
+
+1;

Modified: trunk/vhffs-api/src/Vhffs/Panel/Main.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Main.pm	2008-04-19 21:57:22 UTC (rev 1189)
+++ trunk/vhffs-api/src/Vhffs/Panel/Main.pm	2008-05-02 23:34:30 UTC (rev 1190)
@@ -34,6 +34,7 @@
 use Vhffs::Panel::Svn;
 use Vhffs::Panel::Git;
 use Vhffs::Panel::Web;
+use Vhffs::Panel::Cron;
 
 =pod
 
@@ -614,6 +615,12 @@
             my $dns = Vhffs::Panel::DNS::getall_per_group( $vhffs, $gid );
             $services_list .= $panel->create_service_index('dns', $dns)->output;
         }
+
+        if($config->get_service_availability('cron')) {
+            my $cron = Vhffs::Panel::Cron::getall_per_group( $vhffs, $gid );
+            $services_list .= $panel->create_service_index('cron', $cron)->output;
+        }
+
         $template->param( SERVICES => $services_list );
 	}
 	return $template;
@@ -793,6 +800,7 @@
         svn => 'SVN repositories',
         git => 'Git repositories',
         web => 'Webareas',
+	cron => 'Cron jobs',
     );
 
     my $vhffs = $panel->{vhffs};

Modified: trunk/vhffs-api/src/Vhffs/Panel/Menu.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Menu.pm	2008-04-19 21:57:22 UTC (rev 1189)
+++ trunk/vhffs-api/src/Vhffs/Panel/Menu.pm	2008-05-02 23:34:30 UTC (rev 1190)
@@ -71,6 +71,7 @@
     push @$items, {path => 'repository', label => gettext('Dl repos') } if( $config->get_service_availability('repository') );
     push @$items, {path => 'mail', label => gettext('Mail') } if( $config->get_service_availability('mail') );
     push @$items, {path => 'mailinglist', label => gettext('ML') } if( $config->get_service_availability('mailinglist') );
+    push @$items, {path => 'cron', label => gettext('Crons') } if( $config->get_service_availability('cron') );
     $context_tmpl->param( MENU_ITEMS => $items );
     return $context_tmpl->output();
 }
@@ -120,6 +121,7 @@
     push @$items, {path => 'admin/repository', label => gettext('Dl repos') } if( $config->get_service_availability('repository') );
     push @$items, {path => 'admin/mail', label => gettext('Mail') } if( $config->get_service_availability('mail') );
     push @$items, {path => 'admin/mailing', label => gettext('ML') } if( $config->get_service_availability('mailinglist') );
+    push @$items, {path => 'admin/cron', label => gettext('Crons') } if( $config->get_service_availability('cron') );
     $context_tmpl->param( MENU_ITEMS => $items );
     return $context_tmpl->output();
 

Added: trunk/vhffs-api/src/Vhffs/Services/Cron.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Cron.pm	                        (rev 0)
+++ trunk/vhffs-api/src/Vhffs/Services/Cron.pm	2008-05-02 23:34:30 UTC (rev 1190)
@@ -0,0 +1,376 @@
+#!%PERL%
+# Copyright (c) vhffs project and its contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright 
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in 
+#    the documentation and/or other materials provided with the 
+#    distribution.
+# 3. Neither the name of vhffs nor the names of its contributors 
+#    may be used to endorse or promote products derived from this 
+#    software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+# POSSIBILITY OF SUCH DAMAGE.
+
+# This file is a part of VHFFS4 Hosting Platform
+# Please respect the licence of this file and the whole software
+
+
+=pod
+
+=head1 NAME
+
+Vhffs::Services::Cron - Handle cron jobs in VHFFS
+
+=head1 SYNOPSIS
+
+TODO
+
+=head1 METHODS
+
+=cut
+
+use strict;
+use utf8;
+
+package Vhffs::Services::Cron;
+
+use base qw(Vhffs::Object);
+use Vhffs::Group;
+
+sub check_cronpath($)
+{
+	my $name = shift;
+	return ($name =~ /^\/[a-z0-9]+\/[a-z0-9]+\/[a-zA-Z0-9\.\_\-\/]+$/);
+}
+
+sub delete
+{
+	my $self = shift;
+	return unless defined $self;
+
+	my $dbh = $self->get_db_object();
+	return $dbh->do(q{DELETE FROM vhffs_cron WHERE object_id=?}, undef, $self->get_oid());
+	
+	return -2 if( $self->SUPER::delete < 0 );
+	return 1;
+}
+
+=pod
+
+=head2 create
+
+	my $cron = Vhffs::Services::Cron::create($main, $rname, $description, $user, $group);
+	die('Unable to create cron') unless(defined $cron);
+
+Creates a new cron job in database and return the corresponding
+fully functional object.
+
+=cut
+
+sub create 
+{
+	my ($main, $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;
+	$interval = $mininterval if( $interval < $mininterval );
+
+	my $cron;
+	my $dbh = $main->get_db_object();
+	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);
+		die('Unable to create parent object') unless(defined $parent);
+
+		my $sql = 'INSERT INTO vhffs_cron(cronpath, interval, reportmail, running, object_id) VALUES(?, ?, ?, 0, ?)';
+		my $sth = $dbh->prepare($sql);
+		$sth->execute($cronpath, $interval, $reportmail, $parent->get_oid);
+
+		$dbh->commit;
+		$cron = get_by_cronpath($main, $cronpath);
+	};
+
+	if($@) {
+		warn "Unable to create cron job $cronpath: $@\n";
+		$dbh->rollback;
+	}
+
+	return $cron;
+}
+
+=pod
+
+=head2 get_by_cronpath
+
+	my $repo = Vhffs::Services::Cron::get_by_cronpath($main, $path);
+	die('Cron not found') unless(defined $path);
+
+Fetches an existing cron job.
+
+=cut
+
+sub get_by_cronpath($$) {
+	my ($main, $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_object();
+	return undef unless(@params = $dbh->selectrow_array($sql, undef, $path));
+
+	return _new Vhffs::Services::Cron($main, @params);
+}
+
+=head2 fill_object
+
+See C<Vhffs::Object::fill_object
+
+=cut
+
+sub fill_object {
+	my ($class, $obj) = @_;
+	my $sql = q{SELECT cron_id, cronpath, interval, reportmail, lastrundate, lastrunreturncode, nextrundate, running
+		FROM vhffs_cron WHERE object_id = ?};
+	return $class->SUPER::_fill_object($obj, $sql);
+}
+
+sub _new {
+	my ($class, $main, $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);
+	return undef unless(defined $self);
+
+	$self->{cron_id} = $cron_id;
+	$self->{cronpath} = $cronpath;
+	$self->{interval} = $interval;
+	$self->{reportmail} = $reportmail;
+	$self->{lastrundate} = $lastrundate;
+	$self->{lastrunreturncode} = $lastrunreturncode;
+	$self->{nextrundate} = $nextrundate;
+	$self->{running} = $running;
+
+	return $self;
+}
+
+sub commit
+{
+	my $self = shift;
+
+	my $query = 'UPDATE vhffs_cron SET interval=?, reportmail=?, lastrundate=?, lastrunreturncode=?, nextrundate=?, running=? WHERE cron_id=?';
+
+	my $request = $self->{'db'}->prepare($query);
+	$request->execute( $self->{'interval'} , $self->{'reportmail'} , $self->{'lastrundate'} , $self->{'lastrunreturncode'} , $self->{'nextrundate'} , $self->{'running'} , $self->{'cron_id'} ) or return -1;
+
+	return -2 if( $self->SUPER::commit < 0 );
+	return 1;
+}
+
+
+sub getall
+{
+	my ($vhffs, $state, $path, $group) = @_;
+
+	my $repos = [];
+	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, vhffs_object o WHERE c.object_id = o.object_id';
+	if(defined($state)) {
+		$sql .= ' AND o.state = ?';
+		push(@params, $state);
+	}
+	if(defined $path) {
+		$sql .= ' AND c.cronpath = ?';
+		push(@params, $path);
+	}
+	if(defined($group)) {
+		$sql .= ' AND o.owner_gid = ?';
+		push(@params, $group->get_gid);
+	}
+	$sql .= ' ORDER BY c.cronpath';
+    
+	my $dbh = $vhffs->get_db_object();
+	my $sth = $dbh->prepare($sql);
+	$sth->execute(@params) or return undef;
+
+	while(my $r = $sth->fetchrow_arrayref()) {
+		push(@$repos, _new Vhffs::Services::Cron($vhffs, @$r));
+	}
+	return $repos;
+}
+
+sub get_label {
+	my $self = shift;
+	return $self->{'cronpath'};
+}
+
+
+sub get_cronpath {
+	my $self = shift;
+	return $self->{'cronpath'};
+}
+
+sub get_name
+{
+	my $self = shift;
+	return $self->{'cronpath'};
+}
+
+sub set_name
+{
+	my ($self , $value) = @_;
+	if( check_cronpath($value) )  {
+		$self->{'cronpath'} = $value;
+		return 0;
+	}
+	return 1;
+}
+
+sub get_interval
+{
+	my $self = shift;
+	return $self->{'interval'};
+}
+
+sub set_interval
+{
+	my ($self , $value) = @_;
+	my $mininterval = $self->get_main->get_config->get_service('cron')->{'minimum_interval'}*60;
+	$value = $mininterval if( $value < $mininterval );
+	$self->{'interval'} = $value;
+	return 0;
+}
+
+sub get_reportmail
+{
+	my $self = shift;
+	return $self->{'reportmail'};
+}
+
+sub set_reportmail
+{
+	my ($self , $value) = @_;
+	if( $value eq '' || Vhffs::Functions::valid_mail($value) )  {
+		$self->{'reportmail'} = $value;
+		return 0;
+	}
+	return 1;
+}
+
+sub get_lastrundate
+{
+	my $self = shift;
+	return $self->{'lastrundate'};
+}
+
+sub set_lastrundate
+{
+	my ($self , $value) = @_;
+	if( $value =~ /^\d+$/ )  {
+		$self->{'lastrundate'} = $value;
+		return 0;
+	}
+	return 1;
+}
+
+sub get_lastrunreturncode
+{
+	my $self = shift;
+	return $self->{'lastrunreturncode'};
+}
+
+sub set_lastrunreturncode
+{
+	my ($self , $value) = @_;
+	if( $value =~ /^\d+$/ )  {
+		$self->{'lastrunreturncode'} = $value;
+		return 0;
+	}
+	return 1;
+}
+
+sub get_nextrundate
+{
+	my $self = shift;
+	return $self->{'nextrundate'};
+}
+
+sub set_nextrundate
+{
+	my ($self , $value) = @_;
+	if( $value =~ /^\d+$/ )  {
+		$self->{'nextrundate'} = $value;
+		return 0;
+	}
+	return 1;
+}
+
+sub get_running
+{
+	my $self = shift;
+	return $self->{'running'};
+}
+
+sub set_running
+{
+	my ($self , $value) = @_;
+	if( $value =~ /^\d+$/ )  {
+		$self->{'running'} = $value;
+		return 0;
+	}
+	return 1;
+}
+
+sub getall_per_group
+{
+	my ($main, $group) = @_;
+	my @result;
+	my $repos = [];
+	return undef if ( ! defined $group );
+
+	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 o.owner_gid = ?';
+
+	my $dbh = $main->get_db_object();
+	my $sth = $dbh->prepare($sql);
+	$sth->execute($group->get_gid) or return undef;
+
+	while(my $r = $sth->fetchrow_arrayref()) {
+		push(@$repos, _new Vhffs::Services::Cron($main, @$r));
+	}
+	return $repos;
+}
+
+
+
+
+1;
+
+__END__
+
+=head1 AUTHORS
+
+Sylvain Rochet < gradator at gradator dot net >

Modified: trunk/vhffs-api/src/Vhffs/Services.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services.pm	2008-04-19 21:57:22 UTC (rev 1189)
+++ trunk/vhffs-api/src/Vhffs/Services.pm	2008-05-02 23:34:30 UTC (rev 1190)
@@ -44,5 +44,6 @@
 use Vhffs::Services::Repository;
 use Vhffs::Services::Svn;
 use Vhffs::Services::Git;
+use Vhffs::Services::Cron;
 
 1;

Modified: trunk/vhffs-backend/conf/vhffs.conf.dist.in
===================================================================
--- trunk/vhffs-backend/conf/vhffs.conf.dist.in	2008-04-19 21:57:22 UTC (rev 1189)
+++ trunk/vhffs-backend/conf/vhffs.conf.dist.in	2008-05-02 23:34:30 UTC (rev 1190)
@@ -456,6 +456,18 @@
 		url_stats		=	http://stats.downloads.hoster
 	</repository>
 
+	# Configuration for cron jobs
+	<cron>
+		# Use this module or not
+		activate	=	no
+
+		# Minimum allowed interval between cron starts (in minutes)
+		minimum_interval	=	15
+
+		# URL to the documentation (optional)
+		url_doc		=	http://help.myhoster.net/cron
+	</cron>
+
 </services>
 
 

Modified: trunk/vhffs-backend/src/pgsql/initdb.sql.in
===================================================================
--- trunk/vhffs-backend/src/pgsql/initdb.sql.in	2008-04-19 21:57:22 UTC (rev 1189)
+++ trunk/vhffs-backend/src/pgsql/initdb.sql.in	2008-05-02 23:34:30 UTC (rev 1190)
@@ -409,6 +409,30 @@
 	CONSTRAINT vhffs_git_pkey PRIMARY KEY( git_id )
 ) WITH OIDS;
 
+-- Cron tasks
+
+CREATE TABLE vhffs_cron
+(
+	cron_id SERIAL,
+-- Path to the cron script/binary
+	cronpath varchar NOT NULL,
+-- At which interval the cron should run
+	interval int4 NOT NULL,
+-- Where to send reports in case of error
+	reportmail varchar NOT NULL,
+-- When the cron has been started
+	lastrundate int8,
+-- Return code
+	lastrunreturncode int4,
+-- When the cron should be started
+	nextrundate int8,
+-- If this cron is running or not (also used to detect collision if multiple schedulers are running)
+	running int4,
+-- Object representing this Cron
+	object_id int4 NOT NULL,
+	CONSTRAINT vhffs_cron_pkey PRIMARY KEY( cron_id )
+) WITH OIDS;
+
 -- Table containing all registered tags for this platform
 
 CREATE TABLE vhffs_tag (
@@ -502,6 +526,7 @@
 ALTER TABLE vhffs_dns ADD CONSTRAINT vhffs_dns_unique_domain UNIQUE (domain);
 ALTER TABLE vhffs_ml ADD CONSTRAINT vhffs_ml_unique_address UNIQUE (local_part, domain);
 ALTER TABLE vhffs_ml_subscribers ADD CONSTRAINT vhffs_ml_subscribers_member_list UNIQUE (ml_id, member);
+ALTER TABLE vhffs_cron ADD CONSTRAINT vhffs_cron_unique_cronpath UNIQUE (cronpath);
 
 -- This index drastically improves performances on get_used_letters
 CREATE INDEX idx_vhffs_httpd_servername_firstletter ON vhffs_httpd(substr(servername, 1, 1));
@@ -553,6 +578,8 @@
 CREATE INDEX idx_vhffs_history_date ON vhffs_history(date);
 CREATE INDEX idx_vhffs_mailings_date ON vhffs_mailings(date);
 CREATE INDEX idx_vhffs_users_lastloginpanel ON vhffs_users(lastloginpanel);
+-- nextrundate is used to known which cron we should run
+CREATE INDEX idx_vhffs_cron_nextrun ON vhffs_cron(nextrundate);
 
 /****** Non primary key constraints.
       Defining foreign keys here allow to create tables in any order.
@@ -594,6 +621,8 @@
 
 ALTER TABLE vhffs_repository ADD CONSTRAINT fk_vhffs_vhffs_repository_vhffs_object FOREIGN KEY (object_id) REFERENCES vhffs_object(object_id) ON DELETE CASCADE;
 
+ALTER TABLE vhffs_cron ADD CONSTRAINT fk_vhffs_vhffs_cron_vhffs_object FOREIGN KEY (object_id) REFERENCES vhffs_object(object_id) ON DELETE CASCADE;
+
 ALTER TABLE vhffs_svn ADD CONSTRAINT fk_vhffs_svn_vhffs_object FOREIGN KEY (object_id) REFERENCES vhffs_object(object_id) ON DELETE CASCADE;
 
 ALTER TABLE vhffs_git ADD CONSTRAINT fk_vhffs_git_vhffs_object FOREIGN KEY (object_id) REFERENCES vhffs_object(object_id) ON DELETE CASCADE;

Modified: trunk/vhffs-compat/4.1.sql
===================================================================
--- trunk/vhffs-compat/4.1.sql	2008-04-19 21:57:22 UTC (rev 1189)
+++ trunk/vhffs-compat/4.1.sql	2008-05-02 23:34:30 UTC (rev 1190)
@@ -19,3 +19,21 @@
 ALTER TABLE vhffs_boxes ALTER COLUMN allowimap SET DEFAULT true;
 UPDATE vhffs_boxes SET allowimap=true;
 ALTER TABLE vhffs_boxes ALTER COLUMN allowimap SET NOT NULL;
+
+-- add vhffs_cron table
+CREATE TABLE vhffs_cron
+(
+        cron_id SERIAL,
+        cronpath varchar NOT NULL,
+        interval int4 NOT NULL,
+        reportmail varchar NOT NULL,
+        lastrundate int8,
+        lastrunreturncode int4,
+        nextrundate int8,
+        running int4,
+        object_id int4 NOT NULL,
+        CONSTRAINT vhffs_cron_pkey PRIMARY KEY( cron_id )
+) WITH OIDS;
+ALTER TABLE vhffs_cron ADD CONSTRAINT vhffs_cron_unique_cronpath UNIQUE (cronpath);
+CREATE INDEX idx_vhffs_cron_nextrun ON vhffs_cron(nextrundate);
+ALTER TABLE vhffs_cron ADD CONSTRAINT fk_vhffs_vhffs_cron_vhffs_object FOREIGN KEY (object_id) REFERENCES vhffs_object(object_id) ON DELETE CASCADE;

Modified: trunk/vhffs-panel/Makefile.am
===================================================================
--- trunk/vhffs-panel/Makefile.am	2008-04-19 21:57:22 UTC (rev 1189)
+++ trunk/vhffs-panel/Makefile.am	2008-05-02 23:34:30 UTC (rev 1190)
@@ -73,6 +73,9 @@
 	admin/web/index.pl \
 	admin/web/list.pl \
 	admin/web/search.pl \
+	admin/cron/index.pl \
+	admin/cron/list.pl \
+	admin/cron/search.pl \
 	admin/broadcast_delete.pl \
 	admin/broadcast_list.pl \
 	admin/broadcast_submit.pl \
@@ -132,7 +135,11 @@
 	web/create.pl \
 	web/delete.pl \
 	web/index.pl \
-	web/prefs.pl
+	web/prefs.pl \
+	cron/index.pl \
+	cron/prefs.pl \
+	cron/create.pl \
+	cron/delete.pl
 
 
 # Define the substitution we need to point perl script at correct location

Added: trunk/vhffs-panel/admin/cron/index.pl
===================================================================
--- trunk/vhffs-panel/admin/cron/index.pl	                        (rev 0)
+++ trunk/vhffs-panel/admin/cron/index.pl	2008-05-02 23:34:30 UTC (rev 1190)
@@ -0,0 +1,61 @@
+#!%PERL% -w 
+# Copyright (c) vhffs project and its contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright 
+#   notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in 
+#   the documentation and/or other materials provided with the 
+#   distribution.
+#3. Neither the name of vhffs nor the names of its contributors 
+#   may be used to endorse or promote products derived from this 
+#   software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+# POSSIBILITY OF SUCH DAMAGE.
+
+
+use utf8;
+use POSIX qw(locale_h);
+use HTML::Template;
+use locale;
+use Locale::gettext;
+use strict;
+
+
+use lib '%VHFFS_LIB_DIR%';
+use Vhffs::Panel::Main;
+use Vhffs::Panel::Admin;
+
+my $panel = new Vhffs::Panel::Main();
+exit 0 unless $panel;
+my $session = $panel->get_session;
+exit 0 unless $session;
+
+$panel->check_admin;
+
+my $templatedir = $panel->{templatedir};
+
+my $template = new HTML::Template(filename => $templatedir.'/panel/admin/index.tmpl');
+
+$panel->set_title(gettext('Cron jobs\' administration'));
+
+$template->param( CATEGORIES => [ Vhffs::Panel::Admin::get_cron_category ] );
+
+$panel->build( $template );
+$panel->display;


Property changes on: trunk/vhffs-panel/admin/cron/index.pl
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/vhffs-panel/admin/cron/list.pl
===================================================================
--- trunk/vhffs-panel/admin/cron/list.pl	                        (rev 0)
+++ trunk/vhffs-panel/admin/cron/list.pl	2008-05-02 23:34:30 UTC (rev 1190)
@@ -0,0 +1,103 @@
+#!%PERL% -w 
+# Copyright (c) vhffs project and its contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright 
+#   notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in 
+#   the documentation and/or other materials provided with the 
+#   distribution.
+#3. Neither the name of vhffs nor the names of its contributors 
+#   may be used to endorse or promote products derived from this 
+#   software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+# POSSIBILITY OF SUCH DAMAGE.
+
+use strict;
+use utf8;
+use POSIX qw(locale_h);
+use HTML::Template;
+use locale;
+use Locale::gettext;
+use CGI;
+use CGI::Session;
+
+
+use lib '%VHFFS_LIB_DIR%';
+use Vhffs::User;
+use Vhffs::Group;
+use Vhffs::Main;
+use Vhffs::Panel::Main;
+use Vhffs::Panel::Menu;
+use Vhffs::Panel::Cron;
+use Vhffs::Stats;
+use Vhffs::Constants;
+
+my $panel = new Vhffs::Panel::Main();
+exit 0 unless $panel;
+my $session = $panel->get_session;
+exit 0 unless $session;
+
+my $vhffs = $panel->{'vhffs'};
+my $user = $panel->{'user'};
+my $cgi = $panel->{'cgi'};
+my $templatedir = $panel->{'templatedir'};
+my $template;
+
+if( ($user->is_moderator != 1 ) && ( $user->is_admin != 1 ) )
+{	
+	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
+	$template->param( MESSAGE => gettext('You are not allowed to see it') );
+}
+else
+{
+	$template = new HTML::Template( filename => $templatedir.'/panel/admin/misc/list.tmpl' );
+	my $name = $cgi->param('NAME');
+
+	if( defined( $name ) )
+	{
+		$template->param( TITLE => gettext('Search result for Cron jobs').': '.$name );
+	}
+	else
+	{
+		$template->param( TITLE => gettext('List of all Cron jobs') );
+	}
+
+	$template->param( TEXT_TITLE1 => gettext('Cron path') );
+	$template->param( TEXT_TITLE2 => gettext('Group') );
+	$template->param( TEXT_TITLE3 => gettext('State') );
+
+	my $crons = Vhffs::Panel::Cron::search( $vhffs , $name );
+
+	if( defined $crons )
+	{
+		my $subtemplate = new HTML::Template( filename => $templatedir.'/panel/admin/cron/part.tmpl', global_vars => 1 );
+		if( $user->is_admin == 1 )  {
+			$subtemplate->param( ACTION => gettext('Modify') );
+		} else {
+			$subtemplate->param( ACTION => gettext('Show') );
+		}
+
+		$subtemplate->param(CRONS => $crons);
+		$template->param( LIST => $subtemplate->output );
+	}
+}
+
+$panel->build( $template );
+$panel->display;


Property changes on: trunk/vhffs-panel/admin/cron/list.pl
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/vhffs-panel/admin/cron/search.pl
===================================================================
--- trunk/vhffs-panel/admin/cron/search.pl	                        (rev 0)
+++ trunk/vhffs-panel/admin/cron/search.pl	2008-05-02 23:34:30 UTC (rev 1190)
@@ -0,0 +1,85 @@
+#!%PERL% -w 
+# Copyright (c) vhffs project and its contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright 
+#   notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in 
+#   the documentation and/or other materials provided with the 
+#   distribution.
+#3. Neither the name of vhffs nor the names of its contributors 
+#   may be used to endorse or promote products derived from this 
+#   software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+# POSSIBILITY OF SUCH DAMAGE.
+
+
+use utf8;
+use POSIX qw(locale_h);
+use HTML::Template;
+use locale;
+use Locale::gettext;
+use CGI;
+use CGI::Session;
+use strict;
+
+
+use lib '%VHFFS_LIB_DIR%';
+use Vhffs::User;
+use Vhffs::Group;
+use Vhffs::Main;
+use Vhffs::Panel::Main;
+use Vhffs::Panel::Menu;
+use Vhffs::Stats;
+use Vhffs::Constants;
+
+my $panel = new Vhffs::Panel::Main();
+exit 0 unless $panel;
+my $session = $panel->get_session;
+exit 0 unless $session;
+
+my $vhffs = $panel->{'vhffs'};
+my $maintemplate = $panel->{'template'};
+my $user = $panel->{'user'};
+#my $group = $panel->{'group'};
+my $projectname = $session->param("project");
+my $cgi = $panel->{'cgi'};
+my $servername = $cgi->param("name");
+my $template;
+
+my $templatedir = $vhffs->get_config->get_templatedir;
+
+if( ($user->is_moderator != 1 ) && ( $user->is_admin != 1 ) )
+{
+	
+	$template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
+	my $message = gettext( "You are not allowed to see it");
+	$template->param( MESSAGE => $message );
+}
+else
+{
+	$template = new HTML::Template( filename => $templatedir."/panel/admin/cron/search.tmpl" );
+
+	$template->param( TITLE => gettext("Search for a cron job") );
+
+}
+
+$panel->build( $template );
+$panel->display;
+


Property changes on: trunk/vhffs-panel/admin/cron/search.pl
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/vhffs-panel/cron/create.pl
===================================================================
--- trunk/vhffs-panel/cron/create.pl	                        (rev 0)
+++ trunk/vhffs-panel/cron/create.pl	2008-05-02 23:34:30 UTC (rev 1190)
@@ -0,0 +1,125 @@
+#!%PERL% -w
+# Copyright (c) vhffs project and its contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright 
+#   notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in 
+#   the documentation and/or other materials provided with the 
+#   distribution.
+#3. Neither the name of vhffs nor the names of its contributors 
+#   may be used to endorse or promote products derived from this 
+#   software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+# POSSIBILITY OF SUCH DAMAGE.
+
+use strict;
+use utf8;
+use POSIX qw(locale_h);
+use HTML::Template;
+use locale;
+use Locale::gettext;
+use CGI;
+use CGI::Session;
+use Encode;
+
+use lib '%VHFFS_LIB_DIR%';
+use Vhffs::User;
+use Vhffs::Main;
+use Vhffs::Panel::Main;
+use Vhffs::Panel::Menu;
+use Vhffs::Panel::Group;
+use Vhffs::Services::Cron;
+use Vhffs::Panel::Cron;
+
+my $panel = new Vhffs::Panel::Main();
+exit 0 unless $panel;
+my $session = $panel->get_session;
+exit 0 unless $session;
+
+my $vhffs = $panel->{vhffs};
+my $groupname = $panel->{groupname};
+my $templatedir = $panel->{templatedir};
+my $cgi = $panel->{cgi};
+my $user = $panel->{user};
+my $group = $panel->{group};
+
+unless( $user->can_modify( $group ) ) {
+	my $template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
+	$template->param( MESSAGE => gettext( 'You\'re not allowed to do this (ACL rights)' ) );
+
+	$panel->build( $template );
+	$panel->display;
+}
+else  {
+	my $submitted = defined($cgi->param('cron_submit'));
+	my $cronpath = '';
+	my $interval = '';
+	my $reportmail = '';
+	my $description = '';
+
+	if( $submitted ) {
+		$cronpath = $cgi->param('cronpath');
+		$interval = $cgi->param('interval');
+		$reportmail = $cgi->param('reportmail');
+		$description = Encode::decode_utf8( $cgi->param('description') );
+
+		unless( defined $cronpath && defined $interval && defined $reportmail && defined $description ) {
+			$panel->add_error( gettext('CGI Error !') );
+		} elsif($description =~ /^\s*$/) {
+			$panel->add_error( gettext('You must enter a description') );
+		} elsif(!Vhffs::Services::Cron::check_cronpath($cronpath)) {
+			$panel->add_error( gettext('Invalid cronpath, it must contain only letters, numbers, underscore, dash, dot or slash. A valid cronpath will be something like /home/group/script.sh)') );
+		} elsif( $interval !~ /^\d+$/ || $interval <= 0 )  {
+			$panel->add_error( gettext('Invalid interval, it must be a positive integer') );
+		} elsif( $reportmail ne ''  &&  !Vhffs::Functions::valid_mail( $reportmail )  )  {
+			$panel->add_error( gettext('The email you entered fails syntax check') );
+		} elsif(defined Vhffs::Panel::Cron::create_cron($vhffs, $cronpath, $interval*60, $reportmail , $description, $user, $group)) {
+			my $url = '/group/view.pl?project='.$panel->{groupname}.'&msg='.gettext('The Cron job was successfully created !');
+			$panel->redirect($url);
+		} else {
+			$panel->add_error( 'An error occured while creating the object.' );
+		}
+	}
+
+	if( !$submitted || $panel->has_errors() ) {
+		my $template = new HTML::Template( filename => $templatedir.'/panel/cron/create.tmpl' );
+
+		$panel->set_title( gettext('Create a Cron job') );
+
+		#$template->param( INFOS => sprintf( gettext('The database name is prefixed by your groupname followed by an underscore (%s_dbname). The database user is the database full name (%s_dbname).') , $groupname, $groupname) );
+		$template->param( GROUP_NAME => gettext('Group owning this cron job') );
+		$template->param( TEXT_CRONPATH_LABEL => gettext('Path') );
+		$template->param( TEXT_CRONPATH_HELP => gettext('Absolute path of the command to run') );
+		$template->param( TEXT_INTERVAL_LABEL => gettext('Interval') );
+		$template->param( TEXT_INTERVAL_HELP => sprintf(gettext('In minutes, at which interval this cron should be started, the minimum interval is set to %d minutes'), $vhffs->get_config->get_service('cron')->{'minimum_interval'}) );
+		$template->param( TEXT_REPORTMAIL_LABEL => gettext('Mail to') );
+		$template->param( TEXT_REPORTMAIL_HELP => gettext('Email to which report will be sent if something went wrong') );
+		$template->param( CRONPATH_VALUE => $cronpath );
+		$template->param( INTERVAL_VALUE => $interval );
+		$template->param( REPORTMAIL_VALUE => $reportmail );
+		$template->param( GROUP => $groupname );
+		$template->param( SEND => gettext('Send') );
+		$template->param( DESCRIPTION => gettext('Description') );
+		$template->param( DESCRIPTION_VALUE => $description );
+
+		$panel->build( $template );
+		$panel->display;
+	}
+}


Property changes on: trunk/vhffs-panel/cron/create.pl
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/vhffs-panel/cron/delete.pl
===================================================================
--- trunk/vhffs-panel/cron/delete.pl	                        (rev 0)
+++ trunk/vhffs-panel/cron/delete.pl	2008-05-02 23:34:30 UTC (rev 1190)
@@ -0,0 +1,104 @@
+#!%PERL% -w 
+# Copyright (c) vhffs project and its contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright 
+#   notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in 
+#   the documentation and/or other materials provided with the 
+#   distribution.
+#3. Neither the name of vhffs nor the names of its contributors 
+#   may be used to endorse or promote products derived from this 
+#   software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+# POSSIBILITY OF SUCH DAMAGE.
+
+
+use utf8;
+use POSIX qw(locale_h);
+use HTML::Template;
+use locale;
+use Locale::gettext;
+use CGI;
+use CGI::Session;
+use strict;
+
+use lib '%VHFFS_LIB_DIR%';
+use Vhffs::User;
+use Vhffs::Main;
+use Vhffs::Group;
+use Vhffs::Panel::Main;
+use Vhffs::Panel::Menu;
+use Vhffs::Panel::Group;
+use Vhffs::Services::Cron;
+
+my $panel = new Vhffs::Panel::Main();
+exit 0 unless $panel;
+my $session = $panel->get_session;
+exit 0 unless $session;
+
+my $vhffs = $panel->{'vhffs'};
+my $user = $panel->{'user'};
+my $group = $panel->{'group'};
+my $cgi = $panel->{'cgi'};
+my $templatedir = $panel->{'templatedir'};
+
+my $message;
+my $owner = $cgi->param('PROJECT_OWNER');
+my $cronpath = $cgi->param('CRONPATH');
+my $sure = $cgi->param('DELETE');
+
+my $cron = Vhffs::Services::Cron::get_by_cronpath( $vhffs, $cronpath );
+
+unless( defined $cron )
+{
+	$message = gettext("This cron job doesn't exist in VHFFS database");
+}
+elsif( ! defined $sure )
+{
+	$message = gettext( "CGI Error !" );
+}
+elsif( !$user->can_delete( $cron ) )
+{
+	$message = gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' );
+}
+elsif( $sure == 0 )
+{
+	$message = gettext( "This cron job will NOT be deleted" );
+}
+else
+{
+	$cron->set_status( Vhffs::Constants::TO_DELETE );
+	if( $cron->commit < 0 )
+	{
+		$message = gettext('Cannot apply changes');
+	}
+	else
+	{
+		$message = gettext('This cron job will be deleted');
+	}
+}
+
+
+my $template = new HTML::Template( filename => $templatedir."/panel/misc/simplemsg.tmpl" );
+$template->param( MESSAGE => $message );
+
+$panel->set_refresh_url( "/cron/prefs.pl?name=$cronpath" );
+$panel->build( $template );
+$panel->display;


Property changes on: trunk/vhffs-panel/cron/delete.pl
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/vhffs-panel/cron/index.pl
===================================================================
--- trunk/vhffs-panel/cron/index.pl	                        (rev 0)
+++ trunk/vhffs-panel/cron/index.pl	2008-05-02 23:34:30 UTC (rev 1190)
@@ -0,0 +1,70 @@
+#!%PERL%
+# Copyright (c) vhffs project and its contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright 
+#   notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in 
+#   the documentation and/or other materials provided with the 
+#   distribution.
+#3. Neither the name of vhffs nor the names of its contributors 
+#   may be used to endorse or promote products derived from this 
+#   software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+# POSSIBILITY OF SUCH DAMAGE.
+
+
+use utf8;
+use POSIX qw(locale_h);
+use HTML::Template;
+use locale;
+use Locale::gettext;
+use strict;
+
+use lib '%VHFFS_LIB_DIR%';
+use Vhffs::Panel::Main;
+use Vhffs::Panel::Cron;
+
+my $panel = new Vhffs::Panel::Main();
+exit 0 unless $panel;
+my $session = $panel->get_session;
+exit 0 unless $session;
+
+my $vhffs = $panel->{vhffs};
+my $group = $panel->{group};
+
+unless( defined $group ) {
+	$panel->set_title( gettext('Error') );
+	$panel->add_error( gettext('You have to select a group first') );
+	$panel->build;
+	$panel->display;
+} else {
+	# Group is in session => access is granted for user and group is activated
+	# no need to check
+	$panel->set_title( sprintf(gettext('Cron jobs for %s'), $group->get_groupname) );
+	my $crons = Vhffs::Panel::Cron::getall_per_group( $vhffs, $group->get_gid );
+	if($crons < 0) {
+		$panel->add_error( gettext('Unable to get cron jobs') );
+		$panel->build;
+		$panel->display;
+	} else {
+		$panel->build( $panel->create_service_index('cron', $crons) );
+		$panel->display;
+	}
+}


Property changes on: trunk/vhffs-panel/cron/index.pl
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/vhffs-panel/cron/prefs.pl
===================================================================
--- trunk/vhffs-panel/cron/prefs.pl	                        (rev 0)
+++ trunk/vhffs-panel/cron/prefs.pl	2008-05-02 23:34:30 UTC (rev 1190)
@@ -0,0 +1,195 @@
+#!%PERL% -w
+# Copyright (c) vhffs project and its contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright 
+#   notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in 
+#   the documentation and/or other materials provided with the 
+#   distribution.
+#3. Neither the name of vhffs nor the names of its contributors 
+#   may be used to endorse or promote products derived from this 
+#   software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+# POSSIBILITY OF SUCH DAMAGE.
+
+
+use utf8;
+use POSIX qw(locale_h);
+use HTML::Template;
+use locale;
+use Locale::gettext;
+use CGI;
+use CGI::Session;
+use strict;
+
+use lib '%VHFFS_LIB_DIR%';
+use Vhffs::User;
+use Vhffs::Group;
+use Vhffs::Main;
+use Vhffs::Panel::Main;
+use Vhffs::Panel::Menu;
+use Vhffs::Panel::Object;
+use Vhffs::Panel::Template;
+use Vhffs::Services::Cron;
+
+my $panel = new Vhffs::Panel::Main();
+exit 0 unless $panel;
+my $session = $panel->get_session;
+exit 0 unless $session;
+
+my $vhffs = $panel->{'vhffs'};
+my $user = $panel->{'user'};
+my $group = $panel->{'group'};
+my $cgi = $panel->{'cgi'};
+my $templatedir = $panel->{'templatedir'};
+
+my $cronpath = $cgi->param('name');
+my $cron = Vhffs::Services::Cron::get_by_cronpath( $vhffs , $cronpath );
+my $template;
+
+
+unless( defined $cronpath )
+{
+	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
+	$template->param( MESSAGE => gettext( 'CGI Error !' ) );
+}
+elsif( ! defined $cron )
+{
+	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
+	$template->param( MESSAGE => gettext('Cannot get informations on this object') );
+}
+elsif( !$user->can_view( $cron ) )
+{
+	$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
+	$template->param( MESSAGE => gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' ) );
+}
+else
+{
+	if( defined $cgi->param('save_prefs_submit') ) {
+		save_prefs();
+	}
+
+	$template = new Vhffs::Panel::Template( filename => $templatedir."/panel/cron/prefs.tmpl" );
+
+	$panel->set_title( gettext("Cron job Administration") );
+
+	$template->param( TEXT_CRONPATH => gettext("Path") );
+	$template->param( VALUE_CRONPATH => $cron->get_cronpath );
+
+	$template->param( TEXT_INTERVAL => gettext("Interval between runs") );
+	$template->param( VALUE_INTERVAL => $cron->get_interval/60 );
+	$template->param( TEXT_MINUTES => gettext("minutes") );
+
+	$template->param( TEXT_REPORTMAIL => gettext("Mail reports to") );
+	$template->param( VALUE_REPORTMAIL => $cron->get_reportmail );
+
+	use DateTime;
+	use DateTime::Locale;
+	my $loc = DateTime::Locale->load($user->get_lang);
+	my $dt;
+	my $datestr;
+
+	if( defined $cron->get_lastrundate )  {
+		$dt = DateTime->from_epoch( epoch => $cron->get_lastrundate, locale => $user->get_lang);
+		$datestr = $dt->strftime($loc->medium_date_format()).' '.$dt->strftime($loc->long_time_format());
+	} else {
+		$datestr = gettext('Never');
+	}
+	$template->param( TEXT_LASTRUNDATE => gettext("Last run date was") );
+	$template->param( VALUE_LASTRUNDATE => $datestr );
+
+	my $rt = $cron->get_lastrunreturncode;
+	$rt = gettext('Never') unless defined $rt;
+	$template->param( TEXT_LASTRUNRETURNCODE => gettext("Last run return code was") );
+	$template->param( VALUE_LASTRUNRETURNCODE => $rt );
+
+	if( defined $cron->get_nextrundate )  {
+		$dt = DateTime->from_epoch( epoch => $cron->get_nextrundate, locale => $user->get_lang);
+		$datestr = $dt->strftime($loc->medium_date_format()).' '.$dt->strftime($loc->long_time_format());
+	} else {
+		$datestr = gettext('As soon as possible');
+	}
+	$template->param( TEXT_NEXTRUNDATE => gettext("Next run is scheduled at") );
+	$template->param( VALUE_NEXTRUNDATE => $datestr );
+
+	$template->param( TEXT_RUNNING => gettext("State") );
+	my $state = $cron->get_running;
+	my $statestr = '';
+	if( $state == 0 ) {
+		$statestr = gettext('Sleeping');
+	} elsif( $state == 1 ) {
+		$statestr = gettext('Running');
+	} else {
+		$statestr = gettext('Collided, something went wrong, recovering');
+	}
+	$template->param( VALUE_RUNNING => $statestr );
+
+	$template->param( VALUE_OID => $cron->get_oid );
+	$template->param( TEXT_ACL_ADMIN => gettext("Admin Rights on this object (ACL)") );
+	$template->param( EXPLAIN_ADMIN_ACL => gettext("You can Manage rights on this service for each user in the VHFFS database. Please read help before manage it.") );
+	$template->param( ADMIN_ACL => gettext("Ok, go to ACL admin") );
+
+	$template->param( TEXT_SEND => gettext("Modify") );
+	$template->param( TEXT_DELETE_CRON => gettext("Delete this cron job") );
+	$template->param( TEXT_BEFORE_DELETE => gettext("This action is non-reversible. All services associated to this project will be DESTROYED.") );
+	$template->param( ASK_DELETE_CRON => gettext("Are you SURE you want DELETE this Cron job ?") );
+	$template->param( YES => gettext("Yes I'm sure of what I do") );
+	$template->param( NO => gettext("No, I'm not sure, I prefer to keep this project.") );
+	$template->param( TEXT_DELETE => gettext("Delete") );
+
+	my $adminpart = Vhffs::Panel::Object::admin_part( $panel, $cron );
+	$template->param( ADMIN_PART => $adminpart->output ) if( defined $adminpart );
+}
+
+$panel->build( $template );
+$panel->display;
+
+sub save_prefs {
+	my $ok = 1;
+
+	unless( $user->can_modify($cron) ) {
+		$panel->add_error( gettext('You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights') );
+		return 1;
+	}
+
+	my $interval = $cgi->param('interval');
+	my $reportmail = $cgi->param('reportmail');
+	unless( defined $interval && defined $reportmail ) {
+		$panel->add_error( gettext('CGI Error !') );
+		return 1;
+	}
+
+	$cron->set_interval( $interval*60 );
+	if( $cron->set_reportmail( $reportmail ) ) {
+		$panel->add_error( gettext('The email you entered fails syntax check') );
+		$ok = 0;
+	}
+
+	if( $ok )  {
+		if( $cron->commit < 0)  {
+			$panel->add_error( gettext('Unable to apply changes') );
+			return 1;
+		}
+		$panel->add_info( gettext('Cron job successfully updated') );
+		return 0;
+	}
+
+	return 1;
+}


Property changes on: trunk/vhffs-panel/cron/prefs.pl
___________________________________________________________________
Name: svn:executable
   + *

Modified: trunk/vhffs-panel/templates/Makefile.am
===================================================================
--- trunk/vhffs-panel/templates/Makefile.am	2008-04-19 21:57:22 UTC (rev 1189)
+++ trunk/vhffs-panel/templates/Makefile.am	2008-05-02 23:34:30 UTC (rev 1190)
@@ -50,6 +50,8 @@
 	admin/user/search.tmpl \
 	admin/web/part.tmpl \
 	admin/web/search.tmpl \
+	admin/cron/part.tmpl \
+	admin/cron/search.tmpl \
 	cvs/create.tmpl \
 	cvs/prefs.tmpl \
 	dns/create.tmpl \
@@ -123,4 +125,6 @@
 	user/prefs.tmpl \
 	web/create.tmpl \
 	web/mailuser.tmpl \
-	web/prefs.tmpl
+	web/prefs.tmpl \
+	cron/create.tmpl \
+	cron/prefs.tmpl

Added: trunk/vhffs-panel/templates/admin/cron/part.tmpl
===================================================================
--- trunk/vhffs-panel/templates/admin/cron/part.tmpl	                        (rev 0)
+++ trunk/vhffs-panel/templates/admin/cron/part.tmpl	2008-05-02 23:34:30 UTC (rev 1190)
@@ -0,0 +1,16 @@
+<TMPL_LOOP NAME="CRONS">
+<tr>
+	<td>
+		<TMPL_VAR ESCAPE=1 NAME="CRONPATH">
+	</td>
+	<td>
+		<TMPL_VAR ESCAPE=1 NAME="GROUPNAME"> 
+	</td>
+	<td>
+		<TMPL_VAR ESCAPE=1 NAME="STATE"> 
+	</td>
+	<td>
+		<a href="/cron/prefs.pl?admin_menu=1&amp;name=<TMPL_VAR ESCAPE=1 NAME="CRONPATH">"><TMPL_VAR ESCAPE=1 NAME="ACTION"></a>
+	</td>
+</tr>
+</TMPL_LOOP>

Added: trunk/vhffs-panel/templates/admin/cron/search.tmpl
===================================================================
--- trunk/vhffs-panel/templates/admin/cron/search.tmpl	                        (rev 0)
+++ trunk/vhffs-panel/templates/admin/cron/search.tmpl	2008-05-02 23:34:30 UTC (rev 1190)
@@ -0,0 +1,4 @@
+		<h1><TMPL_VAR ESCAPE=1 NAME="TITLE"></h1>
+		<form method="post" action="list.pl" accept-charset="utf-8">
+			<input type="text" name="NAME" value=""/>
+		</form>

Added: trunk/vhffs-panel/templates/cron/create.tmpl
===================================================================
--- trunk/vhffs-panel/templates/cron/create.tmpl	                        (rev 0)
+++ trunk/vhffs-panel/templates/cron/create.tmpl	2008-05-02 23:34:30 UTC (rev 1190)
@@ -0,0 +1,39 @@
+<form method="post" action="#" class="shortLabel" accept-charset="utf-8">
+	<p>
+		<label>		
+			<TMPL_VAR ESCAPE=1 NAME="GROUP_NAME">: 
+		</label>
+		<TMPL_VAR ESCAPE=1 NAME="GROUP">
+	</p>
+	<p>
+		<label for="cron_path">
+			<TMPL_VAR ESCAPE=1 NAME="TEXT_CRONPATH_LABEL">:
+		</label>
+		<input type="text" name="cronpath" id="cronpath" value="<TMPL_VAR ESCAPE=1 NAME="CRONPATH_VALUE">"/>
+		<TMPL_VAR ESCAPE=1 NAME="TEXT_CRONPATH_HELP">
+	</p>
+	<p>
+		<label for="cron_interval">
+			<TMPL_VAR ESCAPE=1 NAME="TEXT_INTERVAL_LABEL">:
+		</label>
+		<input type="text" name="interval" id="interval" value="<TMPL_VAR ESCAPE=1 NAME="INTERVAL_VALUE">"/>
+		<TMPL_VAR ESCAPE=1 NAME="TEXT_INTERVAL_HELP">
+	</p>
+	<p>
+		<label for="cron_reportmail">
+			<TMPL_VAR ESCAPE=1 NAME="TEXT_REPORTMAIL_LABEL">:
+		</label>
+		<input type="text" name="reportmail" id="reportmail" value="<TMPL_VAR ESCAPE=1 NAME="REPORTMAIL_VALUE">"/>
+		<TMPL_VAR ESCAPE=1 NAME="TEXT_REPORTMAIL_HELP">
+	</p>
+	<p>
+		<label for="description">
+			<TMPL_VAR ESCAPE=1 NAME="DESCRIPTION">:
+		</label>
+		<textarea name="description" id="description" cols="45" rows="7"><TMPL_VAR ESCAPE=1 NAME="DESCRIPTION_VALUE"></textarea>
+	</p>
+	<p class="button" id="buttonSend">
+		<input type="submit" value="<TMPL_VAR ESCAPE=1 NAME="SEND">" name="cron_submit"/>
+	</p>
+</form>
+ 

Added: trunk/vhffs-panel/templates/cron/prefs.tmpl
===================================================================
--- trunk/vhffs-panel/templates/cron/prefs.tmpl	                        (rev 0)
+++ trunk/vhffs-panel/templates/cron/prefs.tmpl	2008-05-02 23:34:30 UTC (rev 1190)
@@ -0,0 +1,101 @@
+<fieldset>
+<legend><TMPL_I18N KEY="Options"></legend>
+<form method="post" action="/cron/prefs.pl" accept-charset="utf-8">
+	<p>
+		<label for="name">
+			<TMPL_VAR ESCAPE=1 NAME="TEXT_CRONPATH"> :
+		</label>
+		<TMPL_VAR ESCAPE=1 NAME="VALUE_CRONPATH">
+		<input type="hidden" name="name" id="name" value="<TMPL_VAR ESCAPE=1 NAME="VALUE_CRONPATH">"/>
+		<br/>
+	</p>
+	<p>
+		<label for="interval">
+			<TMPL_VAR ESCAPE=1 NAME="TEXT_INTERVAL"> :
+		</label>
+		<input type="text" name="interval" id="interval" value="<TMPL_VAR ESCAPE=1 NAME="VALUE_INTERVAL">"/>
+		<TMPL_VAR ESCAPE=1 NAME="TEXT_MINUTES">
+	</p>
+	<p>
+		<label for="reportmail">
+			<TMPL_VAR ESCAPE=1 NAME="TEXT_REPORTMAIL"> :
+		</label>
+		<input type="text" name="reportmail" id="reportmail" value="<TMPL_VAR ESCAPE=1 NAME="VALUE_REPORTMAIL">"/>
+	</p>
+	<p>
+		<label for="lastrundate">
+			<TMPL_VAR ESCAPE=1 NAME="TEXT_LASTRUNDATE"> :
+		</label>
+		<TMPL_VAR ESCAPE=1 NAME="VALUE_LASTRUNDATE">
+		<br/>
+	</p>
+	<p>
+		<label for="lastrunreturncode">
+			<TMPL_VAR ESCAPE=1 NAME="TEXT_LASTRUNRETURNCODE"> :
+		</label>
+		<TMPL_VAR ESCAPE=1 NAME="VALUE_LASTRUNRETURNCODE">
+		<br/>
+	</p>
+	<p>
+		<label for="nextrundate">
+			<TMPL_VAR ESCAPE=1 NAME="TEXT_NEXTRUNDATE"> :
+		</label>
+		<TMPL_VAR ESCAPE=1 NAME="VALUE_NEXTRUNDATE">
+		<br/>
+	</p>
+	<p>
+		<label for="running">
+			<TMPL_VAR ESCAPE=1 NAME="TEXT_RUNNING"> :
+		</label>
+		<TMPL_VAR ESCAPE=1 NAME="VALUE_RUNNING">
+		<br/>
+	</p>
+	<p class="button">
+		<input type="submit" value="<TMPL_VAR ESCAPE=1 NAME="TEXT_SEND">" name="save_prefs_submit"/>
+	</p>
+</form>
+</fieldset>
+
+<h2><TMPL_VAR ESCAPE=1 NAME="TEXT_ACL_ADMIN"></h2>
+		
+<form method="post" action="../acl/view.pl" accept-charset="utf-8">
+	<p><TMPL_VAR ESCAPE=1 NAME="EXPLAIN_ADMIN_ACL"></p>
+
+	<input type="hidden" name="target_oid" value="<TMPL_VAR ESCAPE=1 NAME="VALUE_OID">" />
+	<p class="button" id="buttonAclAdmin">
+		<input type="submit" value="<TMPL_VAR ESCAPE=1 NAME="ADMIN_ACL">" />
+	</p>
+</form>
+
+
+<h2><TMPL_VAR ESCAPE=1 NAME="TEXT_DELETE_CRON"></h2>
+
+<form method="post" action="delete.pl" accept-charset="utf-8">
+	<fieldset class="delete">
+		<legend>
+			<TMPL_VAR ESCAPE=1 NAME="ASK_DELETE_CRON">:
+		</legend>
+
+		<p class="warning"><TMPL_VAR ESCAPE=1 NAME="TEXT_BEFORE_DELETE"></p>
+		<p>
+			<input type="radio" name="DELETE" id="DELETE_NO"  value="0" checked="checked" />
+			<label for="DELETE_NO">
+				<TMPL_VAR ESCAPE=1 NAME="NO">
+			</label>
+		</p>
+		<p>
+			<input type="radio" name="DELETE" id="DELETE_YES" value="1" />
+			<label for="DELETE_YES">
+				<TMPL_VAR ESCAPE=1 NAME="YES">
+			</label>
+		</p>
+	</fieldset>
+	
+	<p class="button" id="buttonDelete">
+		<input type="hidden" name="CRONPATH" value="<TMPL_VAR ESCAPE=1 NAME="VALUE_CRONPATH">" />
+		<input type="submit" value="<TMPL_VAR ESCAPE=1 NAME="TEXT_DELETE">" />
+	</p>
+				
+</form>
+
+<TMPL_VAR ESCAPE=0 NAME="ADMIN_PART">

Modified: trunk/vhffs-robots/Makefile.am
===================================================================
--- trunk/vhffs-robots/Makefile.am	2008-04-19 21:57:22 UTC (rev 1189)
+++ trunk/vhffs-robots/Makefile.am	2008-05-02 23:34:30 UTC (rev 1190)
@@ -69,7 +69,9 @@
 	src/user_cleanup.pl \
 	src/web_create.pl \
 	src/web_delete.pl \
-	src/web_stats.pl
+	src/web_stats.pl \
+	src/cron_create.pl \
+	src/cron_delete.pl
 
 # Define the substitution we need to point perl script at correct location
 do_sed = $(SED) --in-place \

Added: trunk/vhffs-robots/src/cron_create.pl
===================================================================
--- trunk/vhffs-robots/src/cron_create.pl	                        (rev 0)
+++ trunk/vhffs-robots/src/cron_create.pl	2008-05-02 23:34:30 UTC (rev 1190)
@@ -0,0 +1,68 @@
+#!%PERL%
+# Copyright (c) vhffs project and its contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright 
+#   notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in 
+#   the documentation and/or other materials provided with the 
+#   distribution.
+#3. Neither the name of vhffs nor the names of its contributors 
+#   may be used to endorse or promote products derived from this 
+#   software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+# POSSIBILITY OF SUCH DAMAGE.
+
+#This robot create cron jobs
+#It actives it
+
+# FIXME : This robot is unnecessary, we just have to activate the cron job on creation
+
+use strict;
+use utf8;
+
+use lib '%VHFFS_LIB_DIR%';
+use Vhffs::Services::Cron;
+use Vhffs::Robots;
+use Vhffs::Main;
+
+
+my $vhffs = init Vhffs::Main;
+exit 1 unless defined $vhffs;
+
+Vhffs::Robots::lock( $vhffs , 'cron' );
+
+my $crons = Vhffs::Services::Cron::getall( $vhffs , Vhffs::Constants::WAITING_FOR_CREATION );
+
+foreach my $c ( @{$crons} )
+{
+	$c->set_status( Vhffs::Constants::ACTIVATED );
+	if( $c->commit > 0 )
+	{
+		Vhffs::Robots::vhffs_log( sprintf( 'Created cron job %s' , $c->get_cronpath ) , $vhffs);
+		$c->add_history( 'Robots activated this cron job' );
+	}
+	else
+	{
+		Vhffs::Robots::vhffs_log( sprintf( 'Cannot create cron job %s' , $c->get_cronpath ) , $vhffs);
+	}
+}
+
+Vhffs::Robots::unlock( $vhffs , 'cron' );
+exit 0;


Property changes on: trunk/vhffs-robots/src/cron_create.pl
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/vhffs-robots/src/cron_delete.pl
===================================================================
--- trunk/vhffs-robots/src/cron_delete.pl	                        (rev 0)
+++ trunk/vhffs-robots/src/cron_delete.pl	2008-05-02 23:34:30 UTC (rev 1190)
@@ -0,0 +1,55 @@
+#!%PERL%
+# Copyright (c) vhffs project and its contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright 
+#   notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in 
+#   the documentation and/or other materials provided with the 
+#   distribution.
+#3. Neither the name of vhffs nor the names of its contributors 
+#   may be used to endorse or promote products derived from this 
+#   software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+# POSSIBILITY OF SUCH DAMAGE.
+
+use strict;
+use utf8;
+
+use lib '%VHFFS_LIB_DIR%';
+
+use Vhffs::Services::Cron;
+use Vhffs::Robots;
+use Vhffs::Main;
+
+my $vhffs = init Vhffs::Main;
+exit 1 unless defined $vhffs;
+
+Vhffs::Robots::lock( $vhffs , 'cron' );
+
+my $crons = Vhffs::Services::Cron::getall( $vhffs , Vhffs::Constants::TO_DELETE );
+
+foreach my $c ( @{$crons} )
+{
+	Vhffs::Robots::vhffs_log( sprintf( 'Deleted cron job %s' , $c->get_cronpath ) , $vhffs);
+	$c->delete;
+}
+
+Vhffs::Robots::unlock( $vhffs , 'cron' );
+exit 0;


Property changes on: trunk/vhffs-robots/src/cron_delete.pl
___________________________________________________________________
Name: svn:executable
   + *

Modified: trunk/vhffs-themes/Makefile.am
===================================================================
--- trunk/vhffs-themes/Makefile.am	2008-04-19 21:57:22 UTC (rev 1189)
+++ trunk/vhffs-themes/Makefile.am	2008-05-02 23:34:30 UTC (rev 1190)
@@ -69,6 +69,7 @@
 	vhffs/images/webentry.png \
 	vhffs/images/web.png \
 	vhffs/images/webs.png \
+	vhffs/images/cronentry.png \
 	vhffs/main.css
 
 

Added: trunk/vhffs-themes/vhffs/images/cronentry.png
===================================================================
(Binary files differ)


Property changes on: trunk/vhffs-themes/vhffs/images/cronentry.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: trunk/vhffs-themes/vhffs/main.css
===================================================================
--- trunk/vhffs-themes/vhffs/main.css	2008-04-19 21:57:22 UTC (rev 1189)
+++ trunk/vhffs-themes/vhffs/main.css	2008-05-02 23:34:30 UTC (rev 1190)
@@ -282,6 +282,11 @@
 	min-width:275px;
 }
 
+form.shortLabel label {
+	width:auto;
+	min-width:100px;
+}
+
 fieldset.delete
 {
 	margin:0px;
@@ -710,6 +715,10 @@
     list-style-image: url('images/groupentry.png');
 }
 
+ul.cronList {
+    list-style-image: url('images/cronentry.png');
+}
+
 div.acltable * {
 margin:0;
 padding:0;


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