Add 2 new field typeObject and ObjectId to website

This commit is contained in:
Florian 2020-09-28 17:04:45 +02:00
parent 0db8d1401b
commit de5e6cf546
4 changed files with 48 additions and 2 deletions

View File

@ -0,0 +1,2 @@
ALTER TABLE llx_website_page Add COLUMN fk_typeobject varchar(255);
ALTER TABLE llx_website_page Add COLUMN fk_object varchar(255);

View File

@ -38,5 +38,7 @@ CREATE TABLE llx_website_page
fk_user_modif integer,
date_creation datetime,
tms timestamp,
import_key varchar(14) -- import key
import_key varchar(14), -- import key
fk_typeobject varchar(255),
fk_object varchar(255)
) ENGINE=innodb;

View File

@ -102,6 +102,15 @@ class WebsitePage extends CommonObject
const STATUS_DRAFT = 0;
const STATUS_VALIDATED = 1;
/**
* @var string path type object
*/
public $fk_typeobject;
/**
* @var string path name object
*/
public $fk_object;
// BEGIN MODULEBUILDER PROPERTIES
@ -131,6 +140,8 @@ class WebsitePage extends CommonObject
'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-1, 'position'=>511),
//'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512),
'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-1, 'index'=>1, 'position'=>1000, 'notnull'=>-1),
'fk_typeobject' => array('type' => 'varchar(255)','label' => 'ObjectType', 'enabled'=>1, 'visible'=>1, 'position'=>46, 'searchall'=>0, 'help'=>''),
'fk_object' => array('type' => 'varchar(255)','label' => 'ObjectId', 'enabled'=>1, 'visible'=>1, 'position'=>47, 'searchall'=>0, 'help'=>'')
);
// END MODULEBUILDER PROPERTIES
@ -197,6 +208,8 @@ class WebsitePage extends CommonObject
$sql .= " t.tms as date_modification,";
$sql .= " t.fk_user_creat,";
$sql .= " t.fk_user_modif";
$sql .= " t.fk_typeobject,";
$sql .= " t.fk_object";
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
//$sql .= ' WHERE entity IN ('.getEntity('website').')'; // entity is on website level
$sql .= ' WHERE 1 = 1';
@ -244,6 +257,8 @@ class WebsitePage extends CommonObject
$this->date_modification = $this->db->jdate($obj->date_modification);
$this->fk_user_creat = $obj->fk_user_creat;
$this->fk_user_modif = $obj->fk_user_modif;
$this->fk_typeobject = $obj->fk_typeobject;
$this->fk_object = $obj->fk_object;
}
$this->db->free($resql);
@ -298,6 +313,8 @@ class WebsitePage extends CommonObject
$sql .= " t.tms as date_modification,";
$sql .= " t.fk_user_creat,";
$sql .= " t.fk_user_modif";
$sql .= " t.fk_typeobject,";
$sql .= " t.fk_object";
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
$sql .= ' WHERE t.fk_website = '.$websiteid;
// Manage filter
@ -349,6 +366,8 @@ class WebsitePage extends CommonObject
$record->date_modification = $this->db->jdate($obj->date_modification);
$record->fk_user_creat = $obj->fk_user_creat;
$record->fk_user_modif = $obj->fk_user_modif;
$record->fk_typeobject = $obj->fk_typeobject;
$record->fk_object = $obj->fk_object;
//var_dump($record->id);
$records[$record->id] = $record;
}

View File

@ -825,6 +825,12 @@ if ($action == 'addcontainer')
if (!$error)
{
if (GETPOSTISSET('WEBSITE_OBJECTCLASS')){
$objectpage->fk_typeobject = GETPOST('WEBSITE_OBJECTCLASS');
}
if (GETPOSTISSET('WEBSITE_OBJECTID')){
$objectpage->fk_object = GETPOST('WEBSITE_OBJECTID');
}
$pageid = $objectpage->create($user);
if ($pageid <= 0) {
$error++;
@ -1412,7 +1418,12 @@ if ($action == 'updatemeta')
$objectpage->lang = GETPOST('WEBSITE_LANG', 'aZ09');
$objectpage->htmlheader = trim(GETPOST('htmlheader', 'none'));
$objectpage->fk_page = (GETPOST('pageidfortranslation', 'int') > 0 ? GETPOST('pageidfortranslation', 'int') : 0);
if(GETPOSTISSET('WEBSITE_OBJECTCLASS')){
$objectpage->fk_typeobject = GETPOST('WEBSITE_OBJECTCLASS', 'aZ09');
}
if(GETPOSTISSET('WEBSITE_OBJECTID')){
$objectpage->fk_typeobject = GETPOST('WEBSITE_OBJECTID','aZ09');
}
$newdatecreation = dol_mktime(GETPOST('datecreationhour', 'int'), GETPOST('datecreationmin', 'int'), GETPOST('datecreationsec', 'int'), GETPOST('datecreationmonth', 'int'), GETPOST('datecreationday', 'int'), GETPOST('datecreationyear', 'int'));
if ($newdatecreation) $objectpage->date_creation = $newdatecreation;
@ -3119,6 +3130,18 @@ if ($action == 'editmeta' || $action == 'createcontainer')
print '<input type="text" class="flat minwidth300" name="WEBSITE_ALIASALT" value="'.dol_escape_htmltag($pagealiasalt).'">';
print '</td></tr>';
print '<tr><td class="titlefieldcreate">';
print 'ObjectClass';
print '</td><td>';
print '<input type="text" class="flat minwidth300" name="WEBSITE_OBJECTCLASS" placeholder="/path/class/ObjectClass.class.php" >';
print '</td></tr>';
print '<tr><td class="titlefieldcreate">';
print 'ObjectID';
print '</td><td>';
print '<input type="text" class="flat minwidth300" name="WEBSITE_OBJECTID" >';
print '</td></tr>';
$fuser = new User($db);
print '<tr><td>';