Fix bad definition of field for parent

This commit is contained in:
Laurent Destailleur 2020-06-11 18:31:26 +02:00
parent a48f263af2
commit c289001507
4 changed files with 15 additions and 7 deletions

View File

@ -7977,7 +7977,9 @@ abstract class CommonObject
break; break;
} }
} else { } else {
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $table . ' WHERE ' . $this->fk_element . ' = ' . $this->id; // Delete record in child table
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $table . ' WHERE ' . $this->fk_element . ' = ' . $this->id;
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (!$resql) { if (!$resql) {
$error++; $error++;

View File

@ -55,7 +55,7 @@ class Societe extends CommonObject
public $table_element = 'societe'; public $table_element = 'societe';
/** /**
* @var int Field with ID of parent key if this field has a parent * @var int Field with ID of parent key if this field has a parent or for child tables
*/ */
public $fk_element = 'fk_soc'; public $fk_element = 'fk_soc';

View File

@ -173,9 +173,9 @@ class WebsitePage extends CommonObject
//public $table_element_line = 'mymodule_myobjectline'; //public $table_element_line = 'mymodule_myobjectline';
/** /**
* @var int Field with ID of parent key if this object has a parent * @var int Field with ID of parent key if this field has a parent or for child tables
*/ */
public $fk_element = 'fk_website'; public $fk_element = 'fk_website_page';
/** /**
* @var int Name of subtable class that manage subtable lines * @var int Name of subtable class that manage subtable lines
@ -572,7 +572,7 @@ class WebsitePage extends CommonObject
if (!$error) { if (!$error) {
$result = $this->deleteCommon($user, $trigger); $result = $this->deleteCommon($user, $trigger);
if ($result > 0) if ($result <= 0)
{ {
$error++; $error++;
} }
@ -593,10 +593,17 @@ class WebsitePage extends CommonObject
dol_delete_file($filealias); dol_delete_file($filealias);
dol_delete_file($filetpl); dol_delete_file($filetpl);
} else {
$this->error = $websiteobj->error;
$this->errors = $websiteobj->errors;
} }
} }
return $result; if (! $error) {
return 1;
} else {
return -1;
}
} }
/** /**

View File

@ -86,7 +86,6 @@ if (GETPOST('createfromclone', 'alpha')) { $action = 'createfromclone'; }
if (GETPOST('createpagefromclone', 'alpha')) { $action = 'createpagefromclone'; } if (GETPOST('createpagefromclone', 'alpha')) { $action = 'createpagefromclone'; }
if (empty($action) && $file_manager) $action = 'file_manager'; if (empty($action) && $file_manager) $action = 'file_manager';
if (empty($action) && $replacesite) $action = 'replacesite'; if (empty($action) && $replacesite) $action = 'replacesite';
if (GETPOST('refreshsite') || GETPOST('refreshsite_x') || GETPOST('refreshsite.x')) $pageid = 0; if (GETPOST('refreshsite') || GETPOST('refreshsite_x') || GETPOST('refreshsite.x')) $pageid = 0;
// Load variable for pagination // Load variable for pagination