From bdb38da9d3370b4ab20fa532990ad7fdf577a01f Mon Sep 17 00:00:00 2001 From: Florian Date: Mon, 28 Sep 2020 18:17:23 +0200 Subject: [PATCH] Add 2 new field typeObject and ObjectId to website --- .../install/mysql/migration/11.0.0-12.0.0.sql | 3 +++ .../install/mysql/tables/llx_website_page.sql | 4 ++- htdocs/website/class/websitepage.class.php | 22 ++++++++++++++-- htdocs/website/index.php | 25 ++++++++++++++++++- 4 files changed, 50 insertions(+), 4 deletions(-) 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 index 994e5d89495..23830014690 100644 --- a/htdocs/install/mysql/migration/11.0.0-12.0.0.sql +++ b/htdocs/install/mysql/migration/11.0.0-12.0.0.sql @@ -335,3 +335,6 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (72 insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,localtax1,localtax1_type,note,active) values (722, 72, '18','0', '0.9', '1', 'VAT Rate 18+0.9', 1); ALTER TABLE llx_expedition ADD COLUMN billed smallint DEFAULT 0; + +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 bacbc8e802b..ae339cfd119 100644 --- a/htdocs/install/mysql/tables/llx_website_page.sql +++ b/htdocs/install/mysql/tables/llx_website_page.sql @@ -39,5 +39,7 @@ CREATE TABLE llx_website_page author_alias varchar(64), date_creation datetime, tms timestamp, - import_key varchar(14) -- import key + import_key varchar(14), -- import k + 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 b5e29e04176..a3563418873 100644 --- a/htdocs/website/class/websitepage.class.php +++ b/htdocs/website/class/websitepage.class.php @@ -104,6 +104,14 @@ class WebsitePage extends CommonObject */ public $author_alias; + /** + * @var string path type object + */ + public $fk_typeobject; + /** + * @var string path name object + */ + public $fk_object; const STATUS_DRAFT = 0; const STATUS_VALIDATED = 1; @@ -161,6 +169,8 @@ class WebsitePage extends CommonObject 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-1, 'position'=>512), //'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 @@ -260,7 +270,9 @@ class WebsitePage extends CommonObject $sql .= " t.fk_user_creat,"; $sql .= " t.author_alias,"; $sql .= " t.fk_user_modif,"; - $sql .= " t.import_key"; + $sql .= " t.import_key,"; + $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'; @@ -319,6 +331,8 @@ class WebsitePage extends CommonObject $this->author_alias = $obj->author_alias; $this->fk_user_modif = $obj->fk_user_modif; $this->import_key = $obj->import_key; + $this->fk_typeobject = $obj->fk_typeobject; + $this->fk_object = $obj->fk_object; } $this->db->free($resql); @@ -374,7 +388,9 @@ class WebsitePage extends CommonObject $sql .= " t.fk_user_creat,"; $sql .= " t.author_alias,"; $sql .= " t.fk_user_modif,"; - $sql .= " t.import_key"; + $sql .= " t.import_key,"; + $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 @@ -443,6 +459,8 @@ class WebsitePage extends CommonObject $record->author_alias = $obj->author_alias; $record->fk_user_modif = $obj->fk_user_modif; $record->import_key = $obj->import_key; + $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 a36f33ee682..e62887407d6 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -981,6 +981,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++; @@ -1657,7 +1663,12 @@ if ($action == 'updatemeta') $objectpage->htmlheader = trim(GETPOST('htmlheader', 'none')); $objectpage->fk_page = (GETPOST('pageidfortranslation', 'int') > 0 ? GETPOST('pageidfortranslation', 'int') : 0); $objectpage->author_alias = trim(GETPOST('WEBSITE_AUTHORALIAS', 'alphanohtml')); - + if(GETPOSTISSET('WEBSITE_OBJECTCLASS')){ + $objectpage->fk_typeobject = GETPOST('WEBSITE_OBJECTCLASS', 'alpha'); + } + 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; @@ -3578,6 +3589,18 @@ if ($action == 'editmeta' || $action == 'createcontainer') print ""; } + print ''; + print 'ObjectClass'; + print ''; + print ''; + print ''; + + print ''; + print 'ObjectID'; + print ''; + print ''; + print ''; + $fuser = new User($db);