dolibarr 24.0.0-beta
member.lib.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro@open-dsi.fr>
4 * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
5 * Copyright (C) 2017 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
7 * Copyright (C) 2025-2026 Frédéric France <frederic.france@free.fr>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 * or see https://www.gnu.org/
22 */
23
36{
37 global $db, $langs, $conf, $user;
38
39 $h = 0;
40 $head = array();
41
42 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/card.php', ['id' => $object->id]);
43 $head[$h][1] = $langs->trans("Member");
44 $head[$h][2] = 'general';
45 $h++;
46
47 if ((isModEnabled('ldap') && getDolGlobalString('LDAP_MEMBER_ACTIVE'))
48 && (!getDolGlobalString('MAIN_DISABLE_LDAP_TAB') || !empty($user->admin))) {
49 $langs->load("ldap");
50
51 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/ldap.php', ['id' => $object->id]);
52 $head[$h][1] = $langs->trans("LDAPCard");
53 $head[$h][2] = 'ldap';
54 $h++;
55 }
56
57 if ($user->hasRight('adherent', 'cotisation', 'lire')) {
58 $nbSubscription = is_array($object->subscriptions) ? count($object->subscriptions) : 0;
59 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/subscription.php', ['id' => $object->id]);
60 $head[$h][1] = $langs->trans("Subscriptions");
61 $head[$h][2] = 'subscription';
62 if ($nbSubscription > 0) {
63 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbSubscription.'</span>';
64 }
65 $h++;
66 }
67
68 if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') {
69 if ($user->hasRight('partnership', 'read')) {
70 $nbPartnership = is_array($object->partnerships) ? count($object->partnerships) : 0;
71 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/partnership/partnership_list.php', ['id' => $object->id]);
72 $head[$h][1] = $langs->trans("Partnerships");
73 $nbNote = 0;
74 $sql = "SELECT COUNT(n.rowid) as nb";
75 $sql .= " FROM ".MAIN_DB_PREFIX."partnership as n";
76 $sql .= " WHERE fk_member = ".((int) $object->id);
77 $resql = $db->query($sql);
78 if ($resql) {
79 $obj = $db->fetch_object($resql);
80 $nbNote = $obj->nb;
81 } else {
83 }
84 if ($nbNote > 0) {
85 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
86 }
87 $head[$h][2] = 'partnerships';
88 if ($nbPartnership > 0) {
89 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbPartnership.'</span>';
90 }
91 $h++;
92 }
93 }
94
95 // Show more tabs from modules
96 // Entries must be declared in modules descriptor with line
97 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
98 // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
99 complete_head_from_modules($conf, $langs, $object, $head, $h, 'member', 'add', 'core');
100
101 $nbNote = 0;
102 if (!empty($object->note_private)) {
103 $nbNote++;
104 }
105 if (!empty($object->note_public)) {
106 $nbNote++;
107 }
108 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/note.php', ['id' => $object->id]);
109 $head[$h][1] = $langs->trans("Note");
110 $head[$h][2] = 'note';
111 if ($nbNote > 0) {
112 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
113 }
114 $h++;
115
116 // Attachments
117 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
118 require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
119 $upload_dir = $conf->adherent->multidir_output[$object->entity ?? $conf->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'member');
120 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
121 $nbLinks = Link::count($db, $object->element, $object->id);
122 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/document.php', ['id' => $object->id]);
123 $head[$h][1] = $langs->trans('Documents');
124 if (($nbFiles + $nbLinks) > 0) {
125 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
126 }
127 $head[$h][2] = 'document';
128 $h++;
129
130 // Show agenda tab
131 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/agenda.php', ['id' => $object->id]);
132 $head[$h][1] = $langs->trans("Events");
133 if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) {
134 $nbEvent = 0;
135 // Enable caching of thirdparty count actioncomm
136 require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
137 $cachekey = 'count_events_member_'.$object->id;
138 $dataretrieved = dol_getcache($cachekey);
139 if (!is_null($dataretrieved)) {
140 $nbEvent = $dataretrieved;
141 } else {
142 $sql = "SELECT COUNT(id) as nb";
143 $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm";
144 $sql .= " WHERE elementtype = 'member' AND fk_element = ".((int) $object->id);
145 $resql = $db->query($sql);
146 if ($resql) {
147 $obj = $db->fetch_object($resql);
148 $nbEvent = $obj->nb;
149 } else {
150 dol_syslog('Failed to count actioncomm '.$db->lasterror(), LOG_ERR);
151 }
152 dol_setcache($cachekey, $nbEvent, 120); // If setting cache fails, this is not a problem, so we do not test result.
153 }
154
155 $head[$h][1] .= '/';
156 $head[$h][1] .= $langs->trans("Agenda");
157 if ($nbEvent > 0) {
158 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbEvent.'</span>';
159 }
160 }
161 $head[$h][2] = 'agenda';
162 $h++;
163
164 complete_head_from_modules($conf, $langs, $object, $head, $h, 'member', 'add', 'external');
165
166 complete_head_from_modules($conf, $langs, $object, $head, $h, 'member', 'remove');
167
168 return $head;
169}
170
178{
179 global $langs, $conf, $user;
180
181 $h = 0;
182 $head = array();
183
184 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/type.php', ['rowid' => $object->id]);
185 $head[$h][1] = $langs->trans("MemberType");
186 $head[$h][2] = 'card';
187 $h++;
188
189 // Multilangs
190 if (getDolGlobalInt('MAIN_MULTILANGS')) {
191 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/type_translation.php', ['rowid' => $object->id]);
192 $head[$h][1] = $langs->trans("Translation");
193 $head[$h][2] = 'translation';
194 $h++;
195 }
196
197 if ((isModEnabled('ldap') && getDolGlobalString('LDAP_MEMBER_TYPE_ACTIVE'))
198 && (!getDolGlobalString('MAIN_DISABLE_LDAP_TAB') || !empty($user->admin))) {
199 $langs->load("ldap");
200
201 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/type_ldap.php', ['rowid' => $object->id]);
202 $head[$h][1] = $langs->trans("LDAPCard");
203 $head[$h][2] = 'ldap';
204 $h++;
205 }
206
207 // Show more tabs from modules
208 // Entries must be declared in modules descriptor with line
209 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
210 // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
211 complete_head_from_modules($conf, $langs, $object, $head, $h, 'membertype');
212
213 complete_head_from_modules($conf, $langs, $object, $head, $h, 'membertype', 'remove');
214
215 return $head;
216}
217
224{
225 global $langs, $conf, $user, $extrafields;
226
227 $extrafields->fetch_name_optionals_label('adherent');
228 $extrafields->fetch_name_optionals_label('adherent_type');
229
230 $h = 0;
231 $head = array();
232
233 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/admin/member.php');
234 $head[$h][1] = $langs->trans("Miscellaneous");
235 $head[$h][2] = 'general';
236 $h++;
237
238 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/admin/member_emails.php');
239 $head[$h][1] = $langs->trans("EMails");
240 $head[$h][2] = 'emails';
241 $h++;
242
243 // Show more tabs from modules
244 // Entries must be declared in modules descriptor with line
245 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
246 // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
247 complete_head_from_modules($conf, $langs, null, $head, $h, 'member_admin');
248
249 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/admin/member_extrafields.php');
250 $head[$h][1] = $langs->trans("ExtraFieldsMember");
251 $nbExtrafields = $extrafields->attributes['adherent']['count'];
252 if ($nbExtrafields > 0) {
253 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
254 }
255 $head[$h][2] = 'attributes';
256 $h++;
257
258 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/admin/member_type_extrafields.php');
259 $head[$h][1] = $langs->trans("ExtraFieldsMemberType");
260 $nbExtrafields = $extrafields->attributes['adherent_type']['count'];
261 if ($nbExtrafields > 0) {
262 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
263 }
264 $head[$h][2] = 'attributes_type';
265 $h++;
266
267 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/admin/website.php');
268 $head[$h][1] = $langs->trans("BlankSubscriptionForm");
269 $head[$h][2] = 'website';
270 $h++;
271
272 complete_head_from_modules($conf, $langs, null, $head, $h, 'member_admin', 'remove');
273
274 return $head;
275}
276
277
285{
286 global $conf, $langs;
287
288 $h = 0;
289 $head = array();
290 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/stats/geo.php', ['mode' => 'memberbycountry']);
291 $head[$h][1] = $langs->trans("Country");
292 $head[$h][2] = 'statscountry';
293 $h++;
294
295 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/stats/geo.php', ['mode' => 'memberbyregion']);
296 $head[$h][1] = $langs->trans("Region");
297 $head[$h][2] = 'statsregion';
298 $h++;
299
300 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/stats/geo.php', ['mode' => 'memberbystate']);
301 $head[$h][1] = $langs->trans("State");
302 $head[$h][2] = 'statsstate';
303 $h++;
304
305 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/stats/geo.php', ['mode' => 'memberbytown']);
306 $head[$h][1] = $langs->trans('Town');
307 $head[$h][2] = 'statstown';
308 $h++;
309
310 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/stats/byproperties.php');
311 $head[$h][1] = $langs->trans('ByProperties');
312 $head[$h][2] = 'statsbyproperties';
313 $h++;
314
315
316 // Show more tabs from modules
317 // Entries must be declared in modules descriptor with line
318 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
319 // $this->tabs = array('entity:-tabname); to remove a tab
320 complete_head_from_modules($conf, $langs, $object, $head, $h, 'member_stats');
321
322 complete_head_from_modules($conf, $langs, $object, $head, $h, 'member_stats', 'remove');
323
324 return $head;
325}
326
327
335{
336 global $langs, $conf;
337
338 $h = 0;
339 $head = array();
340
341 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/stats/index.php');
342 $head[$h][1] = $langs->trans("Subscriptions");
343 $head[$h][2] = 'statssubscription';
344 $h++;
345
346 // Show more tabs from modules
347 // Entries must be declared in modules descriptor with line
348 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
349 // $this->tabs = array('entity:-tabname); to remove a tab
350 complete_head_from_modules($conf, $langs, $object, $head, $h, 'membership_stats');
351
352 complete_head_from_modules($conf, $langs, $object, $head, $h, 'memberships_stats', 'remove');
353
354 return $head;
355}
356
357
365{
366 global $db, $langs, $conf, $user;
367
368 $h = 0;
369 $head = array();
370
371 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/subscription/card.php', ['rowid' => $object->id]);
372 $head[$h][1] = $langs->trans("Subscription");
373 $head[$h][2] = 'general';
374 $h++;
375
376 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/subscription/info.php', ['rowid' => $object->id]);
377 $head[$h][1] = $langs->trans("Info");
378 $head[$h][2] = 'info';
379 $h++;
380
381 // Show more tabs from modules
382 // Entries must be declared in modules descriptor with line
383 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
384 // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
385 complete_head_from_modules($conf, $langs, $object, $head, $h, 'subscription');
386
387 complete_head_from_modules($conf, $langs, $object, $head, $h, 'subscription', 'remove');
388
389 return $head;
390}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
Class to manage members of a foundation.
Class to manage members type.
Class to manage subscriptions of foundation members.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:64
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
membership_stats_prepare_head($object)
Return array head with list of tabs to view object stats information.
subscription_prepare_head(Subscription $object)
Return array head with list of tabs to view object information.
member_prepare_head(Adherent $object)
Return array head with list of tabs to view object information.
member_type_prepare_head(AdherentType $object)
Return array head with list of tabs to view object information.
member_admin_prepare_head()
Return array head with list of tabs to view object information.
member_stats_prepare_head($object)
Return array head with list of tabs to view object stats information.
dol_setcache($memoryid, $data, $expire=0, $filecache=0, $replace=0)
Save data into a memory area shared by all users, all sessions on server.
dol_getcache($memoryid, $filecache=0)
Read a memory area shared by all users, all sessions on server.