Passed
Push — scrutinizer-code-quality ( 09f5a1...c4c5fb )
by Adam
56:05 queued 14:08
created

EmployeesViewDetail   A

Complexity

Total Complexity 18

Size/Duplication

Total Lines 99
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 1 Features 1
Metric Value
c 1
b 1
f 1
dl 0
loc 99
ccs 0
cts 73
cp 0
rs 10
wmc 18
lcom 2
cbo 2

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A EmployeesViewDetail() 0 10 2
C getModuleTitle() 0 48 8
C display() 0 22 7
1
<?php
2
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3
4
/*********************************************************************************
5
 * SugarCRM Community Edition is a customer relationship management program developed by
6
 * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
7
8
 * SuiteCRM is an extension to SugarCRM Community Edition developed by Salesagility Ltd.
9
 * Copyright (C) 2011 - 2014 Salesagility Ltd.
10
 *
11
 * This program is free software; you can redistribute it and/or modify it under
12
 * the terms of the GNU Affero General Public License version 3 as published by the
13
 * Free Software Foundation with the addition of the following permission added
14
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
15
 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
16
 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
17
 *
18
 * This program is distributed in the hope that it will be useful, but WITHOUT
19
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20
 * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
21
 * details.
22
 *
23
 * You should have received a copy of the GNU Affero General Public License along with
24
 * this program; if not, see http://www.gnu.org/licenses or write to the Free
25
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26
 * 02110-1301 USA.
27
 *
28
 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
29
 * SW2-130, Cupertino, CA 95014, USA. or at email address [email protected].
30
 *
31
 * The interactive user interfaces in modified source and object code versions
32
 * of this program must display Appropriate Legal Notices, as required under
33
 * Section 5 of the GNU Affero General Public License version 3.
34
 *
35
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
36
 * these Appropriate Legal Notices must retain the display of the "Powered by
37
 * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
38
 * reasonably feasible for  technical reasons, the Appropriate Legal Notices must
39
 * display the words  "Powered by SugarCRM" and "Supercharged by SuiteCRM".
40
 ********************************************************************************/
41
42
43
require_once('include/MVC/View/views/view.detail.php');
44
45
class EmployeesViewDetail extends ViewDetail {
46
47
 	function __construct(){
48
 		parent::__construct();
49
 	}
50
51
    /**
52
     * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
53
     */
54
    function EmployeesViewDetail(){
55
        $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
56
        if(isset($GLOBALS['log'])) {
57
            $GLOBALS['log']->deprecated($deprecatedMessage);
58
        }
59
        else {
60
            trigger_error($deprecatedMessage, E_USER_DEPRECATED);
61
        }
62
        self::__construct();
63
    }
64
65
66
   /**
67
    * Return the "breadcrumbs" to display at the top of the page
68
    *
69
    * @param  bool $show_help optional, true if we show the help links
70
    * @return HTML string containing breadcrumb title
71
    */
72
    public function getModuleTitle($show_help = true)
73
    {
74
        global $sugar_version, $sugar_flavor, $server_unique_key, $current_language, $action, $current_user;
75
76
        $theTitle = "<div class='moduleTitle'>\n";
77
78
        $module = preg_replace("/ /","",$this->module);
79
80
        $params = $this->_getModuleTitleParams();
81
        $count = count($params);
82
        $index = 0;
83
84
		if(SugarThemeRegistry::current()->directionality == "rtl") {
85
			$params = array_reverse($params);
86
		}
87
88
        $paramString = '';
89
        foreach($params as $parm){
90
            $index++;
91
            $paramString .= $parm;
92
            if($index < $count){
93
                $paramString .= $this->getBreadCrumbSymbol();
94
            }
95
        }
96
97
        if(!empty($paramString)){
98
            $theTitle .= "<h2> $paramString </h2>\n";
99
        }
100
101
        if ($show_help) {
102
            $theTitle .= "<span class='utils'>";
103
            if(is_admin($current_user) || is_admin_for_module($current_user, $this->module))
104
            {
105
            $createImageURL = SugarThemeRegistry::current()->getImageURL('create-record.gif');
106
            $theTitle .= <<<EOHTML
107
&nbsp;
108
<a href="index.php?module={$module}&action=EditView&return_module={$module}&return_action=DetailView" class="utilsLink">
109
<img src='{$createImageURL}' alt='{$GLOBALS['app_strings']['LNK_CREATE']}'></a>
110
<a href="index.php?module={$module}&action=EditView&return_module={$module}&return_action=DetailView" class="utilsLink">
111
{$GLOBALS['app_strings']['LNK_CREATE']}
112
</a>
113
EOHTML;
114
            }
115
        }
116
117
        $theTitle .= "</span></div>\n";
118
        return $theTitle;
119
    }
120
121
 	function display() {
122
       	if(is_admin($GLOBALS['current_user']) || $_REQUEST['record'] == $GLOBALS['current_user']->id) {
123
			 $this->ss->assign('DISPLAY_EDIT', true);
124
        }
125
        if(is_admin($GLOBALS['current_user'])){
126
 			$this->ss->assign('DISPLAY_DUPLICATE', true);
127
 		}
128
129
 		$showDeleteButton = FALSE;
130
 		if(  $_REQUEST['record'] != $GLOBALS['current_user']->id && $GLOBALS['current_user']->isAdminForModule('Users') )
131
        {
132
            $showDeleteButton = TRUE;
133
 		     if( empty($this->bean->user_name) ) //Indicates just employee
134
 		         $deleteWarning = $GLOBALS['mod_strings']['LBL_DELETE_EMPLOYEE_CONFIRM'];
135
 		     else
136
 		         $deleteWarning = $GLOBALS['mod_strings']['LBL_DELETE_USER_CONFIRM'];
137
 		     $this->ss->assign('DELETE_WARNING', $deleteWarning);
138
        }
139
        $this->ss->assign('DISPLAY_DELETE', $showDeleteButton);
140
141
 		parent::display();
142
 	}
143
}
144
?>
145