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