Fix bad value for ref of old contracts

This commit is contained in:
Laurent Destailleur 2017-07-03 02:09:14 +02:00
parent 8a96260892
commit 9e26e6b0a3
10 changed files with 132 additions and 53 deletions

View File

@ -25,8 +25,10 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
require_once DOL_DOCUMENT_ROOT.'/websites/class/website.class.php';
$langs->load("errors");
$langs->load("admin");
@ -35,7 +37,6 @@ $langs->load("website");
$action=GETPOST('action','alpha')?GETPOST('action','alpha'):'view';
$confirm=GETPOST('confirm','alpha');
$id=GETPOST('id','int');
$rowid=GETPOST('rowid','alpha');
$id=1;
@ -135,7 +136,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
}
}
// Si verif ok et action add, on ajoute la ligne
if ($ok && GETPOST('actionadd'))
{
@ -185,7 +186,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
if ($result) // Add is ok
{
setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
$_POST=array('id'=>$id); // Clean $_POST array, we keep only
unset($_POST); // Clean $_POST array, we keep only
}
else
{
@ -204,6 +205,10 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
$website=new Website($db);
$rowid=GETPOST('rowid','int');
$website->fetch($rowid);
// Modify entry
$sql = "UPDATE ".$tabname[$id]." SET ";
// Modifie valeur des champs
@ -229,7 +234,17 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
dol_syslog("actionmodify", LOG_DEBUG);
//print $sql;
$resql = $db->query($sql);
if (! $resql)
if ($resql)
{
$newname = dol_sanitizeFileName(GETPOST('ref','aZ09'));
if ($newname != $website->ref)
{
$srcfile=DOL_DATA_ROOT.'/websites/'.$website->ref;
$destfile=DOL_DATA_ROOT.'/websites/'.$newname;
@rename($srcfile, $destfile);
}
}
else
{
setEventMessages($db->error(), null, 'errors');
}
@ -249,7 +264,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete
$sql = "DELETE from ".MAIN_DB_PREFIX."website_pages WHERE fk_website ='".$rowid."'";
$result = $db->query($sql);
$sql = "DELETE from ".MAIN_DB_PREFIX."website WHERE rowid ='".$rowid."'";
$result = $db->query($sql);
if (! $result)
@ -321,7 +336,7 @@ print "<br>\n";
// Confirmation de la suppression de la ligne
if ($action == 'delete')
{
print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&id='.$id, $langs->trans('DeleteWebsite'), $langs->trans('ConfirmDeleteWebsite'), 'confirm_delete','',0,1);
print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid, $langs->trans('DeleteWebsite'), $langs->trans('ConfirmDeleteWebsite'), 'confirm_delete','',0,1);
}
//var_dump($elementList);
@ -355,7 +370,7 @@ if ($id)
$fieldlist=explode(',',$tabfield[$id]);
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="noborder" width="100%">';
@ -388,9 +403,7 @@ if ($id)
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
}
if ($id == 4) print '<td></td>';
print '<td colspan="4">';
print '<input type="hidden" name="id" value="'.$id.'">';
print '</td>';
print '</tr>';
@ -444,19 +457,19 @@ if ($id)
if ($num)
{
print '<br>';
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="rowid" value="'.$rowid.'">';
print '<table class="noborder" width="100%">';
// There is several pages
if ($num > $listlimit)
{
print '<tr class="none"><td align="right" colspan="'.(3+count($fieldlist)).'">';
print_fleche_navigation($page, $_SERVER["PHP_SELF"], '&id='.$id, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page+1).'</span></li>');
print_fleche_navigation($page, $_SERVER["PHP_SELF"], '', ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page+1).'</span></li>');
print '</td></tr>';
}
@ -486,11 +499,11 @@ if ($id)
// Affiche nom du champ
if ($showfield)
{
print getTitleFieldOfList($valuetoshow,0,$_SERVER["PHP_SELF"],($sortable?$fieldlist[$field]:''),($page?'page='.$page.'&':'').'&id='.$id,"","align=".$align,$sortfield,$sortorder);
print getTitleFieldOfList($valuetoshow,0,$_SERVER["PHP_SELF"],($sortable?$fieldlist[$field]:''),($page?'page='.$page.'&':''),"","align=".$align,$sortfield,$sortorder);
}
}
print getTitleFieldOfList($langs->trans("Status"),0,$_SERVER["PHP_SELF"],"status",($page?'page='.$page.'&':'').'&id='.$id,"",'align="center"',$sortfield,$sortorder);
print getTitleFieldOfList($langs->trans("Status"),0,$_SERVER["PHP_SELF"],"status",($page?'page='.$page.'&':''),"",'align="center"',$sortfield,$sortorder);
print getTitleFieldOfList('');
print getTitleFieldOfList('');
print '</tr>';
@ -539,7 +552,7 @@ if ($id)
// Can an entry be erased or disabled ?
$iserasable=1;$isdisable=1; // true by default
$url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&amp;code='.(! empty($obj->code)?urlencode($obj->code):'').'&amp;id='.$id.'&amp;';
$url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&amp;code='.(! empty($obj->code)?urlencode($obj->code):'').'&amp;';
// Active
print '<td align="center" class="nowrap">';
@ -558,9 +571,9 @@ if ($id)
}
$i++;
}
print '</table>';
print '</form>';
}
}

