NEW Add field author public alias for blog post on website module
This commit is contained in:
parent
94b17d34c7
commit
6f636d6d69
@ -62,6 +62,8 @@ UPDATE llx_website_page SET lang = 'pt' WHERE lang like 'pt_%';
|
|||||||
ALTER TABLE llx_website ADD COLUMN lang varchar(8);
|
ALTER TABLE llx_website ADD COLUMN lang varchar(8);
|
||||||
ALTER TABLE llx_website ADD COLUMN otherlang varchar(255);
|
ALTER TABLE llx_website ADD COLUMN otherlang varchar(255);
|
||||||
|
|
||||||
|
ALTER TABLE llx_website_page ADD COLUMN author_alias varchar(64);
|
||||||
|
|
||||||
ALTER TABLE llx_holiday_users DROP INDEX uk_holiday_users;
|
ALTER TABLE llx_holiday_users DROP INDEX uk_holiday_users;
|
||||||
ALTER TABLE llx_holiday_users ADD UNIQUE INDEX uk_holiday_users(fk_user, fk_type);
|
ALTER TABLE llx_holiday_users ADD UNIQUE INDEX uk_holiday_users(fk_user, fk_type);
|
||||||
|
|
||||||
|
|||||||
@ -36,6 +36,7 @@ CREATE TABLE llx_website_page
|
|||||||
grabbed_from varchar(255),
|
grabbed_from varchar(255),
|
||||||
fk_user_creat integer,
|
fk_user_creat integer,
|
||||||
fk_user_modif integer,
|
fk_user_modif integer,
|
||||||
|
author_alias varchar(64),
|
||||||
date_creation datetime,
|
date_creation datetime,
|
||||||
tms timestamp,
|
tms timestamp,
|
||||||
import_key varchar(14) -- import key
|
import_key varchar(14) -- import key
|
||||||
|
|||||||
@ -125,3 +125,4 @@ UseTextBetween5And70Chars=For good SEO practices, use a text between 5 and 70 ch
|
|||||||
MainLanguage=Main language
|
MainLanguage=Main language
|
||||||
OtherLanguages=Other languages
|
OtherLanguages=Other languages
|
||||||
UseManifest=Provide a manifest.json file
|
UseManifest=Provide a manifest.json file
|
||||||
|
PublicAuthorAlias=Public author alias
|
||||||
@ -98,6 +98,11 @@ class WebsitePage extends CommonObject
|
|||||||
*/
|
*/
|
||||||
public $date_modification;
|
public $date_modification;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string author_alias
|
||||||
|
*/
|
||||||
|
public $author_alias;
|
||||||
|
|
||||||
|
|
||||||
const STATUS_DRAFT = 0;
|
const STATUS_DRAFT = 0;
|
||||||
const STATUS_VALIDATED = 1;
|
const STATUS_VALIDATED = 1;
|
||||||
@ -128,7 +133,8 @@ class WebsitePage extends CommonObject
|
|||||||
'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>501),
|
'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>501),
|
||||||
//'date_valid' =>array('type'=>'datetime', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>502),
|
//'date_valid' =>array('type'=>'datetime', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>502),
|
||||||
'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-1, 'notnull'=>true, 'position'=>510),
|
'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-1, 'notnull'=>true, 'position'=>510),
|
||||||
'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-1, 'position'=>511),
|
'author_alias' =>array('type'=>'varchar(64)', 'label'=>'AuthorAlias', 'enabled'=>1, 'visible'=>-1, 'index'=>0, 'position'=>511, 'comment'=>'Author alias'),
|
||||||
|
'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),
|
//'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),
|
'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-1, 'index'=>1, 'position'=>1000, 'notnull'=>-1),
|
||||||
);
|
);
|
||||||
@ -199,6 +205,7 @@ class WebsitePage extends CommonObject
|
|||||||
$sql .= " t.date_creation,";
|
$sql .= " t.date_creation,";
|
||||||
$sql .= " t.tms as date_modification,";
|
$sql .= " t.tms as date_modification,";
|
||||||
$sql .= " t.fk_user_creat,";
|
$sql .= " t.fk_user_creat,";
|
||||||
|
$sql .= " t.author_alias,";
|
||||||
$sql .= " t.fk_user_modif";
|
$sql .= " t.fk_user_modif";
|
||||||
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
|
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
|
||||||
//$sql .= ' WHERE entity IN ('.getEntity('website').')'; // entity is on website level
|
//$sql .= ' WHERE entity IN ('.getEntity('website').')'; // entity is on website level
|
||||||
@ -246,6 +253,7 @@ class WebsitePage extends CommonObject
|
|||||||
$this->date_creation = $this->db->jdate($obj->date_creation);
|
$this->date_creation = $this->db->jdate($obj->date_creation);
|
||||||
$this->date_modification = $this->db->jdate($obj->date_modification);
|
$this->date_modification = $this->db->jdate($obj->date_modification);
|
||||||
$this->fk_user_creat = $obj->fk_user_creat;
|
$this->fk_user_creat = $obj->fk_user_creat;
|
||||||
|
$this->author_alias = $obj->author_alias;
|
||||||
$this->fk_user_modif = $obj->fk_user_modif;
|
$this->fk_user_modif = $obj->fk_user_modif;
|
||||||
}
|
}
|
||||||
$this->db->free($resql);
|
$this->db->free($resql);
|
||||||
@ -300,6 +308,7 @@ class WebsitePage extends CommonObject
|
|||||||
$sql .= " t.date_creation,";
|
$sql .= " t.date_creation,";
|
||||||
$sql .= " t.tms as date_modification,";
|
$sql .= " t.tms as date_modification,";
|
||||||
$sql .= " t.fk_user_creat,";
|
$sql .= " t.fk_user_creat,";
|
||||||
|
$sql .= " t.author_alias,";
|
||||||
$sql .= " t.fk_user_modif";
|
$sql .= " t.fk_user_modif";
|
||||||
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
|
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
|
||||||
$sql .= ' WHERE t.fk_website = '.$websiteid;
|
$sql .= ' WHERE t.fk_website = '.$websiteid;
|
||||||
@ -353,6 +362,7 @@ class WebsitePage extends CommonObject
|
|||||||
$record->date_creation = $this->db->jdate($obj->date_creation);
|
$record->date_creation = $this->db->jdate($obj->date_creation);
|
||||||
$record->date_modification = $this->db->jdate($obj->date_modification);
|
$record->date_modification = $this->db->jdate($obj->date_modification);
|
||||||
$record->fk_user_creat = $obj->fk_user_creat;
|
$record->fk_user_creat = $obj->fk_user_creat;
|
||||||
|
$record->author_alias = $obj->author_alias;
|
||||||
$record->fk_user_modif = $obj->fk_user_modif;
|
$record->fk_user_modif = $obj->fk_user_modif;
|
||||||
//var_dump($record->id);
|
//var_dump($record->id);
|
||||||
$records[$record->id] = $record;
|
$records[$record->id] = $record;
|
||||||
@ -533,6 +543,7 @@ class WebsitePage extends CommonObject
|
|||||||
$object->pageurl = $newref;
|
$object->pageurl = $newref;
|
||||||
$object->aliasalt = '';
|
$object->aliasalt = '';
|
||||||
$object->fk_user_creat = $user->id;
|
$object->fk_user_creat = $user->id;
|
||||||
|
$object->author_alias = '';
|
||||||
$object->date_creation = $now;
|
$object->date_creation = $now;
|
||||||
$object->title = ($newtitle == '1' ? $object->title : ($newtitle ? $newtitle : $object->title));
|
$object->title = ($newtitle == '1' ? $object->title : ($newtitle ? $newtitle : $object->title));
|
||||||
if (!empty($newlang)) $object->lang = $newlang;
|
if (!empty($newlang)) $object->lang = $newlang;
|
||||||
@ -689,5 +700,6 @@ class WebsitePage extends CommonObject
|
|||||||
$this->date_creation = $now - (24 * 30 * 3600);
|
$this->date_creation = $now - (24 * 30 * 3600);
|
||||||
$this->date_modification = $now - (24 * 7 * 3600);
|
$this->date_modification = $now - (24 * 7 * 3600);
|
||||||
$this->fk_user_creat = $user->id;
|
$this->fk_user_creat = $user->id;
|
||||||
|
$this->author_alias = 'mypublicpseudo';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -794,6 +794,7 @@ if ($action == 'addcontainer')
|
|||||||
$objectpage->image = GETPOST('WEBSITE_IMAGE', 'alpha');
|
$objectpage->image = GETPOST('WEBSITE_IMAGE', 'alpha');
|
||||||
$objectpage->keywords = GETPOST('WEBSITE_KEYWORDS', 'alphanohtml');
|
$objectpage->keywords = GETPOST('WEBSITE_KEYWORDS', 'alphanohtml');
|
||||||
$objectpage->htmlheader = GETPOST('htmlheader', 'none');
|
$objectpage->htmlheader = GETPOST('htmlheader', 'none');
|
||||||
|
$objectpage->author_alias = GETPOST('WEBSITE_AUTHORALIAS', 'alphanohtml');
|
||||||
|
|
||||||
$substitutionarray = array();
|
$substitutionarray = array();
|
||||||
$substitutionarray['__WEBSITE_CREATE_BY__'] = $user->getFullName($langs);
|
$substitutionarray['__WEBSITE_CREATE_BY__'] = $user->getFullName($langs);
|
||||||
@ -1437,6 +1438,7 @@ if ($action == 'updatemeta')
|
|||||||
$objectpage->keywords = GETPOST('WEBSITE_KEYWORDS', 'alphanohtml');
|
$objectpage->keywords = GETPOST('WEBSITE_KEYWORDS', 'alphanohtml');
|
||||||
$objectpage->htmlheader = trim(GETPOST('htmlheader', 'none'));
|
$objectpage->htmlheader = trim(GETPOST('htmlheader', 'none'));
|
||||||
$objectpage->fk_page = (GETPOST('pageidfortranslation', 'int') > 0 ? GETPOST('pageidfortranslation', 'int') : 0);
|
$objectpage->fk_page = (GETPOST('pageidfortranslation', 'int') > 0 ? GETPOST('pageidfortranslation', 'int') : 0);
|
||||||
|
$objectpage->author_alias = trim(GETPOST('WEBSITE_AUTHORALIAS', 'alphanohtml'));
|
||||||
|
|
||||||
$newdatecreation = dol_mktime(GETPOST('datecreationhour', 'int'), GETPOST('datecreationmin', 'int'), GETPOST('datecreationsec', 'int'), GETPOST('datecreationmonth', 'int'), GETPOST('datecreationday', 'int'), GETPOST('datecreationyear', 'int'));
|
$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;
|
if ($newdatecreation) $objectpage->date_creation = $newdatecreation;
|
||||||
@ -3066,6 +3068,7 @@ if ($action == 'editmeta' || $action == 'createcontainer')
|
|||||||
$pagedatemodification = $objectpage->date_modification;
|
$pagedatemodification = $objectpage->date_modification;
|
||||||
$pageauthorid = $objectpage->fk_user_creat;
|
$pageauthorid = $objectpage->fk_user_creat;
|
||||||
$pageusermodifid = $objectpage->fk_user_modif;
|
$pageusermodifid = $objectpage->fk_user_modif;
|
||||||
|
$pageauthoralias = $objectpage->author_alias;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -3073,6 +3076,7 @@ if ($action == 'editmeta' || $action == 'createcontainer')
|
|||||||
$pagedatecreation = dol_now();
|
$pagedatecreation = dol_now();
|
||||||
$pageauthorid = $user->id;
|
$pageauthorid = $user->id;
|
||||||
$pageusermodifid = 0;
|
$pageusermodifid = 0;
|
||||||
|
$pageauthoralias = '';
|
||||||
}
|
}
|
||||||
if (GETPOST('WEBSITE_TITLE', 'alpha')) $pagetitle = GETPOST('WEBSITE_TITLE', 'alpha');
|
if (GETPOST('WEBSITE_TITLE', 'alpha')) $pagetitle = GETPOST('WEBSITE_TITLE', 'alpha');
|
||||||
if (GETPOST('WEBSITE_PAGENAME', 'alpha')) $pageurl = GETPOST('WEBSITE_PAGENAME', 'alpha');
|
if (GETPOST('WEBSITE_PAGENAME', 'alpha')) $pageurl = GETPOST('WEBSITE_PAGENAME', 'alpha');
|
||||||
@ -3232,6 +3236,12 @@ if ($action == 'editmeta' || $action == 'createcontainer')
|
|||||||
}
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
|
print '<tr><td>';
|
||||||
|
print $langs->trans('PublicAuthorAlias');
|
||||||
|
print '</td><td>';
|
||||||
|
print '<input type="text" class="flat minwidth300" name="WEBSITE_AUTHORALIAS" value="'.dol_escape_htmltag($pageauthoralias).'">';
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
print '<tr><td>';
|
print '<tr><td>';
|
||||||
print $langs->trans('DateCreation');
|
print $langs->trans('DateCreation');
|
||||||
print '</td><td>';
|
print '</td><td>';
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env php
|
#!/usr/bin/env php
|
||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2007-2016 Laurent Destailleur <eldy@users.sourceforge.net>
|
/* Copyright (C) 2020 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -37,18 +37,22 @@ define('EVEN_IF_ONLY_LOGIN_ALLOWED', 1); // Set this define to 0 if you want to
|
|||||||
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
if (empty($argv[3]) || !in_array($argv[1], array('test', 'confirm'))) {
|
$mode = $argv[1];
|
||||||
|
$websiteref = $argv[2];
|
||||||
|
$joomlaserverinfo = $argv[3];
|
||||||
|
$image = 'image/__WEBSITE_KEY__/images/stories/dolibarr.png';
|
||||||
|
|
||||||
|
$max = 1;
|
||||||
|
|
||||||
|
if (empty($argv[3]) || !in_array($argv[1], array('test', 'confirm')) || empty($websiteref)) {
|
||||||
print "Usage: $script_file (test|confirm) website login:pass@serverjoomla/tableprefix/databasejoomla\n";
|
print "Usage: $script_file (test|confirm) website login:pass@serverjoomla/tableprefix/databasejoomla\n";
|
||||||
print "\n";
|
print "\n";
|
||||||
print "Load joomla news and create them into Dolibarr database (if they don't alreay exist).\n";
|
print "Load joomla news and create them into Dolibarr database (if they don't alreay exist).\n";
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$mode = $argv[1];
|
|
||||||
$website = $argv[2];
|
|
||||||
$joomlaserverinfo = $argv[3];
|
|
||||||
|
|
||||||
require $path."../../htdocs/master.inc.php";
|
require $path."../../htdocs/master.inc.php";
|
||||||
|
include_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php';
|
||||||
|
|
||||||
$langs->load('main');
|
$langs->load('main');
|
||||||
|
|
||||||
@ -61,6 +65,15 @@ $joomladatabase = $joomlaserverinfoarray[4];
|
|||||||
$joomlaport = 3306;
|
$joomlaport = 3306;
|
||||||
|
|
||||||
|
|
||||||
|
$website = new Website($db);
|
||||||
|
$result = $website->fetch(0, $websiteref);
|
||||||
|
if ($result <= 0) {
|
||||||
|
print 'Error, web site '.$websiteref.' not found'."\n";
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
$websiteid = $website->id;
|
||||||
|
$importid = dol_print_date(dol_now(), 'dayhourlog');
|
||||||
|
|
||||||
$dbjoomla=getDoliDBInstance('mysqli', $joomlahost, $joomlalogin, $joomlapass, $joomladatabase, $joomlaport);
|
$dbjoomla=getDoliDBInstance('mysqli', $joomlahost, $joomlalogin, $joomlapass, $joomladatabase, $joomlaport);
|
||||||
if ($dbjoomla->error)
|
if ($dbjoomla->error)
|
||||||
{
|
{
|
||||||
@ -68,7 +81,10 @@ if ($dbjoomla->error)
|
|||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = 'SELECT id, title, alias, created, introtext, `fulltext` FROM '.$joomlaprefix.'_content WHERE 1 = 1';
|
$sql = 'SELECT c.id, c.title, c.alias, c.created, c.introtext, `fulltext`, c.metadesc, c.metakey, c.language, c.created, c.publish_up, u.username FROM '.$joomlaprefix.'_content as c';
|
||||||
|
$sql.= ' LEFT JOIN '.$joomlaprefix.'_users as u ON u.id = c.created_by';
|
||||||
|
$sql.= ' WHERE featured = 1';
|
||||||
|
$sql.= ' ORDER BY publish_up ASC';
|
||||||
$resql = $dbjoomla->query($sql);
|
$resql = $dbjoomla->query($sql);
|
||||||
|
|
||||||
if (! $resql) {
|
if (! $resql) {
|
||||||
@ -76,18 +92,50 @@ if (! $resql) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$db->begin();
|
||||||
|
|
||||||
while ($obj = $dbjoomla->fetch_object($resql)) {
|
while ($obj = $dbjoomla->fetch_object($resql)) {
|
||||||
$i = 0;
|
$i = 0;
|
||||||
if ($obj) {
|
if ($obj) {
|
||||||
$i++;
|
$i++;
|
||||||
$id = $obj->id;
|
$id = $obj->id;
|
||||||
$title = $obj->title;
|
|
||||||
$alias = $obj->alias;
|
$alias = $obj->alias;
|
||||||
$description = dol_string_nohtmltag($obj->introtext);
|
$title = $obj->title;
|
||||||
$hmtltext = $obj->fulltext;
|
//$description = dol_string_nohtmltag($obj->introtext);
|
||||||
|
$description = trim(dol_trunc(dol_string_nohtmltag($obj->metadesc), 250));
|
||||||
|
if (empty($description)) $description = trim(dol_trunc(dol_string_nohtmltag($obj->introtext), 250));
|
||||||
|
$hmtltext = $obj->introtext.'<br>'."\n".'<hr>'."\n".'<br>'."\n".$obj->fulltext;
|
||||||
|
$language = ($obj->language && $obj->language != '*' ? $obj->language : 'en');
|
||||||
|
$keywords = $obj->metakey;
|
||||||
|
$author_alias = $obj->username;
|
||||||
|
|
||||||
print $i.' '.$id.' '.$title."\n";
|
$date_creation = $dbjoomla->jdate($obj->publish_up);
|
||||||
|
|
||||||
|
print $i.' '.$id.' '.$title.' '.$language.' '.$keywords.' '.$importid."\n";
|
||||||
|
|
||||||
|
$sqlinsert = 'INSERT INTO '.MAIN_DB_PREFIX.'website_page(fk_website, pageurl, aliasalt, title, description, keywords, content, status, type_container, lang, import_key, image, date_creation, author_alias)';
|
||||||
|
$sqlinsert .= " VALUES(".$websiteid.", '".$db->escape($alias)."', '', '".$db->escape($title)."', '".$db->escape($description)."', '".$db->escape($keywords)."', ";
|
||||||
|
$sqlinsert .= " '".$db->escape($hmtltext)."', '1', 'blogpost', '".$db->escape($language)."', '".$db->escape($importid)."', '".$db->escape($image)."', '".$db->idate($date_creation)."', '".$db->escape($author_alias)."')";
|
||||||
|
print $sqlinsert."\n";
|
||||||
|
|
||||||
|
$result = $db->query($sqlinsert);
|
||||||
|
if ($result <= 0) {
|
||||||
|
$error++;
|
||||||
|
print 'Error, '.$db->lasterror.": ".$sqlinsert."\n";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($max && $i <= $max) {
|
||||||
|
print 'Nb max of record reached. We stop now.'."\n";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($mode == 'confirm' && ! $error) {
|
||||||
|
$db->commit();
|
||||||
|
} else {
|
||||||
|
$db->rollback();
|
||||||
}
|
}
|
||||||
|
|
||||||
exit($error);
|
exit($error);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user