Merge branch '9.0' of git@github.com:Dolibarr/dolibarr.git into develop

Conflicts:
	htdocs/langs/en_US/website.lang
This commit is contained in:
Laurent Destailleur 2018-12-17 18:50:06 +01:00
commit 623afd1020
9 changed files with 90 additions and 46 deletions

View File

@ -2119,6 +2119,9 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
if (empty($conf->multicompany->enabled)) $entity=1;
else $entity=0;
}
// Fix modulepart
if ($modulepart == 'users') $modulepart='user';
dol_syslog('modulepart='.$modulepart.' original_file='.$original_file.' entity='.$entity);
// We define $accessallowed and $sqlprotectagainstexternals
$accessallowed=0;

View File

@ -1442,6 +1442,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
{
if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) // If you experienc trouble with pdf thumb generation and imagick, you can disable here.
{
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$ret = dol_convert_file($file, 'png', $fileimage);
if ($ret < 0) $error++;
}

View File

@ -212,6 +212,10 @@ function dolWebsiteOutput($content)
$content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
$content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/', '\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
$content=preg_replace('/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
$content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
$content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)hashp=([^\)]*)(["\']?\))/', '\1/wrapper.php\2hashp\3\4', $content, -1, $nbrep);
$content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=mycompany([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=mycompany\3file=\4\5', $content, -1, $nbrep);
}
else
@ -222,6 +226,10 @@ function dolWebsiteOutput($content)
$content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1medias/\4\5', $content, -1, $nbrep);
$content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/', '\1medias/\4\5', $content, -1, $nbrep);
$content=preg_replace('/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
$content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
$content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)hashp=([^\)]*)(["\']?\))/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
$content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=mycompany([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=mycompany\3file=\4\5', $content, -1, $nbrep);
}
}

View File

@ -38,7 +38,7 @@ if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
// For direct external download link, we don't need to load/check we are into a login session
if (isset($_GET["hashp"]))
if (isset($_GET["hashp"]) && ! defined("NOLOGIN"))
{
if (! defined("NOLOGIN")) define("NOLOGIN",1);
if (! defined("NOCSRFCHECK")) define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
@ -107,12 +107,6 @@ if (in_array($modulepart, array('facture_paiement','unpaid')))
* View
*/
// Define attachment (attachment=true to force choice popup 'open'/'save as')
$attachment = true;
if (preg_match('/\.(html|htm)$/i',$original_file)) $attachment = false;
if (isset($_GET["attachment"])) $attachment = GETPOST("attachment",'alpha')?true:false;
if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false;
// If we have a hash public (hashp), we guess the original_file.
if (! empty($hashp))
{
@ -122,8 +116,14 @@ if (! empty($hashp))
if ($result > 0)
{
$tmp = explode('/', $ecmfile->filepath, 2); // $ecmfile->filepath is relative to document directory
$moduleparttocheck = $tmp[0];
if ($modulepart) // Not required for link using public hashp
// filepath can be 'users/X' or 'X/propale/PR11111'
if (is_numeric($tmp[0])) // If first tmp is numeric, it is subdir of company for multicompany, we take next part.
{
$tmp = explode('/', $tmp[1], 2);
}
$moduleparttocheck = $tmp[0]; // moduleparttocheck is first part of path
if ($modulepart) // Not required, so often not defined, for link using public hashp parameter.
{
if ($moduleparttocheck == $modulepart)
{
@ -149,6 +149,12 @@ if (! empty($hashp))
}
}
// Define attachment (attachment=true to force choice popup 'open'/'save as')
$attachment = true;
if (preg_match('/\.(html|htm)$/i',$original_file)) $attachment = false;
if (isset($_GET["attachment"])) $attachment = GETPOST("attachment",'alpha')?true:false;
if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false;
// Define mime type
$type = 'application/octet-stream';
if (GETPOST('type','alpha')) $type=GETPOST('type','alpha');

View File

@ -1955,16 +1955,26 @@ else
}
$totalpaid = price2num($totalpaid); // Round $totalpaid to fix floating problem after addition into loop
if ($object->paid == 0)
$remaintopay = price2num($object->total_ttc - $totalpaid);
$resteapayeraffiche = $remaintopay;
$cssforamountpaymentcomplete = 'amountpaymentcomplete';
if ($object->status == ExpenseReport::STATUS_REFUSED)
{
print '<tr><td colspan="' . $nbcols . '" align="right">'.$langs->trans("AlreadyPaid").':</td><td align="right">'.price($totalpaid).'</td><td></td></tr>';
print '<tr><td colspan="' . $nbcols . '" align="right">'.$langs->trans("AmountExpected").':</td><td align="right">'.price($object->total_ttc).'</td><td></td></tr>';
$remaintopay = price2num($object->total_ttc - $totalpaid);
print '<tr><td colspan="' . $nbcols . '" align="right">'.$langs->trans("RemainderToPay").':</td>';
print '<td align="right"'.($remaintopay?' class="amountremaintopay"':'').'>'.price($remaintopay).'</td><td></td></tr>';
$cssforamountpaymentcomplete = 'amountpaymentneutral';
$resteapayeraffiche = 0;
}
elseif ($object->paid == 0)
{
$cssforamountpaymentcomplete = 'amountpaymentneutral';
}
print '<tr><td colspan="' . $nbcols . '" align="right">'.$langs->trans("AlreadyPaid").':</td><td align="right">'.price($totalpaid).'</td><td></td></tr>';
print '<tr><td colspan="' . $nbcols . '" align="right">'.$langs->trans("AmountExpected").':</td><td align="right">'.price($object->total_ttc).'</td><td></td></tr>';
print '<tr><td colspan="' . $nbcols . '" align="right">'.$langs->trans("RemainderToPay").':</td>';
print '<td align="right"'.($resteapayeraffiche?' class="amountremaintopay"':(' class="'.$cssforamountpaymentcomplete.'"')).'>'.price($resteapayeraffiche).'</td><td></td></tr>';
$db->free($resql);
}
else

View File

@ -92,4 +92,5 @@ ZipOfWebsitePackageToImport=Zip file of website package
ShowSubcontainers=Include dynamic content
InternalURLOfPage=Internal URL of page
ThisPageIsTranslationOf=This page/container is a translation of
ThisPageHasTranslationPages=This page/container has translation
ThisPageHasTranslationPages=This page/container has translation
NoWebSiteCreateOneFirst=No website created yet. Create on first.

View File

@ -131,8 +131,14 @@ if (! empty($hashp))
if ($result > 0)
{
$tmp = explode('/', $ecmfile->filepath, 2); // $ecmfile->filepath is relative to document directory
$moduleparttocheck = $tmp[0];
if ($modulepart) // Not required for link using public hashp
// filepath can be 'users/X' or 'X/propale/PR11111'
if (is_numeric($tmp[0])) // If first tmp is numeric, it is subdir of company for multicompany, we take next part.
{
$tmp = explode('/', $tmp[1], 2);
}
$moduleparttocheck = $tmp[0]; // moduleparttocheck is first part of path
if ($modulepart) // Not required, so often not defined, for link using public hashp parameter.
{
if ($moduleparttocheck == $modulepart)
{

View File

@ -366,7 +366,7 @@ if ($action == 'addcontainer')
$urltograb.='/';
}
$pageurl = dol_sanitizeFileName(preg_replace('/[\/\.]/','-', preg_replace('/\/+$/', '', $urltograbwithoutdomainandparam)));
$urltograbdirwithoutslash = dirname($urltograb.'.');
$urltograbdirrootwithoutslash = getRootURLFromURL($urltograbdirwithoutslash);
// Exemple, now $urltograbdirwithoutslash is https://www.dolimed.com/screenshots
@ -869,14 +869,14 @@ if ($action == 'updatecss')
$filemaster=$pathofwebsite.'/master.inc.php';
dol_syslog("Save master file ".$filemaster);
dol_mkdir($pathofwebsite);
// Now generate the master.inc.php page
$result = dolSaveMasterFile($filemaster);
if (! $result) setEventMessages('Failed to write file '.$filemaster, null, 'errors');
// Html header file
$htmlheadercontent ='';
@ -1472,8 +1472,15 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf
{
if (! $error)
{
setEventMessages($langs->trans("NoPageYet"), null, 'warnings');
setEventMessages($langs->trans("YouCanCreatePageOrImportTemplate"), null, 'warnings');
if (empty($websitekey) || $websitekey == '-1')
{
setEventMessages($langs->trans("NoWebSiteCreateOneFirst"), null, 'warnings');
}
else
{
setEventMessages($langs->trans("NoPageYet"), null, 'warnings');
setEventMessages($langs->trans("YouCanCreatePageOrImportTemplate"), null, 'warnings');
}
}
}
}
@ -1666,11 +1673,10 @@ if ($action != 'preview' && $action != 'editcontent' && $action != 'editsource')
if (! GETPOST('hide_websitemenu'))
{
//var_dump($objectpage);exit;
print '<div class="centpercent websitebar">';
//var_dump($objectpage);exit;
print '<div class="centpercent websitebar">';
if (count($object->records) > 0) // There is at least one web site
{
// ***** Part for web sites
print '<!-- Bar for website -->';
print '<div class="websiteselection hideonsmartphoneimp minwidth100 tdoverflowmax100">';
@ -1713,12 +1719,15 @@ if (count($object->records) > 0) // There is at least one web site
if (! empty($object->virtualhost)) $virtualurl=$object->virtualhost;
}
$array=$objectpage->fetchAll($object->id, 'ASC,ASC', 'type_container,pageurl');
$array=array();
if ($object->id > 0)
{
$array=$objectpage->fetchAll($object->id, 'ASC,ASC', 'type_container,pageurl');
}
if (! is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors);
$atleastonepage=(is_array($array) && count($array) > 0);
if ($websitekey && ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone'))
if ($websitekey && $websitekey != '-1' && ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone'))
{
$disabled='';
if (empty($user->rights->website->write)) $disabled=' disabled="disabled"';
@ -1828,7 +1837,7 @@ if (count($object->records) > 0) // There is at least one web site
// Toolbar for pages
if ($websitekey && ! in_array($action, array('editcss','editmenu','importsite')))
if ($websitekey && $websitekey != '-1' && ! in_array($action, array('editcss','editmenu','importsite')))
{
print '</div>'; // Close current websitebar to open a new one
@ -2125,17 +2134,8 @@ if (count($object->records) > 0) // There is at least one web site
}
}
}
}
else
{
print '<div class="websiteselection">';
$langs->load("errors");
print $langs->trans("ErrorModuleSetupNotComplete");
print '<div>';
$action='';
}
print '</div>'; // end current websitebar
print '</div>'; // end current websitebar
}
@ -2743,7 +2743,8 @@ if ($action == 'editsource')
$doleditor->Create(0, '', false);
}*/
print "</div>\n</form>\n";
print "</div>\n";
print "</form>\n";
if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone')
@ -2874,8 +2875,16 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa
}
else
{
print '<br><br><div class="center">'.$langs->trans("PreviewOfSiteNotYetAvailable", $object->ref).'</center><br><br><br>';
print '<div class="center"><div class="logo_setup"></div></div>';
if (empty($websitekey) || $websitekey == '-1')
{
print '<br><br><div class="center">'.$langs->trans("NoWebSiteCreateOneFirst").'</center><br><br><br>';
print '<div class="center"><div class="logo_setup"></div></div>';
}
else
{
print '<br><br><div class="center">'.$langs->trans("PreviewOfSiteNotYetAvailable", $object->ref).'</center><br><br><br>';
print '<div class="center"><div class="logo_setup"></div></div>';
}
}
}