dolibarr  16.0.5
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 
33 function member_prepare_head(Adherent $object)
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.'/adherents/partnership.php?rowid='.$object->id;
70  $head[$h][1] = $langs->trans("Partnership");
71  $head[$h][2] = 'partnership';
72  if ($nbPartnership > 0) {
73  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbPartnership.'</span>';
74  }
75  $h++;
76  }
77  }
78 
79  // Show more tabs from modules
80  // Entries must be declared in modules descriptor with line
81  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
82  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
83  complete_head_from_modules($conf, $langs, $object, $head, $h, 'member');
84 
85  $nbNote = 0;
86  if (!empty($object->note_private)) {
87  $nbNote++;
88  }
89  if (!empty($object->note_public)) {
90  $nbNote++;
91  }
92  $head[$h][0] = DOL_URL_ROOT.'/adherents/note.php?id='.$object->id;
93  $head[$h][1] = $langs->trans("Note");
94  $head[$h][2] = 'note';
95  if ($nbNote > 0) {
96  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
97  }
98  $h++;
99 
100  // Attachments
101  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
102  require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
103  $upload_dir = $conf->adherent->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'member');
104  $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
105  $nbLinks = Link::count($db, $object->element, $object->id);
106  $head[$h][0] = DOL_URL_ROOT.'/adherents/document.php?id='.$object->id;
107  $head[$h][1] = $langs->trans('Documents');
108  if (($nbFiles + $nbLinks) > 0) {
109  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
110  }
111  $head[$h][2] = 'document';
112  $h++;
113 
114  // Show agenda tab
115  if (isModEnabled('agenda')) {
116  $head[$h][0] = DOL_URL_ROOT."/adherents/agenda.php?id=".$object->id;
117  $head[$h][1] = $langs->trans("Events");
118  if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
119  $head[$h][1] .= '/';
120  $head[$h][1] .= $langs->trans("Agenda");
121  }
122  $head[$h][2] = 'agenda';
123  $h++;
124  }
125 
126  complete_head_from_modules($conf, $langs, $object, $head, $h, 'member', 'remove');
127 
128  return $head;
129 }
130 
138 {
139  global $langs, $conf, $user;
140 
141  $h = 0;
142  $head = array();
143 
144  $head[$h][0] = DOL_URL_ROOT.'/adherents/type.php?rowid='.$object->id;
145  $head[$h][1] = $langs->trans("MemberType");
146  $head[$h][2] = 'card';
147  $h++;
148 
149  // Multilangs
150  if (!empty($conf->global->MAIN_MULTILANGS)) {
151  $head[$h][0] = DOL_URL_ROOT."/adherents/type_translation.php?rowid=".$object->id;
152  $head[$h][1] = $langs->trans("Translation");
153  $head[$h][2] = 'translation';
154  $h++;
155  }
156 
157  if ((!empty($conf->ldap->enabled) && !empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE))
158  && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || !empty($user->admin))) {
159  $langs->load("ldap");
160 
161  $head[$h][0] = DOL_URL_ROOT.'/adherents/type_ldap.php?rowid='.$object->id;
162  $head[$h][1] = $langs->trans("LDAPCard");
163  $head[$h][2] = 'ldap';
164  $h++;
165  }
166 
167  // Show more tabs from modules
168  // Entries must be declared in modules descriptor with line
169  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
170  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
171  complete_head_from_modules($conf, $langs, $object, $head, $h, 'membertype');
172 
173  complete_head_from_modules($conf, $langs, $object, $head, $h, 'membertype', 'remove');
174 
175  return $head;
176 }
177 
184 {
185  global $langs, $conf, $user;
186 
187  $h = 0;
188  $head = array();
189 
190  $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/member.php';
191  $head[$h][1] = $langs->trans("Miscellaneous");
192  $head[$h][2] = 'general';
193  $h++;
194 
195  $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/member_emails.php';
196  $head[$h][1] = $langs->trans("EMails");
197  $head[$h][2] = 'emails';
198  $h++;
199 
200  // Show more tabs from modules
201  // Entries must be declared in modules descriptor with line
202  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
203  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
204  complete_head_from_modules($conf, $langs, null, $head, $h, 'member_admin');
205 
206  $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/member_extrafields.php';
207  $head[$h][1] = $langs->trans("ExtraFieldsMember");
208  $head[$h][2] = 'attributes';
209  $h++;
210 
211  $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/member_type_extrafields.php';
212  $head[$h][1] = $langs->trans("ExtraFieldsMemberType");
213  $head[$h][2] = 'attributes_type';
214  $h++;
215 
216  $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/website.php';
217  $head[$h][1] = $langs->trans("BlankSubscriptionForm");
218  $head[$h][2] = 'website';
219  $h++;
220 
221  complete_head_from_modules($conf, $langs, null, $head, $h, 'member_admin', 'remove');
222 
223  return $head;
224 }
225 
226 
233 function member_stats_prepare_head($object)
234 {
235  global $langs, $conf, $user;
236 
237  $h = 0;
238  $head = array();
239 
240  $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/index.php';
241  $head[$h][1] = $langs->trans("Subscriptions");
242  $head[$h][2] = 'statssubscription';
243  $h++;
244 
245  $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbycountry';
246  $head[$h][1] = $langs->trans("Country");
247  $head[$h][2] = 'statscountry';
248  $h++;
249 
250  $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbyregion';
251  $head[$h][1] = $langs->trans("Region");
252  $head[$h][2] = 'statsregion';
253  $h++;
254 
255  $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbystate';
256  $head[$h][1] = $langs->trans("State");
257  $head[$h][2] = 'statsstate';
258  $h++;
259 
260  $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbytown';
261  $head[$h][1] = $langs->trans('Town');
262  $head[$h][2] = 'statstown';
263  $h++;
264 
265  $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/byproperties.php';
266  $head[$h][1] = $langs->trans('ByProperties');
267  $head[$h][2] = 'statsbyproperties';
268  $h++;
269 
270  // Show more tabs from modules
271  // Entries must be declared in modules descriptor with line
272  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
273  // $this->tabs = array('entity:-tabname); to remove a tab
274  complete_head_from_modules($conf, $langs, $object, $head, $h, 'member_stats');
275 
276  complete_head_from_modules($conf, $langs, $object, $head, $h, 'member_stats', 'remove');
277 
278  return $head;
279 }
280 
288 {
289  global $db, $langs, $conf, $user;
290 
291  $h = 0;
292  $head = array();
293 
294  $head[$h][0] = DOL_URL_ROOT.'/adherents/subscription/card.php?rowid='.$object->id;
295  $head[$h][1] = $langs->trans("Subscription");
296  $head[$h][2] = 'general';
297  $h++;
298 
299  $head[$h][0] = DOL_URL_ROOT.'/adherents/subscription/info.php?rowid='.$object->id;
300  $head[$h][1] = $langs->trans("Info");
301  $head[$h][2] = 'info';
302  $h++;
303 
304  // Show more tabs from modules
305  // Entries must be declared in modules descriptor with line
306  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
307  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
308  complete_head_from_modules($conf, $langs, $object, $head, $h, 'subscription');
309 
310  complete_head_from_modules($conf, $langs, $object, $head, $h, 'subscription', 'remove');
311 
312  return $head;
313 }
AdherentType
Class to manage members type.
Definition: adherent_type.class.php:35
member_type_prepare_head
member_type_prepare_head(AdherentType $object)
Return array head with list of tabs to view object informations.
Definition: member.lib.php:137
member_admin_prepare_head
member_admin_prepare_head()
Return array head with list of tabs to view object informations.
Definition: member.lib.php:183
member_prepare_head
member_prepare_head(Adherent $object)
Return array head with list of tabs to view object informations.
Definition: member.lib.php:33
dol_dir_list
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
Definition: files.lib.php:60
complete_head_from_modules
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add')
Complete or removed entries into a head array (used to build tabs).
Definition: functions.lib.php:9024
subscription_prepare_head
subscription_prepare_head(Subscription $object)
Return array head with list of tabs to view object informations.
Definition: member.lib.php:287
get_exdir
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
Definition: functions.lib.php:6535
Subscription
Class to manage subscriptions of foundation members.
Definition: subscription.class.php:33
member_stats_prepare_head
member_stats_prepare_head($object)
Return array head with list of tabs to view object stats informations.
Definition: member.lib.php:233
Adherent
Class to manage members of a foundation.
Definition: adherent.class.php:46
getDolGlobalString
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
Definition: functions.lib.php:80
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:105