Merge pull request #14852 from inovea-conseil/newfieldwebsite

NEW website page fields
This commit is contained in:
Laurent Destailleur 2020-10-01 19:31:14 +02:00 committed by GitHub
commit 14736bee63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 4 deletions

View File

@ -330,3 +330,6 @@ ALTER TABLE llx_bank ADD COLUMN origin_type varchar(64) NULL;
ALTER TABLE llx_bank ADD COLUMN import_key varchar(14);
ALTER TABLE llx_menu MODIFY COLUMN enabled text;
ALTER TABLE llx_website_page ADD COLUMN object_type varchar(255);
ALTER TABLE llx_website_page ADD COLUMN fk_object varchar(255);

View File

@ -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 key
object_type varchar(255),
fk_object varchar(255)
) ENGINE=innodb;

View File

@ -3,6 +3,7 @@
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2020 Nicolas ZABOURI <info@inovea-conseil.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -104,6 +105,15 @@ class WebsitePage extends CommonObject
*/
public $author_alias;
/**
* @var string path of external object
*/
public $object_type;
/**
* @var string id of external object
*/
public $fk_object;
const STATUS_DRAFT = 0;
const STATUS_VALIDATED = 1;
@ -161,6 +171,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),
'object_type' => 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 +272,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.object_type,";
$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 +333,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->object_type = $obj->object_type;
$this->fk_object = $obj->fk_object;
}
$this->db->free($resql);
@ -374,7 +390,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.object_type,";
$sql .= " t.fk_object";
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
$sql .= ' WHERE t.fk_website = '.$websiteid;
// Manage filter
@ -443,6 +461,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->object_type = $obj->object_type;
$record->fk_object = $obj->fk_object;
//var_dump($record->id);
$records[$record->id] = $record;
}

View File

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2016-2020 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2020 Nicolas ZABOURI <info@inovea-conseil.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -941,7 +942,8 @@ if ($action == 'addcontainer')
$objectpage->keywords = str_replace(array('<', '>'), '', GETPOST('WEBSITE_KEYWORDS', 'alphanohtml'));
$objectpage->htmlheader = GETPOST('htmlheader', 'none');
$objectpage->author_alias = GETPOST('WEBSITE_AUTHORALIAS', 'alphanohtml');
$objectpage->object_type = GETPOST('WEBSITE_OBJECTCLASS');
$objectpage->fk_object = GETPOST('WEBSITE_OBJECTID');
$substitutionarray = array();
$substitutionarray['__WEBSITE_CREATE_BY__'] = $user->getFullName($langs);
@ -1657,6 +1659,8 @@ 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'));
$objectpage->object_type = GETPOST('WEBSITE_OBJECTCLASS', 'alpha');
$objectpage->fk_object = 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 +3582,18 @@ if ($action == 'editmeta' || $action == 'createcontainer')
print "</td></tr>";
}
print '<tr><td class="titlefieldcreate">';
print 'ObjectClass';
print '</td><td>';
print '<input type="text" class="flat minwidth300" name="WEBSITE_OBJECTCLASS" placeholder="ClassName::/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);