View File

@ -865,7 +865,7 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
// Make a change into HTML code to allow to include images from medias directory.
// <img alt="" src="/dolibarr_dev/htdocs/viewimage.php?modulepart=medias&amp;entity=1&amp;file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
// become
// <img alt="" src="'.DOL_DATA_ROOT.'/media/image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
// <img alt="" src="'.DOL_DATA_ROOT.'/medias/image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
$newfreetext=preg_replace('/(<img.*src=")[^\"]*viewimage\.php[^\"]*modulepart=medias[^\"]*file=([^\"]*)("[^\/]*\/>)/', '\1'.DOL_DATA_ROOT.'/medias/\2\3', $newfreetext);
$line.=$outputlangs->convToOutputCharset($newfreetext);

View File

@ -31,21 +31,36 @@
function dolWebsiteOutput($content)
{
global $db, $langs, $conf, $user;
global $dolibarr_main_url_root;
dol_syslog("dolWebsiteOutput start");
if (! defined('USEDOLIBARRSERVER'))
{
// Replace link of Dolibarr medias with direct link for virtual server
// Define $urlwithroot
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
$symlinktomediaexists=1;
// Make a change into HTML code to allow to include images from medias directory correct with direct link for virtual server
// <img alt="" src="/dolibarr_dev/htdocs/viewimage.php?modulepart=medias&amp;entity=1&amp;file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
// become
// <img alt="" src="'.$urlwithroot.'/medias/image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
$nbrep=0;
if (! $symlinktomediaexists)
{
$content=preg_replace('/(<img.*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/>)/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
}
else
{
$content=preg_replace('/(<img.*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/>)/', '\1medias/\4\5', $content, -1, $nbrep);
}
}
dol_syslog("dolWebsiteOutput end");
print $content;
}

View File

@ -42,15 +42,15 @@ class modWebsites extends DolibarrModules
$this->db = $db;
$this->numero = 10000;
// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
// It is used to group modules in module setup page
$this->family = "portal";
$this->module_position = 50;
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i','',get_class($this));
$this->description = "Enable the public website with CMS features";
$this->version = 'development'; // 'experimental' or 'dolibarr' or version
$this->description = "Enable to build and serve public websites with CMS features";
$this->version = 'experimental'; // 'experimental' or 'dolibarr' or version
// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
// Where to store the module in setup page (0=common,1=interface,2=others,3=very specific)

View File

@ -346,6 +346,8 @@ ALTER TABLE llx_product_fournisseur_price_log ADD COLUMN multicurrency_tx d
ALTER TABLE llx_product_fournisseur_price_log ADD COLUMN multicurrency_price double(24,8) DEFAULT NULL;
ALTER TABLE llx_product_fournisseur_price_log ADD COLUMN multicurrency_price_ttc double(24,8) DEFAULT NULL;
UPDATE TABLE llx_contrat set ref = rowid where ref is null or ref = '';
create table llx_payment_various
(
rowid integer AUTO_INCREMENT PRIMARY KEY,

View File

@ -14,8 +14,9 @@ EditPageContent=Edit Content
Website=Web site
Webpage=Web page
AddPage=Add page
HomePage=Home Page
PreviewOfSiteNotYetAvailable=Preview of your website <strong>%s</strong> not yet available. You must first add a page.
RequestedPageHasNoContentYet=Requested page with id %s has not content yet or cache file .tpl.php was removed. Edit content of page to solve this.
RequestedPageHasNoContentYet=Requested page with id %s has no content yet, or cache file .tpl.php was removed. Edit content of the page to solve this.
PageDeleted=Page '%s' of website %s deleted
PageAdded=Page '%s' added
ViewSiteInNewTab=View site in new tab

View File

@ -18,7 +18,7 @@
<h2>Error</h2>
<br>
You requested a page that does not exists.
You requested a website or a page that does not exists.
<br>
<?php print isset($_SERVER["HTTP_REFERER"])?'You come from '.$_SERVER["HTTP_REFERER"].'.':''; ?>

View File

@ -67,23 +67,51 @@ if (empty($pageid))
{
require_once DOL_DOCUMENT_ROOT.'/websites/class/website.class.php';
require_once DOL_DOCUMENT_ROOT.'/websites/class/websitepage.class.php';
$object=new Website($db);
$object->fetch(0, $website);
$objectpage=new WebsitePage($db);
$array=$objectpage->fetchAll($object->id);
if (count($array) > 0)
if (empty($object->id))
{
$firstrep=reset($array);
$pageid=$firstrep->id;
if (empty($pageid))
{
// Return header 404
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found", true, 404);
include DOL_DOCUMENT_ROOT.'/public/error-404.php';
exit;
}
}
$objectpage=new WebsitePage($db);
if ($object->fk_default_home > 0)
{
$result=$objectpage->fetch($object->fk_default_home);
if ($result > 0)
{
$pageid = $objectpage->id;
}
}
if (empty($pageid))
{
$array=$objectpage->fetchAll($object->id);
if (is_array($array) && count($array) > 0)
{
$firstrep=reset($array);
$pageid=$firstrep->id;
}
}
}
if (empty($pageid))
{
// Return header 404
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found", true, 404);
$langs->load("website");
print $langs->trans("PreviewOfSiteNotYetAvailable");
include DOL_DOCUMENT_ROOT.'/public/error-404.php';
exit;
}
@ -95,7 +123,7 @@ if ($pageid == 'css') // No more used ?
header('Content-type: text/css');
// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access.
//if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate');
//else
//else
header('Cache-Control: no-cache');
$original_file=$dolibarr_main_data_root.'/websites/'.$website.'/styles.css.php';
}
@ -136,9 +164,13 @@ $original_file_osencoded=dol_osencode($original_file); // New file name encoded
// This test if file exists should be useless. We keep it to find bug more easily
if (! file_exists($original_file_osencoded))
{
// Return header 404
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found", true, 404);
$langs->load("website");
print $langs->trans("RequestedPageHasNoContentYet", $pageid);
//dol_print_error(0,$langs->trans("ErrorFileDoesNotExists",$original_file));
include DOL_DOCUMENT_ROOT.'/public/error-404.php';
exit;
}

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2016-2017 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
@ -18,8 +18,7 @@
/**
* \file htdocs/public/websites/styles.css.php
* \ingroup website
* \brief Page to output style page
* \author Laurent Destailleur
* \brief Page to output style page. Called with <link rel="stylesheet" href="styles.css.php?websiteid=123" type="text/css" />
*/
define('NOTOKENRENEWAL',1); // Disables token renewal
@ -48,6 +47,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$error=0;
$website=GETPOST('website', 'alpha');
$websiteid=GETPOST('websiteid', 'int');
$pageid=GETPOST('page', 'alpha')?GETPOST('page', 'alpha'):GETPOST('pageid', 'alpha');
$accessallowed = 1;
@ -67,13 +67,20 @@ if (empty($pageid))
{
require_once DOL_DOCUMENT_ROOT.'/websites/class/website.class.php';
require_once DOL_DOCUMENT_ROOT.'/websites/class/websitepage.class.php';
$object=new Website($db);
$object->fetch(0, $website);
if ($websiteid)
{
$object->fetch($websiteid);
$website=$object->ref;
}
else
{
$object->fetch(0, $website);
}
$objectpage=new WebsitePage($db);
$array=$objectpage->fetchAll($object->id);
if (count($array) > 0)
{
$firstrep=reset($array);

View File

@ -414,7 +414,7 @@ if ($action == 'updatemeta')
$tplcontent.= '<meta name="title" content="'.dol_escape_htmltag($objectpage->title).'" />'."\n";
$tplcontent.= '<meta name="description" content="'.dol_escape_htmltag($objectpage->description).'" />'."\n";
$tplcontent.= '<meta name="generator" content="'.DOL_APPLICATION_TITLE.'" />'."\n";
$tplcontent.= '<link rel="stylesheet" href="styles.css.php?website='.$website.'" type="text/css" />'."\n";
$tplcontent.= '<link rel="stylesheet" href="styles.css.php?websiteid='.$object->id.'" type="text/css" />'."\n";
$tplcontent.= '<title>'.dol_escape_htmltag($objectpage->title).'</title>'."\n";
$tplcontent.= '</header>'."\n";
@ -452,6 +452,15 @@ if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage
{
$object->fetch(0, $website);
// Check symlink to medias and restore it if ko
$pathtomedias=DOL_DATA_ROOT.'/medias';
$pathtomediasinwebsite=$pathofwebsite.'/medias';
if (! is_link(dol_osencode($pathtomediasinwebsite)))
{
dol_syslog("Create symlink for ".$pathtomedias." into name ".$pathtomediasinwebsite);
symlink($pathtomedias, $pathtomediasinwebsite);
}
/*if (GETPOST('savevirtualhost') && $object->virtualhost != GETPOST('previewsite'))
{
$object->virtualhost = GETPOST('previewsite', 'alpha');
@ -558,7 +567,7 @@ if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage
$tplcontent.= '<meta name="title" content="'.dol_escape_htmltag($objectpage->title).'" />'."\n";
$tplcontent.= '<meta name="description" content="'.dol_escape_htmltag($objectpage->description).'" />'."\n";
$tplcontent.= '<meta name="generator" content="'.DOL_APPLICATION_TITLE.'" />'."\n";
$tplcontent.= '<link rel="stylesheet" href="styles.css.php?website='.$website.'" type="text/css" />'."\n";
$tplcontent.= '<link rel="stylesheet" href="styles.css.php?websiteid='.$object->id.'" type="text/css" />'."\n";
$tplcontent.= '<title>'.dol_escape_htmltag($objectpage->title).'</title>'."\n";
$tplcontent.= '</header>'."\n";