From 0e0197f24640f512676c3b5b9251c547bdfbf4da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 16 Sep 2018 19:26:49 +0200 Subject: [PATCH] reduce complexity of cronjob class --- htdocs/cron/class/cronjob.class.php | 46 +++++++++++++---------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 26d81c08385..dc853e0da7d 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -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"'); } } }