dolibarr 20.0.0
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 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 * or see https://www.gnu.org/
21 */
22
35{
36 global $db, $langs, $conf, $user;
37
38 $h = 0;
39 $head = array();
40
41 $head[$h][0] = DOL_URL_ROOT.'/adherents/card.php?rowid='.$object->id;
42 $head[$h][1] = $langs->trans("Member");
43 $head[$h][2] = 'general';
44 $h++;
45
46 if ((!empty($conf->ldap->enabled) && getDolGlobalString('LDAP_MEMBER_ACTIVE'))
47 && (!getDolGlobalString('MAIN_DISABLE_LDAP_TAB') || !empty($user->admin))) {
48 $langs->load("ldap");
49
50 $head[$h][0] = DOL_URL_ROOT.'/adherents/ldap.php?id='.$object->id;
51 $head[$h][1] = $langs->trans("LDAPCard");
52 $head[$h][2] = 'ldap';
53 $h++;
54 }
55
56 if ($user->hasRight('adherent', 'cotisation', 'lire')) {
57 $nbSubscription = is_array($object->subscriptions) ? count($object->subscriptions) : 0;
58 $head[$h][0] = DOL_URL_ROOT.'/adherents/subscription.php?rowid='.$object->id;
59 $head[$h][1] = $langs->trans("Subscriptions");
60 $head[$h][2] = 'subscription';
61 if ($nbSubscription > 0) {
62 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbSubscription.'</span>';
63 }
64 $h++;
65 }
66
67 if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') {
68 if ($user->hasRight('partnership', 'read')) {
69 $nbPartnership = is_array($object->partnerships) ? count($object->partnerships) : 0;
70 $head[$h][0] = DOL_URL_ROOT.'/partnership/partnership_list.php?rowid='.$object->id;
71 $head[$h][1] = $langs->trans("Partnerships");
72 $nbNote = 0;
73 $sql = "SELECT COUNT(n.rowid) as nb";
74 $sql .= " FROM ".MAIN_DB_PREFIX."partnership as n";
75 $sql .= " WHERE fk_member = ".((int) $object->id);
76 $resql = $db->query($sql);
77 if ($resql) {
78 $obj = $db->fetch_object($resql);
79 $nbNote = $obj->nb;
80 } else {
81 dol_print_error($db);
82 }
83 if ($nbNote > 0) {
84 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
85 }
86 $head[$h][2] = 'partnerships';
87 if ($nbPartnership > 0) {
88 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbPartnership.'</span>';
89 }
90 $h++;
91 }
92 }
93
94 // Show more tabs from modules
95 // Entries must be declared in modules descriptor with line
96 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
97 // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
98 complete_head_from_modules($conf, $langs, $object, $head, $h, 'member', 'add', 'core');
99
100 $nbNote = 0;
101 if (!empty($object->note_private)) {
102 $nbNote++;
103 }
104 if (!empty($object->note_public)) {
105 $nbNote++;
106 }
107 $head[$h][0] = DOL_URL_ROOT.'/adherents/note.php?id='.$object->id;
108 $head[$h][1] = $langs->trans("Note");
109 $head[$h][2] = 'note';
110 if ($nbNote > 0) {
111 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
112 }
113 $h++;
114
115 // Attachments
116 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
117 require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
118 $upload_dir = $conf->adherent->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'member');
119 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
120 $nbLinks = Link::count($db, $object->element, $object->id);
121 $head[$h][0] = DOL_URL_ROOT.'/adherents/document.php?id='.$object->id;
122 $head[$h][1] = $langs->trans('Documents');
123 if (($nbFiles + $nbLinks) > 0) {
124 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
125 }
126 $head[$h][2] = 'document';
127 $h++;
128
129 // Show agenda tab
130 $head[$h][0] = DOL_URL_ROOT.'/adherents/agenda.php?id='.$object->id;
131 $head[$h][1] = $langs->trans("Events");
132 if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) {
133 $nbEvent = 0;
134 // Enable caching of thirdparty count actioncomm
135 require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
136 $cachekey = 'count_events_member_'.$object->id;
137 $dataretrieved = dol_getcache($cachekey);
138 if (!is_null($dataretrieved)) {
139 $nbEvent = $dataretrieved;
140 } else {
141 $sql = "SELECT COUNT(id) as nb";
142 $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm";
143 $sql .= " WHERE elementtype = 'member' AND fk_element = ".((int) $object->id);
144 $resql = $db->query($sql);
145 if ($resql) {
146 $obj = $db->fetch_object($resql);
147 $nbEvent = $obj->nb;
148 } else {
149 dol_syslog('Failed to count actioncomm '.$db->lasterror(), LOG_ERR);
150 }
151 dol_setcache($cachekey, $nbEvent, 120); // If setting cache fails, this is not a problem, so we do not test result.
152 }
153
154 $head[$h][1] .= '/';
155 $head[$h][1] .= $langs->trans("Agenda");
156 if ($nbEvent > 0) {
157 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbEvent.'</span>';
158 }
159 }
160 $head[$h][2] = 'agenda';
161 $h++;
162
163 complete_head_from_modules($conf, $langs, $object, $head, $h, 'member', 'add', 'external');
164
165 complete_head_from_modules($conf, $langs, $object, $head, $h, 'member', 'remove');
166
167 return $head;
168}
169
177{
178 global $langs, $conf, $user;
179
180 $h = 0;
181 $head = array();
182
183 $head[$h][0] = DOL_URL_ROOT.'/adherents/type.php?rowid='.$object->id;
184 $head[$h][1] = $langs->trans("MemberType");
185 $head[$h][2] = 'card';
186 $h++;
187
188 // Multilangs
189 if (getDolGlobalInt('MAIN_MULTILANGS')) {
190 $head[$h][0] = DOL_URL_ROOT."/adherents/type_translation.php?rowid=".$object->id;
191 $head[$h][1] = $langs->trans("Translation");
192 $head[$h][2] = 'translation';
193 $h++;
194 }
195
196 if ((!empty($conf->ldap->enabled) && getDolGlobalString('LDAP_MEMBER_TYPE_ACTIVE'))
197 && (!getDolGlobalString('MAIN_DISABLE_LDAP_TAB') || !empty($user->admin))) {
198 $langs->load("ldap");
199
200 $head[$h][0] = DOL_URL_ROOT.'/adherents/type_ldap.php?rowid='.$object->id;
201 $head[$h][1] = $langs->trans("LDAPCard");
202 $head[$h][2] = 'ldap';
203 $h++;
204 }
205
206 // Show more tabs from modules
207 // Entries must be declared in modules descriptor with line
208 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
209 // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
210 complete_head_from_modules($conf, $langs, $object, $head, $h, 'membertype');
211
212 complete_head_from_modules($conf, $langs, $object, $head, $h, 'membertype', 'remove');
213
214 return $head;
215}
216
223{
224 global $langs, $conf, $user, $db;
225
226 $extrafields = new ExtraFields($db);
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] = 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] = 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] = 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] = 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] = 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 $langs, $conf, $user;
287
288 $h = 0;
289 $head = array();
290
291 $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/index.php';
292 $head[$h][1] = $langs->trans("Subscriptions");
293 $head[$h][2] = 'statssubscription';
294 $h++;
295
296 $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbycountry';
297 $head[$h][1] = $langs->trans("Country");
298 $head[$h][2] = 'statscountry';
299 $h++;
300
301 $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbyregion';
302 $head[$h][1] = $langs->trans("Region");
303 $head[$h][2] = 'statsregion';
304 $h++;
305
306 $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbystate';
307 $head[$h][1] = $langs->trans("State");
308 $head[$h][2] = 'statsstate';
309 $h++;
310
311 $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbytown';
312 $head[$h][1] = $langs->trans('Town');
313 $head[$h][2] = 'statstown';
314 $h++;
315
316 $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/byproperties.php';
317 $head[$h][1] = $langs->trans('ByProperties');
318 $head[$h][2] = 'statsbyproperties';
319 $h++;
320
321 // Show more tabs from modules
322 // Entries must be declared in modules descriptor with line
323 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
324 // $this->tabs = array('entity:-tabname); to remove a tab
325 complete_head_from_modules($conf, $langs, $object, $head, $h, 'member_stats');
326
327 complete_head_from_modules($conf, $langs, $object, $head, $h, 'member_stats', 'remove');
328
329 return $head;
330}
331
339{
340 global $db, $langs, $conf, $user;
341
342 $h = 0;
343 $head = array();
344
345 $head[$h][0] = DOL_URL_ROOT.'/adherents/subscription/card.php?rowid='.$object->id;
346 $head[$h][1] = $langs->trans("Subscription");
347 $head[$h][2] = 'general';
348 $h++;
349
350 $head[$h][0] = DOL_URL_ROOT.'/adherents/subscription/info.php?rowid='.$object->id;
351 $head[$h][1] = $langs->trans("Info");
352 $head[$h][2] = 'info';
353 $h++;
354
355 // Show more tabs from modules
356 // Entries must be declared in modules descriptor with line
357 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
358 // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
359 complete_head_from_modules($conf, $langs, $object, $head, $h, 'subscription');
360
361 complete_head_from_modules($conf, $langs, $object, $head, $h, 'subscription', 'remove');
362
363 return $head;
364}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
Class to manage members of a foundation.
Class to manage members type.
Class to manage standard extra fields.
Class to manage subscriptions of foundation members.
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:63
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 dolibarr global constant string value.
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.
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)
Save data into a memory area shared by all users, all sessions on server.
dol_getcache($memoryid)
Read a memory area shared by all users, all sessions on server.