From b46c5330bbbef580d40f63ea414413e5017851eb Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 24 Sep 2011 15:57:52 +0000 Subject: [PATCH 01/48] Fix: broken canvas --- .../actions_contactcard_common.class.php | 2 +- htdocs/contact/fiche.php | 8 +-- htdocs/core/class/canvas.class.php | 61 +++++++++---------- htdocs/societe/class/societe.class.php | 21 ++----- htdocs/societe/soc.php | 11 +--- 5 files changed, 39 insertions(+), 64 deletions(-) diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php index 6f7ceced553..9e8d17fa718 100644 --- a/htdocs/contact/canvas/actions_contactcard_common.class.php +++ b/htdocs/contact/canvas/actions_contactcard_common.class.php @@ -54,7 +54,7 @@ abstract class ActionsContactCardCommon function __construct($DB, $dirmodule, $targetmodule, $canvas, $card) { $this->db = $DB; - $this->dirmodule = $dirmodule; + $this->dirmodule = $targetmodule; $this->targetmodule = $targetmodule; $this->canvas = $canvas; $this->card = $card; diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php index 745d0c3d6e7..4f66bbdfc92 100644 --- a/htdocs/contact/fiche.php +++ b/htdocs/contact/fiche.php @@ -277,11 +277,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists()) // ----------------------------------------- // When used with CANVAS // ----------------------------------------- - if (! $objcanvas->hasActions() && $id) - { - $object = new Societe($db); - $object->fetch($id); // For use with "pure canvas" (canvas that contains templates only) - } + $objcanvas->assign_values($action, $id); // Set value for templates $objcanvas->display_canvas(); // Show template } @@ -328,8 +324,6 @@ else /* * Fiche en mode creation */ - $object->canvas=$canvas; - $object->fk_departement = $_POST["departement_id"]; // We set pays_id, pays_code and label for the selected country diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index 5e7d4321ca4..e2a9672428a 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -32,28 +32,29 @@ class Canvas var $db; var $error; var $errors=array(); - + var $actiontype; var $dirmodule; // Module directory var $targetmodule; // Module concerned by canvas (ex: thirdparty, contact, ...) - var $canvas; // Name of canvas (ex: company, individual, product, service, ...) + var $canvas; // Name of canvas var $card; // Tab (sub-canvas) - var $template_dir; // Initialized by getCanvas with templates directory - var $control; // Initialized by getCanvas with controller instance + var $template_dir; // Initialized by getCanvas with templates directory + var $control_file; // Initialized by getCanvas with controller file name + var $control; // Initialized by getCanvas with controller instance + var $object; // Initialized by getCanvas with dao instance, filled by getObject /** * Constructor * - * @param DoliDB $DB Database handler - * @param string $actiontype Action type ('create', 'view', 'edit', 'list') + * @param DoliDB $DB Database handler */ function __construct($DB, $actiontype='view') { $this->db = $DB; - + $this->actiontype = $actiontype; if ($this->actiontype == 'add') $this->actiontype='create'; if ($this->actiontype == 'update') $this->actiontype='edit'; @@ -61,17 +62,19 @@ class Canvas } /** - * Initialize properties: ->targetmodule, ->canvas, ->card, ->dirmodule, ->template_dir + * Initialize properties: ->targetmodule, ->canvas, ->card + * and MVC properties: ->control (Controller), ->control->object (Model), ->template_dir (View) * - * @param string $module Name of target module (thirdparty, contact, ...) - * @param string $card Tab name of card (ex: 'card', 'info', 'contactcard', ...) or '' for a list page - * @param string $canvas Name of canvas (ex: mycanvas, default, or mycanvas@myexternalmodule) - * @return void + * @param module Name of target module (thirdparty, contact, ...) + * @param card Type of card (ex: 'card', 'info', 'contactcard', ...) or '' for a list page + * @param canvas Name of canvas (ex: mycanvas, default, or mycanvas@myexternalmodule) */ function getCanvas($module, $card, $canvas) { global $conf, $langs; + $error=''; + // Set properties with value specific to dolibarr core: this->targetmodule, this->card, this->canvas $this->targetmodule = $module; $this->canvas = $canvas; @@ -86,7 +89,6 @@ class Canvas // For compatibility if ($this->dirmodule == 'thirdparty') { $this->dirmodule = 'societe'; } - // Control file $controlclassfile = dol_buildpath('/'.$this->dirmodule.'/canvas/'.$this->canvas.'/actions_'.$this->card.'_'.$this->canvas.'.class.php'); if (file_exists($controlclassfile)) { @@ -108,29 +110,21 @@ class Canvas //print 'dimodule='.$dirmodule.' canvas='.$this->canvas.'
'; //print ' => template_dir='.$this->template_dir.'
'; + //print ' => control_file='.$this->control_file.' is_object(this->control)='.is_object($this->control).'
'; + + return 1; } - - - /** - * Return if a canvas contains an action controller - * - * @return boolean Return if canvas contains actions (old feature. now actions should be inside hooks) - */ - function hasActions() - { - return (! is_object($this->control)); - } - + /** * Shared method for canvas to execute actions - * - * @param string &$action Action string + * + * @param string $action Action string * @param int $id Object id - * @return mixed Return return code of doActions of canvas + * @return void */ function doActions(&$action='view', $id=0) { - if (method_exists($this->control,'doActions')) + if (method_exists($this->control,'doActions')) { $ret = $this->control->doActions($action, $id); return $ret; @@ -139,8 +133,8 @@ class Canvas /** * Shared method for canvas to assign values for templates - * - * @param string &$action Action string + * + * @param string $action Action string * @param int $id Object id * @return void */ @@ -152,7 +146,7 @@ class Canvas /** * Return the template to display canvas (if it exists) * - * @return int 0=Canvas template file does not exist, 1=Canvas template file exists + * @return string Path to display canvas file if it exists, '' otherwise. */ function displayCanvasExists() { @@ -164,7 +158,8 @@ class Canvas /** * Display a canvas page. This will include the template for output. - * Variables used by templates may have been defined or loaded before into the assign_values function. + * Variables used by templates may have been defined, loaded before + * into the assign_values function. * * @return void */ diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 36b8bf3a7d0..a8d7823341a 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -298,8 +298,7 @@ class Societe extends CommonObject $result = 0; $this->name = trim($this->name); - $this->nom=$this->name; // For backward compatibility - + if (! $this->name) { $this->errors[] = 'ErrorBadThirdPartyName'; @@ -394,16 +393,11 @@ class Societe extends CommonObject // Clean parameters $this->id = $id; - $this->name=$this->name?trim($this->name):trim($this->nom); - $this->nom=trim($this->nom); // TODO obsolete - $this->address=$this->address?trim($this->address):trim($this->adresse); - $this->adresse=$this->address; // TODO obsolete - $this->zip=$this->zip?trim($this->zip):trim($this->cp); - $this->cp=$this->zip; // TODO obsolete - $this->town=$this->town?trim($this->town):trim($this->ville); - $this->ville=$this->town; // TODO obsolete - $this->state_id=trim($this->state_id); - $this->pays_id=trim($this->pays_id); + $this->name = trim($this->name); + $this->address = trim($this->address); + $this->zip = trim($this->zip); + $this->town = trim($this->town); + $this->state_id = trim($this->state_id); $this->country_id = trim($this->country_id); $this->tel = trim($this->tel); $this->fax = trim($this->fax); @@ -413,9 +407,6 @@ class Societe extends CommonObject $this->fax = preg_replace("/\./","",$this->fax); $this->email = trim($this->email); $this->url = $this->url?clean_url($this->url,0):''; - $this->siren=trim($this->siren); // TODO obsolete - $this->siret=trim($this->siret); // TODO obsolete - $this->ape=trim($this->ape); // TODO obsolete $this->idprof1 = trim($this->idprof1); $this->idprof2 = trim($this->idprof2); $this->idprof3 = trim($this->idprof3); diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 66097323008..b289e334c60 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -104,7 +104,6 @@ if (empty($reshook)) require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); if ($action == 'update') $object->fetch($socid); - else $object->canvas=$canvas; if (GETPOST("private") == 1) { @@ -475,13 +474,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists()) // ----------------------------------------- // When used with CANVAS // ----------------------------------------- - if (! $objcanvas->hasActions() && $socid) - { - $object = new Societe($db); - $object->fetch($socid); // For use with "pure canvas" (canvas that contains templates only) - } - $objcanvas->assign_values($action, $socid); // Set value for templates - $objcanvas->display_canvas(); // Show template + + $objcanvas->assign_values($action, $socid); // Set value for templates + $objcanvas->display_canvas(); // Show template } else { From d8c48e4708244cbc7ead10018ab68a1e66a5b383 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 24 Sep 2011 16:06:07 +0000 Subject: [PATCH 02/48] Fix: bad name --- htdocs/contact/canvas/actions_contactcard_common.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php index 9e8d17fa718..6f7ceced553 100644 --- a/htdocs/contact/canvas/actions_contactcard_common.class.php +++ b/htdocs/contact/canvas/actions_contactcard_common.class.php @@ -54,7 +54,7 @@ abstract class ActionsContactCardCommon function __construct($DB, $dirmodule, $targetmodule, $canvas, $card) { $this->db = $DB; - $this->dirmodule = $targetmodule; + $this->dirmodule = $dirmodule; $this->targetmodule = $targetmodule; $this->canvas = $canvas; $this->card = $card; From bbe1991f12d323c57adc8586a19ae78406516ad3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 20:50:57 +0000 Subject: [PATCH 03/48] Fix: Little fix after canvas changes to be able to have "pure canvas" (canvas with no controller, only templates). --- htdocs/contact/fiche.php | 8 +++++++- htdocs/societe/soc.php | 11 ++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php index 4f66bbdfc92..745d0c3d6e7 100644 --- a/htdocs/contact/fiche.php +++ b/htdocs/contact/fiche.php @@ -277,7 +277,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists()) // ----------------------------------------- // When used with CANVAS // ----------------------------------------- - + if (! $objcanvas->hasActions() && $id) + { + $object = new Societe($db); + $object->fetch($id); // For use with "pure canvas" (canvas that contains templates only) + } $objcanvas->assign_values($action, $id); // Set value for templates $objcanvas->display_canvas(); // Show template } @@ -324,6 +328,8 @@ else /* * Fiche en mode creation */ + $object->canvas=$canvas; + $object->fk_departement = $_POST["departement_id"]; // We set pays_id, pays_code and label for the selected country diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index b289e334c60..66097323008 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -104,6 +104,7 @@ if (empty($reshook)) require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); if ($action == 'update') $object->fetch($socid); + else $object->canvas=$canvas; if (GETPOST("private") == 1) { @@ -474,9 +475,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists()) // ----------------------------------------- // When used with CANVAS // ----------------------------------------- - - $objcanvas->assign_values($action, $socid); // Set value for templates - $objcanvas->display_canvas(); // Show template + if (! $objcanvas->hasActions() && $socid) + { + $object = new Societe($db); + $object->fetch($socid); // For use with "pure canvas" (canvas that contains templates only) + } + $objcanvas->assign_values($action, $socid); // Set value for templates + $objcanvas->display_canvas(); // Show template } else { From 00759be0fd6c4e4076e33e26258ea1f67bc28a20 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 20:51:36 +0000 Subject: [PATCH 04/48] Doxygen --- htdocs/core/class/canvas.class.php | 54 +++++++++++++++++------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index e2a9672428a..1a56caeae7c 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -32,29 +32,28 @@ class Canvas var $db; var $error; var $errors=array(); - + var $actiontype; var $dirmodule; // Module directory var $targetmodule; // Module concerned by canvas (ex: thirdparty, contact, ...) - var $canvas; // Name of canvas + var $canvas; // Name of canvas (ex: company, individual, product, service, ...) var $card; // Tab (sub-canvas) - var $template_dir; // Initialized by getCanvas with templates directory - var $control_file; // Initialized by getCanvas with controller file name - var $control; // Initialized by getCanvas with controller instance - var $object; // Initialized by getCanvas with dao instance, filled by getObject + var $template_dir; // Initialized by getCanvas with templates directory + var $control; // Initialized by getCanvas with controller instance /** * Constructor * - * @param DoliDB $DB Database handler + * @param DoliDB $DB Database handler + * @param string $actiontype Action type ('create', 'view', 'edit', 'list') */ function __construct($DB, $actiontype='view') { $this->db = $DB; - + $this->actiontype = $actiontype; if ($this->actiontype == 'add') $this->actiontype='create'; if ($this->actiontype == 'update') $this->actiontype='edit'; @@ -62,19 +61,16 @@ class Canvas } /** - * Initialize properties: ->targetmodule, ->canvas, ->card - * and MVC properties: ->control (Controller), ->control->object (Model), ->template_dir (View) + * Initialize properties: ->targetmodule, ->canvas, ->card, ->dirmodule, ->template_dir * - * @param module Name of target module (thirdparty, contact, ...) - * @param card Type of card (ex: 'card', 'info', 'contactcard', ...) or '' for a list page - * @param canvas Name of canvas (ex: mycanvas, default, or mycanvas@myexternalmodule) + * @param string $module Name of target module (thirdparty, contact, ...) + * @param string $card Tab name of card (ex: 'card', 'info', 'contactcard', ...) or '' for a list page + * @param string $canvas Name of canvas (ex: mycanvas, default, or mycanvas@myexternalmodule) */ function getCanvas($module, $card, $canvas) { global $conf, $langs; - $error=''; - // Set properties with value specific to dolibarr core: this->targetmodule, this->card, this->canvas $this->targetmodule = $module; $this->canvas = $canvas; @@ -89,6 +85,7 @@ class Canvas // For compatibility if ($this->dirmodule == 'thirdparty') { $this->dirmodule = 'societe'; } + // Control file $controlclassfile = dol_buildpath('/'.$this->dirmodule.'/canvas/'.$this->canvas.'/actions_'.$this->card.'_'.$this->canvas.'.class.php'); if (file_exists($controlclassfile)) { @@ -110,21 +107,31 @@ class Canvas //print 'dimodule='.$dirmodule.' canvas='.$this->canvas.'
'; //print ' => template_dir='.$this->template_dir.'
'; - //print ' => control_file='.$this->control_file.' is_object(this->control)='.is_object($this->control).'
'; return 1; } - + + + /** + * Return if a canvas contains an action controller + * + * @return boolean Return if canvas contains actions (old feature. now actions should be inside hooks) + */ + function hasActions() + { + return (! is_object($this->control)); + } + /** * Shared method for canvas to execute actions - * + * * @param string $action Action string * @param int $id Object id - * @return void + * @return mixed Return return code of doActions of canvas */ function doActions(&$action='view', $id=0) { - if (method_exists($this->control,'doActions')) + if (method_exists($this->control,'doActions')) { $ret = $this->control->doActions($action, $id); return $ret; @@ -133,7 +140,7 @@ class Canvas /** * Shared method for canvas to assign values for templates - * + * * @param string $action Action string * @param int $id Object id * @return void @@ -146,7 +153,7 @@ class Canvas /** * Return the template to display canvas (if it exists) * - * @return string Path to display canvas file if it exists, '' otherwise. + * @return int 0=Canvas template file does not exist, 1=Canvas template file exists */ function displayCanvasExists() { @@ -158,8 +165,7 @@ class Canvas /** * Display a canvas page. This will include the template for output. - * Variables used by templates may have been defined, loaded before - * into the assign_values function. + * Variables used by templates may have been defined or loaded before into the assign_values function. * * @return void */ From b331fccb6c44403ea7797842572c3f59d1650104 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 20:56:08 +0000 Subject: [PATCH 05/48] Doxygen --- htdocs/core/class/canvas.class.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index 1a56caeae7c..5e7d4321ca4 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -66,6 +66,7 @@ class Canvas * @param string $module Name of target module (thirdparty, contact, ...) * @param string $card Tab name of card (ex: 'card', 'info', 'contactcard', ...) or '' for a list page * @param string $canvas Name of canvas (ex: mycanvas, default, or mycanvas@myexternalmodule) + * @return void */ function getCanvas($module, $card, $canvas) { @@ -107,8 +108,6 @@ class Canvas //print 'dimodule='.$dirmodule.' canvas='.$this->canvas.'
'; //print ' => template_dir='.$this->template_dir.'
'; - - return 1; } @@ -125,7 +124,7 @@ class Canvas /** * Shared method for canvas to execute actions * - * @param string $action Action string + * @param string &$action Action string * @param int $id Object id * @return mixed Return return code of doActions of canvas */ @@ -141,7 +140,7 @@ class Canvas /** * Shared method for canvas to assign values for templates * - * @param string $action Action string + * @param string &$action Action string * @param int $id Object id * @return void */ From a6bc946af95b17b56bb8cdf7f0f40f082e704dc3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 21:51:52 +0000 Subject: [PATCH 06/48] Doxygen From a55d7b7623d222b4fefe755e31ae1e6dbf7326c6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 21:52:53 +0000 Subject: [PATCH 07/48] Add file to ignore From 12bf83f8732c097bfbcfeb2b4afd3588c2181378 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 21:55:18 +0000 Subject: [PATCH 08/48] Add hidden option PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS From 3e6313893158efe5fc1f75e58690b101540caee3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 22:25:01 +0000 Subject: [PATCH 09/48] Qual: Uniformize code From e4cd35ec57024ccd0af7bb43a45403aafb3182bf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 22:31:28 +0000 Subject: [PATCH 10/48] Fix: Restore obsolete var when they are used as "init". I suggest to remove first all references that are in "read" mode by new name and remove reference that are in "write" mode only once there is no more call to old name in page that used them. This is to reduce risk of bugs. --- htdocs/societe/class/societe.class.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index a8d7823341a..36b8bf3a7d0 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -298,7 +298,8 @@ class Societe extends CommonObject $result = 0; $this->name = trim($this->name); - + $this->nom=$this->name; // For backward compatibility + if (! $this->name) { $this->errors[] = 'ErrorBadThirdPartyName'; @@ -393,11 +394,16 @@ class Societe extends CommonObject // Clean parameters $this->id = $id; - $this->name = trim($this->name); - $this->address = trim($this->address); - $this->zip = trim($this->zip); - $this->town = trim($this->town); - $this->state_id = trim($this->state_id); + $this->name=$this->name?trim($this->name):trim($this->nom); + $this->nom=trim($this->nom); // TODO obsolete + $this->address=$this->address?trim($this->address):trim($this->adresse); + $this->adresse=$this->address; // TODO obsolete + $this->zip=$this->zip?trim($this->zip):trim($this->cp); + $this->cp=$this->zip; // TODO obsolete + $this->town=$this->town?trim($this->town):trim($this->ville); + $this->ville=$this->town; // TODO obsolete + $this->state_id=trim($this->state_id); + $this->pays_id=trim($this->pays_id); $this->country_id = trim($this->country_id); $this->tel = trim($this->tel); $this->fax = trim($this->fax); @@ -407,6 +413,9 @@ class Societe extends CommonObject $this->fax = preg_replace("/\./","",$this->fax); $this->email = trim($this->email); $this->url = $this->url?clean_url($this->url,0):''; + $this->siren=trim($this->siren); // TODO obsolete + $this->siret=trim($this->siret); // TODO obsolete + $this->ape=trim($this->ape); // TODO obsolete $this->idprof1 = trim($this->idprof1); $this->idprof2 = trim($this->idprof2); $this->idprof3 = trim($this->idprof3); From 8bbca236c301a72a6a8e95d44c3180336148f611 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 22:43:52 +0000 Subject: [PATCH 11/48] Qual: Removed warnings From 7b2b42b6becb0a4846bbb02a34c4bbff3b10b6bd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 23:42:31 +0000 Subject: [PATCH 12/48] Qual: Uniformize code From 62a0187818ffeb955207e47eed49e6776b4d458a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 23:49:45 +0000 Subject: [PATCH 13/48] Move dev module mantis to nltechno repository From d47979476f893105dfca974eb8ea6d2fb1ec3c10 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 24 Sep 2011 15:57:52 +0000 Subject: [PATCH 14/48] Fix: broken canvas --- .../actions_contactcard_common.class.php | 2 +- htdocs/contact/fiche.php | 8 +-- htdocs/core/class/canvas.class.php | 61 +++++++++---------- htdocs/societe/class/societe.class.php | 21 ++----- htdocs/societe/soc.php | 11 +--- 5 files changed, 39 insertions(+), 64 deletions(-) diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php index 6f7ceced553..9e8d17fa718 100644 --- a/htdocs/contact/canvas/actions_contactcard_common.class.php +++ b/htdocs/contact/canvas/actions_contactcard_common.class.php @@ -54,7 +54,7 @@ abstract class ActionsContactCardCommon function __construct($DB, $dirmodule, $targetmodule, $canvas, $card) { $this->db = $DB; - $this->dirmodule = $dirmodule; + $this->dirmodule = $targetmodule; $this->targetmodule = $targetmodule; $this->canvas = $canvas; $this->card = $card; diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php index 745d0c3d6e7..4f66bbdfc92 100644 --- a/htdocs/contact/fiche.php +++ b/htdocs/contact/fiche.php @@ -277,11 +277,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists()) // ----------------------------------------- // When used with CANVAS // ----------------------------------------- - if (! $objcanvas->hasActions() && $id) - { - $object = new Societe($db); - $object->fetch($id); // For use with "pure canvas" (canvas that contains templates only) - } + $objcanvas->assign_values($action, $id); // Set value for templates $objcanvas->display_canvas(); // Show template } @@ -328,8 +324,6 @@ else /* * Fiche en mode creation */ - $object->canvas=$canvas; - $object->fk_departement = $_POST["departement_id"]; // We set pays_id, pays_code and label for the selected country diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index 5e7d4321ca4..e2a9672428a 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -32,28 +32,29 @@ class Canvas var $db; var $error; var $errors=array(); - + var $actiontype; var $dirmodule; // Module directory var $targetmodule; // Module concerned by canvas (ex: thirdparty, contact, ...) - var $canvas; // Name of canvas (ex: company, individual, product, service, ...) + var $canvas; // Name of canvas var $card; // Tab (sub-canvas) - var $template_dir; // Initialized by getCanvas with templates directory - var $control; // Initialized by getCanvas with controller instance + var $template_dir; // Initialized by getCanvas with templates directory + var $control_file; // Initialized by getCanvas with controller file name + var $control; // Initialized by getCanvas with controller instance + var $object; // Initialized by getCanvas with dao instance, filled by getObject /** * Constructor * - * @param DoliDB $DB Database handler - * @param string $actiontype Action type ('create', 'view', 'edit', 'list') + * @param DoliDB $DB Database handler */ function __construct($DB, $actiontype='view') { $this->db = $DB; - + $this->actiontype = $actiontype; if ($this->actiontype == 'add') $this->actiontype='create'; if ($this->actiontype == 'update') $this->actiontype='edit'; @@ -61,17 +62,19 @@ class Canvas } /** - * Initialize properties: ->targetmodule, ->canvas, ->card, ->dirmodule, ->template_dir + * Initialize properties: ->targetmodule, ->canvas, ->card + * and MVC properties: ->control (Controller), ->control->object (Model), ->template_dir (View) * - * @param string $module Name of target module (thirdparty, contact, ...) - * @param string $card Tab name of card (ex: 'card', 'info', 'contactcard', ...) or '' for a list page - * @param string $canvas Name of canvas (ex: mycanvas, default, or mycanvas@myexternalmodule) - * @return void + * @param module Name of target module (thirdparty, contact, ...) + * @param card Type of card (ex: 'card', 'info', 'contactcard', ...) or '' for a list page + * @param canvas Name of canvas (ex: mycanvas, default, or mycanvas@myexternalmodule) */ function getCanvas($module, $card, $canvas) { global $conf, $langs; + $error=''; + // Set properties with value specific to dolibarr core: this->targetmodule, this->card, this->canvas $this->targetmodule = $module; $this->canvas = $canvas; @@ -86,7 +89,6 @@ class Canvas // For compatibility if ($this->dirmodule == 'thirdparty') { $this->dirmodule = 'societe'; } - // Control file $controlclassfile = dol_buildpath('/'.$this->dirmodule.'/canvas/'.$this->canvas.'/actions_'.$this->card.'_'.$this->canvas.'.class.php'); if (file_exists($controlclassfile)) { @@ -108,29 +110,21 @@ class Canvas //print 'dimodule='.$dirmodule.' canvas='.$this->canvas.'
'; //print ' => template_dir='.$this->template_dir.'
'; + //print ' => control_file='.$this->control_file.' is_object(this->control)='.is_object($this->control).'
'; + + return 1; } - - - /** - * Return if a canvas contains an action controller - * - * @return boolean Return if canvas contains actions (old feature. now actions should be inside hooks) - */ - function hasActions() - { - return (! is_object($this->control)); - } - + /** * Shared method for canvas to execute actions - * - * @param string &$action Action string + * + * @param string $action Action string * @param int $id Object id - * @return mixed Return return code of doActions of canvas + * @return void */ function doActions(&$action='view', $id=0) { - if (method_exists($this->control,'doActions')) + if (method_exists($this->control,'doActions')) { $ret = $this->control->doActions($action, $id); return $ret; @@ -139,8 +133,8 @@ class Canvas /** * Shared method for canvas to assign values for templates - * - * @param string &$action Action string + * + * @param string $action Action string * @param int $id Object id * @return void */ @@ -152,7 +146,7 @@ class Canvas /** * Return the template to display canvas (if it exists) * - * @return int 0=Canvas template file does not exist, 1=Canvas template file exists + * @return string Path to display canvas file if it exists, '' otherwise. */ function displayCanvasExists() { @@ -164,7 +158,8 @@ class Canvas /** * Display a canvas page. This will include the template for output. - * Variables used by templates may have been defined or loaded before into the assign_values function. + * Variables used by templates may have been defined, loaded before + * into the assign_values function. * * @return void */ diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 36b8bf3a7d0..a8d7823341a 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -298,8 +298,7 @@ class Societe extends CommonObject $result = 0; $this->name = trim($this->name); - $this->nom=$this->name; // For backward compatibility - + if (! $this->name) { $this->errors[] = 'ErrorBadThirdPartyName'; @@ -394,16 +393,11 @@ class Societe extends CommonObject // Clean parameters $this->id = $id; - $this->name=$this->name?trim($this->name):trim($this->nom); - $this->nom=trim($this->nom); // TODO obsolete - $this->address=$this->address?trim($this->address):trim($this->adresse); - $this->adresse=$this->address; // TODO obsolete - $this->zip=$this->zip?trim($this->zip):trim($this->cp); - $this->cp=$this->zip; // TODO obsolete - $this->town=$this->town?trim($this->town):trim($this->ville); - $this->ville=$this->town; // TODO obsolete - $this->state_id=trim($this->state_id); - $this->pays_id=trim($this->pays_id); + $this->name = trim($this->name); + $this->address = trim($this->address); + $this->zip = trim($this->zip); + $this->town = trim($this->town); + $this->state_id = trim($this->state_id); $this->country_id = trim($this->country_id); $this->tel = trim($this->tel); $this->fax = trim($this->fax); @@ -413,9 +407,6 @@ class Societe extends CommonObject $this->fax = preg_replace("/\./","",$this->fax); $this->email = trim($this->email); $this->url = $this->url?clean_url($this->url,0):''; - $this->siren=trim($this->siren); // TODO obsolete - $this->siret=trim($this->siret); // TODO obsolete - $this->ape=trim($this->ape); // TODO obsolete $this->idprof1 = trim($this->idprof1); $this->idprof2 = trim($this->idprof2); $this->idprof3 = trim($this->idprof3); diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 66097323008..b289e334c60 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -104,7 +104,6 @@ if (empty($reshook)) require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); if ($action == 'update') $object->fetch($socid); - else $object->canvas=$canvas; if (GETPOST("private") == 1) { @@ -475,13 +474,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists()) // ----------------------------------------- // When used with CANVAS // ----------------------------------------- - if (! $objcanvas->hasActions() && $socid) - { - $object = new Societe($db); - $object->fetch($socid); // For use with "pure canvas" (canvas that contains templates only) - } - $objcanvas->assign_values($action, $socid); // Set value for templates - $objcanvas->display_canvas(); // Show template + + $objcanvas->assign_values($action, $socid); // Set value for templates + $objcanvas->display_canvas(); // Show template } else { From d98a4d729b1aee4dd06853686651f3c50f798c23 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 24 Sep 2011 16:06:07 +0000 Subject: [PATCH 15/48] Fix: bad name --- htdocs/contact/canvas/actions_contactcard_common.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php index 9e8d17fa718..6f7ceced553 100644 --- a/htdocs/contact/canvas/actions_contactcard_common.class.php +++ b/htdocs/contact/canvas/actions_contactcard_common.class.php @@ -54,7 +54,7 @@ abstract class ActionsContactCardCommon function __construct($DB, $dirmodule, $targetmodule, $canvas, $card) { $this->db = $DB; - $this->dirmodule = $targetmodule; + $this->dirmodule = $dirmodule; $this->targetmodule = $targetmodule; $this->canvas = $canvas; $this->card = $card; From 2682805c662ce65d6725015f96ad56c1dfb933c3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 20:50:57 +0000 Subject: [PATCH 16/48] Fix: Little fix after canvas changes to be able to have "pure canvas" (canvas with no controller, only templates). --- htdocs/contact/fiche.php | 8 +++++++- htdocs/societe/soc.php | 11 ++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php index 4f66bbdfc92..745d0c3d6e7 100644 --- a/htdocs/contact/fiche.php +++ b/htdocs/contact/fiche.php @@ -277,7 +277,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists()) // ----------------------------------------- // When used with CANVAS // ----------------------------------------- - + if (! $objcanvas->hasActions() && $id) + { + $object = new Societe($db); + $object->fetch($id); // For use with "pure canvas" (canvas that contains templates only) + } $objcanvas->assign_values($action, $id); // Set value for templates $objcanvas->display_canvas(); // Show template } @@ -324,6 +328,8 @@ else /* * Fiche en mode creation */ + $object->canvas=$canvas; + $object->fk_departement = $_POST["departement_id"]; // We set pays_id, pays_code and label for the selected country diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index b289e334c60..66097323008 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -104,6 +104,7 @@ if (empty($reshook)) require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); if ($action == 'update') $object->fetch($socid); + else $object->canvas=$canvas; if (GETPOST("private") == 1) { @@ -474,9 +475,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists()) // ----------------------------------------- // When used with CANVAS // ----------------------------------------- - - $objcanvas->assign_values($action, $socid); // Set value for templates - $objcanvas->display_canvas(); // Show template + if (! $objcanvas->hasActions() && $socid) + { + $object = new Societe($db); + $object->fetch($socid); // For use with "pure canvas" (canvas that contains templates only) + } + $objcanvas->assign_values($action, $socid); // Set value for templates + $objcanvas->display_canvas(); // Show template } else { From d052d76dc76404284a7586b59bac2792b2c71717 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 20:51:36 +0000 Subject: [PATCH 17/48] Doxygen --- htdocs/core/class/canvas.class.php | 54 +++++++++++++++++------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index e2a9672428a..1a56caeae7c 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -32,29 +32,28 @@ class Canvas var $db; var $error; var $errors=array(); - + var $actiontype; var $dirmodule; // Module directory var $targetmodule; // Module concerned by canvas (ex: thirdparty, contact, ...) - var $canvas; // Name of canvas + var $canvas; // Name of canvas (ex: company, individual, product, service, ...) var $card; // Tab (sub-canvas) - var $template_dir; // Initialized by getCanvas with templates directory - var $control_file; // Initialized by getCanvas with controller file name - var $control; // Initialized by getCanvas with controller instance - var $object; // Initialized by getCanvas with dao instance, filled by getObject + var $template_dir; // Initialized by getCanvas with templates directory + var $control; // Initialized by getCanvas with controller instance /** * Constructor * - * @param DoliDB $DB Database handler + * @param DoliDB $DB Database handler + * @param string $actiontype Action type ('create', 'view', 'edit', 'list') */ function __construct($DB, $actiontype='view') { $this->db = $DB; - + $this->actiontype = $actiontype; if ($this->actiontype == 'add') $this->actiontype='create'; if ($this->actiontype == 'update') $this->actiontype='edit'; @@ -62,19 +61,16 @@ class Canvas } /** - * Initialize properties: ->targetmodule, ->canvas, ->card - * and MVC properties: ->control (Controller), ->control->object (Model), ->template_dir (View) + * Initialize properties: ->targetmodule, ->canvas, ->card, ->dirmodule, ->template_dir * - * @param module Name of target module (thirdparty, contact, ...) - * @param card Type of card (ex: 'card', 'info', 'contactcard', ...) or '' for a list page - * @param canvas Name of canvas (ex: mycanvas, default, or mycanvas@myexternalmodule) + * @param string $module Name of target module (thirdparty, contact, ...) + * @param string $card Tab name of card (ex: 'card', 'info', 'contactcard', ...) or '' for a list page + * @param string $canvas Name of canvas (ex: mycanvas, default, or mycanvas@myexternalmodule) */ function getCanvas($module, $card, $canvas) { global $conf, $langs; - $error=''; - // Set properties with value specific to dolibarr core: this->targetmodule, this->card, this->canvas $this->targetmodule = $module; $this->canvas = $canvas; @@ -89,6 +85,7 @@ class Canvas // For compatibility if ($this->dirmodule == 'thirdparty') { $this->dirmodule = 'societe'; } + // Control file $controlclassfile = dol_buildpath('/'.$this->dirmodule.'/canvas/'.$this->canvas.'/actions_'.$this->card.'_'.$this->canvas.'.class.php'); if (file_exists($controlclassfile)) { @@ -110,21 +107,31 @@ class Canvas //print 'dimodule='.$dirmodule.' canvas='.$this->canvas.'
'; //print ' => template_dir='.$this->template_dir.'
'; - //print ' => control_file='.$this->control_file.' is_object(this->control)='.is_object($this->control).'
'; return 1; } - + + + /** + * Return if a canvas contains an action controller + * + * @return boolean Return if canvas contains actions (old feature. now actions should be inside hooks) + */ + function hasActions() + { + return (! is_object($this->control)); + } + /** * Shared method for canvas to execute actions - * + * * @param string $action Action string * @param int $id Object id - * @return void + * @return mixed Return return code of doActions of canvas */ function doActions(&$action='view', $id=0) { - if (method_exists($this->control,'doActions')) + if (method_exists($this->control,'doActions')) { $ret = $this->control->doActions($action, $id); return $ret; @@ -133,7 +140,7 @@ class Canvas /** * Shared method for canvas to assign values for templates - * + * * @param string $action Action string * @param int $id Object id * @return void @@ -146,7 +153,7 @@ class Canvas /** * Return the template to display canvas (if it exists) * - * @return string Path to display canvas file if it exists, '' otherwise. + * @return int 0=Canvas template file does not exist, 1=Canvas template file exists */ function displayCanvasExists() { @@ -158,8 +165,7 @@ class Canvas /** * Display a canvas page. This will include the template for output. - * Variables used by templates may have been defined, loaded before - * into the assign_values function. + * Variables used by templates may have been defined or loaded before into the assign_values function. * * @return void */ From abb3004275b06da0ca0f69e578ab0290e69c96b3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 20:56:08 +0000 Subject: [PATCH 18/48] Doxygen --- htdocs/core/class/canvas.class.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index 1a56caeae7c..5e7d4321ca4 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -66,6 +66,7 @@ class Canvas * @param string $module Name of target module (thirdparty, contact, ...) * @param string $card Tab name of card (ex: 'card', 'info', 'contactcard', ...) or '' for a list page * @param string $canvas Name of canvas (ex: mycanvas, default, or mycanvas@myexternalmodule) + * @return void */ function getCanvas($module, $card, $canvas) { @@ -107,8 +108,6 @@ class Canvas //print 'dimodule='.$dirmodule.' canvas='.$this->canvas.'
'; //print ' => template_dir='.$this->template_dir.'
'; - - return 1; } @@ -125,7 +124,7 @@ class Canvas /** * Shared method for canvas to execute actions * - * @param string $action Action string + * @param string &$action Action string * @param int $id Object id * @return mixed Return return code of doActions of canvas */ @@ -141,7 +140,7 @@ class Canvas /** * Shared method for canvas to assign values for templates * - * @param string $action Action string + * @param string &$action Action string * @param int $id Object id * @return void */ From 91f55643bd005a6cf035d1964d27fd59ee628481 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 21:51:52 +0000 Subject: [PATCH 19/48] Doxygen From 1f99503e6cb0649e8f71c2154cf3d070820b3b90 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 21:52:53 +0000 Subject: [PATCH 20/48] Add file to ignore From d5cf4d8a84075453e683967ff1c0710f9aceb3f3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 21:55:18 +0000 Subject: [PATCH 21/48] Add hidden option PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS From c2a8884f75ff2567badec288727c7b16ca1b005f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 22:25:01 +0000 Subject: [PATCH 22/48] Qual: Uniformize code From dafa08bf9141db648dafd70390fa27d0912289af Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 22:31:28 +0000 Subject: [PATCH 23/48] Fix: Restore obsolete var when they are used as "init". I suggest to remove first all references that are in "read" mode by new name and remove reference that are in "write" mode only once there is no more call to old name in page that used them. This is to reduce risk of bugs. --- htdocs/societe/class/societe.class.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index a8d7823341a..36b8bf3a7d0 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -298,7 +298,8 @@ class Societe extends CommonObject $result = 0; $this->name = trim($this->name); - + $this->nom=$this->name; // For backward compatibility + if (! $this->name) { $this->errors[] = 'ErrorBadThirdPartyName'; @@ -393,11 +394,16 @@ class Societe extends CommonObject // Clean parameters $this->id = $id; - $this->name = trim($this->name); - $this->address = trim($this->address); - $this->zip = trim($this->zip); - $this->town = trim($this->town); - $this->state_id = trim($this->state_id); + $this->name=$this->name?trim($this->name):trim($this->nom); + $this->nom=trim($this->nom); // TODO obsolete + $this->address=$this->address?trim($this->address):trim($this->adresse); + $this->adresse=$this->address; // TODO obsolete + $this->zip=$this->zip?trim($this->zip):trim($this->cp); + $this->cp=$this->zip; // TODO obsolete + $this->town=$this->town?trim($this->town):trim($this->ville); + $this->ville=$this->town; // TODO obsolete + $this->state_id=trim($this->state_id); + $this->pays_id=trim($this->pays_id); $this->country_id = trim($this->country_id); $this->tel = trim($this->tel); $this->fax = trim($this->fax); @@ -407,6 +413,9 @@ class Societe extends CommonObject $this->fax = preg_replace("/\./","",$this->fax); $this->email = trim($this->email); $this->url = $this->url?clean_url($this->url,0):''; + $this->siren=trim($this->siren); // TODO obsolete + $this->siret=trim($this->siret); // TODO obsolete + $this->ape=trim($this->ape); // TODO obsolete $this->idprof1 = trim($this->idprof1); $this->idprof2 = trim($this->idprof2); $this->idprof3 = trim($this->idprof3); From 412a1921ce3ec35240e256f9f70efb297979e6ef Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 22:43:52 +0000 Subject: [PATCH 24/48] Qual: Removed warnings From 80f285b1bcce7129b9fad31f2f68a2001d08da3b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 23:42:31 +0000 Subject: [PATCH 25/48] Qual: Uniformize code From 7306626f10d2e909e2fc90bd0de394f637f5d7a9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 23:49:45 +0000 Subject: [PATCH 26/48] Move dev module mantis to nltechno repository From 6b8ed87b922e47b77894d8b75b86606a58a3cafc Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 24 Sep 2011 15:57:52 +0000 Subject: [PATCH 27/48] Fix: broken canvas --- .../actions_contactcard_common.class.php | 2 +- htdocs/contact/fiche.php | 8 +-- htdocs/core/class/canvas.class.php | 61 +++++++++---------- htdocs/societe/class/societe.class.php | 21 ++----- htdocs/societe/soc.php | 11 +--- 5 files changed, 39 insertions(+), 64 deletions(-) diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php index 6f7ceced553..9e8d17fa718 100644 --- a/htdocs/contact/canvas/actions_contactcard_common.class.php +++ b/htdocs/contact/canvas/actions_contactcard_common.class.php @@ -54,7 +54,7 @@ abstract class ActionsContactCardCommon function __construct($DB, $dirmodule, $targetmodule, $canvas, $card) { $this->db = $DB; - $this->dirmodule = $dirmodule; + $this->dirmodule = $targetmodule; $this->targetmodule = $targetmodule; $this->canvas = $canvas; $this->card = $card; diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php index 745d0c3d6e7..4f66bbdfc92 100644 --- a/htdocs/contact/fiche.php +++ b/htdocs/contact/fiche.php @@ -277,11 +277,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists()) // ----------------------------------------- // When used with CANVAS // ----------------------------------------- - if (! $objcanvas->hasActions() && $id) - { - $object = new Societe($db); - $object->fetch($id); // For use with "pure canvas" (canvas that contains templates only) - } + $objcanvas->assign_values($action, $id); // Set value for templates $objcanvas->display_canvas(); // Show template } @@ -328,8 +324,6 @@ else /* * Fiche en mode creation */ - $object->canvas=$canvas; - $object->fk_departement = $_POST["departement_id"]; // We set pays_id, pays_code and label for the selected country diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index 5e7d4321ca4..e2a9672428a 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -32,28 +32,29 @@ class Canvas var $db; var $error; var $errors=array(); - + var $actiontype; var $dirmodule; // Module directory var $targetmodule; // Module concerned by canvas (ex: thirdparty, contact, ...) - var $canvas; // Name of canvas (ex: company, individual, product, service, ...) + var $canvas; // Name of canvas var $card; // Tab (sub-canvas) - var $template_dir; // Initialized by getCanvas with templates directory - var $control; // Initialized by getCanvas with controller instance + var $template_dir; // Initialized by getCanvas with templates directory + var $control_file; // Initialized by getCanvas with controller file name + var $control; // Initialized by getCanvas with controller instance + var $object; // Initialized by getCanvas with dao instance, filled by getObject /** * Constructor * - * @param DoliDB $DB Database handler - * @param string $actiontype Action type ('create', 'view', 'edit', 'list') + * @param DoliDB $DB Database handler */ function __construct($DB, $actiontype='view') { $this->db = $DB; - + $this->actiontype = $actiontype; if ($this->actiontype == 'add') $this->actiontype='create'; if ($this->actiontype == 'update') $this->actiontype='edit'; @@ -61,17 +62,19 @@ class Canvas } /** - * Initialize properties: ->targetmodule, ->canvas, ->card, ->dirmodule, ->template_dir + * Initialize properties: ->targetmodule, ->canvas, ->card + * and MVC properties: ->control (Controller), ->control->object (Model), ->template_dir (View) * - * @param string $module Name of target module (thirdparty, contact, ...) - * @param string $card Tab name of card (ex: 'card', 'info', 'contactcard', ...) or '' for a list page - * @param string $canvas Name of canvas (ex: mycanvas, default, or mycanvas@myexternalmodule) - * @return void + * @param module Name of target module (thirdparty, contact, ...) + * @param card Type of card (ex: 'card', 'info', 'contactcard', ...) or '' for a list page + * @param canvas Name of canvas (ex: mycanvas, default, or mycanvas@myexternalmodule) */ function getCanvas($module, $card, $canvas) { global $conf, $langs; + $error=''; + // Set properties with value specific to dolibarr core: this->targetmodule, this->card, this->canvas $this->targetmodule = $module; $this->canvas = $canvas; @@ -86,7 +89,6 @@ class Canvas // For compatibility if ($this->dirmodule == 'thirdparty') { $this->dirmodule = 'societe'; } - // Control file $controlclassfile = dol_buildpath('/'.$this->dirmodule.'/canvas/'.$this->canvas.'/actions_'.$this->card.'_'.$this->canvas.'.class.php'); if (file_exists($controlclassfile)) { @@ -108,29 +110,21 @@ class Canvas //print 'dimodule='.$dirmodule.' canvas='.$this->canvas.'
'; //print ' => template_dir='.$this->template_dir.'
'; + //print ' => control_file='.$this->control_file.' is_object(this->control)='.is_object($this->control).'
'; + + return 1; } - - - /** - * Return if a canvas contains an action controller - * - * @return boolean Return if canvas contains actions (old feature. now actions should be inside hooks) - */ - function hasActions() - { - return (! is_object($this->control)); - } - + /** * Shared method for canvas to execute actions - * - * @param string &$action Action string + * + * @param string $action Action string * @param int $id Object id - * @return mixed Return return code of doActions of canvas + * @return void */ function doActions(&$action='view', $id=0) { - if (method_exists($this->control,'doActions')) + if (method_exists($this->control,'doActions')) { $ret = $this->control->doActions($action, $id); return $ret; @@ -139,8 +133,8 @@ class Canvas /** * Shared method for canvas to assign values for templates - * - * @param string &$action Action string + * + * @param string $action Action string * @param int $id Object id * @return void */ @@ -152,7 +146,7 @@ class Canvas /** * Return the template to display canvas (if it exists) * - * @return int 0=Canvas template file does not exist, 1=Canvas template file exists + * @return string Path to display canvas file if it exists, '' otherwise. */ function displayCanvasExists() { @@ -164,7 +158,8 @@ class Canvas /** * Display a canvas page. This will include the template for output. - * Variables used by templates may have been defined or loaded before into the assign_values function. + * Variables used by templates may have been defined, loaded before + * into the assign_values function. * * @return void */ diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 36b8bf3a7d0..a8d7823341a 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -298,8 +298,7 @@ class Societe extends CommonObject $result = 0; $this->name = trim($this->name); - $this->nom=$this->name; // For backward compatibility - + if (! $this->name) { $this->errors[] = 'ErrorBadThirdPartyName'; @@ -394,16 +393,11 @@ class Societe extends CommonObject // Clean parameters $this->id = $id; - $this->name=$this->name?trim($this->name):trim($this->nom); - $this->nom=trim($this->nom); // TODO obsolete - $this->address=$this->address?trim($this->address):trim($this->adresse); - $this->adresse=$this->address; // TODO obsolete - $this->zip=$this->zip?trim($this->zip):trim($this->cp); - $this->cp=$this->zip; // TODO obsolete - $this->town=$this->town?trim($this->town):trim($this->ville); - $this->ville=$this->town; // TODO obsolete - $this->state_id=trim($this->state_id); - $this->pays_id=trim($this->pays_id); + $this->name = trim($this->name); + $this->address = trim($this->address); + $this->zip = trim($this->zip); + $this->town = trim($this->town); + $this->state_id = trim($this->state_id); $this->country_id = trim($this->country_id); $this->tel = trim($this->tel); $this->fax = trim($this->fax); @@ -413,9 +407,6 @@ class Societe extends CommonObject $this->fax = preg_replace("/\./","",$this->fax); $this->email = trim($this->email); $this->url = $this->url?clean_url($this->url,0):''; - $this->siren=trim($this->siren); // TODO obsolete - $this->siret=trim($this->siret); // TODO obsolete - $this->ape=trim($this->ape); // TODO obsolete $this->idprof1 = trim($this->idprof1); $this->idprof2 = trim($this->idprof2); $this->idprof3 = trim($this->idprof3); diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 66097323008..b289e334c60 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -104,7 +104,6 @@ if (empty($reshook)) require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); if ($action == 'update') $object->fetch($socid); - else $object->canvas=$canvas; if (GETPOST("private") == 1) { @@ -475,13 +474,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists()) // ----------------------------------------- // When used with CANVAS // ----------------------------------------- - if (! $objcanvas->hasActions() && $socid) - { - $object = new Societe($db); - $object->fetch($socid); // For use with "pure canvas" (canvas that contains templates only) - } - $objcanvas->assign_values($action, $socid); // Set value for templates - $objcanvas->display_canvas(); // Show template + + $objcanvas->assign_values($action, $socid); // Set value for templates + $objcanvas->display_canvas(); // Show template } else { From 0bdcde36bf9eacb3b5b562367743ee6098ece455 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 24 Sep 2011 16:06:07 +0000 Subject: [PATCH 28/48] Fix: bad name --- htdocs/contact/canvas/actions_contactcard_common.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php index 9e8d17fa718..6f7ceced553 100644 --- a/htdocs/contact/canvas/actions_contactcard_common.class.php +++ b/htdocs/contact/canvas/actions_contactcard_common.class.php @@ -54,7 +54,7 @@ abstract class ActionsContactCardCommon function __construct($DB, $dirmodule, $targetmodule, $canvas, $card) { $this->db = $DB; - $this->dirmodule = $targetmodule; + $this->dirmodule = $dirmodule; $this->targetmodule = $targetmodule; $this->canvas = $canvas; $this->card = $card; From d9e239fd858ba6c9bb9be73fff4f47f054394b4f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 20:50:57 +0000 Subject: [PATCH 29/48] Fix: Little fix after canvas changes to be able to have "pure canvas" (canvas with no controller, only templates). --- htdocs/contact/fiche.php | 8 +++++++- htdocs/societe/soc.php | 11 ++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php index 4f66bbdfc92..745d0c3d6e7 100644 --- a/htdocs/contact/fiche.php +++ b/htdocs/contact/fiche.php @@ -277,7 +277,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists()) // ----------------------------------------- // When used with CANVAS // ----------------------------------------- - + if (! $objcanvas->hasActions() && $id) + { + $object = new Societe($db); + $object->fetch($id); // For use with "pure canvas" (canvas that contains templates only) + } $objcanvas->assign_values($action, $id); // Set value for templates $objcanvas->display_canvas(); // Show template } @@ -324,6 +328,8 @@ else /* * Fiche en mode creation */ + $object->canvas=$canvas; + $object->fk_departement = $_POST["departement_id"]; // We set pays_id, pays_code and label for the selected country diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index b289e334c60..66097323008 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -104,6 +104,7 @@ if (empty($reshook)) require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); if ($action == 'update') $object->fetch($socid); + else $object->canvas=$canvas; if (GETPOST("private") == 1) { @@ -474,9 +475,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists()) // ----------------------------------------- // When used with CANVAS // ----------------------------------------- - - $objcanvas->assign_values($action, $socid); // Set value for templates - $objcanvas->display_canvas(); // Show template + if (! $objcanvas->hasActions() && $socid) + { + $object = new Societe($db); + $object->fetch($socid); // For use with "pure canvas" (canvas that contains templates only) + } + $objcanvas->assign_values($action, $socid); // Set value for templates + $objcanvas->display_canvas(); // Show template } else { From e3c6e4d1bd35b74a9a6d3d298a6d4a39015dec92 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 20:51:36 +0000 Subject: [PATCH 30/48] Doxygen --- htdocs/core/class/canvas.class.php | 54 +++++++++++++++++------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index e2a9672428a..1a56caeae7c 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -32,29 +32,28 @@ class Canvas var $db; var $error; var $errors=array(); - + var $actiontype; var $dirmodule; // Module directory var $targetmodule; // Module concerned by canvas (ex: thirdparty, contact, ...) - var $canvas; // Name of canvas + var $canvas; // Name of canvas (ex: company, individual, product, service, ...) var $card; // Tab (sub-canvas) - var $template_dir; // Initialized by getCanvas with templates directory - var $control_file; // Initialized by getCanvas with controller file name - var $control; // Initialized by getCanvas with controller instance - var $object; // Initialized by getCanvas with dao instance, filled by getObject + var $template_dir; // Initialized by getCanvas with templates directory + var $control; // Initialized by getCanvas with controller instance /** * Constructor * - * @param DoliDB $DB Database handler + * @param DoliDB $DB Database handler + * @param string $actiontype Action type ('create', 'view', 'edit', 'list') */ function __construct($DB, $actiontype='view') { $this->db = $DB; - + $this->actiontype = $actiontype; if ($this->actiontype == 'add') $this->actiontype='create'; if ($this->actiontype == 'update') $this->actiontype='edit'; @@ -62,19 +61,16 @@ class Canvas } /** - * Initialize properties: ->targetmodule, ->canvas, ->card - * and MVC properties: ->control (Controller), ->control->object (Model), ->template_dir (View) + * Initialize properties: ->targetmodule, ->canvas, ->card, ->dirmodule, ->template_dir * - * @param module Name of target module (thirdparty, contact, ...) - * @param card Type of card (ex: 'card', 'info', 'contactcard', ...) or '' for a list page - * @param canvas Name of canvas (ex: mycanvas, default, or mycanvas@myexternalmodule) + * @param string $module Name of target module (thirdparty, contact, ...) + * @param string $card Tab name of card (ex: 'card', 'info', 'contactcard', ...) or '' for a list page + * @param string $canvas Name of canvas (ex: mycanvas, default, or mycanvas@myexternalmodule) */ function getCanvas($module, $card, $canvas) { global $conf, $langs; - $error=''; - // Set properties with value specific to dolibarr core: this->targetmodule, this->card, this->canvas $this->targetmodule = $module; $this->canvas = $canvas; @@ -89,6 +85,7 @@ class Canvas // For compatibility if ($this->dirmodule == 'thirdparty') { $this->dirmodule = 'societe'; } + // Control file $controlclassfile = dol_buildpath('/'.$this->dirmodule.'/canvas/'.$this->canvas.'/actions_'.$this->card.'_'.$this->canvas.'.class.php'); if (file_exists($controlclassfile)) { @@ -110,21 +107,31 @@ class Canvas //print 'dimodule='.$dirmodule.' canvas='.$this->canvas.'
'; //print ' => template_dir='.$this->template_dir.'
'; - //print ' => control_file='.$this->control_file.' is_object(this->control)='.is_object($this->control).'
'; return 1; } - + + + /** + * Return if a canvas contains an action controller + * + * @return boolean Return if canvas contains actions (old feature. now actions should be inside hooks) + */ + function hasActions() + { + return (! is_object($this->control)); + } + /** * Shared method for canvas to execute actions - * + * * @param string $action Action string * @param int $id Object id - * @return void + * @return mixed Return return code of doActions of canvas */ function doActions(&$action='view', $id=0) { - if (method_exists($this->control,'doActions')) + if (method_exists($this->control,'doActions')) { $ret = $this->control->doActions($action, $id); return $ret; @@ -133,7 +140,7 @@ class Canvas /** * Shared method for canvas to assign values for templates - * + * * @param string $action Action string * @param int $id Object id * @return void @@ -146,7 +153,7 @@ class Canvas /** * Return the template to display canvas (if it exists) * - * @return string Path to display canvas file if it exists, '' otherwise. + * @return int 0=Canvas template file does not exist, 1=Canvas template file exists */ function displayCanvasExists() { @@ -158,8 +165,7 @@ class Canvas /** * Display a canvas page. This will include the template for output. - * Variables used by templates may have been defined, loaded before - * into the assign_values function. + * Variables used by templates may have been defined or loaded before into the assign_values function. * * @return void */ From edb5a7185bc51e77f81a721ba395a5fa7fced663 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 20:56:08 +0000 Subject: [PATCH 31/48] Doxygen --- htdocs/core/class/canvas.class.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index 1a56caeae7c..5e7d4321ca4 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -66,6 +66,7 @@ class Canvas * @param string $module Name of target module (thirdparty, contact, ...) * @param string $card Tab name of card (ex: 'card', 'info', 'contactcard', ...) or '' for a list page * @param string $canvas Name of canvas (ex: mycanvas, default, or mycanvas@myexternalmodule) + * @return void */ function getCanvas($module, $card, $canvas) { @@ -107,8 +108,6 @@ class Canvas //print 'dimodule='.$dirmodule.' canvas='.$this->canvas.'
'; //print ' => template_dir='.$this->template_dir.'
'; - - return 1; } @@ -125,7 +124,7 @@ class Canvas /** * Shared method for canvas to execute actions * - * @param string $action Action string + * @param string &$action Action string * @param int $id Object id * @return mixed Return return code of doActions of canvas */ @@ -141,7 +140,7 @@ class Canvas /** * Shared method for canvas to assign values for templates * - * @param string $action Action string + * @param string &$action Action string * @param int $id Object id * @return void */ From 412b2a400ec2393ab5f746978ce475e692bb6cd6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 21:51:52 +0000 Subject: [PATCH 32/48] Doxygen From 52dec0fa41c5d23995c010021d9dcc1977870a9f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 21:52:53 +0000 Subject: [PATCH 33/48] Add file to ignore From 40f436b7b0b642d9618f48adbab7d4e7df2cc7f0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 21:55:18 +0000 Subject: [PATCH 34/48] Add hidden option PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS From 39dd7cb17330f2bd3f5bf712be063d911ca62278 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 22:25:01 +0000 Subject: [PATCH 35/48] Qual: Uniformize code From 090b2946e42f1f31f7b079c5c2665a14e71998b7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 22:31:28 +0000 Subject: [PATCH 36/48] Fix: Restore obsolete var when they are used as "init". I suggest to remove first all references that are in "read" mode by new name and remove reference that are in "write" mode only once there is no more call to old name in page that used them. This is to reduce risk of bugs. --- htdocs/societe/class/societe.class.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index a8d7823341a..36b8bf3a7d0 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -298,7 +298,8 @@ class Societe extends CommonObject $result = 0; $this->name = trim($this->name); - + $this->nom=$this->name; // For backward compatibility + if (! $this->name) { $this->errors[] = 'ErrorBadThirdPartyName'; @@ -393,11 +394,16 @@ class Societe extends CommonObject // Clean parameters $this->id = $id; - $this->name = trim($this->name); - $this->address = trim($this->address); - $this->zip = trim($this->zip); - $this->town = trim($this->town); - $this->state_id = trim($this->state_id); + $this->name=$this->name?trim($this->name):trim($this->nom); + $this->nom=trim($this->nom); // TODO obsolete + $this->address=$this->address?trim($this->address):trim($this->adresse); + $this->adresse=$this->address; // TODO obsolete + $this->zip=$this->zip?trim($this->zip):trim($this->cp); + $this->cp=$this->zip; // TODO obsolete + $this->town=$this->town?trim($this->town):trim($this->ville); + $this->ville=$this->town; // TODO obsolete + $this->state_id=trim($this->state_id); + $this->pays_id=trim($this->pays_id); $this->country_id = trim($this->country_id); $this->tel = trim($this->tel); $this->fax = trim($this->fax); @@ -407,6 +413,9 @@ class Societe extends CommonObject $this->fax = preg_replace("/\./","",$this->fax); $this->email = trim($this->email); $this->url = $this->url?clean_url($this->url,0):''; + $this->siren=trim($this->siren); // TODO obsolete + $this->siret=trim($this->siret); // TODO obsolete + $this->ape=trim($this->ape); // TODO obsolete $this->idprof1 = trim($this->idprof1); $this->idprof2 = trim($this->idprof2); $this->idprof3 = trim($this->idprof3); From 32be8486070256dbd98b739c5838a828f921e6ab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 22:43:52 +0000 Subject: [PATCH 37/48] Qual: Removed warnings From 0b337c66a22ace535217253093245094acac2e2d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 23:42:31 +0000 Subject: [PATCH 38/48] Qual: Uniformize code From eea0b08fc3f8251d91eff7ec7f895660b9b7f454 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 23:49:45 +0000 Subject: [PATCH 39/48] Move dev module mantis to nltechno repository From af8fe02504d6ec3bad143ddd8d493feec46c1d8b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 21:55:18 +0000 Subject: [PATCH 40/48] Add hidden option PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS From 221299db9ce7693ab9ca28224a79ff5e1690b3b7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 22:25:01 +0000 Subject: [PATCH 41/48] Qual: Uniformize code From ad832ea6001dc4a92c6e773358d5db71fb5ddcaa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 22:31:28 +0000 Subject: [PATCH 42/48] Fix: Restore obsolete var when they are used as "init". I suggest to remove first all references that are in "read" mode by new name and remove reference that are in "write" mode only once there is no more call to old name in page that used them. This is to reduce risk of bugs. From 01ca51fc718635ae26208b7faa270d4d24fb3c78 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 22:43:52 +0000 Subject: [PATCH 43/48] Qual: Removed warnings From 6bf3bfc5d1a11ab8f6bc60a9af4c033586d39c1c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 23:42:31 +0000 Subject: [PATCH 44/48] Qual: Uniformize code From 8e654121bb3925e0243a97f71e1e09ba4ef4ffc9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Sep 2011 23:49:45 +0000 Subject: [PATCH 45/48] Move dev module mantis to nltechno repository From dfac311a882b8753e5509b5daff6a12dac375082 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Sep 2011 10:23:07 +0000 Subject: [PATCH 46/48] Doxygen --- htdocs/core/class/canvas.class.php | 60 ++++++++++++++++-------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index 5e7d4321ca4..edf58f117b1 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -110,33 +110,6 @@ class Canvas //print ' => template_dir='.$this->template_dir.'
'; } - - /** - * Return if a canvas contains an action controller - * - * @return boolean Return if canvas contains actions (old feature. now actions should be inside hooks) - */ - function hasActions() - { - return (! is_object($this->control)); - } - - /** - * Shared method for canvas to execute actions - * - * @param string &$action Action string - * @param int $id Object id - * @return mixed Return return code of doActions of canvas - */ - function doActions(&$action='view', $id=0) - { - if (method_exists($this->control,'doActions')) - { - $ret = $this->control->doActions($action, $id); - return $ret; - } - } - /** * Shared method for canvas to assign values for templates * @@ -176,5 +149,38 @@ class Canvas include($this->template_dir.($this->card?$this->card.'_':'').$this->actiontype.'.tpl.php'); // Include native PHP template } + + // This functions should not be used anymore because canvas should contains only templates. + // http://wiki.dolibarr.org/index.php/Canvas_development + + /** + * Return if a canvas contains an action controller + * + * @return boolean Return if canvas contains actions (old feature. now actions should be inside hooks) + */ + function hasActions() + { + return (! is_object($this->control)); + } + + /** + * Shared method for canvas to execute actions + * + * @param string &$action Action string + * @param int $id Object id + * @return mixed Return return code of doActions of canvas + * @deprecated This function is called if you add a doActions class inside your canvas. Try to not + * do that and add action code into a hook instead. + * @see http://wiki.dolibarr.org/index.php/Canvas_development + */ + function doActions(&$action='view', $id=0) + { + if (method_exists($this->control,'doActions')) + { + $ret = $this->control->doActions($action, $id); + return $ret; + } + } + } ?> From 81098a75fe984abfbca22573040459cfb99ffdf5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Sep 2011 10:32:58 +0000 Subject: [PATCH 47/48] Fix: Wrong direction of test --- htdocs/core/class/canvas.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index edf58f117b1..3965afbe33a 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -160,7 +160,7 @@ class Canvas */ function hasActions() { - return (! is_object($this->control)); + return (is_object($this->control)); } /** From 3b45774f0d20e43b9cf3745e002b66027c7e804e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Sep 2011 12:06:53 +0000 Subject: [PATCH 48/48] Removed strong. It's not a link. --- htdocs/admin/tools/eaccelerator.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/tools/eaccelerator.php b/htdocs/admin/tools/eaccelerator.php index 28f488a5f90..825b3811e03 100644 --- a/htdocs/admin/tools/eaccelerator.php +++ b/htdocs/admin/tools/eaccelerator.php @@ -85,7 +85,7 @@ function compare($x, $y) /** * Compare revisions - * + * * @param array $x Parts of version 1 * @param array $y Parts of version 2 * @return int 1 if 1<2, 0 if 1=2, -1 if 1>2 @@ -104,7 +104,7 @@ function revcompare($x, $y) /** * Output table - * + * * @param array $list Array of records * @return void */ @@ -179,7 +179,7 @@ function create_script_table($list) /** * Output table - * + * * @param array $list Array of records * @return void */ @@ -348,7 +348,7 @@ if (function_exists('eaccelerator_get')) print "

"; print "
"; print '
'; -print 'Eaccelerator is created by the eAccelerator team, http://eaccelerator.net

'; +print 'Eaccelerator is created by the eAccelerator team, http://eaccelerator.net

'; print "
";