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.
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.
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
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
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.
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.
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 ********************************************************************************/
40 require_once('include/MVC/View/views/view.detail.php');
41 require_once('modules/Users/UserViewHelper.php');
43 class UsersViewDetail extends ViewDetail {
45 function UsersViewDetail(){
49 function preDisplay() {
50 global $current_user, $app_strings, $sugar_config;
52 if(!isset($this->bean->id) ) {
53 // No reason to set everything up just to have it fail in the display() call
59 $viewHelper = new UserViewHelper($this->ss, $this->bean, 'DetailView');
60 $viewHelper->setupAdditionalFields();
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();
70 $errors.=translate('LBL_NEW_USER_PASSWORD_'.$_REQUEST['pwd_set'],'Users');
74 //IF BEAN USER IS LOCKOUT
75 if($this->bean->getPreference('lockout')=='1') {
76 $errors.=translate('ERR_USER_IS_LOCKED_OUT','Users');
79 $this->ss->assign("ERRORS", $errors);
80 $this->ss->assign("ERROR_MESSAGE", $msgGood ? translate('LBL_PASSWORD_SENT','Users') : translate('LBL_CANNOT_SEND_PASSWORD','Users'));
82 if ((is_admin($current_user) || $_REQUEST['record'] == $current_user->id
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']."'> ";
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')
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']."'> ";
98 if($this->bean->id != $current_user->id) {
99 $buttons .="<input type='button' class='button' onclick='confirmDelete();' value='".$app_strings['LBL_DELETE_BUTTON_LABEL']."' /> ";
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')."'> ";
110 $this->ss->assign('EDITBUTTONS',$buttons);
112 $show_roles = (!($this->bean->is_group=='1' || $this->bean->portal_only=='1'));
113 $this->ss->assign('SHOW_ROLES', $show_roles);
118 require_once('modules/ACLRoles/DetailUserRole.php');
122 $role_html = ob_get_contents();
124 $this->ss->assign('ROLE_HTML',$role_html);
129 public function getMetaDataFile() {
130 $userType = 'Regular';
131 if($this->bean->is_group == 1){
135 if ( $userType != 'Regular' ) {
136 $oldType = $this->type;
137 $this->type = $oldType.'group';
139 $metadataFile = parent::getMetaDataFile();
140 if ( $userType != 'Regular' ) {
141 $this->type = $oldType;
143 return $metadataFile;
147 if ($this->bean->portal_only == 1 || $this->bean->is_group == 1 ) {
148 $this->options['show_subpanels'] = false;
149 $this->dv->formName = 'DetailViewGroup';
152 return parent::display();