Fix: A method of a business class should not accept itself as a parameter.
This commit is contained in:
parent
e326b78e5e
commit
c7eea92e83
@ -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.157 2011/08/20 15:11:31 eldy Exp $
|
* \version $Id: commonobject.class.php,v 1.158 2011/08/20 15:30:38 eldy Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@ -1931,31 +1931,30 @@ class CommonObject
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Add/Update extra fields
|
* Add/Update extra fields
|
||||||
* TODO Use also type of field to do manage date fields
|
|
||||||
*/
|
*/
|
||||||
function insertExtraFields($object)
|
function insertExtraFields()
|
||||||
{
|
{
|
||||||
if (sizeof($object->array_options) > 0)
|
if (sizeof($this->array_options) > 0)
|
||||||
{
|
{
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".$object->id;
|
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".$this->id;
|
||||||
dol_syslog(get_class($object)."::insertExtraFields delete sql=".$sql_del);
|
dol_syslog(get_class($this)."::insertExtraFields delete sql=".$sql_del);
|
||||||
$this->db->query($sql_del);
|
$this->db->query($sql_del);
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX.$object->table_element."_extrafields (fk_object";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."_extrafields (fk_object";
|
||||||
foreach($object->array_options as $key => $value)
|
foreach($this->array_options as $key => $value)
|
||||||
{
|
{
|
||||||
// Add field of attribut
|
// Add field of attribut
|
||||||
$sql.=",".substr($key,8); // Remove 'options_' prefix
|
$sql.=",".substr($key,8); // Remove 'options_' prefix
|
||||||
}
|
}
|
||||||
$sql .= ") VALUES (".$object->id;
|
$sql .= ") VALUES (".$this->id;
|
||||||
foreach($object->array_options as $key => $value)
|
foreach($this->array_options as $key => $value)
|
||||||
{
|
{
|
||||||
// Add field o fattribut
|
// Add field o fattribut
|
||||||
if ($object->array_options[$key] != '')
|
if ($this->array_options[$key] != '')
|
||||||
{
|
{
|
||||||
$sql.=",'".$object->array_options[$key]."'";
|
$sql.=",'".$this->array_options[$key]."'";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1964,12 +1963,12 @@ class CommonObject
|
|||||||
}
|
}
|
||||||
$sql.=")";
|
$sql.=")";
|
||||||
|
|
||||||
dol_syslog(get_class($object)."::insertExtraFields insert sql=".$sql);
|
dol_syslog(get_class($this)."::insertExtraFields insert sql=".$sql);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if (! $resql)
|
if (! $resql)
|
||||||
{
|
{
|
||||||
$this->error=$this->db->lasterror();
|
$this->error=$this->db->lasterror();
|
||||||
dol_syslog(get_class($object)."::update ".$this->error,LOG_ERR);
|
dol_syslog(get_class($this)."::update ".$this->error,LOG_ERR);
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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.100 2011/08/18 22:25:46 eldy Exp $
|
* \version $Id: societe.class.php,v 1.101 2011/08/20 15:30:39 eldy Exp $
|
||||||
*/
|
*/
|
||||||
require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
|
||||||
|
|
||||||
@ -544,7 +544,7 @@ class Societe extends CommonObject
|
|||||||
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
if (empty($reshook))
|
if (empty($reshook))
|
||||||
{
|
{
|
||||||
$result=$this->insertExtraFields($this);
|
$result=$this->insertExtraFields();
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user