Try a better way to manage extra fields from external module
This commit is contained in:
parent
938a636c0e
commit
581f0a0e09
@ -1,37 +0,0 @@
|
|||||||
<?php
|
|
||||||
/* Copyright (C) 2011 Regis Houssin <regis@dolibarr.fr>
|
|
||||||
*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file htdocs/adherents/class/actions_adherent.class.php
|
|
||||||
* \ingroup member
|
|
||||||
* \brief File for member class
|
|
||||||
* \version $Id: actions_adherent.class.php,v 1.1 2011/08/09 17:59:48 hregis Exp $
|
|
||||||
*/
|
|
||||||
require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \class ActionsAdherent
|
|
||||||
* \brief Class to manage members objects
|
|
||||||
*/
|
|
||||||
class ActionsAdherent extends Adherent
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
|
||||||
@ -24,7 +24,7 @@
|
|||||||
* \file htdocs/adherents/class/adherent.class.php
|
* \file htdocs/adherents/class/adherent.class.php
|
||||||
* \ingroup member
|
* \ingroup member
|
||||||
* \brief File of class to manage members of a foundation
|
* \brief File of class to manage members of a foundation
|
||||||
* \version $Id: adherent.class.php,v 1.46 2011/08/09 17:59:46 hregis Exp $
|
* \version $Id: adherent.class.php,v 1.47 2011/08/10 00:50:17 eldy Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
|
||||||
@ -421,32 +421,20 @@ class Adherent extends CommonObject
|
|||||||
{
|
{
|
||||||
$nbrowsaffected+=$this->db->affected_rows($resql);
|
$nbrowsaffected+=$this->db->affected_rows($resql);
|
||||||
|
|
||||||
/*
|
// Actions on extra fields (by external module or standard code)
|
||||||
$result=$this->insertExtraFields();
|
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
|
||||||
if ($result < 0)
|
$hookmanager=new HookManager($db);
|
||||||
|
$hookmanager->callHooks(array('member_extrafields'));
|
||||||
|
$reshook=$hookmanager->executeHooks('insertExtraFields',$action,$this,$socid); // Note that $action and $object may have been modified by some hooks
|
||||||
|
if (empty($reshook))
|
||||||
{
|
{
|
||||||
$error++;
|
$result=$this->insertExtraFields();
|
||||||
|
if ($result < 0)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*/
|
else if ($reshook < 0) $error++;
|
||||||
|
|
||||||
// Hook for external modules
|
|
||||||
if (! empty($this->hooks))
|
|
||||||
{
|
|
||||||
foreach($this->hooks as $hook)
|
|
||||||
{
|
|
||||||
if ($hook['type'] == 'member_extrafields' && ! empty($hook['modules']))
|
|
||||||
{
|
|
||||||
foreach($hook['modules'] as $module)
|
|
||||||
{
|
|
||||||
if (method_exists($module,'insertExtraFields'))
|
|
||||||
{
|
|
||||||
$result=$module->insertExtraFields($this);
|
|
||||||
if ($result < 0) $error++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update password
|
// Update password
|
||||||
if (! $error && $this->pass)
|
if (! $error && $this->pass)
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
* \file htdocs/adherents/fiche.php
|
* \file htdocs/adherents/fiche.php
|
||||||
* \ingroup member
|
* \ingroup member
|
||||||
* \brief Page of member
|
* \brief Page of member
|
||||||
* \version $Id: fiche.php,v 1.239 2011/08/09 17:59:52 hregis Exp $
|
* \version $Id: fiche.php,v 1.240 2011/08/10 00:50:19 eldy Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require("../main.inc.php");
|
require("../main.inc.php");
|
||||||
@ -32,7 +32,7 @@ require_once(DOL_DOCUMENT_ROOT."/lib/images.lib.php");
|
|||||||
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
|
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php");
|
||||||
//require_once(DOL_DOCUMENT_ROOT."/core/class/extrafields.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/core/class/extrafields.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/adherents/class/cotisation.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/adherents/class/cotisation.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/compta/bank/class/account.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/compta/bank/class/account.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formcompany.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formcompany.class.php");
|
||||||
@ -46,7 +46,7 @@ $langs->load("users");
|
|||||||
if (! $user->rights->adherent->lire) accessforbidden();
|
if (! $user->rights->adherent->lire) accessforbidden();
|
||||||
|
|
||||||
$object = new Adherent($db);
|
$object = new Adherent($db);
|
||||||
//$extrafields = new ExtraFields($db);
|
$extrafields = new ExtraFields($db);
|
||||||
|
|
||||||
$errmsg=''; $errmsgs=array();
|
$errmsg=''; $errmsgs=array();
|
||||||
|
|
||||||
@ -80,17 +80,19 @@ if ($rowid)
|
|||||||
$caneditfieldmember=$user->rights->adherent->creer;
|
$caneditfieldmember=$user->rights->adherent->creer;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Instantiate hooks of thirdparty module. Note that conf->hooks_modules contains array array
|
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
||||||
if (is_array($conf->hooks_modules) && !empty($conf->hooks_modules))
|
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
|
||||||
{
|
$hookmanager=new HookManager($db);
|
||||||
$object->callHooks('member_extrafields');
|
$hookmanager->callHooks(array('member_extrafields'));
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$reshook=$hookmanager->executeHooks('doActions',$action,$object,$socid); // Note that $action and $object may have been modified by some hooks
|
||||||
|
|
||||||
|
|
||||||
if ($_POST['action'] == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer))
|
if ($_POST['action'] == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer))
|
||||||
{
|
{
|
||||||
$error=0;
|
$error=0;
|
||||||
@ -599,7 +601,7 @@ if ($user->rights->adherent->creer && $_POST["action"] == 'confirm_add_spip' &&
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// fetch optionals attributes and labels
|
// fetch optionals attributes and labels
|
||||||
//$extralabels=$extrafields->fetch_name_optionals_label('member');
|
$extralabels=$extrafields->fetch_name_optionals_label('member');
|
||||||
|
|
||||||
$help_url='EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros';
|
$help_url='EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros';
|
||||||
llxHeader('',$langs->trans("Member"),$help_url);
|
llxHeader('',$langs->trans("Member"),$help_url);
|
||||||
@ -770,34 +772,18 @@ if ($action == 'create')
|
|||||||
print $html->selectyesno("public",$object->public,1);
|
print $html->selectyesno("public",$object->public,1);
|
||||||
print "</td></tr>\n";
|
print "</td></tr>\n";
|
||||||
|
|
||||||
// Attribut optionnels
|
// Other attributes
|
||||||
/*
|
$reshook=$hookmanager->executeHooks('showInputFields',$action,$object); // Note that $action and $object may have been modified by hook
|
||||||
foreach($extrafields->attribute_label as $key=>$label)
|
if (empty($reshook))
|
||||||
{
|
{
|
||||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:'');
|
foreach($extrafields->attribute_label as $key=>$label)
|
||||||
print "<tr><td>".$label.'</td><td>';
|
{
|
||||||
print $extrafields->showInputField($key,$value);
|
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:'');
|
||||||
print '</td></tr>'."\n";
|
print "<tr><td>".$label.'</td><td>';
|
||||||
|
print $extrafields->showInputField($key,$value);
|
||||||
|
print '</td></tr>'."\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
// Hook for external modules
|
|
||||||
if (! empty($object->hooks))
|
|
||||||
{
|
|
||||||
foreach($object->hooks as $hook)
|
|
||||||
{
|
|
||||||
if ($hook['type'] == 'member_extrafields' && ! empty($hook['modules']))
|
|
||||||
{
|
|
||||||
foreach($hook['modules'] as $module)
|
|
||||||
{
|
|
||||||
if (method_exists($module,'showInputFields'))
|
|
||||||
{
|
|
||||||
$module->showInputFields($object,$_POST);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// Third party Dolibarr
|
// Third party Dolibarr
|
||||||
@ -1004,33 +990,17 @@ if ($action == 'edit')
|
|||||||
print "</td></tr>\n";
|
print "</td></tr>\n";
|
||||||
|
|
||||||
// Other attributes
|
// Other attributes
|
||||||
/*
|
$reshook=$hookmanager->executeHooks('showInputFields',$action,$object); // Note that $action and $object may have been modified by hook
|
||||||
foreach($extrafields->attribute_label as $key=>$label)
|
if (empty($reshook))
|
||||||
{
|
{
|
||||||
$value=(isset($_POST["options_$key"])?$_POST["options_$key"]:$object->array_options["options_$key"]);
|
foreach($extrafields->attribute_label as $key=>$label)
|
||||||
print "<tr><td>".$label."</td><td>";
|
{
|
||||||
print $extrafields->showInputField($key,$value);
|
$value=(isset($_POST["options_$key"])?$_POST["options_$key"]:$object->array_options["options_$key"]);
|
||||||
print "</td></tr>\n";
|
print "<tr><td>".$label."</td><td>";
|
||||||
}
|
print $extrafields->showInputField($key,$value);
|
||||||
*/
|
print "</td></tr>\n";
|
||||||
|
}
|
||||||
// Hook for external modules
|
}
|
||||||
if (! empty($object->hooks))
|
|
||||||
{
|
|
||||||
foreach($object->hooks as $hook)
|
|
||||||
{
|
|
||||||
if ($hook['type'] == 'member_extrafields' && ! empty($hook['modules']))
|
|
||||||
{
|
|
||||||
foreach($hook['modules'] as $module)
|
|
||||||
{
|
|
||||||
if (method_exists($module,'showInputFields'))
|
|
||||||
{
|
|
||||||
$module->showInputFields($object,$_POST,$rowid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Third party Dolibarr
|
// Third party Dolibarr
|
||||||
if ($conf->societe->enabled)
|
if ($conf->societe->enabled)
|
||||||
@ -1332,33 +1302,17 @@ if ($rowid && $action != 'edit')
|
|||||||
print '<tr><td>'.$langs->trans("Status").'</td><td class="valeur">'.$object->getLibStatut(4).'</td></tr>';
|
print '<tr><td>'.$langs->trans("Status").'</td><td class="valeur">'.$object->getLibStatut(4).'</td></tr>';
|
||||||
|
|
||||||
// Other attributes
|
// Other attributes
|
||||||
/*
|
$reshook=$hookmanager->executeHooks('showOutputField',$action,$object,$socid); // Note that $action and $object may have been modified by hook
|
||||||
foreach($extrafields->attribute_label as $key=>$label)
|
if (empty($reshook))
|
||||||
{
|
{
|
||||||
$value=$object->array_options["options_$key"];
|
foreach($extrafields->attribute_label as $key=>$label)
|
||||||
print "<tr><td>".$label."</td><td>";
|
|
||||||
print $extrafields->showOutputField($key,$value);
|
|
||||||
print "</td></tr>\n";
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Hook for external modules
|
|
||||||
if (! empty($object->hooks))
|
|
||||||
{
|
|
||||||
foreach($object->hooks as $hook)
|
|
||||||
{
|
{
|
||||||
if ($hook['type'] == 'member_extrafields' && ! empty($hook['modules']))
|
$value=$object->array_options["options_$key"];
|
||||||
{
|
print "<tr><td>".$label."</td><td>";
|
||||||
foreach($hook['modules'] as $module)
|
print $extrafields->showOutputField($key,$value);
|
||||||
{
|
print "</td></tr>\n";
|
||||||
if (method_exists($module,'showOutputFields'))
|
}
|
||||||
{
|
}
|
||||||
$module->showOutputFields($object,$rowid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Third party Dolibarr
|
// Third party Dolibarr
|
||||||
if ($conf->societe->enabled)
|
if ($conf->societe->enabled)
|
||||||
@ -1568,5 +1522,5 @@ if ($rowid && $action != 'edit')
|
|||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
llxFooter('$Date: 2011/08/09 17:59:52 $ - $Revision: 1.239 $');
|
llxFooter('$Date: 2011/08/10 00:50:19 $ - $Revision: 1.240 $');
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
* \file htdocs/core/class/commonobject.class.php
|
* \file htdocs/core/class/commonobject.class.php
|
||||||
* \ingroup core
|
* \ingroup core
|
||||||
* \brief File of parent class of all other business classes (invoices, contracts, proposals, orders, ...)
|
* \brief File of parent class of all other business classes (invoices, contracts, proposals, orders, ...)
|
||||||
* \version $Id: commonobject.class.php,v 1.150 2011/08/09 17:59:45 hregis Exp $
|
* \version $Id: commonobject.class.php,v 1.151 2011/08/10 00:50:17 eldy Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@ -1436,66 +1436,6 @@ class CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Init array this->hooks with instantiated controler and/or dao
|
|
||||||
* @param arraytype Array list of hooked tab/features. For example: thirdpartytab, ...
|
|
||||||
*/
|
|
||||||
function callHooks($arraytype)
|
|
||||||
{
|
|
||||||
global $conf;
|
|
||||||
|
|
||||||
if (! is_array($arraytype)) $arraytype=array($arraytype);
|
|
||||||
|
|
||||||
$i=0;
|
|
||||||
|
|
||||||
foreach($conf->hooks_modules as $module => $hooks)
|
|
||||||
{
|
|
||||||
if ($conf->$module->enabled)
|
|
||||||
{
|
|
||||||
foreach($arraytype as $type)
|
|
||||||
{
|
|
||||||
if (in_array($type,$hooks))
|
|
||||||
{
|
|
||||||
$path = $module;
|
|
||||||
if ($module == 'adherent') $path = 'adherents';
|
|
||||||
$path = '/'.$path.'/class/';
|
|
||||||
$actionfile = 'actions_'.$module.'.class.php';
|
|
||||||
$daofile = 'dao_'.$module.'.class.php';
|
|
||||||
$pathroot = '';
|
|
||||||
|
|
||||||
$this->hooks[$i]['type']=$type;
|
|
||||||
|
|
||||||
// Include actions class (controller)
|
|
||||||
//print 'include '.$path.$actionfile."\n";
|
|
||||||
$resaction=dol_include_once($path.$actionfile);
|
|
||||||
|
|
||||||
// Include dataservice class (model)
|
|
||||||
//print 'include '.$path.$daofile."\n";
|
|
||||||
$resdao=dol_include_once($path.$daofile);
|
|
||||||
|
|
||||||
// Instantiate actions class (controller)
|
|
||||||
if ($resaction)
|
|
||||||
{
|
|
||||||
$controlclassname = 'Actions'.ucfirst($module);
|
|
||||||
$objModule = new $controlclassname($this->db);
|
|
||||||
$this->hooks[$i]['modules'][$objModule->module_number] = $objModule;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO storing dao is useless here. It's goal of controller to known which dao to manage
|
|
||||||
if ($resdao)
|
|
||||||
{
|
|
||||||
// Instantiate dataservice class (model)
|
|
||||||
$modelclassname = 'Dao'.ucfirst($module);
|
|
||||||
$this->hooks[$i]['modules'][$objModule->module_number]->object = new $modelclassname($this->db);
|
|
||||||
}
|
|
||||||
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get special code of line
|
* Get special code of line
|
||||||
* @param lineid Id of line
|
* @param lineid Id of line
|
||||||
@ -1989,64 +1929,6 @@ class CommonObject
|
|||||||
include(DOL_DOCUMENT_ROOT.'/core/tpl/originproductline.tpl.php');
|
include(DOL_DOCUMENT_ROOT.'/core/tpl/originproductline.tpl.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function showInputFields($object,$post='',$id=0)
|
|
||||||
{
|
|
||||||
global $conf;
|
|
||||||
|
|
||||||
require_once(DOL_DOCUMENT_ROOT."/core/class/extrafields.class.php");
|
|
||||||
|
|
||||||
$extrafields = new ExtraFields($this->db);
|
|
||||||
|
|
||||||
$elementtype = $object->element;
|
|
||||||
if ($object->element == 'societe') $elementtype = 'company';
|
|
||||||
|
|
||||||
$extralabels=$extrafields->fetch_name_optionals_label($elementtype);
|
|
||||||
|
|
||||||
if ($id)
|
|
||||||
{
|
|
||||||
$res=$object->fetch_optionals($id,$extralabels);
|
|
||||||
if ($res < 0) { dol_print_error($db); exit; }
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach($extrafields->attribute_label as $key=>$label)
|
|
||||||
{
|
|
||||||
$value=(isset($post["options_$key"])?$post["options_$key"]:($id?$object->array_options["options_$key"]:''));
|
|
||||||
print "<tr><td>".$label.'</td><td colspan="3">';
|
|
||||||
print $extrafields->showInputField($key,$value);
|
|
||||||
print '</td></tr>'."\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function showOutputFields($object,$id)
|
|
||||||
{
|
|
||||||
global $conf;
|
|
||||||
|
|
||||||
require_once(DOL_DOCUMENT_ROOT."/core/class/extrafields.class.php");
|
|
||||||
|
|
||||||
$extrafields = new ExtraFields($this->db);
|
|
||||||
|
|
||||||
$elementtype = $object->element;
|
|
||||||
if ($object->element == 'societe') $elementtype = 'company';
|
|
||||||
|
|
||||||
$extralabels=$extrafields->fetch_name_optionals_label($elementtype);
|
|
||||||
|
|
||||||
$res=$object->fetch_optionals($id,$extralabels);
|
|
||||||
if ($res < 0) { dol_print_error($db); exit; }
|
|
||||||
|
|
||||||
foreach($extrafields->attribute_label as $key=>$label)
|
|
||||||
{
|
|
||||||
$value=$object->array_options["options_$key"];
|
|
||||||
print "<tr><td>".$label.'</td><td colspan="3">';
|
|
||||||
print $extrafields->showOutputField($key,$value);
|
|
||||||
print "</td></tr>\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add/Update extra fields
|
* Add/Update extra fields
|
||||||
@ -2054,7 +1936,7 @@ class CommonObject
|
|||||||
*/
|
*/
|
||||||
function insertExtraFields($object)
|
function insertExtraFields($object)
|
||||||
{
|
{
|
||||||
if (sizeof($object->array_options) > 0)
|
if (sizeof($object->array_options) > 0)
|
||||||
{
|
{
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
|
|||||||
187
htdocs/core/class/hookmanager.class.php
Executable file
187
htdocs/core/class/hookmanager.class.php
Executable file
@ -0,0 +1,187 @@
|
|||||||
|
<?php
|
||||||
|
/* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
|
||||||
|
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file htdocs/core/class/hookmanager.class.php
|
||||||
|
* \ingroup core
|
||||||
|
* \brief File of class to manage hooks
|
||||||
|
* \version $Id: hookmanager.class.php,v 1.1 2011/08/10 00:50:16 eldy Exp $
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \class HookManager
|
||||||
|
* \brief Class to manage hooks
|
||||||
|
*/
|
||||||
|
|
||||||
|
class HookManager
|
||||||
|
{
|
||||||
|
var $db;
|
||||||
|
|
||||||
|
var $linkedObjectBlock;
|
||||||
|
var $objectid;
|
||||||
|
|
||||||
|
// Array with instantiated classes
|
||||||
|
var $hooks=array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructeur de la classe
|
||||||
|
* @param DB Handler acces base de donnees
|
||||||
|
*/
|
||||||
|
function HookManager($DB)
|
||||||
|
{
|
||||||
|
$this->db = $DB;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init array this->hooks with instantiated controler and/or dao
|
||||||
|
* @param arraytype Array list of hooked tab/features. For example: thirdpartytab, ...
|
||||||
|
* @return int Always 1
|
||||||
|
*/
|
||||||
|
function callHooks($arraytype)
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
// Test if ther is hooks to manage
|
||||||
|
if (! is_array($conf->hooks_modules) || empty($conf->hooks_modules)) return;
|
||||||
|
|
||||||
|
// For backward compatibility
|
||||||
|
if (! is_array($arraytype)) $arraytype=array($arraytype);
|
||||||
|
|
||||||
|
$i=0;
|
||||||
|
foreach($conf->hooks_modules as $module => $hooks)
|
||||||
|
{
|
||||||
|
if ($conf->$module->enabled)
|
||||||
|
{
|
||||||
|
foreach($arraytype as $type)
|
||||||
|
{
|
||||||
|
if (in_array($type,$hooks))
|
||||||
|
{
|
||||||
|
$path = $module;
|
||||||
|
if ($module == 'adherent') $path = 'adherents';
|
||||||
|
$path = '/'.$path.'/class/';
|
||||||
|
$actionfile = 'actions_'.$module.'.class.php';
|
||||||
|
//$daofile = 'dao_'.$module.'.class.php';
|
||||||
|
$pathroot = '';
|
||||||
|
|
||||||
|
$this->hooks[$i]['type']=$type;
|
||||||
|
|
||||||
|
// Include actions class overwriting hooks
|
||||||
|
$resaction=dol_include_once($path.$actionfile);
|
||||||
|
if ($resaction)
|
||||||
|
{
|
||||||
|
$controlclassname = 'Actions'.ucfirst($module);
|
||||||
|
$objModule = new $controlclassname($this->db);
|
||||||
|
$this->hooks[$i]['modules'][$objModule->module_number] = $objModule;
|
||||||
|
}
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute hooks (if the were initialized) for the given method
|
||||||
|
* @param method Method name to hook ('doActions', 'printSearchForm', ...)
|
||||||
|
* @param action Action code ('create', 'edit', 'view', 'add', 'update', 'delete'...)
|
||||||
|
* @param object Object to use hooks on
|
||||||
|
* @param socid Soc Id.
|
||||||
|
* @param string For doActions,showInputField,showOutputField: Return 0 if we want to keep doing standard actions, >0 if if want to stop standard actions, >0 means KO.
|
||||||
|
* For printSearchForm,printLeftBlock: Return HTML string.
|
||||||
|
* $this->error or this->errors are also defined with hooks errors.
|
||||||
|
*/
|
||||||
|
function executeHooks($method, &$action='', &$object='', $id='')
|
||||||
|
{
|
||||||
|
if (! is_array($this->hooks) || empty($this->hooks)) return '';
|
||||||
|
|
||||||
|
// Loop on each hook
|
||||||
|
$resaction=0; $resprint='';
|
||||||
|
foreach($this->hooks as $hook)
|
||||||
|
{
|
||||||
|
if (! empty($this->hook['modules']))
|
||||||
|
{
|
||||||
|
foreach($this->hook['modules'] as $module)
|
||||||
|
{
|
||||||
|
// Hooks that return int
|
||||||
|
if ($method == 'doActions' && method_exists($module,$method))
|
||||||
|
{
|
||||||
|
$restmp+=$module->doActions($object, $action, $id); // action can be changed by method (to go back to other action for example), socid can be changed/set by method (during creation for example)
|
||||||
|
if ($restmp < 0 || ! empty($module->error) || (! empty($module->errors) && sizeof($module->errors) > 0))
|
||||||
|
{
|
||||||
|
$this->error=$module->error; $this->errors=$module->errors;
|
||||||
|
if ($action=='add') $action='create'; // TODO this change must be inside the doActions
|
||||||
|
if ($action=='update') $action='edit'; // TODO this change must be inside the doActions
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$resaction+=$restmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($method == 'showInputFields' && method_exists($module,$method))
|
||||||
|
{
|
||||||
|
$restmp+=$module->showInputFields($object, $action, $id); // action can be changed by method (to go back to other action for example), socid can be changed/set by method (during creation for example)
|
||||||
|
if ($restmp < 0 || ! empty($module->error) || (! empty($module->errors) && sizeof($module->errors) > 0))
|
||||||
|
{
|
||||||
|
$this->error=$module->error; $this->errors=$module->errors;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$resaction+=$restmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($method == 'showOutputFields' && method_exists($module,$method))
|
||||||
|
{
|
||||||
|
$restmp+=$module->showOutputFields($object, $id); // action can be changed by method (to go back to other action for example), socid can be changed/set by method (during creation for example)
|
||||||
|
if ($restmp < 0 || ! empty($module->error) || (! empty($module->errors) && sizeof($module->errors) > 0))
|
||||||
|
{
|
||||||
|
$this->error=$module->error; $this->errors=$module->errors;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$resaction+=$restmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Hooks that return a string
|
||||||
|
if ($method == 'printSearchForm' && method_exists($module,$method))
|
||||||
|
{
|
||||||
|
$resprint.='<!-- Begin search form hook area -->'."\n";
|
||||||
|
$resprint.=$module->printSearchForm($object, $action, $id); // action can be changed by method (to go back to other action for example), socid can be changed/set by method (during creation for example)
|
||||||
|
$resprint.="\n".'<!-- End of search form hook area -->'."\n";
|
||||||
|
}
|
||||||
|
if ($method == 'printLeftBlock' && method_exists($module,$method))
|
||||||
|
{
|
||||||
|
$resprint.='<!-- Begin left block hook area -->'."\n";
|
||||||
|
$resprint.=$module->printLeftBlock($object, $action, $id); // action can be changed by method (to go back to other action for example), socid can be changed/set by method (during creation for example)
|
||||||
|
$resprint.="\n".'<!-- End of left block hook area -->'."\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($method == 'doActions' || $method == 'showInputField' || $method == 'showOutputFields') return $resaction;
|
||||||
|
return $resprint;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@ -28,7 +28,7 @@
|
|||||||
* \file htdocs/includes/modules/modAdherent.class.php
|
* \file htdocs/includes/modules/modAdherent.class.php
|
||||||
* \ingroup member
|
* \ingroup member
|
||||||
* \brief File descriptor or module Member
|
* \brief File descriptor or module Member
|
||||||
* \version $Id: modAdherent.class.php,v 1.88 2011/08/09 17:59:51 hregis Exp $
|
* \version $Id: modAdherent.class.php,v 1.89 2011/08/10 00:50:18 eldy Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
include_once(DOL_DOCUMENT_ROOT ."/includes/modules/DolibarrModules.class.php");
|
include_once(DOL_DOCUMENT_ROOT ."/includes/modules/DolibarrModules.class.php");
|
||||||
@ -74,7 +74,6 @@ class modAdherent extends DolibarrModules
|
|||||||
// Constantes
|
// Constantes
|
||||||
//-----------
|
//-----------
|
||||||
$this->const = array();
|
$this->const = array();
|
||||||
$this->const[0] = array("MAIN_MODULE_ADHERENT_HOOKS","chaine",'member_extrafields','',0);
|
|
||||||
$this->const[2] = array("MAIN_SEARCHFORM_ADHERENT","yesno","1","Show form for quick member search");
|
$this->const[2] = array("MAIN_SEARCHFORM_ADHERENT","yesno","1","Show form for quick member search");
|
||||||
$this->const[3] = array("ADHERENT_MAIL_RESIL","texte","Votre adhésion vient d'être résiliée.\r\nNous espérons vous revoir très bientôt","Mail de résiliation");
|
$this->const[3] = array("ADHERENT_MAIL_RESIL","texte","Votre adhésion vient d'être résiliée.\r\nNous espérons vous revoir très bientôt","Mail de résiliation");
|
||||||
$this->const[4] = array("ADHERENT_MAIL_VALID","texte","Votre adhésion vient d'être validée. \r\nVoici le rappel de vos coordonnées (toute information erronée entrainera la non validation de votre inscription) :\r\n\r\n%INFOS%\r\n\r\n","Mail de validation");
|
$this->const[4] = array("ADHERENT_MAIL_VALID","texte","Votre adhésion vient d'être validée. \r\nVoici le rappel de vos coordonnées (toute information erronée entrainera la non validation de votre inscription) :\r\n\r\n%INFOS%\r\n\r\n","Mail de validation");
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
/**
|
/**
|
||||||
* \defgroup societe Module societe
|
* \defgroup societe Module societe
|
||||||
* \brief Module to manage third parties (customers, prospects)
|
* \brief Module to manage third parties (customers, prospects)
|
||||||
* \version $Id: modSociete.class.php,v 1.121 2011/08/09 17:59:50 hregis Exp $
|
* \version $Id: modSociete.class.php,v 1.122 2011/08/10 00:50:18 eldy Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -106,15 +106,6 @@ class modSociete extends DolibarrModules
|
|||||||
$this->const[$r][4] = 0;
|
$this->const[$r][4] = 0;
|
||||||
$r++;
|
$r++;
|
||||||
|
|
||||||
$this->const[$r][0] = "MAIN_MODULE_SOCIETE_HOOKS";
|
|
||||||
$this->const[$r][1] = "chaine";
|
|
||||||
$this->const[$r][2] = "thirdparty_extrafields";
|
|
||||||
$this->const[$r][3] = "";
|
|
||||||
$this->const[$r][4] = 0;
|
|
||||||
$this->const[$r][4] = 'current';
|
|
||||||
$this->const[$r][4] = 1;
|
|
||||||
$r++;
|
|
||||||
|
|
||||||
// Boxes
|
// Boxes
|
||||||
$this->boxes = array();
|
$this->boxes = array();
|
||||||
$r=0;
|
$r=0;
|
||||||
|
|||||||
@ -25,7 +25,7 @@
|
|||||||
* \file htdocs/main.inc.php
|
* \file htdocs/main.inc.php
|
||||||
* \ingroup core
|
* \ingroup core
|
||||||
* \brief File that defines environment for Dolibarr pages only (variables not required by scripts)
|
* \brief File that defines environment for Dolibarr pages only (variables not required by scripts)
|
||||||
* \version $Id: main.inc.php,v 1.756 2011/07/31 23:19:05 eldy Exp $
|
* \version $Id: main.inc.php,v 1.757 2011/08/10 00:50:19 eldy Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ini_set('memory_limit', '64M'); // This may be useless if memory is hard limited by your PHP
|
@ini_set('memory_limit', '64M'); // This may be useless if memory is hard limited by your PHP
|
||||||
@ -1311,12 +1311,9 @@ function left_menu($menu_array_before, $helppagename='', $moresearchform='', $me
|
|||||||
print "\n";
|
print "\n";
|
||||||
|
|
||||||
// Instantiate hooks of thirdparty module
|
// Instantiate hooks of thirdparty module
|
||||||
if (is_array($conf->hooks_modules) && !empty($conf->hooks_modules))
|
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
|
||||||
{
|
$hookmanager=new HookManager($db);
|
||||||
require_once(DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php');
|
$hookmanager->callHooks(array('printSearchform','leftblock'));
|
||||||
$object = new CommonObject($db);
|
|
||||||
$object->callHooks(array('searchform','leftblock'));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Define $searchform
|
// Define $searchform
|
||||||
if ($conf->societe->enabled && $conf->global->MAIN_SEARCHFORM_SOCIETE && $user->rights->societe->lire)
|
if ($conf->societe->enabled && $conf->global->MAIN_SEARCHFORM_SOCIETE && $user->rights->societe->lire)
|
||||||
@ -1348,24 +1345,8 @@ function left_menu($menu_array_before, $helppagename='', $moresearchform='', $me
|
|||||||
img_object('','user').' '.$langs->trans("Members"), 'member', 'sall');
|
img_object('','user').' '.$langs->trans("Members"), 'member', 'sall');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search form hook for external modules
|
// Execute hook printSearchForm
|
||||||
if (! empty($object->hooks))
|
$searchform.=$hookmanager->executeHooks('printSearchForm'); // Note that $action and $object may have been modified by some hooks
|
||||||
{
|
|
||||||
$searchform.='<!-- Begin search form hook area -->'."\n";
|
|
||||||
|
|
||||||
foreach($object->hooks as $hook)
|
|
||||||
{
|
|
||||||
if ($hook['type'] == 'searchform' && ! empty($hook['modules']))
|
|
||||||
{
|
|
||||||
foreach($hook['modules'] as $module)
|
|
||||||
{
|
|
||||||
if (method_exists($module,'printSearchForm')) $searchform.=$module->printSearchForm();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$searchform.="\n".'<!-- End of search form hook area -->'."\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Define $bookmarks
|
// Define $bookmarks
|
||||||
if ($conf->bookmark->enabled && $user->rights->bookmark->lire)
|
if ($conf->bookmark->enabled && $user->rights->bookmark->lire)
|
||||||
@ -1475,24 +1456,9 @@ function left_menu($menu_array_before, $helppagename='', $moresearchform='', $me
|
|||||||
|
|
||||||
print "\n";
|
print "\n";
|
||||||
|
|
||||||
// Left block hook for external modules
|
// Execute hook printLeftBlock
|
||||||
if (! empty($object->hooks))
|
$leftblock.=$hookmanager->executeHooks('printLeftBlock'); // Note that $action and $object may have been modified by some hooks
|
||||||
{
|
print $leftblock;
|
||||||
print '<!-- Begin left block hook area -->'."\n";
|
|
||||||
|
|
||||||
foreach($object->hooks as $hook)
|
|
||||||
{
|
|
||||||
if ($hook['type'] == 'leftblock' && ! empty($hook['modules']))
|
|
||||||
{
|
|
||||||
foreach($hook['modules'] as $module)
|
|
||||||
{
|
|
||||||
if (method_exists($module,'printLeftBlock')) $module->printLeftBlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print "\n".'<!-- End of left block hook area -->'."\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($conf->use_javascript_ajax && $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) print '</div> <!-- End left layout -->'."\n";
|
if ($conf->use_javascript_ajax && $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) print '</div> <!-- End left layout -->'."\n";
|
||||||
else print '</td>';
|
else print '</td>';
|
||||||
|
|||||||
@ -1,37 +0,0 @@
|
|||||||
<?php
|
|
||||||
/* Copyright (C) 2011 Regis Houssin <regis@dolibarr.fr>
|
|
||||||
*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file htdocs/societe/class/actions_societe.class.php
|
|
||||||
* \ingroup societe
|
|
||||||
* \brief File for third party class
|
|
||||||
* \version $Id: actions_societe.class.php,v 1.1 2011/08/09 09:13:08 hregis Exp $
|
|
||||||
*/
|
|
||||||
require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \class ActionsSociete
|
|
||||||
* \brief Class to manage third parties objects (customers, suppliers, prospects...)
|
|
||||||
*/
|
|
||||||
class ActionsSociete extends Societe
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
|
||||||
@ -26,7 +26,7 @@
|
|||||||
* \file htdocs/societe/class/societe.class.php
|
* \file htdocs/societe/class/societe.class.php
|
||||||
* \ingroup societe
|
* \ingroup societe
|
||||||
* \brief File for third party class
|
* \brief File for third party class
|
||||||
* \version $Id: societe.class.php,v 1.93 2011/08/09 17:59:50 hregis Exp $
|
* \version $Id: societe.class.php,v 1.94 2011/08/10 00:50:16 eldy Exp $
|
||||||
*/
|
*/
|
||||||
require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
|
||||||
|
|
||||||
@ -533,32 +533,20 @@ class Societe extends CommonObject
|
|||||||
// Si le fournisseur est classe on l'ajoute
|
// Si le fournisseur est classe on l'ajoute
|
||||||
$this->AddFournisseurInCategory($this->fournisseur_categorie);
|
$this->AddFournisseurInCategory($this->fournisseur_categorie);
|
||||||
|
|
||||||
/*
|
// Actions on extra fields (by external module or standard code)
|
||||||
$result=$this->insertExtraFields();
|
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
|
||||||
if ($result < 0)
|
$hookmanager=new HookManager($db);
|
||||||
|
$hookmanager->callHooks(array('thirdparty_extrafields'));
|
||||||
|
$reshook=$hookmanager->executeHooks('insertExtraFields',$action,$this,$socid); // Note that $action and $object may have been modified by some hooks
|
||||||
|
if (empty($reshook))
|
||||||
{
|
{
|
||||||
$error++;
|
$result=$this->insertExtraFields($this);
|
||||||
|
if ($result < 0)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*/
|
else if ($reshook < 0) $error++;
|
||||||
|
|
||||||
// Hook for external modules
|
|
||||||
if (! empty($this->hooks))
|
|
||||||
{
|
|
||||||
foreach($this->hooks as $hook)
|
|
||||||
{
|
|
||||||
if ($hook['type'] == 'thirdparty_extrafields' && ! empty($hook['modules']))
|
|
||||||
{
|
|
||||||
foreach($hook['modules'] as $module)
|
|
||||||
{
|
|
||||||
if (method_exists($module,'insertExtraFields'))
|
|
||||||
{
|
|
||||||
$result=$module->insertExtraFields($this);
|
|
||||||
if ($result < 0) $error++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $error && $call_trigger)
|
if (! $error && $call_trigger)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -25,7 +25,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.129 2011/08/09 17:59:52 hregis Exp $
|
* \version $Id: soc.php,v 1.130 2011/08/10 00:50:19 eldy Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require("../main.inc.php");
|
require("../main.inc.php");
|
||||||
@ -35,7 +35,7 @@ require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
|
|||||||
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formadmin.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formadmin.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formcompany.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formcompany.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
|
||||||
//require_once(DOL_DOCUMENT_ROOT."/core/class/extrafields.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/core/class/extrafields.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php");
|
||||||
if ($conf->adherent->enabled) require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
|
if ($conf->adherent->enabled) require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ $action = GETPOST('action');
|
|||||||
$confirm = GETPOST('confirm');
|
$confirm = GETPOST('confirm');
|
||||||
|
|
||||||
$object = new Societe($db);
|
$object = new Societe($db);
|
||||||
//$extrafields = new ExtraFields($db);
|
$extrafields = new ExtraFields($db);
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
$socid = GETPOST("socid");
|
$socid = GETPOST("socid");
|
||||||
@ -75,11 +75,10 @@ else
|
|||||||
$result = restrictedArea($user, 'societe', $socid);
|
$result = restrictedArea($user, 'societe', $socid);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Instantiate hooks of thirdparty module. Note that conf->hooks_modules contains array array
|
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
||||||
if (is_array($conf->hooks_modules) && !empty($conf->hooks_modules))
|
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
|
||||||
{
|
$hookmanager=new HookManager($db);
|
||||||
$object->callHooks(array('thirdpartycard','thirdparty_extrafields'));
|
$hookmanager->callHooks(array('thirdpartycard','thirdparty_extrafields'));
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -87,35 +86,8 @@ if (is_array($conf->hooks_modules) && !empty($conf->hooks_modules))
|
|||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$reshook=0;
|
$reshook=$hookmanager->executeHooks('doActions',$action,$object,$socid); // Note that $action and $object may have been modified by some hooks
|
||||||
|
|
||||||
// Hook of actions. After that, reshook is 0 if we need to process standard actions, >0 otherwise.
|
|
||||||
if (! empty($object->hooks))
|
|
||||||
{
|
|
||||||
foreach($object->hooks as $hook)
|
|
||||||
{
|
|
||||||
if (! empty($hook['modules']))
|
|
||||||
{
|
|
||||||
foreach($hook['modules'] as $module)
|
|
||||||
{
|
|
||||||
if (method_exists($module,'doActions'))
|
|
||||||
{
|
|
||||||
$resaction+=$module->doActions($object,$action,$socid); // object is deprecated, action can be changed by method (to go back to other action for example), socid can be changed/set by method (during creation for example)
|
|
||||||
if ($resaction < 0 || ! empty($module->error) || (! empty($module->errors) && sizeof($module->errors) > 0))
|
|
||||||
{
|
|
||||||
$error=$module->error; $errors=$module->errors;
|
|
||||||
if ($action=='add') $action='create'; // TODO this chnage must be inside the doActions
|
|
||||||
if ($action=='update') $action='edit'; // TODO this chnage must be inside the doActions
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$reshook+=$resaction;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------- start deprecated. Use hook to hook actions.
|
// ---------- start deprecated. Use hook to hook actions.
|
||||||
// If canvas actions are defined, because on url, or because contact was created with canvas feature on, we use the canvas feature.
|
// If canvas actions are defined, because on url, or because contact was created with canvas feature on, we use the canvas feature.
|
||||||
@ -133,6 +105,7 @@ if (method_exists($objcanvas->control,'doActions'))
|
|||||||
}
|
}
|
||||||
// ---------- end deprecated.
|
// ---------- end deprecated.
|
||||||
|
|
||||||
|
|
||||||
if (empty($reshook))
|
if (empty($reshook))
|
||||||
{
|
{
|
||||||
if ($_POST["getcustomercode"])
|
if ($_POST["getcustomercode"])
|
||||||
@ -502,7 +475,7 @@ if (empty($reshook))
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// fetch optionals attributes and labels
|
// fetch optionals attributes and labels
|
||||||
//$extralabels=$extrafields->fetch_name_optionals_label('company');
|
$extralabels=$extrafields->fetch_name_optionals_label('company');
|
||||||
|
|
||||||
$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
|
$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
|
||||||
llxHeader('',$langs->trans("ThirdParty"),$help_url);
|
llxHeader('',$langs->trans("ThirdParty"),$help_url);
|
||||||
@ -1025,33 +998,17 @@ else
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Other attributes
|
// Other attributes
|
||||||
/*
|
$reshook=$hookmanager->executeHooks('showInputFields',$action,$object); // Note that $action and $object may have been modified by hook
|
||||||
foreach($extrafields->attribute_label as $key=>$label)
|
if (empty($reshook))
|
||||||
{
|
{
|
||||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:'');
|
foreach($extrafields->attribute_label as $key=>$label)
|
||||||
print "<tr><td>".$label.'</td><td colspan="3">';
|
{
|
||||||
print $extrafields->showInputField($key,$value);
|
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:'');
|
||||||
print '</td></tr>'."\n";
|
print "<tr><td>".$label.'</td><td colspan="3">';
|
||||||
|
print $extrafields->showInputField($key,$value);
|
||||||
|
print '</td></tr>'."\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
// Hook for external modules
|
|
||||||
if (! empty($object->hooks))
|
|
||||||
{
|
|
||||||
foreach($object->hooks as $hook)
|
|
||||||
{
|
|
||||||
if ($hook['type'] == 'thirdparty_extrafields' && ! empty($hook['modules']))
|
|
||||||
{
|
|
||||||
foreach($hook['modules'] as $module)
|
|
||||||
{
|
|
||||||
if (method_exists($module,'showInputFields'))
|
|
||||||
{
|
|
||||||
$module->showInputFields($object,$_POST);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ajout du logo
|
// Ajout du logo
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
@ -1077,10 +1034,10 @@ else
|
|||||||
|
|
||||||
if ($socid)
|
if ($socid)
|
||||||
{
|
{
|
||||||
//$object = new Societe($db);
|
$object = new Societe($db);
|
||||||
$res=$object->fetch($socid);
|
$res=$object->fetch($socid);
|
||||||
if ($res < 0) { dol_print_error($db,$object->error); exit; }
|
if ($res < 0) { dol_print_error($db,$object->error); exit; }
|
||||||
//$res=$object->fetch_optionals($socid,$extralabels);
|
$res=$object->fetch_optionals($socid,$extralabels);
|
||||||
//if ($res < 0) { dol_print_error($db); exit; }
|
//if ($res < 0) { dol_print_error($db); exit; }
|
||||||
|
|
||||||
// Load object modCodeTiers
|
// Load object modCodeTiers
|
||||||
@ -1468,33 +1425,17 @@ else
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Other attributes
|
// Other attributes
|
||||||
/*
|
$reshook=$hookmanager->executeHooks('showInputFields',$action,$object); // Note that $action and $object may have been modified by hook
|
||||||
foreach($extrafields->attribute_label as $key=>$label)
|
if (empty($reshook))
|
||||||
{
|
{
|
||||||
$value=(isset($_POST["options_$key"])?$_POST["options_$key"]:$object->array_options["options_$key"]);
|
foreach($extrafields->attribute_label as $key=>$label)
|
||||||
print "<tr><td>".$label."</td><td colspan=\"3\">";
|
{
|
||||||
print $extrafields->showInputField($key,$value);
|
$value=(isset($_POST["options_$key"])?$_POST["options_$key"]:$object->array_options["options_$key"]);
|
||||||
print "</td></tr>\n";
|
print "<tr><td>".$label."</td><td colspan=\"3\">";
|
||||||
|
print $extrafields->showInputField($key,$value);
|
||||||
|
print "</td></tr>\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
// Hook for external modules
|
|
||||||
if (! empty($object->hooks))
|
|
||||||
{
|
|
||||||
foreach($object->hooks as $hook)
|
|
||||||
{
|
|
||||||
if ($hook['type'] == 'thirdparty_extrafields' && ! empty($hook['modules']))
|
|
||||||
{
|
|
||||||
foreach($hook['modules'] as $module)
|
|
||||||
{
|
|
||||||
if (method_exists($module,'showInputFields'))
|
|
||||||
{
|
|
||||||
$module->showInputFields($object,$_POST,$socid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Logo
|
// Logo
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
@ -1531,10 +1472,10 @@ else
|
|||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
//$object = new Societe($db);
|
$object = new Societe($db);
|
||||||
$res=$object->fetch($socid);
|
$res=$object->fetch($socid);
|
||||||
if ($res < 0) { dol_print_error($db,$object->error); exit; }
|
if ($res < 0) { dol_print_error($db,$object->error); exit; }
|
||||||
//$res=$object->fetch_optionals($socid,$extralabels);
|
$res=$object->fetch_optionals($socid,$extralabels);
|
||||||
//if ($res < 0) { dol_print_error($db); exit; }
|
//if ($res < 0) { dol_print_error($db); exit; }
|
||||||
|
|
||||||
|
|
||||||
@ -1824,33 +1765,17 @@ else
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Other attributes
|
// Other attributes
|
||||||
/*
|
$reshook=$hookmanager->executeHooks('showOutputFields',$action,$object,$socid); // Note that $action and $object may have been modified by hook
|
||||||
foreach($extrafields->attribute_label as $key=>$label)
|
if (empty($reshook))
|
||||||
{
|
{
|
||||||
$value=$object->array_options["options_$key"];
|
foreach($extrafields->attribute_label as $key=>$label)
|
||||||
print "<tr><td>".$label.'</td><td colspan="3">';
|
{
|
||||||
print $extrafields->showOutputField($key,$value);
|
$value=$object->array_options["options_$key"];
|
||||||
print "</td></tr>\n";
|
print "<tr><td>".$label.'</td><td colspan="3">';
|
||||||
|
print $extrafields->showOutputField($key,$value);
|
||||||
|
print "</td></tr>\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
// Hook for external modules
|
|
||||||
if (! empty($object->hooks))
|
|
||||||
{
|
|
||||||
foreach($object->hooks as $hook)
|
|
||||||
{
|
|
||||||
if ($hook['type'] == 'thirdparty_extrafields' && ! empty($hook['modules']))
|
|
||||||
{
|
|
||||||
foreach($hook['modules'] as $module)
|
|
||||||
{
|
|
||||||
if (method_exists($module,'showOutputFields'))
|
|
||||||
{
|
|
||||||
$module->showOutputFields($object,$socid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ban
|
// Ban
|
||||||
if (empty($conf->global->SOCIETE_DISABLE_BANKACCOUNT))
|
if (empty($conf->global->SOCIETE_DISABLE_BANKACCOUNT))
|
||||||
@ -2029,5 +1954,5 @@ else
|
|||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
llxFooter('$Date: 2011/08/09 17:59:52 $ - $Revision: 1.129 $');
|
llxFooter('$Date: 2011/08/10 00:50:19 $ - $Revision: 1.130 $');
|
||||||
?>
|
?>
|
||||||
Loading…
Reference in New Issue
Block a user