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-2012 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 ********************************************************************************/
39 require_once('modules/Users/UserViewHelper.php');
41 class UsersViewDetail extends ViewDetail {
43 function UsersViewDetail(){
47 function preDisplay() {
48 global $current_user, $app_strings, $sugar_config;
50 if(!isset($this->bean->id) ) {
51 // No reason to set everything up just to have it fail in the display() call
57 $viewHelper = new UserViewHelper($this->ss, $this->bean, 'DetailView');
58 $viewHelper->setupAdditionalFields();
62 if (isset($_REQUEST['pwd_set']) && $_REQUEST['pwd_set']!= 0){
63 if ($_REQUEST['pwd_set']=='4'){
64 require_once('modules/Users/password_utils.php');
65 $errors.=canSendPassword();
68 $errors.=translate('LBL_NEW_USER_PASSWORD_'.$_REQUEST['pwd_set'],'Users');
72 //IF BEAN USER IS LOCKOUT
73 if($this->bean->getPreference('lockout')=='1') {
74 $errors.=translate('ERR_USER_IS_LOCKED_OUT','Users');
77 $this->ss->assign("ERRORS", $errors);
78 $this->ss->assign("ERROR_MESSAGE", $msgGood ? translate('LBL_PASSWORD_SENT','Users') : translate('LBL_CANNOT_SEND_PASSWORD','Users'));
80 if ((is_admin($current_user) || $_REQUEST['record'] == $current_user->id
82 && !empty($sugar_config['default_user_name'])
83 && $sugar_config['default_user_name'] == $this->bean->user_name
84 && isset($sugar_config['lock_default_user_name'])
85 && $sugar_config['lock_default_user_name']) {
86 $buttons[] = "<input id='edit_button' accessKey='".$app_strings['LBL_EDIT_BUTTON_KEY']."' name='Edit' title='".$app_strings['LBL_EDIT_BUTTON_TITLE']."' value='".$app_strings['LBL_EDIT_BUTTON_LABEL']."' 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' value='" . $app_strings['LBL_EDIT_BUTTON_LABEL'] . "'>";
89 elseif (is_admin($current_user)|| ($GLOBALS['current_user']->isAdminForModule('Users')&& !$this->bean->is_admin)
90 || $_REQUEST['record'] == $current_user->id) {
91 $buttons[] = "<input title='".$app_strings['LBL_EDIT_BUTTON_TITLE']."' accessKey='".$app_strings['LBL_EDIT_BUTTON_KEY']."' name='Edit' id='edit_button' value='".$app_strings['LBL_EDIT_BUTTON_LABEL']."' 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' value='" . $app_strings['LBL_EDIT_BUTTON_LABEL'] . "'>";
92 if ((is_admin($current_user)|| $GLOBALS['current_user']->isAdminForModule('Users')
94 if (!$current_user->is_group){
95 $buttons[] = "<input id='duplicate_button' 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 if($this->bean->id != $current_user->id) {
98 $buttons[] ="<input id='delete_button' type='button' class='button' onclick='confirmDelete();' value='".$app_strings['LBL_DELETE_BUTTON_LABEL']."' />";
101 if (!$this->bean->portal_only && !$this->bean->is_group && !$this->bean->external_auth_only
102 && isset($sugar_config['passwordsetting']['SystemGeneratedPasswordON']) && $sugar_config['passwordsetting']['SystemGeneratedPasswordON']){
103 $buttons[] = "<input title='".translate('LBL_GENERATE_PASSWORD_BUTTON_TITLE','Users')."' class='button' LANGUAGE=javascript onclick='generatepwd(\"".$this->bean->id."\");' type='button' name='password' value='".translate('LBL_GENERATE_PASSWORD_BUTTON_LABEL','Users')."'>";
109 $buttons = array_merge($buttons, $this->ss->get_template_vars('BUTTONS_HEADER'));
111 $this->ss->assign('EDITBUTTONS',$buttons);
113 $show_roles = (!($this->bean->is_group=='1' || $this->bean->portal_only=='1'));
114 $this->ss->assign('SHOW_ROLES', $show_roles);
115 //Mark whether or not the user is a group or portal user
116 $this->ss->assign('IS_GROUP_OR_PORTAL', ($this->bean->is_group=='1' || $this->bean->portal_only=='1') ? true : false);
120 require_once('modules/ACLRoles/DetailUserRole.php');
124 $role_html = ob_get_contents();
126 $this->ss->assign('ROLE_HTML',$role_html);
131 public function getMetaDataFile() {
132 $userType = 'Regular';
133 if($this->bean->is_group == 1){
137 if ( $userType != 'Regular' ) {
138 $oldType = $this->type;
139 $this->type = $oldType.'group';
141 $metadataFile = parent::getMetaDataFile();
142 if ( $userType != 'Regular' ) {
143 $this->type = $oldType;
145 return $metadataFile;
149 if ($this->bean->portal_only == 1 || $this->bean->is_group == 1 ) {
150 $this->options['show_subpanels'] = false;
151 $this->dv->formName = 'DetailViewGroup';
152 $this->dv->view = 'DetailViewGroup';
155 //handle request to reset the homepage
156 if(isset($_REQUEST['reset_homepage'])){
157 $this->bean->resetPreferences('Home');
158 global $current_user;
159 if($this->bean->id == $current_user->id) {
160 $_COOKIE[$current_user->id . '_activePage'] = '0';
161 setcookie($current_user->id . '_activePage','0',3000);
165 return parent::display();
172 * This is a protected function that returns the help text portion. It is called from getModuleTitle.
173 * We override the function from SugarView.php to make sure the create link only appears if the current user
174 * meets the valid criteria.
176 * @param $module String the formatted module name
177 * @return $theTitle String the HTML for the help text
179 protected function getHelpText($module)
183 if($GLOBALS['current_user']->isAdminForModule('Users')
185 $createImageURL = SugarThemeRegistry::current()->getImageURL('create-record.gif');
186 $url = ajaxLink("index.php?module=$module&action=EditView&return_module=$module&return_action=DetailView");
187 $theTitle = <<<EOHTML
189 <img src='{$createImageURL}' alt='{$GLOBALS['app_strings']['LNK_CREATE']}'>
190 <a href="{$url}" class="utilsLink">
191 {$GLOBALS['app_strings']['LNK_CREATE']}