indentation

This commit is contained in:
Cédric Salvador 2013-07-01 15:35:55 +02:00
parent 96cea7b79a
commit edc5de4f24
3 changed files with 62 additions and 62 deletions

View File

@ -65,7 +65,7 @@ class Cronjob extends CommonObject
var $fk_user_mod; var $fk_user_mod;
var $note; var $note;
var $nbrun; var $nbrun;
var $libname; var $libname;
var $lines; var $lines;
@ -114,7 +114,7 @@ class Cronjob extends CommonObject
if (isset($this->status)) $this->status=trim($this->status); if (isset($this->status)) $this->status=trim($this->status);
if (isset($this->note)) $this->note=trim($this->note); if (isset($this->note)) $this->note=trim($this->note);
if (isset($this->nbrun)) $this->nbrun=trim($this->nbrun); if (isset($this->nbrun)) $this->nbrun=trim($this->nbrun);
if (isset($this->libname)) $this->libname = trim($this->libname); if (isset($this->libname)) $this->libname = trim($this->libname);
// Check parameters // Check parameters
// Put here code to add a control on parameters values // Put here code to add a control on parameters values
@ -150,11 +150,11 @@ class Cronjob extends CommonObject
$this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronObject')); $this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronObject'));
$error++; $error++;
} }
if (($this->jobtype=='function') && (empty($this->libname))) { if (($this->jobtype=='function') && (empty($this->libname))) {
$this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronLib')); $this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronLib'));
$error++; $error++;
} }
// Insert request // Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX."cronjob("; $sql = "INSERT INTO ".MAIN_DB_PREFIX."cronjob(";
@ -184,10 +184,10 @@ class Cronjob extends CommonObject
$sql.= "fk_user_mod,"; $sql.= "fk_user_mod,";
$sql.= "note,"; $sql.= "note,";
$sql.= "nbrun"; $sql.= "nbrun";
$sql .= ",libname"; $sql .= ",libname";
$sql.= ") VALUES ("; $sql.= ") VALUES (";
$sql.= " ".$this->db->idate(dol_now()).","; $sql.= " ".$this->db->idate(dol_now()).",";
$sql.= " ".(! isset($this->jobtype)?'NULL':"'".$this->db->escape($this->jobtype)."'").","; $sql.= " ".(! isset($this->jobtype)?'NULL':"'".$this->db->escape($this->jobtype)."'").",";
@ -214,7 +214,7 @@ class Cronjob extends CommonObject
$sql.= " ".$user->id.","; $sql.= " ".$user->id.",";
$sql.= " ".(! isset($this->note)?'NULL':"'".$this->db->escape($this->note)."'").","; $sql.= " ".(! isset($this->note)?'NULL':"'".$this->db->escape($this->note)."'").",";
$sql.= " ".(! isset($this->nbrun)?'0':"'".$this->db->escape($this->nbrun)."'").","; $sql.= " ".(! isset($this->nbrun)?'0':"'".$this->db->escape($this->nbrun)."'").",";
$sql.= " ".(! isset($this->libname)?'NULL':"'".$this->db->escape($this->libname)."'").""; $sql.= " ".(! isset($this->libname)?'NULL':"'".$this->db->escape($this->libname)."'")."";
$sql.= ")"; $sql.= ")";
@ -301,7 +301,7 @@ class Cronjob extends CommonObject
$sql.= " t.fk_user_mod,"; $sql.= " t.fk_user_mod,";
$sql.= " t.note,"; $sql.= " t.note,";
$sql.= " t.nbrun"; $sql.= " t.nbrun";
$sql .= ", t.libname"; $sql .= ", t.libname";
$sql.= " FROM ".MAIN_DB_PREFIX."cronjob as t"; $sql.= " FROM ".MAIN_DB_PREFIX."cronjob as t";
@ -344,7 +344,7 @@ class Cronjob extends CommonObject
$this->fk_user_mod = $obj->fk_user_mod; $this->fk_user_mod = $obj->fk_user_mod;
$this->note = $obj->note; $this->note = $obj->note;
$this->nbrun = $obj->nbrun; $this->nbrun = $obj->nbrun;
$this->libname = $obj->libname; $this->libname = $obj->libname;
} }
$this->db->free($resql); $this->db->free($resql);
@ -401,7 +401,7 @@ class Cronjob extends CommonObject
$sql.= " t.fk_user_mod,"; $sql.= " t.fk_user_mod,";
$sql.= " t.note,"; $sql.= " t.note,";
$sql.= " t.nbrun"; $sql.= " t.nbrun";
$sql .= ", t.libname"; $sql .= ", t.libname";
$sql.= " FROM ".MAIN_DB_PREFIX."cronjob as t"; $sql.= " FROM ".MAIN_DB_PREFIX."cronjob as t";
$sql.= " WHERE 1 = 1"; $sql.= " WHERE 1 = 1";
@ -474,7 +474,7 @@ class Cronjob extends CommonObject
$line->fk_user_mod = $obj->fk_user_mod; $line->fk_user_mod = $obj->fk_user_mod;
$line->note = $obj->note; $line->note = $obj->note;
$line->nbrun = $obj->nbrun; $line->nbrun = $obj->nbrun;
$line->libname = $obj->libname; $line->libname = $obj->libname;
$this->lines[]=$line; $this->lines[]=$line;
$i++; $i++;
@ -568,10 +568,10 @@ class Cronjob extends CommonObject
$error++; $error++;
} }
if (($this->jobtype=='function') && (empty($this->libname))) { if (($this->jobtype=='function') && (empty($this->libname))) {
$this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronLib')); $this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronLib'));
$error++; $error++;
} }
// Update request // Update request
@ -600,7 +600,7 @@ class Cronjob extends CommonObject
$sql.= " fk_user_mod=".$user->id.","; $sql.= " fk_user_mod=".$user->id.",";
$sql.= " note=".(isset($this->note)?"'".$this->db->escape($this->note)."'":"null").","; $sql.= " note=".(isset($this->note)?"'".$this->db->escape($this->note)."'":"null").",";
$sql.= " nbrun=".(isset($this->nbrun)?$this->nbrun:"null"); $sql.= " nbrun=".(isset($this->nbrun)?$this->nbrun:"null");
$sql.= ", libname=".(isset($this->libname)?"'".$this->db->escape($this->libname)."'":"null"); $sql.= ", libname=".(isset($this->libname)?"'".$this->db->escape($this->libname)."'":"null");
$sql.= " WHERE rowid=".$this->id; $sql.= " WHERE rowid=".$this->id;
@ -959,47 +959,47 @@ class Cronjob extends CommonObject
} }
if($this->jobtype == 'function') if($this->jobtype == 'function')
{ {
//load lib //load lib
$libpath = '/' . strtolower($this->module_name) . '/lib/' . $this->libname; $libpath = '/' . strtolower($this->module_name) . '/lib/' . $this->libname;
$ret = dol_include_once($libpath); $ret = dol_include_once($libpath);
if ($ret === false) if ($ret === false)
{ {
$this->error = $langs->trans('CronCannotLoadLib') . ': ' . $libpath; $this->error = $langs->trans('CronCannotLoadLib') . ': ' . $libpath;
dol_syslog(get_class($this) . "::run_jobs " . $this->error, LOG_ERR); dol_syslog(get_class($this) . "::run_jobs " . $this->error, LOG_ERR);
return -1; return -1;
} }
// Load langs // Load langs
$result=$langs->load($this->module_name . '@' . $this->module_name); $result=$langs->load($this->module_name . '@' . $this->module_name);
if ($result<0) if ($result<0)
{ {
dol_syslog(get_class($this) . "::run_jobs Cannot load module langs" . $langs->error, LOG_ERR); dol_syslog(get_class($this) . "::run_jobs Cannot load module langs" . $langs->error, LOG_ERR);
return -1; return -1;
} }
dol_syslog(get_class($this) . "::run_jobs " . $this->libname . "::" . $this->methodename."(" . $this->params . ");", LOG_DEBUG); dol_syslog(get_class($this) . "::run_jobs " . $this->libname . "::" . $this->methodename."(" . $this->params . ");", LOG_DEBUG);
$params_arr = array(); $params_arr = array();
$params_arr = explode(", ", $this->params); $params_arr = explode(", ", $this->params);
if (!is_array($params_arr)) if (!is_array($params_arr))
{ {
$result = call_user_func($this->methodename, $this->params); $result = call_user_func($this->methodename, $this->params);
} }
else else
{ {
$result = call_user_func_array($this->methodename, $params_arr); $result = call_user_func_array($this->methodename, $params_arr);
} }
if ($result === false) if ($result === false)
{ {
dol_syslog(get_class($this) . "::run_jobs " . $object->error, LOG_ERR); dol_syslog(get_class($this) . "::run_jobs " . $object->error, LOG_ERR);
return -1; return -1;
} }
else else
{ {
$this->lastoutput=var_export($result,true); $this->lastoutput=var_export($result,true);
$this->lastresult=var_export($result,true); $this->lastresult=var_export($result,true);
} }
} }
// Run a command line // Run a command line
if ($this->jobtype=='command') if ($this->jobtype=='command')
@ -1150,7 +1150,7 @@ class Cronjobline
var $fk_user_mod; var $fk_user_mod;
var $note; var $note;
var $nbrun; var $nbrun;
var $libname; var $libname;
/** /**
* Constructor * Constructor

View File

@ -47,5 +47,5 @@ CREATE TABLE llx_cronjob
fk_user_author integer DEFAULT NULL, fk_user_author integer DEFAULT NULL,
fk_user_mod integer DEFAULT NULL, fk_user_mod integer DEFAULT NULL,
note text, note text,
libname varchar(255) libname varchar(255)
)ENGINE=innodb; )ENGINE=innodb;

View File

@ -1,8 +1,8 @@
#!/usr/bin/php #!/usr/bin/php
<?php <?php
/* Copyright (C) 2012 Nicolas Villa aka Boyquotes http://informetic.fr /* Copyright (C) 2012 Nicolas Villa aka Boyquotes http://informetic.fr
* Copyright (C) 2013 Florian Henry <forian.henry@open-concept.pro * Copyright (C) 2013 Florian Henry <forian.henry@open-concept.pro
* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by