Fix deletion of website page
This commit is contained in:
parent
e31e889595
commit
7061e9b4cb
@ -181,7 +181,7 @@ class MyObject extends CommonObject
|
|||||||
//public $table_element_line = 'mymodule_myobjectline';
|
//public $table_element_line = 'mymodule_myobjectline';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int Field with ID of parent key if this field has a parent
|
* @var int Field with ID of parent key if this object has a parent
|
||||||
*/
|
*/
|
||||||
//public $fk_element = 'fk_myobject';
|
//public $fk_element = 'fk_myobject';
|
||||||
|
|
||||||
@ -193,12 +193,12 @@ class MyObject extends CommonObject
|
|||||||
/**
|
/**
|
||||||
* @var array List of child tables. To test if we can delete object.
|
* @var array List of child tables. To test if we can delete object.
|
||||||
*/
|
*/
|
||||||
//protected $childtables=array();
|
//protected $childtables = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array List of child tables. To know object to delete on cascade.
|
* @var array List of child tables. To know object to delete on cascade.
|
||||||
*/
|
*/
|
||||||
//protected $childtablesoncascade=array('mymodule_myobjectdet');
|
//protected $childtablesoncascade = array('mymodule_myobjectdet');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var MyObjectLine[] Array of subtable lines
|
* @var MyObjectLine[] Array of subtable lines
|
||||||
|
|||||||
@ -49,6 +49,7 @@ class WebsitePage extends CommonObject
|
|||||||
*/
|
*/
|
||||||
public $picto = 'file-code';
|
public $picto = 'file-code';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int ID
|
* @var int ID
|
||||||
*/
|
*/
|
||||||
@ -164,6 +165,35 @@ class WebsitePage extends CommonObject
|
|||||||
// END MODULEBUILDER PROPERTIES
|
// END MODULEBUILDER PROPERTIES
|
||||||
|
|
||||||
|
|
||||||
|
// If this object has a subtable with lines
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int Name of subtable line
|
||||||
|
*/
|
||||||
|
//public $table_element_line = 'mymodule_myobjectline';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int Field with ID of parent key if this object has a parent
|
||||||
|
*/
|
||||||
|
public $fk_element = 'fk_website';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int Name of subtable class that manage subtable lines
|
||||||
|
*/
|
||||||
|
//public $class_element_line = 'MyObjectline';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array List of child tables. To test if we can delete object.
|
||||||
|
*/
|
||||||
|
//protected $childtables=array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array List of child tables. To know object to delete on cascade.
|
||||||
|
*/
|
||||||
|
protected $childtablesoncascade = array('categorie_website_page');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
@ -523,9 +553,33 @@ class WebsitePage extends CommonObject
|
|||||||
*/
|
*/
|
||||||
public function delete(User $user, $notrigger = false)
|
public function delete(User $user, $notrigger = false)
|
||||||
{
|
{
|
||||||
$result = $this->deleteCommon($user, $trigger);
|
$error = 0;
|
||||||
|
|
||||||
if ($result > 0)
|
// Delete all child tables
|
||||||
|
if (!$error) {
|
||||||
|
foreach ($this->childtablesoncascade as $table)
|
||||||
|
{
|
||||||
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX.$table;
|
||||||
|
$sql .= " WHERE fk_website_page = ".(int) $this->id;
|
||||||
|
|
||||||
|
$result = $this->db->query($sql);
|
||||||
|
if (!$result) {
|
||||||
|
$error++;
|
||||||
|
$this->errors[] = $this->db->lasterror();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$error) {
|
||||||
|
$result = $this->deleteCommon($user, $trigger);
|
||||||
|
if ($result > 0)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$error)
|
||||||
{
|
{
|
||||||
$websiteobj = new Website($this->db);
|
$websiteobj = new Website($this->db);
|
||||||
$result = $websiteobj->fetch($this->fk_website);
|
$result = $websiteobj->fetch($this->fk_website);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user