]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Users/views/view.detail.php
Release 6.4.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-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 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 = "";
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' 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']."'>  ";
87         }
88         elseif (is_admin($current_user)|| ($GLOBALS['current_user']->isAdminForModule('Users')&& !$this->bean->is_admin)
89                 || $_REQUEST['record'] == $current_user->id) {
90             $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']."'>  ";
91             if ((is_admin($current_user)|| $GLOBALS['current_user']->isAdminForModule('Users')
92                     )) {
93                 if (!$current_user->is_group){
94                     $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']."'>  ";
95                     
96                     if($this->bean->id != $current_user->id) {
97                         $buttons .="<input type='button' class='button' onclick='confirmDelete();' value='".$app_strings['LBL_DELETE_BUTTON_LABEL']."' /> ";
98                     }
99                     
100                     if (!$this->bean->portal_only && !$this->bean->is_group && !$this->bean->external_auth_only
101                         && isset($sugar_config['passwordsetting']['SystemGeneratedPasswordON']) && $sugar_config['passwordsetting']['SystemGeneratedPasswordON']){
102                         $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')."'>  ";
103                     }
104                 }
105             }
106         }
107         
108         $this->ss->assign('EDITBUTTONS',$buttons);
109
110         $show_roles = (!($this->bean->is_group=='1' || $this->bean->portal_only=='1'));
111         $this->ss->assign('SHOW_ROLES', $show_roles);
112         //Mark whether or not the user is a group or portal user
113         $this->ss->assign('IS_GROUP_OR_PORTAL', ($this->bean->is_group=='1' || $this->bean->portal_only=='1') ? true : false);
114         if ( $show_roles ) {
115             ob_start();
116             echo "<div>";
117             require_once('modules/ACLRoles/DetailUserRole.php');
118             echo "</div></div>";
119             
120
121             $role_html = ob_get_contents();
122             ob_end_clean();
123             $this->ss->assign('ROLE_HTML',$role_html);
124         }
125
126     }
127
128     public function getMetaDataFile() {
129         $userType = 'Regular';
130         if($this->bean->is_group == 1){
131             $userType = 'Group';
132         }
133
134         if ( $userType != 'Regular' ) {
135             $oldType = $this->type;
136             $this->type = $oldType.'group';
137         }
138         $metadataFile = parent::getMetaDataFile();
139         if ( $userType != 'Regular' ) {
140             $this->type = $oldType;
141         }
142         return $metadataFile;
143     }
144
145     function display() {
146         if ($this->bean->portal_only == 1 || $this->bean->is_group == 1 ) {
147             $this->options['show_subpanels'] = false;
148             $this->dv->formName = 'DetailViewGroup';
149             $this->dv->view = 'DetailViewGroup';
150         }
151         
152             //handle request to reset the homepage
153         if(isset($_REQUEST['reset_homepage'])){
154             $this->bean->resetPreferences('Home');
155             global $current_user;
156             if($this->bean->id == $current_user->id) {
157                 $_COOKIE[$current_user->id . '_activePage'] = '0';
158                 setcookie($current_user->id . '_activePage','0',3000);
159             }
160         }
161
162         return parent::display();
163     }
164
165     
166     /**
167      * getHelpText
168      *
169      * This is a protected function that returns the help text portion.  It is called from getModuleTitle.
170      * We override the function from SugarView.php to make sure the create link only appears if the current user
171      * meets the valid criteria.
172      *
173      * @param $module String the formatted module name
174      * @return $theTitle String the HTML for the help text
175      */
176     protected function getHelpText($module)
177     {
178         $theTitle = '';
179
180         if($GLOBALS['current_user']->isAdminForModule('Users')
181         ) {
182         $createImageURL = SugarThemeRegistry::current()->getImageURL('create-record.gif');
183         $url = ajaxLink("index.php?module=$module&action=EditView&return_module=$module&return_action=DetailView");
184         $theTitle = <<<EOHTML
185 &nbsp;
186 <img src='{$createImageURL}' alt='{$GLOBALS['app_strings']['LNK_CREATE']}'>
187 <a href="{$url}" class="utilsLink">
188 {$GLOBALS['app_strings']['LNK_CREATE']}
189 </a>
190 EOHTML;
191         }
192         return $theTitle;
193     }
194
195 }