dolibarr  7.0.0-beta
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@capnetworks.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  $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  $h++;
62  }
63 
64  // Show more tabs from modules
65  // Entries must be declared in modules descriptor with line
66  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
67  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
68  complete_head_from_modules($conf,$langs,$object,$head,$h,'member');
69 
70  $nbNote = 0;
71  if(!empty($object->note)) $nbNote++;
72  if(!empty($object->note_private)) $nbNote++;
73  if(!empty($object->note_public)) $nbNote++;
74  $head[$h][0] = DOL_URL_ROOT.'/adherents/note.php?id='.$object->id;
75  $head[$h][1] = $langs->trans("Note");
76  $head[$h][2] = 'note';
77  if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
78  $h++;
79 
80  // Attachments
81  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
82  require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
83  $upload_dir = $conf->adherent->multidir_output[$object->entity].'/'.get_exdir(0,0,0,1,$object,'member');
84  $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
85  $nbLinks=Link::count($db, $object->element, $object->id);
86  $head[$h][0] = DOL_URL_ROOT.'/adherents/document.php?id='.$object->id;
87  $head[$h][1] = $langs->trans('Documents');
88  if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
89  $head[$h][2] = 'document';
90  $h++;
91 
92  // Show agenda tab
93  if (! empty($conf->agenda->enabled))
94  {
95  $head[$h][0] = DOL_URL_ROOT."/adherents/agenda.php?id=".$object->id;
96  $head[$h][1] = $langs->trans("Events");
97  if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
98  {
99  $head[$h][1].= '/';
100  $head[$h][1].= $langs->trans("Agenda");
101  }
102  $head[$h][2] = 'agenda';
103  $h++;
104  }
105 
106  complete_head_from_modules($conf,$langs,$object,$head,$h,'member','remove');
107 
108  return $head;
109 }
110 
118 {
119  global $langs, $conf, $user;
120 
121  $h=0;
122  $head = array();
123 
124  $head[$h][0] = DOL_URL_ROOT.'/adherents/type.php?rowid='.$object->id;
125  $head[$h][1] = $langs->trans("Card");
126  $head[$h][2] = 'card';
127  $h++;
128 
129  if ((! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE))
130  && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || ! empty($user->admin)))
131  {
132  $langs->load("ldap");
133 
134  $head[$h][0] = DOL_URL_ROOT.'/adherents/type_ldap.php?rowid='.$object->id;
135  $head[$h][1] = $langs->trans("LDAPCard");
136  $head[$h][2] = 'ldap';
137  $h++;
138  }
139 
140  // Show more tabs from modules
141  // Entries must be declared in modules descriptor with line
142  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
143  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
144  complete_head_from_modules($conf,$langs,$object,$head,$h,'membertype');
145 
146  complete_head_from_modules($conf,$langs,$object,$head,$h,'membertype','remove');
147 
148  return $head;
149 }
150 
157 {
158  global $langs, $conf, $user;
159 
160  $h = 0;
161  $head = array();
162 
163  $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent.php';
164  $head[$h][1] = $langs->trans("Miscellaneous");
165  $head[$h][2] = 'general';
166  $h++;
167 
168  $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_emails.php';
169  $head[$h][1] = $langs->trans("EMails");
170  $head[$h][2] = 'emails';
171  $h++;
172 
173  // Show more tabs from modules
174  // Entries must be declared in modules descriptor with line
175  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
176  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
177  complete_head_from_modules($conf,$langs,'',$head,$h,'member_admin');
178 
179  $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_extrafields.php';
180  $head[$h][1] = $langs->trans("ExtraFieldsMember");
181  $head[$h][2] = 'attributes';
182  $h++;
183 
184  $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_type_extrafields.php';
185  $head[$h][1] = $langs->trans("ExtraFieldsMemberType");
186  $head[$h][2] = 'attributes_type';
187  $h++;
188 
189  $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/website.php';
190  $head[$h][1] = $langs->trans("BlankSubscriptionForm");
191  $head[$h][2] = 'website';
192  $h++;
193 
194  complete_head_from_modules($conf,$langs,'',$head,$h,'member_admin','remove');
195 
196  return $head;
197 }
198 
199 
206 function member_stats_prepare_head($object)
207 {
208  global $langs, $conf, $user;
209 
210  $h = 0;
211  $head = array();
212 
213  $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/index.php';
214  $head[$h][1] = $langs->trans("Subscriptions");
215  $head[$h][2] = 'statssubscription';
216  $h++;
217 
218  $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbycountry';
219  $head[$h][1] = $langs->trans("Country");
220  $head[$h][2] = 'statscountry';
221  $h++;
222 
223  $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbyregion';
224  $head[$h][1] = $langs->trans("Region");
225  $head[$h][2] = 'statsregion';
226  $h++;
227 
228  $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbystate';
229  $head[$h][1] = $langs->trans("State");
230  $head[$h][2] = 'statsstate';
231  $h++;
232 
233  $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbytown';
234  $head[$h][1] = $langs->trans('Town');
235  $head[$h][2] = 'statstown';
236  $h++;
237 
238  $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/byproperties.php';
239  $head[$h][1] = $langs->trans('ByProperties');
240  $head[$h][2] = 'statsbyproperties';
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); to remove a tab
247  complete_head_from_modules($conf,$langs,$object,$head,$h,'member_stats');
248 
249  complete_head_from_modules($conf,$langs,$object,$head,$h,'member_stats','remove');
250 
251  return $head;
252 }
253 
261 {
262  global $db, $langs, $conf, $user;
263 
264  $h = 0;
265  $head = array();
266 
267  $head[$h][0] = DOL_URL_ROOT.'/adherents/subscription/card.php?rowid='.$object->id;
268  $head[$h][1] = $langs->trans("Card");
269  $head[$h][2] = 'general';
270  $h++;
271 
272  $head[$h][0] = DOL_URL_ROOT.'/adherents/subscription/info.php?rowid='.$object->id;
273  $head[$h][1] = $langs->trans("Info");
274  $head[$h][2] = 'info';
275  $h++;
276 
277  // Show more tabs from modules
278  // Entries must be declared in modules descriptor with line
279  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
280  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
281  complete_head_from_modules($conf,$langs,$object,$head,$h,'subscription');
282 
283  complete_head_from_modules($conf,$langs,$object,$head,$h,'subscription','remove');
284 
285  return $head;
286 }
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:117
member_admin_prepare_head()
Return array head with list of tabs to view object informations.
Definition: member.lib.php:156
member_prepare_head(Adherent $object)
Return array head with list of tabs to view object informations.
Definition: member.lib.php:33
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="")
Scan a directory and return a list of files/directories.
Definition: files.lib.php:58
subscription_prepare_head(Subscription $object)
Return array head with list of tabs to view object informations.
Definition: member.lib.php:260
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:206
Class to manage members type.
Class to manage subscriptions of foundation members.