Fix look and feel v18

This commit is contained in:
Laurent Destailleur 2023-03-15 11:29:44 +01:00
parent b45cfb278c
commit dc80e6b029

View File

@ -126,16 +126,38 @@ function member_prepare_head(Adherent $object)
$h++;
// Show agenda tab
if (isModEnabled('agenda')) {
$head[$h][0] = DOL_URL_ROOT."/adherents/agenda.php?id=".$object->id;
$head[$h][1] = $langs->trans("Events");
if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
$head[$h][1] .= '/';
$head[$h][1] .= $langs->trans("Agenda");
$head[$h][0] = DOL_URL_ROOT.'/adherents/agenda.php?id='.$object->id;
$head[$h][1] = $langs->trans("Events");
if (isModEnabled('agenda')&& (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
$nbEvent = 0;
// Enable caching of thirdparty count actioncomm
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
$cachekey = 'count_events_member_'.$object->id;
$dataretrieved = dol_getcache($cachekey);
if (!is_null($dataretrieved)) {
$nbEvent = $dataretrieved;
} else {
$sql = "SELECT COUNT(id) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm";
$sql .= " WHERE elementtype = 'member' AND fk_element = ".((int) $object->id);
$resql = $db->query($sql);
if ($resql) {
$obj = $db->fetch_object($resql);
$nbEvent = $obj->nb;
} else {
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] .= '/';
$head[$h][1] .= $langs->trans("Agenda");
if ($nbEvent > 0) {
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbEvent.'</span>';
}
$head[$h][2] = 'agenda';
$h++;
}
$head[$h][2] = 'agenda';
$h++;
complete_head_from_modules($conf, $langs, $object, $head, $h, 'member', 'add', 'external');