From 9e18a8b7836b2a5219113d56e7ae281302cee891 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 6 Mar 2023 18:03:30 +0100 Subject: [PATCH] Clean code --- htdocs/comm/propal/agenda.php | 4 ++-- htdocs/core/lib/memory.lib.php | 2 +- htdocs/core/lib/propal.lib.php | 8 ++++---- htdocs/modulebuilder/template/myobject_agenda.php | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/comm/propal/agenda.php b/htdocs/comm/propal/agenda.php index fd8465b58da..f3b35d07cfe 100644 --- a/htdocs/comm/propal/agenda.php +++ b/htdocs/comm/propal/agenda.php @@ -235,7 +235,7 @@ if ($object->id > 0) { // Try to know count of actioncomm from cache require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; - $cachekey = 'count_events_myobject_'.$object->id; + $cachekey = 'count_events_propal_'.$object->id; $nbEvent = dol_getcache($cachekey); print_barre_liste($langs->trans("ActionsOnPropal").(is_numeric($nbEvent) ? '('.$nbEvent.')': ''), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 1); @@ -247,7 +247,7 @@ if ($object->id > 0) { $filters['search_rowid'] = $search_rowid; // TODO Replace this with same code than into list.php - show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module); + show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, property_exists($object, 'module') ? $object->module : ''); } } diff --git a/htdocs/core/lib/memory.lib.php b/htdocs/core/lib/memory.lib.php index 5c4826a2dc5..3be5e902816 100644 --- a/htdocs/core/lib/memory.lib.php +++ b/htdocs/core/lib/memory.lib.php @@ -57,7 +57,7 @@ $shmoffset = 1000; // Max number of entries found into a language file. If too l /** - * Save data into a memory area shared by all users, all sessions on server + * Save data into a memory area shared by all users, all sessions on server. Note: MAIN_CACHE_COUNT must be set. * * @param string $memoryid Memory id of shared area * @param mixed $data Data to save. It must not be a null value. diff --git a/htdocs/core/lib/propal.lib.php b/htdocs/core/lib/propal.lib.php index 205c6a79781..588418c7449 100644 --- a/htdocs/core/lib/propal.lib.php +++ b/htdocs/core/lib/propal.lib.php @@ -112,14 +112,15 @@ function propal_prepare_head($object) $nbEvent = 0; // Enable caching of thirdparty count actioncomm require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; - $cachekey = 'count_events_thirdparty_'.$object->id; + $cachekey = 'count_events_propal_'.$object->id; $dataretrieved = dol_getcache($cachekey); if (!is_null($dataretrieved)) { $nbEvent = $dataretrieved; } else { - /*$sql = "SELECT COUNT(id) as nb"; + $sql = "SELECT COUNT(id) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm"; - $sql .= " WHERE fk_soc = ".((int) $object->id); + $sql .= " WHERE fk_element = ".((int) $object->id); + $sql .= " AND elementtype = 'propal'"; $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); @@ -128,7 +129,6 @@ function propal_prepare_head($object) dol_syslog('Failed to count actioncomm '.$db->lasterror(), LOG_ERR); } dol_setcache($cachekey, $nbEvent, 120); // If setting cache fails, this is not a problem, so we do not test result. - */ } $head[$h][1] .= '/'; diff --git a/htdocs/modulebuilder/template/myobject_agenda.php b/htdocs/modulebuilder/template/myobject_agenda.php index 899ed899382..189bfd6282b 100644 --- a/htdocs/modulebuilder/template/myobject_agenda.php +++ b/htdocs/modulebuilder/template/myobject_agenda.php @@ -319,7 +319,7 @@ if ($object->id > 0) { $filters['search_rowid'] = $search_rowid; // TODO Replace this with same code than into list.php - show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module); + show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, property_exists($object, 'module') ? $object->module : ''); } }