return comment

This commit is contained in:
Frédéric FRANCE
2018-08-14 13:14:55 +02:00
parent a0a6afc224
commit d25fa61998
4 changed files with 25 additions and 11 deletions

View File

@@ -1,6 +1,6 @@
<?php
/* EXPERIMENTAL
*
*
* Copyright (C) 2016 ATM Consulting <support@atm-consulting.fr>
*
* This program is free software; you can redistribute it and/or modify
@@ -22,7 +22,7 @@
* \ingroup core
* \brief File of class to manage all object. Might be replace or merge into commonobject
*/
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
class CoreObject extends CommonObject
@@ -54,7 +54,7 @@ class CoreObject extends CommonObject
$this->id = 0;
$this->datec = 0;
$this->tms = 0;
if (!empty($this->fields))
{
foreach ($this->fields as $field=>$info)
@@ -68,14 +68,14 @@ class CoreObject extends CommonObject
$this->to_delete=false;
$this->is_clone=false;
return true;
}
else
{
return false;
}
}
/**
@@ -110,7 +110,7 @@ class CoreObject extends CommonObject
if($res>0) {
if ($loadChild) $this->fetchChild();
}
return $res;
}
@@ -133,14 +133,14 @@ class CoreObject extends CommonObject
if($object->{$key} === $id) return $k;
}
}
$k = count($this->{$tabName});
$className = ucfirst($tabName);
$this->{$tabName}[$k] = new $className($this->db);
if($id>0 && $key==='id' && $try_to_load)
{
$this->{$tabName}[$k]->fetch($id);
$this->{$tabName}[$k]->fetch($id);
}
return $k;
@@ -171,6 +171,8 @@ class CoreObject extends CommonObject
/**
* Function to fetch children objects
*
* @return void
*/
public function fetchChild()
{
@@ -207,6 +209,7 @@ class CoreObject extends CommonObject
* Function to update children data
*
* @param User $user user object
* @return void
*/
public function saveChild(User &$user)
{
@@ -220,7 +223,7 @@ class CoreObject extends CommonObject
foreach($this->{$className} as $i => &$object)
{
$object->{$this->fk_element} = $this->id;
$object->update($user);
if($this->unsetChildDeleted && isset($object->to_delete) && $object->to_delete==true) unset($this->{$className}[$i]);
}