From 3c98daaf09668882f18f3c684a6affe5f2e18a6e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 30 May 2012 03:46:06 +0200 Subject: [PATCH] More fix for canvas features --- .../default/dao_contact_default.class.php | 42 ------------------- .../default/tpl/contactcard_create.tpl.php | 6 ++- .../default/tpl/contactcard_edit.tpl.php | 2 +- htdocs/core/class/canvas.class.php | 27 ++++++++---- .../canvas/product/tpl/card_create.tpl.php | 2 +- htdocs/product/fiche.php | 3 +- 6 files changed, 28 insertions(+), 54 deletions(-) delete mode 100644 htdocs/contact/canvas/default/dao_contact_default.class.php diff --git a/htdocs/contact/canvas/default/dao_contact_default.class.php b/htdocs/contact/canvas/default/dao_contact_default.class.php deleted file mode 100644 index dbfab60e45d..00000000000 --- a/htdocs/contact/canvas/default/dao_contact_default.class.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/contact/canvas/default/dao_contact_default.class.php - * \ingroup thirdparty - * \brief Fichier de la classe des contacts par defaut - */ - -/** - * \class DaoContactDefault - * \brief Classe permettant la gestion des contacts par defaut, cette classe surcharge la classe contact - */ -class DaoContactDefault extends Contact -{ - /** - * Constructor - * - * @param DoliDB $DB Handler acces base de donnees - */ - function DaoContactDefault($DB) - { - $this->db = $DB; - } - -} - -?> \ No newline at end of file diff --git a/htdocs/contact/canvas/default/tpl/contactcard_create.tpl.php b/htdocs/contact/canvas/default/tpl/contactcard_create.tpl.php index 78e03875100..4cbae520df1 100644 --- a/htdocs/contact/canvas/default/tpl/contactcard_create.tpl.php +++ b/htdocs/contact/canvas/default/tpl/contactcard_create.tpl.php @@ -22,6 +22,10 @@ control->tpl['title']); +dol_htmloutput_errors((is_numeric($object->error)?'':$object->error),$object->errors); + +dol_htmloutput_errors((is_numeric($GLOBALS['error'])?'':$GLOBALS['error']),$GLOBALS['errors']); + dol_htmloutput_errors($this->control->tpl['error'],$this->control->tpl['errors']); echo $this->control->tpl['ajax_selectcountry']; ?> @@ -40,7 +44,7 @@ echo $this->control->tpl['ajax_selectcountry']; ?> trans("Lastname").' / '.$langs->trans("Label"); ?> - + trans("Firstname"); ?> diff --git a/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php b/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php index cf8ac2d8b3e..c8629f185e8 100644 --- a/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php +++ b/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php @@ -53,7 +53,7 @@ echo $this->control->tpl['ajax_selectcountry']; trans("Lastname").' / '.$langs->trans("Label"); ?> - + trans("Firstname"); ?> diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index 41bab9dee8a..97c3e0f780c 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -53,12 +53,25 @@ class Canvas { $this->db = $db; - $this->actiontype = $actiontype; - if ($this->actiontype == 'add') $this->actiontype='create'; - if ($this->actiontype == 'update') $this->actiontype='edit'; - if (empty($this->actiontype) || $this->actiontype == 'delete' || $this->actiontype == 'create_user') $this->actiontype='view'; + $this->actiontype = $this->_cleanaction($actiontype); } + /** + * Return action code cleaned + * + * @param string $action Action type ('create', 'view', 'edit', 'list', 'add', 'update') + * @return string Cleaned action type ('create', 'view', 'edit', 'list') + */ + private function _cleanaction($action) + { + $newaction = $action; + if ($newaction == 'add') $newaction='create'; + if ($newaction == 'update') $newaction='edit'; + if (empty($newaction) || $newaction == 'delete' || $newaction == 'create_user') $newaction='view'; + return $newaction; + } + + /** * Initialize properties: ->targetmodule, ->canvas, ->card, ->dirmodule, ->template_dir * @@ -126,13 +139,13 @@ class Canvas * Return the template to display canvas (if it exists) * * @param string $action Action code - * @return int 0=Canvas template file does not exist, 1=Canvas template file exists + * @return int 0=Canvas template file does not exist, 1=Canvas template file exists */ function displayCanvasExists($action) { if (empty($this->template_dir)) return 0; - if (file_exists($this->template_dir.($this->card?$this->card.'_':'').$this->actiontype.'.tpl.php')) return 1; + if (file_exists($this->template_dir.($this->card?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php')) return 1; else return 0; } @@ -148,7 +161,7 @@ class Canvas global $db, $conf, $langs, $user, $canvas; global $form, $formfile; - include($this->template_dir.($this->card?$this->card.'_':'').$this->actiontype.'.tpl.php'); // Include native PHP template + include($this->template_dir.($this->card?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php'); // Include native PHP template } diff --git a/htdocs/product/canvas/product/tpl/card_create.tpl.php b/htdocs/product/canvas/product/tpl/card_create.tpl.php index bb6eb343ca9..65439ec797b 100755 --- a/htdocs/product/canvas/product/tpl/card_create.tpl.php +++ b/htdocs/product/canvas/product/tpl/card_create.tpl.php @@ -24,7 +24,7 @@ $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSe trans("Product")); ?> -error,$object->errors); ?> +error)?'':$object->error),$object->errors); ?> diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 2ecc3487cd9..e7d9e1f14df 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -286,8 +286,7 @@ if (empty($reshook)) { if ($object->update($object->id, $user) > 0) { - Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); - exit; + $action = 'view'; } else {