dolibarr  7.0.0-beta
contact.lib.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2006-2010 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2010-2017 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 
33 function contact_prepare_head(Contact $object)
34 {
35  global $db, $langs, $conf, $user;
36 
37  $tab = 0;
38  $head = array();
39 
40  $head[$tab][0] = DOL_URL_ROOT.'/contact/card.php?id='.$object->id;
41  $head[$tab][1] = $langs->trans("Card");
42  $head[$tab][2] = 'card';
43  $tab++;
44 
45  if ((! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_CONTACT_ACTIVE))
46  && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || ! empty($user->admin)))
47  {
48  $langs->load("ldap");
49 
50  $head[$tab][0] = DOL_URL_ROOT.'/contact/ldap.php?id='.$object->id;
51  $head[$tab][1] = $langs->trans("LDAPCard");
52  $head[$tab][2] = 'ldap';
53  $tab++;
54  }
55 
56  $head[$tab][0] = DOL_URL_ROOT.'/contact/perso.php?id='.$object->id;
57  $head[$tab][1] = $langs->trans("PersonalInformations");
58  $head[$tab][2] = 'perso';
59  $tab++;
60 
61  // Show more tabs from modules
62  // Entries must be declared in modules descriptor with line
63  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
64  // $this->tabs = array('entity:-tabname); to remove a tab
65  complete_head_from_modules($conf,$langs,$object,$head,$tab,'contact');
66 
67  // Notes
68  if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
69  $nbNote = (empty($object->note_private)?0:1)+(empty($object->note_public)?0:1);
70  $head[$tab][0] = DOL_URL_ROOT.'/contact/note.php?id='.$object->id;
71  $head[$tab][1] = $langs->trans("Note");
72  if($nbNote > 0) $head[$tab][1].= ' <span class="badge">'.$nbNote.'</span>';
73  $head[$tab][2] = 'note';
74  $tab++;
75  }
76 
77  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
78  require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
79  $upload_dir = $conf->societe->dir_output . "/contact/" . dol_sanitizeFileName($object->ref);
80  $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
81  $nbLinks=Link::count($db, $object->element, $object->id);
82  $head[$tab][0] = DOL_URL_ROOT.'/contact/document.php?id='.$object->id;
83  $head[$tab][1] = $langs->trans("Documents");
84  if (($nbFiles+$nbLinks) > 0) $head[$tab][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
85  $head[$tab][2] = 'documents';
86  $tab++;
87 
88  // Agenda / Events
89  $head[$tab][0] = DOL_URL_ROOT.'/contact/agenda.php?id='.$object->id;
90  $head[$tab][1].= $langs->trans("Events");
91  if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
92  {
93  $head[$tab][1].= '/';
94  $head[$tab][1].= $langs->trans("Agenda");
95  }
96  $head[$tab][2] = 'agenda';
97  $tab++;
98 
99  // Log
100  /*
101  $head[$tab][0] = DOL_URL_ROOT.'/contact/info.php?id='.$object->id;
102  $head[$tab][1] = $langs->trans("Info");
103  $head[$tab][2] = 'info';
104  $tab++;*/
105 
106  complete_head_from_modules($conf,$langs,$object,$head,$tab,'contact','remove');
107 
108  return $head;
109 }
110 
Class to manage contact/addresses.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add')
Complete or removed entries into a head array (used to build tabs).
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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
contact_prepare_head(Contact $object)
Prepare array with list of tabs.
Definition: contact.lib.php:33