member.lib.php 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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. /**
  22. * \file htdocs/core/lib/member.lib.php
  23. * \brief Functions for module members
  24. */
  25. /**
  26. * Return array head with list of tabs to view object informations
  27. *
  28. * @param Adherent $object Member
  29. * @return array head
  30. */
  31. function member_prepare_head(Adherent $object)
  32. {
  33. global $db, $langs, $conf, $user;
  34. $h = 0;
  35. $head = array();
  36. $head[$h][0] = DOL_URL_ROOT.'/adherents/card.php?rowid='.$object->id;
  37. $head[$h][1] = $langs->trans("Card");
  38. $head[$h][2] = 'general';
  39. $h++;
  40. if ((! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_MEMBER_ACTIVE))
  41. && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || ! empty($user->admin)))
  42. {
  43. $langs->load("ldap");
  44. $head[$h][0] = DOL_URL_ROOT.'/adherents/ldap.php?id='.$object->id;
  45. $head[$h][1] = $langs->trans("LDAPCard");
  46. $head[$h][2] = 'ldap';
  47. $h++;
  48. }
  49. if (! empty($user->rights->adherent->cotisation->lire))
  50. {
  51. $nbSubscription = is_array($object->subscriptions)?count($object->subscriptions):0;
  52. $head[$h][0] = DOL_URL_ROOT.'/adherents/subscription.php?rowid='.$object->id;
  53. $head[$h][1] = $langs->trans("Subscriptions");
  54. $head[$h][2] = 'subscription';
  55. if ($nbSubscription > 0) $head[$h][1].= ' <span class="badge">'.$nbSubscription.'</span>';
  56. $h++;
  57. }
  58. // Show more tabs from modules
  59. // Entries must be declared in modules descriptor with line
  60. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  61. // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
  62. complete_head_from_modules($conf,$langs,$object,$head,$h,'member');
  63. $nbNote = 0;
  64. if(!empty($object->note)) $nbNote++;
  65. if(!empty($object->note_private)) $nbNote++;
  66. if(!empty($object->note_public)) $nbNote++;
  67. $head[$h][0] = DOL_URL_ROOT.'/adherents/note.php?id='.$object->id;
  68. $head[$h][1] = $langs->trans("Note");
  69. $head[$h][2] = 'note';
  70. if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
  71. $h++;
  72. // Attachments
  73. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  74. require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
  75. $upload_dir = $conf->adherent->multidir_output[$object->entity].'/'.get_exdir(0,0,0,1,$object,'member');
  76. $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
  77. $nbLinks=Link::count($db, $object->element, $object->id);
  78. $head[$h][0] = DOL_URL_ROOT.'/adherents/document.php?id='.$object->id;
  79. $head[$h][1] = $langs->trans('Documents');
  80. if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
  81. $head[$h][2] = 'document';
  82. $h++;
  83. // Show agenda tab
  84. if (! empty($conf->agenda->enabled))
  85. {
  86. $head[$h][0] = DOL_URL_ROOT."/adherents/agenda.php?id=".$object->id;
  87. $head[$h][1] = $langs->trans("Events");
  88. if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
  89. {
  90. $head[$h][1].= '/';
  91. $head[$h][1].= $langs->trans("Agenda");
  92. }
  93. $head[$h][2] = 'agenda';
  94. $h++;
  95. }
  96. complete_head_from_modules($conf,$langs,$object,$head,$h,'member','remove');
  97. return $head;
  98. }
  99. /**
  100. * Return array head with list of tabs to view object informations
  101. *
  102. * @param AdherentType $object Member
  103. * @return array head
  104. */
  105. function member_type_prepare_head(AdherentType $object)
  106. {
  107. global $langs, $conf, $user;
  108. $h=0;
  109. $head = array();
  110. $head[$h][0] = DOL_URL_ROOT.'/adherents/type.php?rowid='.$object->id;
  111. $head[$h][1] = $langs->trans("Card");
  112. $head[$h][2] = 'card';
  113. $h++;
  114. if ((! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE))
  115. && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || ! empty($user->admin)))
  116. {
  117. $langs->load("ldap");
  118. $head[$h][0] = DOL_URL_ROOT.'/adherents/type_ldap.php?rowid='.$object->id;
  119. $head[$h][1] = $langs->trans("LDAPCard");
  120. $head[$h][2] = 'ldap';
  121. $h++;
  122. }
  123. // Show more tabs from modules
  124. // Entries must be declared in modules descriptor with line
  125. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  126. // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
  127. complete_head_from_modules($conf,$langs,$object,$head,$h,'membertype');
  128. complete_head_from_modules($conf,$langs,$object,$head,$h,'membertype','remove');
  129. return $head;
  130. }
  131. /**
  132. * Return array head with list of tabs to view object informations
  133. *
  134. * @return array head
  135. */
  136. function member_admin_prepare_head()
  137. {
  138. global $langs, $conf, $user;
  139. $h = 0;
  140. $head = array();
  141. $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent.php';
  142. $head[$h][1] = $langs->trans("Miscellaneous");
  143. $head[$h][2] = 'general';
  144. $h++;
  145. $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_emails.php';
  146. $head[$h][1] = $langs->trans("EMails");
  147. $head[$h][2] = 'emails';
  148. $h++;
  149. // Show more tabs from modules
  150. // Entries must be declared in modules descriptor with line
  151. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  152. // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
  153. complete_head_from_modules($conf,$langs,'',$head,$h,'member_admin');
  154. $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_extrafields.php';
  155. $head[$h][1] = $langs->trans("ExtraFieldsMember");
  156. $head[$h][2] = 'attributes';
  157. $h++;
  158. $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_type_extrafields.php';
  159. $head[$h][1] = $langs->trans("ExtraFieldsMemberType");
  160. $head[$h][2] = 'attributes_type';
  161. $h++;
  162. $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/website.php';
  163. $head[$h][1] = $langs->trans("BlankSubscriptionForm");
  164. $head[$h][2] = 'website';
  165. $h++;
  166. complete_head_from_modules($conf,$langs,'',$head,$h,'member_admin','remove');
  167. return $head;
  168. }
  169. /**
  170. * Return array head with list of tabs to view object stats informations
  171. *
  172. * @param Adherent $object Member or null
  173. * @return array head
  174. */
  175. function member_stats_prepare_head($object)
  176. {
  177. global $langs, $conf, $user;
  178. $h = 0;
  179. $head = array();
  180. $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/index.php';
  181. $head[$h][1] = $langs->trans("Subscriptions");
  182. $head[$h][2] = 'statssubscription';
  183. $h++;
  184. $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbycountry';
  185. $head[$h][1] = $langs->trans("Country");
  186. $head[$h][2] = 'statscountry';
  187. $h++;
  188. $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbyregion';
  189. $head[$h][1] = $langs->trans("Region");
  190. $head[$h][2] = 'statsregion';
  191. $h++;
  192. $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbystate';
  193. $head[$h][1] = $langs->trans("State");
  194. $head[$h][2] = 'statsstate';
  195. $h++;
  196. $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbytown';
  197. $head[$h][1] = $langs->trans('Town');
  198. $head[$h][2] = 'statstown';
  199. $h++;
  200. $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/byproperties.php';
  201. $head[$h][1] = $langs->trans('ByProperties');
  202. $head[$h][2] = 'statsbyproperties';
  203. $h++;
  204. // Show more tabs from modules
  205. // Entries must be declared in modules descriptor with line
  206. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  207. // $this->tabs = array('entity:-tabname); to remove a tab
  208. complete_head_from_modules($conf,$langs,$object,$head,$h,'member_stats');
  209. complete_head_from_modules($conf,$langs,$object,$head,$h,'member_stats','remove');
  210. return $head;
  211. }
  212. /**
  213. * Return array head with list of tabs to view object informations
  214. *
  215. * @param Subscription $object Subscription
  216. * @return array head
  217. */
  218. function subscription_prepare_head(Subscription $object)
  219. {
  220. global $db, $langs, $conf, $user;
  221. $h = 0;
  222. $head = array();
  223. $head[$h][0] = DOL_URL_ROOT.'/adherents/subscription/card.php?rowid='.$object->id;
  224. $head[$h][1] = $langs->trans("Card");
  225. $head[$h][2] = 'general';
  226. $h++;
  227. $head[$h][0] = DOL_URL_ROOT.'/adherents/subscription/info.php?rowid='.$object->id;
  228. $head[$h][1] = $langs->trans("Info");
  229. $head[$h][2] = 'info';
  230. $h++;
  231. // Show more tabs from modules
  232. // Entries must be declared in modules descriptor with line
  233. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  234. // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
  235. complete_head_from_modules($conf,$langs,$object,$head,$h,'subscription');
  236. complete_head_from_modules($conf,$langs,$object,$head,$h,'subscription','remove');
  237. return $head;
  238. }