trans('Link'), 'link') . ' ' . $form->textwithpicto($langs->trans('UnlinkedMedias'), $langs->trans('ShowOnlyUnlinkedMedias'));
- if (isset($user->conf->SATURNE_MEDIA_GALLERY_SHOW_UNLINKED_MEDIAS) && $user->conf->SATURNE_MEDIA_GALLERY_SHOW_UNLINKED_MEDIAS) {
- print '' . img_picto($langs->trans('Enabled'), 'switch_on') . '';
+ if (getDolUserInt('SATURNE_MEDIA_GALLERY_SHOW_UNLINKED_MEDIAS')) {
+ print '' . img_picto($langs->trans('Enabled'), 'switch_on') . '';
} else {
- print '' . img_picto($langs->trans('Disabled'), 'switch_off') . '';
+ print '' . img_picto($langs->trans('Disabled'), 'switch_off') . '';
} ?>
trans('Calendar'), 'calendar') . ' ' . $form->textwithpicto($langs->trans('Today'), $langs->trans('ShowOnlyMediasAddedToday'));
- if (isset($user->conf->SATURNE_MEDIA_GALLERY_SHOW_TODAY_MEDIAS) && $user->conf->SATURNE_MEDIA_GALLERY_SHOW_TODAY_MEDIAS) {
- print '' . img_picto($langs->trans('Enabled'), 'switch_on') . '';
+ if (getDolUserInt('SATURNE_MEDIA_GALLERY_SHOW_TODAY_MEDIAS')) {
+ print '' . img_picto($langs->trans('Enabled'), 'switch_on') . '';
} else {
- print '' . img_picto($langs->trans('Disabled'), 'switch_off') . '';
+ print '' . img_picto($langs->trans('Disabled'), 'switch_off') . '';
} ?>
diff --git a/lib/documents.lib.php b/lib/documents.lib.php
index c16df38b..d5ca70b8 100644
--- a/lib/documents.lib.php
+++ b/lib/documents.lib.php
@@ -309,7 +309,7 @@ function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, str
// Preview
if (!empty($conf->use_javascript_ajax) && ($conf->browser->layout != 'phone')) {
- $tmparray = getAdvancedPreviewUrl($modulepart, $relativepath, 1, '&entity=' . $entity);
+ $tmparray = getAdvancedPreviewUrl($modulepart, $relativepath, 1, '&entity=' . $conf->entity);
if ($tmparray && $tmparray['url']) {
$out .= '';
//$out.= img_picto('','detail');
diff --git a/lib/medias.lib.php b/lib/medias.lib.php
index 9c79c13c..0253e195 100644
--- a/lib/medias.lib.php
+++ b/lib/medias.lib.php
@@ -48,13 +48,13 @@ function saturne_show_medias(string $moduleName, string $modulepart = 'ecm', str
$filearray = dol_dir_list($dir, 'files', 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC));
- if ($user->conf->SATURNE_MEDIA_GALLERY_SHOW_TODAY_MEDIAS == 1) {
+ if (getDolUserInt('SATURNE_MEDIA_GALLERY_SHOW_TODAY_MEDIAS')) {
$yesterdayTimeStamp = dol_time_plus_duree(dol_now(), -1, 'd');
$filearray = array_filter($filearray, function($file) use ($yesterdayTimeStamp) {
return $file['date'] > $yesterdayTimeStamp;
});
}
- if ($user->conf->SATURNE_MEDIA_GALLERY_SHOW_UNLINKED_MEDIAS == 1) {
+ if (getDolUserInt('SATURNE_MEDIA_GALLERY_SHOW_UNLINKED_MEDIAS')) {
$moduleObjectMedias = dol_dir_list($conf->$moduleNameLowerCase->multidir_output[$conf->entity ?? 1], 'files', 1, '', '.odt|.pdf|barcode|_mini|_medium|_small|_large');
$filearray = array_filter($filearray, function($file) use ($conf, $moduleNameLowerCase, $moduleObjectMedias) {
$fileExists = array_search($file['name'], array_column($moduleObjectMedias, 'name'));
@@ -71,10 +71,11 @@ function saturne_show_medias(string $moduleName, string $modulepart = 'ecm', str
$filearray = dol_sort_array($filearray, $sortfield, $sortorder);
}
- $moduleImageNumberPerPageConf = strtoupper($moduleName) . '_DISPLAY_NUMBER_MEDIA_GALLERY';
- for ($i = (($offset - 1) * $conf->global->$moduleImageNumberPerPageConf); $i < ($conf->global->$moduleImageNumberPerPageConf + (($offset - 1) * $conf->global->$moduleImageNumberPerPageConf)); $i++) {
+ $confName = strtoupper($moduleName) . '_DISPLAY_NUMBER_MEDIA_GALLERY';
+ $moduleImageNumberPerPageConf = getDolGlobalInt($confName);
+ for ($i = (($offset - 1) * $moduleImageNumberPerPageConf); $i < ($moduleImageNumberPerPageConf + (($offset - 1) * $moduleImageNumberPerPageConf)); $i++) {
- $fileName = $filearray[$i]['name'];
+ $fileName = $filearray[$i]['name'] ?? '';
if (image_format_supported($fileName) >= 0) {
$nbphoto++;
@@ -343,7 +344,7 @@ function saturne_show_medias_linked(string $modulepart = 'ecm', string $sdir, $s
}
}
} else {
- $return .= '
';
+ $return .= '
';
}
if (is_object($object)) {
@@ -371,7 +372,7 @@ function saturne_get_thumb_name(string $filename, string $thumbType = 'small'):
* Return media linked elements count
*
* @param string $moduleName Module name
- * @param string $fileName File name
+ * @param string $fileName File name
* @return string $output Show media linked element count
*
*/
@@ -398,14 +399,16 @@ function saturne_get_media_linked_elements(string $moduleName, string $fileName)
$object = new $className($db);
$mediaLinkedElements[$fileArray['name']][$element[0]]['picto'] = $object->picto;
- $mediaLinkedElements[$fileArray['name']][$element[0]]['value']++;
+ if (isset($mediaLinkedElements[$fileArray['name']][$element[0]]['value'])) {
+ $mediaLinkedElements[$fileArray['name']][$element[0]]['value']++;
+ }
}
$output = '';
foreach ($mediaLinkedElements as $mediaLinkedElement) {
foreach ($mediaLinkedElement as $key => $linkedElement) {
$output .= '' . img_picto($langs->trans(ucfirst($key)), $linkedElement['picto'], 'class="paddingright"');
- $output .= $linkedElement['value'];
+ $output .= $linkedElement['value'] ?? 0;
$output .= '';
}
}
diff --git a/lib/object.lib.php b/lib/object.lib.php
index 0e58f217..0202b9d6 100644
--- a/lib/object.lib.php
+++ b/lib/object.lib.php
@@ -100,7 +100,7 @@ function saturne_fetch_all_object_type(string $className = '', string $sortorder
foreach ($filter as $key => $value) {
if ($key == 't.rowid') {
$sqlwhere[] = $key . ' = ' . $value;
- } elseif (in_array($object->fields[$key]['type'], ['date', 'datetime', 'timestamp'])) {
+ } elseif (isset($object->fields[$key]['type']) && in_array($object->fields[$key]['type'], ['date', 'datetime', 'timestamp'])) {
$sqlwhere[] = $key .' = \'' . $object->db->idate($value) . '\'';
} elseif ($key == 'customsql') {
$sqlwhere[] = $value;
diff --git a/lib/saturne_functions.lib.php b/lib/saturne_functions.lib.php
index d35b145b..7210fba9 100644
--- a/lib/saturne_functions.lib.php
+++ b/lib/saturne_functions.lib.php
@@ -99,7 +99,7 @@ function saturne_check_access($permission, object $object = null, bool $allowExt
}
if (isModEnabled('multicompany')) {
- if ($object->id > 0) {
+ if (!is_null($object) && $object->id > 0) {
if ($object->entity != $conf->entity) {
setEventMessage($langs->trans('ChangeEntityRedirection'), 'warnings');
$urltogo = dol_buildpath('/custom/' . $moduleNameLowerCase . '/' . $moduleNameLowerCase . 'index.php?mainmenu=' . $moduleNameLowerCase, 1);
@@ -209,6 +209,7 @@ function saturne_banner_tab(object $object, string $paramId = 'ref', string $mor
if ($resHook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
} else {
+ $customMoreHtmlRef = '';
if (!empty($hookmanager->resArray)) {
list($customMoreHtmlRef, $moreParams) = $hookmanager->resArray;
} else if (!empty($hookmanager->resPrint)) {
@@ -286,7 +287,7 @@ function saturne_banner_tab(object $object, string $paramId = 'ref', string $mor
}
} else {
$BannerElementObject->fetch($object->$objectKey);
- if ($bannerElement == 'societe' || $bannerElement == $moreParams['bannerElement']) {
+ if ($bannerElement == 'societe' || !empty($moreParams['bannerElement']) && $bannerElement == $moreParams['bannerElement']) {
$saturneMoreHtmlRef .= $object->$objectKey > 0 ? $BannerElementObject->getNomUrl(1) : '';
} elseif ($bannerElement == 'project') {
$saturneMoreHtmlRef .= $object->$objectKey > 0 ? $BannerElementObject->getNomUrl(1, '', 1) : '';
@@ -315,16 +316,16 @@ function saturne_banner_tab(object $object, string $paramId = 'ref', string $mor
$resHook = $hookmanager->executeHooks('saturneBannerTabCustomSubdir', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($resHook > 0) {
if (!empty($hookmanager->resArray)) {
- if ($hookmanager->resArray['modulepart']) {
+ if (!empty($hookmanager->resArray['modulepart'])) {
$modulePart = $hookmanager->resArray['modulepart'];
}
- if ($hookmanager->resArray['dir']) {
+ if (!empty($hookmanager->resArray['dir'])) {
$baseDir = $hookmanager->resArray['dir'];
}
- if ($hookmanager->resArray['subdir']) {
+ if (!empty($hookmanager->resArray['subdir'])) {
$subDir = $hookmanager->resArray['subdir'];
}
- if ($hookmanager->resArray['photoLimit']) {
+ if (!empty($hookmanager->resArray['photoLimit'])) {
$photoLimit = $hookmanager->resArray['photoLimit'];
}
}
diff --git a/view/saturne_agenda.php b/view/saturne_agenda.php
index 730b12cb..85122205 100644
--- a/view/saturne_agenda.php
+++ b/view/saturne_agenda.php
@@ -108,8 +108,8 @@
}
// Security check - Protection if external user
-$permissiontoread = $user->rights->$moduleNameLowerCase->$objectType->read;
-$permissiontoadd = $user->rights->$moduleNameLowerCase->$objectType->write;
+$permissiontoread = $user->hasRight($moduleNameLowerCase, $objectType, 'read');
+$permissiontoadd = $user->hasRight($moduleNameLowerCase, $objectType, 'write');
saturne_check_access($permissiontoread, $object);
/*