Passed
Branch develop (59f205)
by
unknown
29:12
created

conferenceorboothPrepareHead()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 45
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 2
eloc 26
nc 2
nop 1
dl 0
loc 45
rs 9.504
c 2
b 0
f 0
1
<?php
2
/* Copyright (C) ---Put here your own copyright and developer email---
3
 *
4
 * This program is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation, either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
16
 */
17
18
/**
19
 * \file    lib/eventorganization_conferenceorbooth.lib.php
20
 * \ingroup eventorganization
21
 * \brief   Library files with common functions for ConferenceOrBooth
22
 */
23
24
/**
25
 * Prepare array of tabs for ConferenceOrBooth
26
 *
27
 * @param	ConferenceOrBooth	$object		ConferenceOrBooth
28
 * @return 	array					Array of tabs
29
 */
30
function conferenceorboothPrepareHead($object)
31
{
32
	global $db, $langs, $conf;
33
34
	$langs->load("eventorganization@eventorganization");
35
36
	$h = 0;
37
	$head = array();
38
39
	$head[$h][0] = dol_buildpath("/eventorganization/conferenceorbooth_card.php", 1).'?id='.$object->id;
40
	$head[$h][1] = $langs->trans("Card");
41
	$head[$h][2] = 'card';
42
	$h++;
43
44
	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
45
	require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
46
	$upload_dir = $conf->eventorganization->dir_output."/conferenceorbooth/".dol_sanitizeFileName($object->ref);
47
	$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
48
	$nbLinks = Link::count($db, $object->element, $object->id);
49
	$head[$h][0] = dol_buildpath("/eventorganization/conferenceorbooth_document.php", 1).'?id='.$object->id;
50
	$head[$h][1] = $langs->trans('Documents');
51
	if (($nbFiles + $nbLinks) > 0) {
52
		$head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
53
	}
54
	$head[$h][2] = 'document';
55
	$h++;
56
57
	$head[$h][0] = dol_buildpath("/eventorganization/conferenceorbooth_agenda.php", 1).'?id='.$object->id;
58
	$head[$h][1] = $langs->trans("Events");
59
	$head[$h][2] = 'agenda';
60
	$h++;
61
62
	// Show more tabs from modules
63
	// Entries must be declared in modules descriptor with line
64
	//$this->tabs = array(
65
	//	'entity:+tabname:Title:@eventorganization:/eventorganization/mypage.php?id=__ID__'
66
	//); // to add new tab
67
	//$this->tabs = array(
68
	//	'entity:-tabname:Title:@eventorganization:/eventorganization/mypage.php?id=__ID__'
69
	//); // to remove a tab
70
	complete_head_from_modules($conf, $langs, $object, $head, $h, 'conferenceorbooth@eventorganization');
71
72
	complete_head_from_modules($conf, $langs, $object, $head, $h, 'conferenceorbooth@eventorganization', 'remove');
73
74
	return $head;
75
}
76