Completed
Branch develop (3a593f)
by
unknown
40:28
created

websiteaccount.lib.php ➔ websiteaccountPrepareHead()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 54

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 54
rs 9.0036
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/* Copyright (C) 2017 Laurent Destailleur  <[email protected]>
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 <http://www.gnu.org/licenses/>.
16
 */
17
18
/**
19
 * \file    htdocs/website/lib/websiteaccount.lib.php
20
 * \ingroup website
21
 * \brief   Library files with common functions for WebsiteAccount
22
 */
23
24
/**
25
 * Prepare array of tabs for SocieteAccount
26
 *
27
 * @param	SocieteAccount	$object		SocieteAccount
28
 * @return 	array						Array of tabs
29
 */
30
function websiteaccountPrepareHead($object)
31
{
32
	global $db, $langs, $conf;
33
34
	$h = 0;
35
	$head = array();
36
37
	$head[$h][0] = dol_buildpath("/website/websiteaccount_card.php", 1).'?id='.$object->id;
38
	$head[$h][1] = $langs->trans("Card");
39
	$head[$h][2] = 'card';
40
	$h++;
41
42
	/*if (isset($object->fields['note_public']) || isset($object->fields['note_private']))
43
	{
44
		$nbNote = 0;
45
		if(!empty($object->fields['note_private'])) $nbNote++;
46
		if(!empty($object->fields['note_public'])) $nbNote++;
47
		$head[$h][0] = dol_buildpath('/monmodule/websiteaccount_note.php', 1).'?id='.$object->id;
48
		$head[$h][1] = $langs->trans('Notes');
49
		if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
50
		$head[$h][2] = 'note';
51
		$h++;
52
	}*/
53
54
	/*
55
	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
56
	require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
57
	$upload_dir = $conf->monmodule->dir_output . "/websiteaccount/" . dol_sanitizeFileName($object->ref);
58
	$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
59
	$nbLinks=Link::count($db, $object->element, $object->id);
60
	$head[$h][0] = dol_buildpath("/monmodule/websiteaccount_document.php", 1).'?id='.$object->id;
61
	$head[$h][1] = $langs->trans('Documents');
62
	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
63
	$head[$h][2] = 'document';
64
	$h++;
65
66
	$head[$h][0] = dol_buildpath("/monmodule/websiteaccount_agenda.php", 1).'?id='.$object->id;
67
	$head[$h][1] = $langs->trans("Events");
68
	$head[$h][2] = 'agenda';
69
	$h++;
70
	*/
71
72
	// Show more tabs from modules
73
	// Entries must be declared in modules descriptor with line
74
	//$this->tabs = array(
75
	//	'entity:+tabname:Title:@monmodule:/monmodule/mypage.php?id=__ID__'
76
	//); // to add new tab
77
	//$this->tabs = array(
78
	//	'entity:-tabname:Title:@monmodule:/monmodule/mypage.php?id=__ID__'
79
	//); // to remove a tab
80
	complete_head_from_modules($conf, $langs, $object, $head, $h, 'websiteaccount@website');
81
82
	return $head;
83
}
84