From de5e6cf546bd0a1dd93d77b83d69e0ce076eb441 Mon Sep 17 00:00:00 2001 From: Florian Date: Mon, 28 Sep 2020 17:04:45 +0200 Subject: [PATCH] Add 2 new field typeObject and ObjectId to website --- .../install/mysql/migration/11.0.0-12.0.0.sql | 2 ++ .../install/mysql/tables/llx_website_page.sql | 4 ++- htdocs/website/class/websitepage.class.php | 19 ++++++++++++++ htdocs/website/index.php | 25 ++++++++++++++++++- 4 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 htdocs/install/mysql/migration/11.0.0-12.0.0.sql diff --git a/htdocs/install/mysql/migration/11.0.0-12.0.0.sql b/htdocs/install/mysql/migration/11.0.0-12.0.0.sql new file mode 100644 index 00000000000..98413f39d82 --- /dev/null +++ b/htdocs/install/mysql/migration/11.0.0-12.0.0.sql @@ -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); diff --git a/htdocs/install/mysql/tables/llx_website_page.sql b/htdocs/install/mysql/tables/llx_website_page.sql index 840e12e0141..156aff0b5a6 100644 --- a/htdocs/install/mysql/tables/llx_website_page.sql +++ b/htdocs/install/mysql/tables/llx_website_page.sql @@ -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; diff --git a/htdocs/website/class/websitepage.class.php b/htdocs/website/class/websitepage.class.php index abdb8d323eb..a0297e11693 100644 --- a/htdocs/website/class/websitepage.class.php +++ b/htdocs/website/class/websitepage.class.php @@ -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; } diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 72fd6d0b70e..0d6df4694b2 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -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 ''; print ''; + print ''; + print 'ObjectClass'; + print ''; + print ''; + print ''; + + print ''; + print 'ObjectID'; + print ''; + print ''; + print ''; + $fuser = new User($db); print '';