reduce complexity of cronjob class

This commit is contained in:
Frédéric FRANCE 2018-09-16 19:26:49 +02:00 committed by GitHub
parent ab0f842db6
commit 0e0197f246
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -244,8 +244,8 @@ class Cronjob extends CommonObject
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."cronjob");
if (! $notrigger)
{
//if (! $notrigger)
//{
// Uncomment this and change MYOBJECT to your own tag if you
// want this action calls a trigger.
@ -255,7 +255,7 @@ class Cronjob extends CommonObject
//$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
}
//}
}
// Commit or rollback
@ -430,7 +430,7 @@ class Cronjob extends CommonObject
$sql.= " WHERE 1 = 1";
if ($processing >= 0) $sql.= " AND t.processing = ".(empty($processing)?'0':'1');
if ($status >= 0 && $status < 2) $sql.= " AND t.status = ".(empty($status)?'0':'1');
if ($status == 2) $sql.= " AND t.status = 2";
elseif ($status == 2) $sql.= " AND t.status = 2";
//Manage filter
if (is_array($filter) && count($filter)>0) {
foreach($filter as $key => $value)
@ -633,10 +633,8 @@ class Cronjob extends CommonObject
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (! $error)
{
if (! $notrigger)
{
//if (! $error && ! $notrigger)
//{
// Uncomment this and change MYOBJECT to your own tag if you
// want this action calls a trigger.
@ -646,8 +644,7 @@ class Cronjob extends CommonObject
//$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
}
}
//}
// Commit or rollback
if ($error)
@ -763,11 +760,11 @@ class Cronjob extends CommonObject
$error++;
}
if (! $error)
{
//if (! $error)
//{
}
//}
unset($this->context['createfromclone']);
@ -1304,34 +1301,33 @@ class Cronjob extends CommonObject
if ($mode == 0)
{
$prefix='';
if ($status == 1) return $langs->trans('Enabled');
if ($status == 0) return $langs->trans('Disabled');
elseif ($status == 0) return $langs->trans('Disabled');
}
if ($mode == 1)
elseif ($mode == 1)
{
if ($status == 1) return $langs->trans('Enabled');
if ($status == 0) return $langs->trans('Disabled');
elseif ($status == 0) return $langs->trans('Disabled');
}
if ($mode == 2)
elseif ($mode == 2)
{
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4','class="pictostatus"').' '.$langs->trans('Enabled');
if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"').' '.$langs->trans('Disabled');
elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"').' '.$langs->trans('Disabled');
}
if ($mode == 3)
elseif ($mode == 3)
{
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4','class="pictostatus"');
if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"');
elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"');
}
if ($mode == 4)
elseif ($mode == 4)
{
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4','class="pictostatus"').' '.$langs->trans('Enabled');
if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"').' '.$langs->trans('Disabled');
elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"').' '.$langs->trans('Disabled');
}
if ($mode == 5)
elseif ($mode == 5)
{
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4','class="pictostatus"');
if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"');
elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"');
}
}
}