dolibarr  13.0.2
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  {
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 (!empty($user->rights->adherent->cotisation->lire))
57  {
58  $nbSubscription = is_array($object->subscriptions) ?count($object->subscriptions) : 0;
59  $head[$h][0] = DOL_URL_ROOT.'/adherents/subscription.php?rowid='.$object->id;
60  $head[$h][1] = $langs->trans("Subscriptions");
61  $head[$h][2] = 'subscription';
62  if ($nbSubscription > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbSubscription.'</span>';
63  $h++;
64  }
65 
66  // Show more tabs from modules
67  // Entries must be declared in modules descriptor with line
68  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
69  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
70  complete_head_from_modules($conf, $langs, $object, $head, $h, 'member');
71 
72  $nbNote = 0;
73  if (!empty($object->note)) $nbNote++;
74  if (!empty($object->note_private)) $nbNote++;
75  if (!empty($object->note_public)) $nbNote++;
76  $head[$h][0] = DOL_URL_ROOT.'/adherents/note.php?id='.$object->id;
77  $head[$h][1] = $langs->trans("Note");
78  $head[$h][2] = 'note';
79  if ($nbNote > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
80  $h++;
81 
82  // Attachments
83  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
84  require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
85  $upload_dir = $conf->adherent->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'member');
86  $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
87  $nbLinks = Link::count($db, $object->element, $object->id);
88  $head[$h][0] = DOL_URL_ROOT.'/adherents/document.php?id='.$object->id;
89  $head[$h][1] = $langs->trans('Documents');
90  if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
91  $head[$h][2] = 'document';
92  $h++;
93 
94  // Show agenda tab
95  if (!empty($conf->agenda->enabled))
96  {
97  $head[$h][0] = DOL_URL_ROOT."/adherents/agenda.php?id=".$object->id;
98  $head[$h][1] = $langs->trans("Events");
99  if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read)))
100  {
101  $head[$h][1] .= '/';
102  $head[$h][1] .= $langs->trans("Agenda");
103  }
104  $head[$h][2] = 'agenda';
105  $h++;
106  }
107 
108  complete_head_from_modules($conf, $langs, $object, $head, $h, 'member', 'remove');
109 
110  return $head;
111 }
112 
120 {
121  global $langs, $conf, $user;
122 
123  $h = 0;
124  $head = array();
125 
126  $head[$h][0] = DOL_URL_ROOT.'/adherents/type.php?rowid='.$object->id;
127  $head[$h][1] = $langs->trans("MemberType");
128  $head[$h][2] = 'card';
129  $h++;
130 
131  // Multilangs
132  if (!empty($conf->global->MAIN_MULTILANGS))
133  {
134  $head[$h][0] = DOL_URL_ROOT."/adherents/type_translation.php?rowid=".$object->id;
135  $head[$h][1] = $langs->trans("Translation");
136  $head[$h][2] = 'translation';
137  $h++;
138  }
139 
140  if ((!empty($conf->ldap->enabled) && !empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE))
141  && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || !empty($user->admin)))
142  {
143  $langs->load("ldap");
144 
145  $head[$h][0] = DOL_URL_ROOT.'/adherents/type_ldap.php?rowid='.$object->id;
146  $head[$h][1] = $langs->trans("LDAPCard");
147  $head[$h][2] = 'ldap';
148  $h++;
149  }
150 
151  // Show more tabs from modules
152  // Entries must be declared in modules descriptor with line
153  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
154  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
155  complete_head_from_modules($conf, $langs, $object, $head, $h, 'membertype');
156 
157  complete_head_from_modules($conf, $langs, $object, $head, $h, 'membertype', 'remove');
158 
159  return $head;
160 }
161 
168 {
169  global $langs, $conf, $user;
170 
171  $h = 0;
172  $head = array();
173 
174  $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent.php';
175  $head[$h][1] = $langs->trans("Miscellaneous");
176  $head[$h][2] = 'general';
177  $h++;
178 
179  $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_emails.php';
180  $head[$h][1] = $langs->trans("EMails");
181  $head[$h][2] = 'emails';
182  $h++;
183 
184  // Show more tabs from modules
185  // Entries must be declared in modules descriptor with line
186  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
187  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
188  complete_head_from_modules($conf, $langs, null, $head, $h, 'member_admin');
189 
190  $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_extrafields.php';
191  $head[$h][1] = $langs->trans("ExtraFieldsMember");
192  $head[$h][2] = 'attributes';
193  $h++;
194 
195  $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_type_extrafields.php';
196  $head[$h][1] = $langs->trans("ExtraFieldsMemberType");
197  $head[$h][2] = 'attributes_type';
198  $h++;
199 
200  $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/website.php';
201  $head[$h][1] = $langs->trans("BlankSubscriptionForm");
202  $head[$h][2] = 'website';
203  $h++;
204 
205  complete_head_from_modules($conf, $langs, null, $head, $h, 'member_admin', 'remove');
206 
207  return $head;
208 }
209 
210 
217 function member_stats_prepare_head($object)
218 {
219  global $langs, $conf, $user;
220 
221  $h = 0;
222  $head = array();
223 
224  $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/index.php';
225  $head[$h][1] = $langs->trans("Subscriptions");
226  $head[$h][2] = 'statssubscription';
227  $h++;
228 
229  $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbycountry';
230  $head[$h][1] = $langs->trans("Country");
231  $head[$h][2] = 'statscountry';
232  $h++;
233 
234  $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbyregion';
235  $head[$h][1] = $langs->trans("Region");
236  $head[$h][2] = 'statsregion';
237  $h++;
238 
239  $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbystate';
240  $head[$h][1] = $langs->trans("State");
241  $head[$h][2] = 'statsstate';
242  $h++;
243 
244  $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbytown';
245  $head[$h][1] = $langs->trans('Town');
246  $head[$h][2] = 'statstown';
247  $h++;
248 
249  $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/byproperties.php';
250  $head[$h][1] = $langs->trans('ByProperties');
251  $head[$h][2] = 'statsbyproperties';
252  $h++;
253 
254  // Show more tabs from modules
255  // Entries must be declared in modules descriptor with line
256  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
257  // $this->tabs = array('entity:-tabname); to remove a tab
258  complete_head_from_modules($conf, $langs, $object, $head, $h, 'member_stats');
259 
260  complete_head_from_modules($conf, $langs, $object, $head, $h, 'member_stats', 'remove');
261 
262  return $head;
263 }
264 
272 {
273  global $db, $langs, $conf, $user;
274 
275  $h = 0;
276  $head = array();
277 
278  $head[$h][0] = DOL_URL_ROOT.'/adherents/subscription/card.php?rowid='.$object->id;
279  $head[$h][1] = $langs->trans("Subscription");
280  $head[$h][2] = 'general';
281  $h++;
282 
283  $head[$h][0] = DOL_URL_ROOT.'/adherents/subscription/info.php?rowid='.$object->id;
284  $head[$h][1] = $langs->trans("Info");
285  $head[$h][2] = 'info';
286  $h++;
287 
288  // Show more tabs from modules
289  // Entries must be declared in modules descriptor with line
290  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
291  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
292  complete_head_from_modules($conf, $langs, $object, $head, $h, 'subscription');
293 
294  complete_head_from_modules($conf, $langs, $object, $head, $h, 'subscription', 'remove');
295 
296  return $head;
297 }
member_type_prepare_head(AdherentType $object)
Return array head with list of tabs to view object informations.
Definition: member.lib.php:119
member_admin_prepare_head()
Return array head with list of tabs to view object informations.
Definition: member.lib.php:167
member_prepare_head(Adherent $object)
Return array head with list of tabs to view object informations.
Definition: member.lib.php:33
subscription_prepare_head(Subscription $object)
Return array head with list of tabs to view object informations.
Definition: member.lib.php:271
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart= '')
Return a path to have a the directory according to object where files are stored. ...
Class to manage members of a foundation.
member_stats_prepare_head($object)
Return array head with list of tabs to view object stats informations.
Definition: member.lib.php:217
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
Class to manage members type.
Class to manage subscriptions of foundation members.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode= 'add')
Complete or removed entries into a head array (used to build tabs).