dolibarr 25.0.0-alpha
home.tpl.php
1<!-- file home.tpl.php -->
2<?php
3/* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
4 * Copyright (C) 2025 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2026 charlene Benke <charlene@patas-monkey.com>
6 */
7// Protection to avoid direct call of template
8if (empty($context) || !is_object($context)) {
9 print "Error, template page can't be called as URL";
10 exit(1);
11}
12'@phan-var-force Context $context';
18?>
19if ($context->userIsLog()) {
20 // menu propal
21 if (isModEnabled('propal') && getDolGlobalInt('WEBPORTAL_PROPAL_LIST_ACCESS')) {
22 $navMenu['propal_list'] = array(
23 'id' => 'propal_list',
24 'rank' => 10,
25 'url' => $context->getControllerUrl('propallist'),
26 'name' => $langs->trans('WebPortalPropalListMenu'),
27 'group' => 'administrative' // group identifier for the group if necessary
28 );
29 }
30 // menu orders
31 if (isModEnabled('order') && getDolGlobalInt('WEBPORTAL_ORDER_LIST_ACCESS')) {
32 $navMenu['order_list'] = array(
33 'id' => 'order_list',
34 'rank' => 20,
35 'url' => $context->getControllerUrl('orderlist'),
36 'name' => $langs->trans('WebPortalOrderListMenu'),
37 'group' => 'administrative' // group identifier for the group if necessary
38 );
39 }
40 // menu invoices
41 if (isModEnabled('invoice') && getDolGlobalInt('WEBPORTAL_INVOICE_LIST_ACCESS')) {
42 $navMenu['invoice_list'] = array(
43 'id' => 'invoice_list',
44 'rank' => 30,
45 'url' => $context->getControllerUrl('invoicelist'),
46 'name' => $langs->trans('WebPortalInvoiceListMenu'),
47 'group' => 'administrative' // group identifier for the group if necessary
48 );
49 }
50
51 // menu documents (GED)
52 if (getDolGlobalInt('WEBPORTAL_DOCUMENT_LIST_ACCESS')) {
53 $navMenu['document_list'] = array(
54 'id' => 'document_list',
55 'rank' => 40,
56 'url' => $context->getControllerUrl('documentlist'),
57 'name' => $langs->trans('MyDocuments'), // CORRIGÉ : Clé de traduction correcte
58 'group' => 'administrative' // group identifier for the group if necessary
59 );
60 }
61 // Shared documents menu
62 if (getDolGlobalInt('WEBPORTAL_SHARED_DOCUMENT_ACCESS')) {
63 $navMenu['shared_documents'] = array(
64 'id' => 'shared_documents',
65 'rank' => 50,
66 'url' => $context->getControllerUrl('shareddocuments'),
67 'name' => $langs->trans('SharedDocuments'),
68 'group' => 'administrative'
69 );
70 }
71 // menu member
72 $cardAccess = getDolGlobalString('WEBPORTAL_MEMBER_CARD_ACCESS');
73 if (isModEnabled('member')
74 && in_array($cardAccess, array('visible', 'edit'))
75 && $context->logged_member
76 && $context->logged_member->id > 0
77 ) {
78 $navMenu['member_card'] = array(
79 'id' => 'member_card',
80 'rank' => 110,
81 'url' => $context->getControllerUrl('membercard'),
82 'name' => $langs->trans('WebPortalMemberCardMenu'),
83 'group' => 'administrative' // group identifier for the group if necessary
84 );
85 }
86 // menu partnership
87 $cardAccess = getDolGlobalString('WEBPORTAL_PARTNERSHIP_CARD_ACCESS');
88 if (isModEnabled('partnership')
89 && in_array($cardAccess, array('visible', 'edit'))
90 && $context->logged_partnership
91 && $context->logged_partnership->id > 0
92 ) {
93 $navMenu['partnership_card'] = array(
94 'id' => 'partnership_card',
95 'rank' => 120,
96 'url' => $context->getControllerUrl('partnershipcard'),
97 'name' => $langs->trans('WebPortalPartnershipCardMenu'),
98 'group' => 'administrative' // group identifier for the group if necessary
99 );
100 }
101}
102
103$parameters = array(
104 'controller' => $context->controller,
105 'Tmenu' => & $navMenu,
106 'TUserMenu' => & $navUserMenu,
107 'TGroupMenu' => & $navGroupMenu,
108 'maxTopMenu' => & $maxTopMenu
109);
110
111$reshook = $hookmanager->executeHooks('PrintTopMenu', $parameters, $context, $context->action); // Note that $action and $object may have been modified by hook
112if ($reshook < 0) {
113 $context->setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
114}
115if (empty($reshook)) {
116 if (!empty($hookmanager->resArray)) {
117 // @phan-suppress-next-line PhanPluginSuspiciousParamOrderInternal
118 $navMenu = array_replace($navMenu, $hookmanager->resArray);
119 }
120
121 if (!empty($navMenu)) {
122 // Sorting
123 uasort($navMenu, 'menuSortInv');
124
125 if (!empty($maxTopMenu) && $maxTopMenu < count($navMenu)) {
126 // AFFECT MENU ITEMS TO GROUPS
127 foreach ($navMenu as $menuId => $menuItem) {
128 // assign items to group menu
129 if (!empty($menuItem['group']) && !empty($navGroupMenu[$menuItem['group']])) {
130 $goupId = $menuItem['group'];
131
132 // set item to group
133 $navGroupMenu[$goupId]['children'][$menuId] = $menuItem;
134
135 // apply rank
136 if (!empty($navGroupMenu[$goupId]['rank']) && $navGroupMenu[$goupId]['rank'] > 0) {
137 // minimum rank of group determine rank of group
138 $navGroupMenu[$goupId]['rank'] = min(abs($navGroupMenu[$goupId]['rank']), abs($menuItem['rank'])); // @phpstan-ignore-line
139 }
140 }
141 }
142 // add grouped items to this menu
143 foreach ($navGroupMenu as $groupId => $groupItem) {
144 // If group have more than 1 item, group is valid
145 if (!empty($groupItem['children']) && count($groupItem['children']) > 1) {
146 // add the group to the menu
147 $navMenu[$groupId] = $groupItem;
148
149 // suppress items children of the group from the menu
150 foreach ($groupItem['children'] as $menuId => $menuItem) {
151 if (isset($navMenu[$menuId])) {
152 unset($navMenu[$menuId]);
153 }
154 }
155 }
156 }
157
158 // final sorting
159 uasort($navMenu, 'menuSortInv');
160 }
161 }
162}
163print '<main class="container">';
164print '<div class="home-links-grid grid">';
165foreach ($navMenu as $menuId => $menuItem) {
166 print '<article class="home-links-card --' . $menuId . '">';
167 print '<div class="home-links-card__icon" ></div>';
168 print '<a class="home-links-card__link" href="' . $menuItem['url'] . '" title="' . $menuItem['name'] . '">' . $menuItem['name'] . '</a>';
169 print '</article>';
170}
171print '</div></main>';
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
$context
@method int call_trigger(string $triggerName, ?User $user)
Definition logout.php:42