diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index e6e4c2de4ce..b0597730e43 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -121,8 +121,6 @@ class Canvas */ public function getCanvas($module, $card, $canvas) { - global $conf, $langs; - // Set properties with value specific to dolibarr core: this->targetmodule, this->card, this->canvas $this->targetmodule = $module; $this->canvas = $canvas; @@ -190,7 +188,12 @@ class Canvas return 0; } - if (file_exists($this->template_dir.(!empty($this->card) ? $this->card.'_' : '').$this->_cleanaction($action).'.tpl.php')) { + $newaction = $action; + if ($action && !in_array($action, array('create', 'view', 'edit', 'list'))) { + $newaction = 'view'; + } + + if (file_exists($this->template_dir.(!empty($this->card) ? $this->card.'_' : '').$this->_cleanaction($newaction).'.tpl.php')) { return 1; } else { return 0; @@ -208,11 +211,16 @@ class Canvas public function display_canvas($action) { // phpcs:enable - global $db, $conf, $langs, $user, $canvas; - global $form, $formfile; + global $db, $conf, $langs, $user, $canvas; // used into include + global $form, $formfile; // used into include + + $newaction = $action; + if ($action && !in_array($action, array('create', 'view', 'edit', 'list'))) { + $newaction = 'view'; + } //var_dump($this->card.'-'.$action); - include $this->template_dir.(!empty($this->card) ? $this->card.'_' : '').$this->_cleanaction($action).'.tpl.php'; // Include native PHP template + include $this->template_dir.(!empty($this->card) ? $this->card.'_' : '').$this->_cleanaction($newaction).'.tpl.php'; // Include native PHP template }