contact.lib.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. /* Copyright (C) 2006-2010 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.com>
  4. * Copyright (C) 2015 Frederic France <frederic.france@free.fr>
  5. * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
  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/contact.lib.php
  23. * \brief Ensemble de fonctions de base pour les contacts
  24. */
  25. /**
  26. * Prepare array with list of tabs
  27. *
  28. * @param Contact $object Object related to tabs
  29. * @return array Array of tabs to show
  30. */
  31. function contact_prepare_head(Contact $object)
  32. {
  33. global $db, $langs, $conf, $user;
  34. $tab = 0;
  35. $head = array();
  36. $head[$tab][0] = DOL_URL_ROOT.'/contact/card.php?id='.$object->id;
  37. $head[$tab][1] = $langs->trans("Card");
  38. $head[$tab][2] = 'card';
  39. $tab++;
  40. if (! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_CONTACT_ACTIVE))
  41. {
  42. $langs->load("ldap");
  43. $head[$tab][0] = DOL_URL_ROOT.'/contact/ldap.php?id='.$object->id;
  44. $head[$tab][1] = $langs->trans("LDAPCard");
  45. $head[$tab][2] = 'ldap';
  46. $tab++;
  47. }
  48. $head[$tab][0] = DOL_URL_ROOT.'/contact/perso.php?id='.$object->id;
  49. $head[$tab][1] = $langs->trans("PersonalInformations");
  50. $head[$tab][2] = 'perso';
  51. $tab++;
  52. // Show more tabs from modules
  53. // Entries must be declared in modules descriptor with line
  54. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  55. // $this->tabs = array('entity:-tabname); to remove a tab
  56. complete_head_from_modules($conf,$langs,$object,$head,$tab,'contact');
  57. // Notes
  58. if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
  59. $nbNote = (empty($object->note_private)?0:1)+(empty($object->note_public)?0:1);
  60. $head[$tab][0] = DOL_URL_ROOT.'/contact/note.php?id='.$object->id;
  61. $head[$tab][1] = $langs->trans("Note");
  62. if($nbNote > 0) $head[$tab][1].= ' <span class="badge">'.$nbNote.'</span>';
  63. $head[$tab][2] = 'note';
  64. $tab++;
  65. }
  66. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  67. require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
  68. $upload_dir = $conf->societe->dir_output . "/contact/" . dol_sanitizeFileName($object->ref);
  69. $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
  70. $nbLinks=Link::count($db, $object->element, $object->id);
  71. $head[$tab][0] = DOL_URL_ROOT.'/contact/document.php?id='.$object->id;
  72. $head[$tab][1] = $langs->trans("Documents");
  73. if (($nbFiles+$nbLinks) > 0) $head[$tab][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
  74. $head[$tab][2] = 'documents';
  75. $tab++;
  76. // Agenda / Events
  77. $head[$tab][0] = DOL_URL_ROOT.'/contact/agenda.php?id='.$object->id;
  78. $head[$tab][1].= $langs->trans("Events");
  79. if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
  80. {
  81. $head[$tab][1].= '/';
  82. $head[$tab][1].= $langs->trans("Agenda");
  83. }
  84. $head[$tab][2] = 'agenda';
  85. $tab++;
  86. // Log
  87. /*
  88. $head[$tab][0] = DOL_URL_ROOT.'/contact/info.php?id='.$object->id;
  89. $head[$tab][1] = $langs->trans("Info");
  90. $head[$tab][2] = 'info';
  91. $tab++;*/
  92. complete_head_from_modules($conf,$langs,$object,$head,$tab,'contact','remove');
  93. return $head;
  94. }