]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Users/views/view.detail.php
Release 6.5.0
[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-2012 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 require_once('modules/Users/UserViewHelper.php');
40
41 class UsersViewDetail extends ViewDetail {
42
43         function UsersViewDetail(){
44                 parent::ViewDetail();
45         }
46
47     function preDisplay() {
48         global $current_user, $app_strings, $sugar_config;
49
50         if(!isset($this->bean->id) ) {
51             // No reason to set everything up just to have it fail in the display() call
52             return;
53         }
54
55         parent::preDisplay();
56
57         $viewHelper = new UserViewHelper($this->ss, $this->bean, 'DetailView');
58         $viewHelper->setupAdditionalFields();
59
60         $errors = "";
61         $msgGood = false;
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();
66             }
67             else {
68                 $errors.=translate('LBL_NEW_USER_PASSWORD_'.$_REQUEST['pwd_set'],'Users');
69                 $msgGood = true;
70             }
71         }else{
72             //IF BEAN USER IS LOCKOUT
73             if($this->bean->getPreference('lockout')=='1') {
74                 $errors.=translate('ERR_USER_IS_LOCKED_OUT','Users');
75             }
76         }
77         $this->ss->assign("ERRORS", $errors);
78         $this->ss->assign("ERROR_MESSAGE", $msgGood ? translate('LBL_PASSWORD_SENT','Users') : translate('LBL_CANNOT_SEND_PASSWORD','Users'));
79         $buttons = array();
80         if ((is_admin($current_user) || $_REQUEST['record'] == $current_user->id
81                 )
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'] .  "'>";
87
88         }
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')
93                     )) {
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']."'>";
96
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']."' />";
99                     }
100
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')."'>";
104                     }
105                 }
106             }
107         }
108
109         $buttons = array_merge($buttons, $this->ss->get_template_vars('BUTTONS_HEADER'));
110
111         $this->ss->assign('EDITBUTTONS',$buttons);
112
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);
117         if ( $show_roles ) {
118             ob_start();
119             echo "<div>";
120             require_once('modules/ACLRoles/DetailUserRole.php');
121             echo "</div></div>";
122
123
124             $role_html = ob_get_contents();
125             ob_end_clean();
126             $this->ss->assign('ROLE_HTML',$role_html);
127         }
128
129     }
130
131     public function getMetaDataFile() {
132         $userType = 'Regular';
133         if($this->bean->is_group == 1){
134             $userType = 'Group';
135         }
136
137         if ( $userType != 'Regular' ) {
138             $oldType = $this->type;
139             $this->type = $oldType.'group';
140         }
141         $metadataFile = parent::getMetaDataFile();
142         if ( $userType != 'Regular' ) {
143             $this->type = $oldType;
144         }
145         return $metadataFile;
146     }
147
148     function display() {
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';
153         }
154
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);
162             }
163         }
164
165         return parent::display();
166     }
167
168
169     /**
170      * getHelpText
171      *
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.
175      *
176      * @param $module String the formatted module name
177      * @return $theTitle String the HTML for the help text
178      */
179     protected function getHelpText($module)
180     {
181         $theTitle = '';
182
183         if($GLOBALS['current_user']->isAdminForModule('Users')
184         ) {
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
188 &nbsp;
189 <img src='{$createImageURL}' alt='{$GLOBALS['app_strings']['LNK_CREATE']}'>
190 <a href="{$url}" class="utilsLink">
191 {$GLOBALS['app_strings']['LNK_CREATE']}
192 </a>
193 EOHTML;
194         }
195         return $theTitle;
196     }
197
198 }