diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index a7f9e9b09b292..3e79ec232b48a 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -6,6 +6,7 @@ * Copyright (C) 2005-2013 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2014 Raphaël Doursenaud + * Copyright (C) 2018 Josep Lluís Amador * * 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 @@ -1328,7 +1329,7 @@ function insert_cronjobs() // Search if cron entry already present $sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."cronjob"; - $sql.= " WHERE module_name = '".$this->db->escape($this->rights_class)."'"; + $sql.= " WHERE module_name = '".$this->db->escape(empty($this->rights_class)?strtolower($this->name):$this->rights_class)."'"; if ($class) $sql.= " AND classesname = '".$this->db->escape($class)."'"; if ($objectname) $sql.= " AND objectname = '".$this->db->escape($objectname)."'"; if ($method) $sql.= " AND methodename = '".$this->db->escape($method)."'"; @@ -1354,7 +1355,7 @@ function insert_cronjobs() if(is_int($status)){ $sql.= ' status,'; } $sql.= " entity, test)"; $sql.= " VALUES ("; - $sql.= "'".$this->db->escape($this->rights_class)."', "; + $sql.= "'".$this->db->escape(empty($this->rights_class)?strtolower($this->name):$this->rights_class)."', "; $sql.= "'".$this->db->idate($now)."', "; $sql.= ($datestart ? "'".$this->db->idate($datestart)."'" : "NULL").", "; $sql.= ($dateend ? "'".$this->db->idate($dateend)."'" : "NULL").", "; @@ -1417,7 +1418,7 @@ function delete_cronjobs() if (is_array($this->cronjobs)) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."cronjob"; - $sql.= " WHERE module_name = '".$this->db->escape($this->rights_class)."'"; + $sql.= " WHERE module_name = '".$this->db->escape(empty($this->rights_class)?strtolower($this->name):$this->rights_class)."'"; $sql.= " AND entity = ".$conf->entity; dol_syslog(get_class($this)."::delete_cronjobs", LOG_DEBUG); @@ -1795,7 +1796,7 @@ function delete_permissions() $err=0; $sql = "DELETE FROM ".MAIN_DB_PREFIX."rights_def"; - $sql.= " WHERE module = '".$this->db->escape($this->rights_class)."'"; + $sql.= " WHERE module = '".$this->db->escape(empty($this->rights_class)?strtolower($this->name):$this->rights_class)."'"; $sql.= " AND entity = ".$conf->entity; dol_syslog(get_class($this)."::delete_permissions", LOG_DEBUG); if (! $this->db->query($sql)) @@ -1833,7 +1834,7 @@ function insert_menus() $menu->menu_handler='all'; //$menu->module=strtolower($this->name); TODO When right_class will be same than module name - $menu->module=$this->rights_class; + $menu->module=empty($this->rights_class)?strtolower($this->name):$this->rights_class; if (! $this->menu[$key]['fk_menu']) { @@ -1929,7 +1930,7 @@ function delete_menus() $err=0; //$module=strtolower($this->name); TODO When right_class will be same than module name - $module=$this->rights_class; + $module=empty($this->rights_class)?strtolower($this->name):$this->rights_class; $sql = "DELETE FROM ".MAIN_DB_PREFIX."menu"; $sql.= " WHERE module = '".$this->db->escape($module)."'";