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

This commit is contained in:
Laurent Destailleur 2022-03-16 21:22:45 +01:00
commit 922a0e58a4
4 changed files with 40 additions and 22 deletions

View File

@ -10563,7 +10563,7 @@ function isAFileWithExecutableContent($filename)
*/ */
function newToken() function newToken()
{ {
return $_SESSION['newtoken']; return empty($_SESSION['newtoken']) ? '' : $_SESSION['newtoken'];
} }
/** /**

View File

@ -27,6 +27,11 @@
include_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php'; include_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php';
include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php'; include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php';
$website = null;
$websitepage = null;
$weblangs = null;
$pagelangs = null;
// Detection browser (copy of code from main.inc.php) // Detection browser (copy of code from main.inc.php)
if (isset($_SERVER["HTTP_USER_AGENT"]) && is_object($conf) && empty($conf->browser->name)) { if (isset($_SERVER["HTTP_USER_AGENT"]) && is_object($conf) && empty($conf->browser->name)) {
$tmp = getBrowserInfo($_SERVER["HTTP_USER_AGENT"]); $tmp = getBrowserInfo($_SERVER["HTTP_USER_AGENT"]);
@ -68,7 +73,7 @@ if ($pageid > 0) {
$weblangs->setDefaultLang(GETPOSTISSET('lang') ? GETPOST('lang', 'aZ09') : (empty($_COOKIE['weblangs-shortcode']) ? 'auto' : preg_replace('/[^a-zA-Z0-9_\-]/', '', $_COOKIE['weblangs-shortcode']))); $weblangs->setDefaultLang(GETPOSTISSET('lang') ? GETPOST('lang', 'aZ09') : (empty($_COOKIE['weblangs-shortcode']) ? 'auto' : preg_replace('/[^a-zA-Z0-9_\-]/', '', $_COOKIE['weblangs-shortcode'])));
$pagelangs->setDefaultLang($websitepage->lang ? $websitepage->lang : $weblangs->shortlang); $pagelangs->setDefaultLang($websitepage->lang ? $websitepage->lang : $weblangs->shortlang);
if (!defined('USEDOLIBARREDITOR') && (in_array($websitepage->type_container, array('menu', 'other')) || empty($websitepage->status))) { if (!defined('USEDOLIBARREDITOR') && (in_array($websitepage->type_container, array('menu', 'other')) || empty($websitepage->status) && !defined('USEDOLIBARRSERVER'))) {
$weblangs->load("website"); $weblangs->load("website");
http_response_code(404); http_response_code(404);
print '<center><br><br>'.$weblangs->trans("YouTryToAccessToAFileThatIsNotAWebsitePage", $websitepage->pageurl, $websitepage->type_container, $websitepage->status).'</center>'; print '<center><br><br>'.$weblangs->trans("YouTryToAccessToAFileThatIsNotAWebsitePage", $websitepage->pageurl, $websitepage->type_container, $websitepage->status).'</center>';

View File

@ -101,12 +101,18 @@ $sql .= ' WHERE s.entity IN ('.getEntity('societe').')';
if (empty($user->rights->societe->client->voir) && !$socid) { if (empty($user->rights->societe->client->voir) && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
} }
if ($socid > 0) {
$sql .= " AND s.rowid = ".((int) $socid);
}
if (empty($user->rights->fournisseur->lire)) { if (empty($user->rights->fournisseur->lire)) {
$sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible $sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible
} }
// Add where from hooks
$parameters = array('socid' => $socid);
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
if (empty($reshook)) {
if ($socid > 0) {
$sql .= " AND s.rowid = ".((int) $socid);
}
}
$sql .= $hookmanager->resPrint;
//print $sql; //print $sql;
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { if ($result) {
@ -284,12 +290,18 @@ $sql .= ' WHERE s.entity IN ('.getEntity('societe').')';
if (empty($user->rights->societe->client->voir) && !$socid) { if (empty($user->rights->societe->client->voir) && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
} }
if ($socid) {
$sql .= " AND s.rowid = ".((int) $socid);
}
if (empty($user->rights->fournisseur->lire)) { if (empty($user->rights->fournisseur->lire)) {
$sql .= " AND (s.fournisseur != 1 OR s.client != 0)"; $sql .= " AND (s.fournisseur != 1 OR s.client != 0)";
} }
// Add where from hooks
$parameters = array('socid' => $socid);
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
if (empty($reshook)) {
if ($socid > 0) {
$sql .= " AND s.rowid = ".((int) $socid);
}
}
$sql .= $hookmanager->resPrint;
$sql .= $db->order("s.tms", "DESC"); $sql .= $db->order("s.tms", "DESC");
$sql .= $db->plimit($max, 0); $sql .= $db->plimit($max, 0);

View File

@ -2520,6 +2520,7 @@ $form = new Form($db);
$formadmin = new FormAdmin($db); $formadmin = new FormAdmin($db);
$formwebsite = new FormWebsite($db); $formwebsite = new FormWebsite($db);
$formother = new FormOther($db); $formother = new FormOther($db);
$formconfirm = "";
// Confirm generation of website sitemaps // Confirm generation of website sitemaps
if ($action == 'confirmgeneratesitemaps') { if ($action == 'confirmgeneratesitemaps') {
@ -3040,7 +3041,7 @@ if (!GETPOST('hide_websitemenu')) {
print '<!-- Code to enabled edit inline ckeditor -->'."\n"; print '<!-- Code to enabled edit inline ckeditor -->'."\n";
print '<script type="text/javascript"> print '<script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
var isEditingEnabled = '.($conf->global->WEBSITE_EDITINLINE ? 'true' : 'false').'; var isEditingEnabled = '.(getDolGlobalString("WEBSITE_EDITINLINE") ? 'true' : 'false').';
if (isEditingEnabled) if (isEditingEnabled)
{ {
switchEditorOnline(true); switchEditorOnline(true);