forked from Wavyzz/dolibarr
Fix: undefined rights_class on modules
When a module has the permission variable rights_class undefined, on unactivate the module are deleted all rows in cronjobs and menu tables with module=''.
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
* Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
* Copyright (C) 2018 Josep Lluís Amador <joseplluis@lliuretic.cat>
|
||||
*
|
||||
* 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 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
|
||||
// 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 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
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 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
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 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
$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 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
$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 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
$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)."'";
|
||||
|
||||
Reference in New Issue
Block a user