diff --git a/class/saturnedashboard.class.php b/class/saturnedashboard.class.php index 125c262a..16d84bdd 100644 --- a/class/saturnedashboard.class.php +++ b/class/saturnedashboard.class.php @@ -101,7 +101,7 @@ public function load_dashboard(?array $moreParams = []): array */ public function show_dashboard(?array $moreParams = []) { - global $conf, $form, $langs, $moduleNameLowerCase, $user; + global $conf, $form, $langs, $moduleNameLowerCase; $width = DolGraph::getDefaultGraphSizeForStats('width'); $height = DolGraph::getDefaultGraphSizeForStats('height'); @@ -115,10 +115,10 @@ public function show_dashboard(?array $moreParams = []) print ''; $confName = dol_strtoupper($moduleNameLowerCase) . '_DASHBOARD_CONFIG'; - $disableWidgetList = json_decode($user->conf->$confName); + $disableWidgetList = json_decode(getDolUserString($confName)); $disableWidgetList = $disableWidgetList->widgets ?? new stdClass(); $dashboardWidgetsArray = []; - if (is_array($dashboards['widgets']) && !empty($dashboards['widgets'])) { + if (isset($dashboards['widgets']) && is_array($dashboards['widgets'])) { foreach ($dashboards['widgets'] as $dashboardWidgets) { foreach ($dashboardWidgets as $key => $dashboardWidget) { if (isset($disableWidgetList->$key) && $disableWidgetList->$key == 0) { @@ -136,7 +136,7 @@ public function show_dashboard(?array $moreParams = []) } print ''; - if (is_array($dashboards['widgets']) && !empty($dashboards['widgets'])) { + if (isset($dashboards['widgets']) && is_array($dashboards['widgets'])) { $widget = ''; foreach ($dashboards['widgets'] as $dashboardWidgets) { foreach ($dashboardWidgets as $key => $dashboardWidget) { @@ -179,7 +179,7 @@ public function show_dashboard(?array $moreParams = []) } } $widget .= ''; - if (is_array($dashboardWidget['moreParams']) && (!empty($dashboardWidget['moreParams']))) { + if (!empty($dashboardWidget['moreParams']) && is_array($dashboardWidget['moreParams'])) { $widget .= '
'; foreach ($dashboardWidget['moreParams'] as $dashboardWidgetMoreParamsKey => $dashboardWidgetMoreParams) { switch ($dashboardWidgetMoreParamsKey) { @@ -248,7 +248,7 @@ public function show_dashboard(?array $moreParams = []) print '
'; - if (is_array($dashboards['graphs']) && !empty($dashboards['graphs'])) { + if (isset($dashboards['graphs']) && is_array($dashboards['graphs'])) { foreach ($dashboards['graphs'] as $dashboardGraphs) { if (is_array($dashboardGraphs) && !empty($dashboardGraphs)) { foreach ($dashboardGraphs as $keyElement => $dashboardGraph) { @@ -315,8 +315,8 @@ public function show_dashboard(?array $moreParams = []) $graph->SetHeight($dashboardGraph['height'] ?? $height); $graph->setShowLegend($dashboardGraph['showlegend'] ?? 2); $graph->draw($fileName[$uniqueKey], $fileUrl[$uniqueKey]); - print '
'; - + print ''; + $downloadCSV = '
'; $downloadCSV .= ''; $downloadCSV .= ''; } $downloadCSV .= '
'; - $dashboardGraph['morehtmlright'] .= $downloadCSV; - + if (isset($dashboardGraph['morehtmlright'])) { + $dashboardGraph['morehtmlright'] .= $downloadCSV; + } else { + $dashboardGraph['morehtmlright'] = $downloadCSV; + } + print load_fiche_titre($dashboardGraph['title'], $dashboardGraph['morehtmlright'], $dashboardGraph['picto']); print $graph->show(); print '
'; @@ -340,11 +344,11 @@ public function show_dashboard(?array $moreParams = []) } } - if (is_array($dashboards['lists']) && !empty($dashboards['lists'])) { + if (isset($dashboards['lists']) && is_array($dashboards['lists'])) { foreach ($dashboards['lists'] as $dashboardLists) { foreach ($dashboardLists as $dashboardList) { if (is_array($dashboardList['data']) && !empty($dashboardList['data'])) { - print '
'; + print '
'; if (!empty($dashboardList['name'])) { $dashboardList['morehtmlright'] = ''; } - print load_fiche_titre($dashboardList['title'], $dashboardList['morehtmlright'], $dashboardList['picto']); + print load_fiche_titre($dashboardList['title'], $dashboardList['morehtmlright'] ?? '', $dashboardList['picto'] ?? ''); print ''; print ''; foreach ($dashboardList['labels'] as $key => $dashboardListLabel) { @@ -362,7 +366,7 @@ public function show_dashboard(?array $moreParams = []) foreach ($dashboardList['data'] as $dashboardListDatasets) { print ''; foreach ($dashboardListDatasets as $key => $dashboardGraphDataset) { - print ''; + print ''; } print ''; } diff --git a/class/saturneobject.class.php b/class/saturneobject.class.php index efdfe228..d528d789 100644 --- a/class/saturneobject.class.php +++ b/class/saturneobject.class.php @@ -161,7 +161,7 @@ public function fetchAll(string $sortorder = '', string $sortfield = '', int $li foreach ($filter as $key => $value) { if ($key == 't.rowid') { $sqlwhere[] = $key . ' = ' . ((int) $value); - } elseif (in_array($this->fields[$key]['type'], ['date', 'datetime', 'timestamp'])) { + } elseif (isset($this->fields[$key]['type']) && in_array($this->fields[$key]['type'], ['date', 'datetime', 'timestamp'])) { $sqlwhere[] = $key . " = '" . $this->db->idate($value) . "'"; } elseif ($key == 'customsql') { $sqlwhere[] = $value; diff --git a/class/saturnesignature.class.php b/class/saturnesignature.class.php index 86f87fcf..cc1f4747 100644 --- a/class/saturnesignature.class.php +++ b/class/saturnesignature.class.php @@ -323,7 +323,7 @@ public function fetchAll(string $sortorder = '', string $sortfield = '', int $li foreach ($filter as $key => $value) { if ($key == 't.rowid') { $sqlwhere[] = $key . '=' . $value; - } elseif (in_array($this->fields[$key]['type'], ['date', 'datetime', 'timestamp'])) { + } elseif (isset($this->fields[$key]['type']) && in_array($this->fields[$key]['type'], ['date', 'datetime', 'timestamp'])) { $sqlwhere[] = $key . ' = \'' . $this->db->idate($value) . '\''; } elseif ($key == 'customsql') { $sqlwhere[] = $value; diff --git a/class/task/saturnetask.class.php b/class/task/saturnetask.class.php index 49a0bb31..e53bc075 100644 --- a/class/task/saturnetask.class.php +++ b/class/task/saturnetask.class.php @@ -83,10 +83,10 @@ public function __construct($db) */ public function load_dashboard($projectId): array { - global $user, $langs; + global $langs; $confName = dol_strtoupper($this->module) . '_DASHBOARD_CONFIG'; - $dashboardConfig = json_decode($user->conf->$confName); + $dashboardConfig = json_decode(getDolUserString($confName)); $array = ['graphs' => [], 'disabledGraphs' => []]; if (empty($dashboardConfig->graphs->TasksRepartition->hide)) { @@ -346,7 +346,6 @@ public function fetchAllTimeSpentAllUsers($morewherefilter = '', $sortfield = '' $newobj->fk_project = $obj->project_id; $newobj->project_ref = $obj->project_ref; $newobj->project_label = $obj->project_label; - $newobj->public = $obj->project_public; $newobj->fk_task = $obj->task_id; $newobj->task_ref = $obj->task_ref; diff --git a/core/tpl/index/index_view.tpl.php b/core/tpl/index/index_view.tpl.php index 08f1ff25..ec35d76d 100644 --- a/core/tpl/index/index_view.tpl.php +++ b/core/tpl/index/index_view.tpl.php @@ -65,7 +65,7 @@ saturne_header(0, '', $title . ' ' . $modModule->version, $helpUrl); -print load_fiche_titre($title . ' ' . $modModule->version, $morehtmlright, $moduleNameLowerCase . '_color.png@' . $moduleNameLowerCase); +print load_fiche_titre($title . ' ' . $modModule->version, $morehtmlright ?? '', $moduleNameLowerCase . '_color.png@' . $moduleNameLowerCase); $moduleJustUpdated = strtoupper($moduleName) . '_JUST_UPDATED'; $moduleVersion = strtoupper($moduleName) . '_VERSION'; diff --git a/core/tpl/medias/medias_gallery_modal.tpl.php b/core/tpl/medias/medias_gallery_modal.tpl.php index 996792c3..38f6243a 100644 --- a/core/tpl/medias/medias_gallery_modal.tpl.php +++ b/core/tpl/medias/medias_gallery_modal.tpl.php @@ -359,18 +359,18 @@
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); /*
' . $dashboardGraphDataset['value'] . '' . $dashboardGraphDataset['value'] . '