dolibarr  9.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.dolibarr@gmail.com>
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 <http://www.gnu.org/licenses/>.
19  * or see http://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("Card");
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">'.$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">'.$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">'.($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("Card");
128  $head[$h][2] = 'card';
129  $h++;
130 
131  if ((! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE))
132  && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || ! empty($user->admin)))
133  {
134  $langs->load("ldap");
135 
136  $head[$h][0] = DOL_URL_ROOT.'/adherents/type_ldap.php?rowid='.$object->id;
137  $head[$h][1] = $langs->trans("LDAPCard");
138  $head[$h][2] = 'ldap';
139  $h++;
140  }
141 
142  // Show more tabs from modules
143  // Entries must be declared in modules descriptor with line
144  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
145  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
146  complete_head_from_modules($conf,$langs,$object,$head,$h,'membertype');
147 
148  complete_head_from_modules($conf,$langs,$object,$head,$h,'membertype','remove');
149 
150  return $head;
151 }
152 
159 {
160  global $langs, $conf, $user;
161 
162  $h = 0;
163  $head = array();
164 
165  $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent.php';
166  $head[$h][1] = $langs->trans("Miscellaneous");
167  $head[$h][2] = 'general';
168  $h++;
169 
170  $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_emails.php';
171  $head[$h][1] = $langs->trans("EMails");
172  $head[$h][2] = 'emails';
173  $h++;
174 
175  // Show more tabs from modules
176  // Entries must be declared in modules descriptor with line
177  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
178  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
179  complete_head_from_modules($conf,$langs,'',$head,$h,'member_admin');
180 
181  $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_extrafields.php';
182  $head[$h][1] = $langs->trans("ExtraFieldsMember");
183  $head[$h][2] = 'attributes';
184  $h++;
185 
186  $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_type_extrafields.php';
187  $head[$h][1] = $langs->trans("ExtraFieldsMemberType");
188  $head[$h][2] = 'attributes_type';
189  $h++;
190 
191  $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/website.php';
192  $head[$h][1] = $langs->trans("BlankSubscriptionForm");
193  $head[$h][2] = 'website';
194  $h++;
195 
196  complete_head_from_modules($conf,$langs,'',$head,$h,'member_admin','remove');
197 
198  return $head;
199 }
200 
201 
208 function member_stats_prepare_head($object)
209 {
210  global $langs, $conf, $user;
211 
212  $h = 0;
213  $head = array();
214 
215  $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/index.php';
216  $head[$h][1] = $langs->trans("Subscriptions");
217  $head[$h][2] = 'statssubscription';
218  $h++;
219 
220  $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbycountry';
221  $head[$h][1] = $langs->trans("Country");
222  $head[$h][2] = 'statscountry';
223  $h++;
224 
225  $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbyregion';
226  $head[$h][1] = $langs->trans("Region");
227  $head[$h][2] = 'statsregion';
228  $h++;
229 
230  $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbystate';
231  $head[$h][1] = $langs->trans("State");
232  $head[$h][2] = 'statsstate';
233  $h++;
234 
235  $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbytown';
236  $head[$h][1] = $langs->trans('Town');
237  $head[$h][2] = 'statstown';
238  $h++;
239 
240  $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/byproperties.php';
241  $head[$h][1] = $langs->trans('ByProperties');
242  $head[$h][2] = 'statsbyproperties';
243  $h++;
244 
245  // Show more tabs from modules
246  // Entries must be declared in modules descriptor with line
247  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
248  // $this->tabs = array('entity:-tabname); to remove a tab
249  complete_head_from_modules($conf,$langs,$object,$head,$h,'member_stats');
250 
251  complete_head_from_modules($conf,$langs,$object,$head,$h,'member_stats','remove');
252 
253  return $head;
254 }
255 
263 {
264  global $db, $langs, $conf, $user;
265 
266  $h = 0;
267  $head = array();
268 
269  $head[$h][0] = DOL_URL_ROOT.'/adherents/subscription/card.php?rowid='.$object->id;
270  $head[$h][1] = $langs->trans("Card");
271  $head[$h][2] = 'general';
272  $h++;
273 
274  $head[$h][0] = DOL_URL_ROOT.'/adherents/subscription/info.php?rowid='.$object->id;
275  $head[$h][1] = $langs->trans("Info");
276  $head[$h][2] = 'info';
277  $h++;
278 
279  // Show more tabs from modules
280  // Entries must be declared in modules descriptor with line
281  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
282  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
283  complete_head_from_modules($conf,$langs,$object,$head,$h,'subscription');
284 
285  complete_head_from_modules($conf,$langs,$object,$head,$h,'subscription','remove');
286 
287  return $head;
288 }
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add')
Complete or removed entries into a head array (used to build tabs).
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart)
Return a path to have a the directory according to object where files are stored. ...
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:158
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:262
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:208
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:59
Class to manage members type.
Class to manage subscriptions of foundation members.