diff --git a/htdocs/core/class/html.formcron.class.php b/htdocs/core/class/html.formcron.class.php
new file mode 100644
index 00000000000..2acb83e3f05
--- /dev/null
+++ b/htdocs/core/class/html.formcron.class.php
@@ -0,0 +1,93 @@
+
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see .
+*/
+
+/**
+ * \file cron/class/html.formcron.class.php
+* \brief Fichier de la classe des fonctions predefinie de composants html cron
+*/
+
+
+/**
+ * Class to manage building of HTML components
+*/
+class FormCron extends Form
+{
+ var $db;
+ var $error;
+
+ /**
+ * Constructor
+ *
+ * @param DoliDB $db Database handler
+ */
+ function __construct($db)
+ {
+ $this->db = $db;
+ return 1;
+ }
+
+
+ /**
+ * Display On Off selector
+ *
+ * @param string $htmlname Html control name
+ * @param string $selected selected value
+ * @param string $readonly Select is read only or not
+ * @return string HTML select field
+ */
+ function select_typejob($htmlname,$selected=0,$readonly=0)
+ {
+ global $langs;
+
+ $langs->load('cron@cron');
+ if (!empty($readonly)) {
+ if ($selected=='command') {
+ $out= $langs->trans('CronType_command');
+ $out.='';
+ $out.= '';
+ $out.='';
+ } elseif ($selected=='method') {
+ $out= $langs->trans('CronType_method');
+ $out.='';
+ $out.= '';
+ $out.='';
+ }
+ }else {
+
+ $out='';
+
+ if ($selected=='command') {
+ $selected_attr=' selected=\"selected\" ';
+ } else {
+ $selected_attr='';
+ }
+ $out.= '';
+
+ if ($selected=='method') {
+ $selected_attr=' selected=\"selected\" ';
+ } else {
+ $selected_attr='';
+ }
+ $out.= '';
+
+ $out.='';
+ }
+
+ return $out;
+ }
+}
diff --git a/htdocs/core/lib/cron.lib.php b/htdocs/core/lib/cron.lib.php
new file mode 100644
index 00000000000..abd85131e29
--- /dev/null
+++ b/htdocs/core/lib/cron.lib.php
@@ -0,0 +1,71 @@
+
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+/**
+ * \file cron/lib/cron.lib.php
+ * \brief Ensemble de fonctions de base pour le module jobs
+ * \ingroup jobs
+ */
+
+/**
+ * Return array of tabs to used on pages for third parties cards.
+ *
+ * @param Object $object Object company shown
+ * @return array Array of tabs
+ */
+
+function cronadmin_prepare_head()
+{
+ global $langs, $conf, $user;
+ $h = 0;
+ $head = array();
+
+ $head[$h][0] = dol_buildpath('/cron/admin/cron.php', 1);
+ $head[$h][1] = $langs->trans("CronSetup");
+ $head[$h][2] = 'setup';
+ $h++;
+
+ complete_head_from_modules($conf, $langs, $object, $head, $h, 'cronadmin');
+
+ complete_head_from_modules($conf, $langs, $object, $head, $h, 'cronadmin', 'remove');
+
+
+ return $head;
+}
+
+function cron_prepare_head($object)
+{
+ global $langs, $conf, $user;
+ $h = 0;
+ $head = array();
+
+ $head[$h][0] = dol_buildpath('/cron/card.php', 1).'?id='.$object->id;
+ $head[$h][1] = $langs->trans("CronTask");
+ $head[$h][2] = 'card';
+ $h++;
+
+ $head[$h][0] = dol_buildpath('/cron/info.php', 1).'?id='.$object->id;
+ $head[$h][1] = $langs->trans("CronInfoPage");
+ $head[$h][2] = 'info';
+ $h++;
+
+ complete_head_from_modules($conf, $langs, $object, $head, $h, 'cron');
+
+ complete_head_from_modules($conf, $langs, $object, $head, $h, 'cron', 'remove');
+
+ return $head;
+}
diff --git a/htdocs/core/modules/modCron.class.php b/htdocs/core/modules/modCron.class.php
index fbc14945f02..53d9afabf30 100644
--- a/htdocs/core/modules/modCron.class.php
+++ b/htdocs/core/modules/modCron.class.php
@@ -1,5 +1,6 @@
+/* Copyright (C) 2012 Nicolas Villa aka Boyquotes http://informetic.fr
+ * Copyright (C) 2013 Florian Henry
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -16,11 +17,11 @@
*/
/**
- * \defgroup webservices Module webservices
- * \brief Module to enable the Dolibarr server of web services
- * \file htdocs/core/modules/modCron.class.php
- * \ingroup cron
- * \brief File to describe cron module
+ * \defgroup cron Module cron
+ * \brief cron module descriptor.
+ * \file cron/core/modules/modCron.class.php
+ * \ingroup cron
+ * \brief Description and activation file for module Jobs
*/
include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
@@ -65,11 +66,20 @@ class modCron extends DolibarrModules
//-------------
$this->depends = array();
$this->requiredby = array();
- $this->langfiles = array("cron");
+ $this->langfiles = array("cron@cron");
// Constantes
//-----------
- $this->const = array();
+ $this->const = array(
+ 0=>array(
+ 'MAIN_CRON_KEY',
+ 'chaine',
+ '',
+ 'CRON KEY',
+ 0,
+ 'main',
+ 0
+ ),);
// New pages on tabs
// -----------------
@@ -79,25 +89,60 @@ class modCron extends DolibarrModules
//------
$this->boxes = array();
- // Permissions
- //------------
- $this->rights = array();
- $this->rights_class = 'cron';
- $r=0;
+ // Permissions
+ $this->rights = array(); // Permission array used by this module
+ $this->rights_class = 'cron';
+ $r=0;
+
+ $this->rights[$r][0] = 23001;
+ $this->rights[$r][1] = 'Read cron jobs';
+ $this->rights[$r][3] = 1;
+ $this->rights[$r][4] = 'read';
+ $r++;
+
+ $this->rights[$r][0] = 23002;
+ $this->rights[$r][1] = 'Create cron Jobs';
+ $this->rights[$r][3] = 0;
+ $this->rights[$r][4] = 'create';
+ $r++;
+
+ $this->rights[$r][0] = 23003;
+ $this->rights[$r][1] = 'Delete cron Jobs';
+ $this->rights[$r][3] = 0;
+ $this->rights[$r][4] = 'delete';
+ $r++;
+
+ $this->rights[$r][0] = 23004;
+ $this->rights[$r][1] = 'Execute cron Jobs';
+ $this->rights[$r][3] = 0;
+ $this->rights[$r][4] = 'execute';
+ $r++;
// Main menu entries
$r=0;
$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=modulesadmintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'type'=>'left', // This is a Left menu entry
- 'titre'=>'CronJobs',
- 'url'=>'/cron/index.php',
- 'langs'=>'cron@cron', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
- 'position'=>100,
+ 'titre'=>'CronListActive',
+ 'url'=>'/cron/list.php?status=1',
+ 'langs'=>'cron', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
+ 'position'=>200,
'enabled'=>'$leftmenu==\'modulesadmintools\'', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
- 'perms'=>'$user->admin', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
+ 'perms'=>'$user->rights->cron->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
'target'=>'',
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
$r++;
+
+ $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=modulesadmintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
+ 'type'=>'left', // This is a Left menu entry
+ 'titre'=>'CronListInactive',
+ 'url'=>'/cron/list.php?status=0',
+ 'langs'=>'cron', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
+ 'position'=>201,
+ 'enabled'=>'$leftmenu==\'modulesadmintools\'', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
+ 'perms'=>'$user->rights->cron->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
+ 'target'=>'',
+ 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
+ $r++;
}
@@ -114,8 +159,6 @@ class modCron extends DolibarrModules
// Prevent pb of modules not correctly disabled
//$this->remove($options);
- $sql = array();
-
return $this->_init($sql,$options);
}
diff --git a/htdocs/cron/admin/cron.php b/htdocs/cron/admin/cron.php
index fd77bcc6851..894e9dc4457 100644
--- a/htdocs/cron/admin/cron.php
+++ b/htdocs/cron/admin/cron.php
@@ -1,34 +1,36 @@
* Copyright (C) 2005-2013 Laurent Destailleur
- * Copyright (C) 2011 Juanjo Menent
- * Copyright (C) 2012 Regis Houssin
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
+* Copyright (C) 2011 Juanjo Menent
+* Copyright (C) 2012 Regis Houssin
+* Copyright (C) 2013 Florian Henry
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see .
+*/
/**
- * \file htdocs/cron/admin/cron.php
- * \ingroup cron
- * \brief Page to setup cron module
- */
+ * \file cron/admin/cron.php
+* \ingroup cron
+*/
-require '../../main.inc.php';
+// Dolibarr environment
+$res = @include("../../main.inc.php"); // From htdocs directory
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/cron.lib.php';
-$langs->load("admin");
-$langs->load("cron");
+$langs->load("admin");
+$langs->load("cron");
if (! $user->admin)
accessforbidden();
@@ -36,37 +38,40 @@ if (! $user->admin)
$actionsave=GETPOST("save");
// Sauvegardes parametres
-if ($actionsave)
+if (!empty($actionsave))
{
- $i=0;
+ $i=0;
- $db->begin();
+ $db->begin();
- $i+=dolibarr_set_const($db,'CRON_KEY',trim(GETPOST("CRON_KEY")),'chaine',0,'',$conf->entity);
+ $i+=dolibarr_set_const($db,'MAIN_CRON_KEY',trim(GETPOST("MAIN_CRON_KEY")),'chaine',0,'',0);
- if ($i >= 1)
- {
- $db->commit();
- setEventMessage($langs->trans("SetupSaved"));
- }
- else
- {
- $db->rollback();
- setEventMessage($langs->trans("Error"), 'errors');
- }
+ if ($i >= 1)
+ {
+ $db->commit();
+ setEventMessage($langs->trans("SetupSaved"));
+ }
+ else
+ {
+ $db->rollback();
+ setEventMessage($langs->trans("Error"), 'errors');
+ }
}
/*
* View
- */
+*/
llxHeader();
$linkback=''.$langs->trans("BackToModuleList").'';
print_fiche_titre($langs->trans("CronSetup"),$linkback,'setup');
-print $langs->trans("CronDesc")." \n";
+// Configuration header
+$head = cronadmin_prepare_head();
+dol_fiche_head($head,'setup',$langs->trans("Module2300Name"),0,'cron');
+
print " \n";
print '