]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Users/views/view.detail.php
Release 6.4.0beta1
[Github/sugarcrm.git] / modules / Users / views / view.detail.php
1 <?php
2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4  * SugarCRM Community Edition is a customer relationship management program developed by
5  * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
6  * 
7  * This program is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU Affero General Public License version 3 as published by the
9  * Free Software Foundation with the addition of the following permission added
10  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11  * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
13  * 
14  * This program is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
17  * details.
18  * 
19  * You should have received a copy of the GNU Affero General Public License along with
20  * this program; if not, see http://www.gnu.org/licenses or write to the Free
21  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22  * 02110-1301 USA.
23  * 
24  * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25  * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
26  * 
27  * The interactive user interfaces in modified source and object code versions
28  * of this program must display Appropriate Legal Notices, as required under
29  * Section 5 of the GNU Affero General Public License version 3.
30  * 
31  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32  * these Appropriate Legal Notices must retain the display of the "Powered by
33  * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34  * technical reasons, the Appropriate Legal Notices must display the words
35  * "Powered by SugarCRM".
36  ********************************************************************************/
37
38
39
40 require_once('include/MVC/View/views/view.detail.php');
41 require_once('modules/Users/UserViewHelper.php');
42
43 class UsersViewDetail extends ViewDetail {
44
45         function UsersViewDetail(){
46                 parent::ViewDetail();
47         }
48     
49     function preDisplay() {
50         global $current_user, $app_strings, $sugar_config;
51
52         if(!isset($this->bean->id) ) {
53             // No reason to set everything up just to have it fail in the display() call
54             return;
55         }
56
57         parent::preDisplay();
58         
59         $viewHelper = new UserViewHelper($this->ss, $this->bean, 'DetailView');
60         $viewHelper->setupAdditionalFields();
61
62         $errors = "";
63         $msgGood = false;
64         if (isset($_REQUEST['pwd_set']) && $_REQUEST['pwd_set']!= 0){
65             if ($_REQUEST['pwd_set']=='4'){
66                 require_once('modules/Users/password_utils.php');
67                 $errors.=canSendPassword();
68             }
69             else {
70                 $errors.=translate('LBL_NEW_USER_PASSWORD_'.$_REQUEST['pwd_set'],'Users');
71                 $msgGood = true;
72             }
73         }else{
74             //IF BEAN USER IS LOCKOUT
75             if($this->bean->getPreference('lockout')=='1') {
76                 $errors.=translate('ERR_USER_IS_LOCKED_OUT','Users');
77             }
78         }
79         $this->ss->assign("ERRORS", $errors);
80         $this->ss->assign("ERROR_MESSAGE", $msgGood ? translate('LBL_PASSWORD_SENT','Users') : translate('LBL_CANNOT_SEND_PASSWORD','Users'));
81         $buttons = "";
82         if ((is_admin($current_user) || $_REQUEST['record'] == $current_user->id
83                 )
84             && !empty($sugar_config['default_user_name'])
85             && $sugar_config['default_user_name'] == $this->bean->user_name
86             && isset($sugar_config['lock_default_user_name'])
87             && $sugar_config['lock_default_user_name']) {
88             $buttons .= "<input id='edit_button' title='".$app_strings['LBL_EDIT_BUTTON_TITLE']."' accessKey='".$app_strings['LBL_EDIT_BUTTON_KEY']."' class='button primary' onclick=\"this.form.return_module.value='Users'; this.form.return_action.value='DetailView'; this.form.return_id.value='".$this->bean->id."'; this.form.action.value='EditView'\" type='submit' name='Edit' value='".$app_strings['LBL_EDIT_BUTTON_LABEL']."'>  ";
89         }
90         elseif (is_admin($current_user)|| ($GLOBALS['current_user']->isAdminForModule('Users')&& !$this->bean->is_admin)
91                 || $_REQUEST['record'] == $current_user->id) {
92             $buttons .= "<input id='edit_button' title='".$app_strings['LBL_EDIT_BUTTON_TITLE']."' accessKey='".$app_strings['LBL_EDIT_BUTTON_KEY']."' class='button primary' onclick=\"this.form.return_module.value='Users'; this.form.return_action.value='DetailView'; this.form.return_id.value='".$this->bean->id."'; this.form.action.value='EditView'\" type='submit' name='Edit' value='".$app_strings['LBL_EDIT_BUTTON_LABEL']."'>  ";
93             if ((is_admin($current_user)|| $GLOBALS['current_user']->isAdminForModule('Users')
94                     )) {
95                 if (!$current_user->is_group){
96                     $buttons .= "<input title='".$app_strings['LBL_DUPLICATE_BUTTON_TITLE']."' accessKey='".$app_strings['LBL_DUPLICATE_BUTTON_KEY']."' class='button' onclick=\"this.form.return_module.value='Users'; this.form.return_action.value='DetailView'; this.form.isDuplicate.value=true; this.form.action.value='EditView'\" type='submit' name='Duplicate' value='".$app_strings['LBL_DUPLICATE_BUTTON_LABEL']."'>  ";
97                     
98                     if($this->bean->id != $current_user->id) {
99                         $buttons .="<input type='button' class='button' onclick='confirmDelete();' value='".$app_strings['LBL_DELETE_BUTTON_LABEL']."' /> ";
100                     }
101                     
102                     if (!$this->bean->portal_only && !$this->bean->is_group && !$this->bean->external_auth_only
103                         && isset($sugar_config['passwordsetting']['SystemGeneratedPasswordON']) && $sugar_config['passwordsetting']['SystemGeneratedPasswordON']){
104                         $buttons .= "<input title='".translate('LBL_GENERATE_PASSWORD_BUTTON_TITLE','Users')."' accessKey='".translate('LBL_GENERATE_PASSWORD_BUTTON_KEY','Users')."' class='button' LANGUAGE=javascript onclick='generatepwd(\"".$this->bean->id."\");' type='button' name='password' value='".translate('LBL_GENERATE_PASSWORD_BUTTON_LABEL','Users')."'>  ";
105                     }
106                 }
107             }
108         }
109         
110         $this->ss->assign('EDITBUTTONS',$buttons);
111
112         $show_roles = (!($this->bean->is_group=='1' || $this->bean->portal_only=='1'));
113         $this->ss->assign('SHOW_ROLES', $show_roles);
114
115         if ( $show_roles ) {
116             ob_start();
117             echo "<div>";
118             require_once('modules/ACLRoles/DetailUserRole.php');
119             echo "</div></div>";
120             
121
122             $role_html = ob_get_contents();
123             ob_end_clean();
124             $this->ss->assign('ROLE_HTML',$role_html);
125         }
126
127     }
128
129     public function getMetaDataFile() {
130         $userType = 'Regular';
131         if($this->bean->is_group == 1){
132             $userType = 'Group';
133         }
134
135         if ( $userType != 'Regular' ) {
136             $oldType = $this->type;
137             $this->type = $oldType.'group';
138         }
139         $metadataFile = parent::getMetaDataFile();
140         if ( $userType != 'Regular' ) {
141             $this->type = $oldType;
142         }
143         return $metadataFile;
144     }
145
146     function display() {
147         if ($this->bean->portal_only == 1 || $this->bean->is_group == 1 ) {
148             $this->options['show_subpanels'] = false;
149             $this->dv->formName = 'DetailViewGroup';
150         }
151
152         return parent::display();
153     }
154 }