Fix: regression, canvas is broken and societe.class and contact.class are incompatible with callHook function
This commit is contained in:
parent
6385641a8e
commit
79880a1aea
@ -24,7 +24,7 @@
|
|||||||
* \file htdocs/contact/fiche.php
|
* \file htdocs/contact/fiche.php
|
||||||
* \ingroup societe
|
* \ingroup societe
|
||||||
* \brief Card of a contact
|
* \brief Card of a contact
|
||||||
* \version $Id: fiche.php,v 1.214 2011/06/29 22:29:51 eldy Exp $
|
* \version $Id: fiche.php,v 1.215 2011/06/30 13:25:32 hregis Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require("../main.inc.php");
|
require("../main.inc.php");
|
||||||
@ -45,11 +45,11 @@ $action = GETPOST('action');
|
|||||||
$socid = GETPOST("socid");
|
$socid = GETPOST("socid");
|
||||||
$id = GETPOST("id");
|
$id = GETPOST("id");
|
||||||
|
|
||||||
$object = new Contact($db);
|
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
if ($user->societe_id) $socid=$user->societe_id;
|
if ($user->societe_id) $socid=$user->societe_id;
|
||||||
|
|
||||||
|
$object = new Contact($db);
|
||||||
|
|
||||||
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
|
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
|
||||||
if (!empty($id)) $object->getCanvas($id);
|
if (!empty($id)) $object->getCanvas($id);
|
||||||
$canvas = (!empty($object->canvas)?$object->canvas:GETPOST("canvas"));
|
$canvas = (!empty($object->canvas)?$object->canvas:GETPOST("canvas"));
|
||||||
@ -68,32 +68,36 @@ else
|
|||||||
$result = restrictedArea($user, 'contact', $id, 'socpeople'); // If we create a contact with no company (shared contacts), no check on write permission
|
$result = restrictedArea($user, 'contact', $id, 'socpeople'); // If we create a contact with no company (shared contacts), no check on write permission
|
||||||
}
|
}
|
||||||
|
|
||||||
// Instantiate hooks of thirdparty module
|
|
||||||
if (is_array($conf->hooks_modules) && !empty($conf->hooks_modules))
|
|
||||||
{
|
|
||||||
$object->callHooks('contactcard');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Hook of actions
|
// If canvas actions are defined, because on url, or because contact was created with canvas feature on, we use the canvas feature.
|
||||||
if (! empty($object->hooks['contactcard']))
|
// If canvas actions are not defined, we use standard feature.
|
||||||
|
if (method_exists($objcanvas->control,'doActions'))
|
||||||
{
|
{
|
||||||
foreach($object->hooks['contactcard'] as $module)
|
// -----------------------------------------
|
||||||
|
// When used with CANVAS
|
||||||
|
// -----------------------------------------
|
||||||
|
$objcanvas->doActions($id);
|
||||||
|
if (empty($objcanvas->error) && (empty($objcanvas->errors) || sizeof($objcanvas->errors) == 0))
|
||||||
{
|
{
|
||||||
$reshook+=$module->doActions($object);
|
if ($action=='add') { $objcanvas->action='create'; $action='create'; }
|
||||||
if (! empty($module->error) || (! empty($module->errors) && sizeof($module->errors) > 0))
|
if ($action=='update') { $objcanvas->action='view'; $action='view'; }
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
$error=$module->error; $errors[]=$module->errors;
|
$error=$objcanvas->error; $errors=$objcanvas->errors;
|
||||||
if ($action=='add') $action='create';
|
if ($action=='add') { $objcanvas->action='create'; $action='create'; }
|
||||||
if ($action=='update') $action='edit';
|
if ($action=='update') { $objcanvas->action='edit'; $action='edit'; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// -----------------------------------------
|
||||||
|
// When used in standard mode
|
||||||
|
// -----------------------------------------
|
||||||
|
|
||||||
// Creation utilisateur depuis contact
|
// Creation utilisateur depuis contact
|
||||||
if ($_POST["action"] == 'confirm_create_user' && $_POST["confirm"] == 'yes' && $user->rights->user->user->creer)
|
if ($_POST["action"] == 'confirm_create_user' && $_POST["confirm"] == 'yes' && $user->rights->user->user->creer)
|
||||||
@ -271,6 +275,7 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->societe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -945,5 +950,5 @@ else
|
|||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
llxFooter('$Date: 2011/06/29 22:29:51 $ - $Revision: 1.214 $');
|
llxFooter('$Date: 2011/06/30 13:25:32 $ - $Revision: 1.215 $');
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
* \file htdocs/societe/canvas/actions_card_common.class.php
|
* \file htdocs/societe/canvas/actions_card_common.class.php
|
||||||
* \ingroup thirdparty
|
* \ingroup thirdparty
|
||||||
* \brief Fichier de la classe Thirdparty card controller (common)
|
* \brief Fichier de la classe Thirdparty card controller (common)
|
||||||
* \version $Id$
|
* \version $Id: actions_card_common.class.php,v 1.22 2011/06/30 13:25:32 hregis Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -259,7 +259,7 @@ class ActionsCardCommon
|
|||||||
|
|
||||||
$oldsoccanvas = new Canvas($this->db);
|
$oldsoccanvas = new Canvas($this->db);
|
||||||
$oldsoccanvas->getCanvas('thirdparty','card',$this->object->canvas);
|
$oldsoccanvas->getCanvas('thirdparty','card',$this->object->canvas);
|
||||||
$result=$oldsoccanvas->fetch($socid);
|
$result=$oldsoccanvas->control->object->fetch($socid);
|
||||||
|
|
||||||
// To avoid setting code if third party is not concerned. But if it had values, we keep them.
|
// To avoid setting code if third party is not concerned. But if it had values, we keep them.
|
||||||
if (empty($this->object->client) && empty($oldsoccanvas->control->object->code_client)) $this->object->code_client='';
|
if (empty($this->object->client) && empty($oldsoccanvas->control->object->code_client)) $this->object->code_client='';
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
* \file htdocs/societe/soc.php
|
* \file htdocs/societe/soc.php
|
||||||
* \ingroup societe
|
* \ingroup societe
|
||||||
* \brief Third party card page
|
* \brief Third party card page
|
||||||
* \version $Id: soc.php,v 1.112 2011/06/29 22:29:51 eldy Exp $
|
* \version $Id: soc.php,v 1.113 2011/06/30 13:25:33 hregis Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require("../main.inc.php");
|
require("../main.inc.php");
|
||||||
@ -50,17 +50,11 @@ if ($conf->notification->enabled) $langs->load("mails");
|
|||||||
$action = GETPOST('action');
|
$action = GETPOST('action');
|
||||||
$confirm = GETPOST('confirm');
|
$confirm = GETPOST('confirm');
|
||||||
|
|
||||||
$error=0; $errors=array();
|
|
||||||
|
|
||||||
$extrafields = new ExtraFields($db);
|
|
||||||
|
|
||||||
$soc = new Societe($db); // TODO Replace this wit object
|
|
||||||
$object = new Societe($db);
|
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
$socid = GETPOST("socid");
|
$socid = GETPOST("socid");
|
||||||
if ($user->societe_id) $socid=$user->societe_id;
|
if ($user->societe_id) $socid=$user->societe_id;
|
||||||
|
|
||||||
|
$soc = new Societe($db);
|
||||||
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
|
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
|
||||||
if (!empty($socid)) $soc->getCanvas($socid);
|
if (!empty($socid)) $soc->getCanvas($socid);
|
||||||
$canvas = (!empty($soc->canvas)?$soc->canvas:GETPOST("canvas"));
|
$canvas = (!empty($soc->canvas)?$soc->canvas:GETPOST("canvas"));
|
||||||
@ -79,33 +73,41 @@ else
|
|||||||
$result = restrictedArea($user, 'societe', $socid);
|
$result = restrictedArea($user, 'societe', $socid);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Instantiate hooks of thirdparty module
|
$error=0; $errors=array();
|
||||||
if (is_array($conf->hooks_modules) && !empty($conf->hooks_modules))
|
|
||||||
{
|
|
||||||
$object->callHooks('thirdpartycard');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
$extrafields = new ExtraFields($db);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Hook of actions
|
// If canvas actions are defined, because on url, or because contact was created with canvas feature on, we use the canvas feature.
|
||||||
if (! empty($object->hooks['thirdpartycard']))
|
// If canvas actions are not defined, we use standard feature.
|
||||||
|
if (method_exists($objcanvas->control,'doActions'))
|
||||||
{
|
{
|
||||||
foreach($object->hooks['thirdpartycard'] as $module)
|
// -----------------------------------------
|
||||||
{
|
// When used with CANVAS
|
||||||
$reshook+=$module->doActions($object);
|
// -----------------------------------------
|
||||||
if (! empty($module->error) || (! empty($module->errors) && sizeof($module->errors) > 0))
|
$objcanvas->doActions($socid);
|
||||||
{
|
|
||||||
$error=$module->error; $errors[]=$module->errors;
|
|
||||||
if ($action=='add') $action='create';
|
|
||||||
if ($action=='update') $action='edit';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (empty($objcanvas->error) && (empty($objcanvas->errors) || sizeof($objcanvas->errors) == 0))
|
||||||
|
{
|
||||||
|
if ($action=='add') { $objcanvas->action='create'; $action='create'; }
|
||||||
|
if ($action=='update') { $objcanvas->action='view'; $action='view'; }
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$error=$objcanvas->error; $errors=$objcanvas->errors;
|
||||||
|
if ($action=='add') { $objcanvas->action='create'; $action='create'; }
|
||||||
|
if ($action=='update') { $objcanvas->action='edit'; $action='edit'; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// -----------------------------------------
|
||||||
|
// When used in standard mode
|
||||||
|
// -----------------------------------------
|
||||||
|
|
||||||
if ($_POST["getcustomercode"])
|
if ($_POST["getcustomercode"])
|
||||||
{
|
{
|
||||||
@ -463,6 +465,7 @@ if ($action == 'builddoc') // En get ou en post
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1943,5 +1946,5 @@ else
|
|||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
llxFooter('$Date: 2011/06/29 22:29:51 $ - $Revision: 1.112 $');
|
llxFooter('$Date: 2011/06/30 13:25:33 $ - $Revision: 1.113 $');
|
||||||
?>
|
?>
|
||||||
Loading…
Reference in New Issue
Block a user