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');
42 class UsersViewEdit extends ViewEdit {
43 var $useForSubpanel = true;
44 function UsersViewEdit(){
48 function preDisplay() {
49 $this->fieldHelper = new UserViewHelper($this->ss, $this->bean, 'EditView');
50 $this->fieldHelper->setupAdditionalFields();
55 public function getMetaDataFile() {
56 $userType = 'Regular';
57 if($this->fieldHelper->usertype == 'GROUP'){
61 if ( $userType != 'Regular' ) {
62 $oldType = $this->type;
63 $this->type = $oldType.'group';
65 $metadataFile = parent::getMetaDataFile();
66 if ( $userType != 'Regular' ) {
67 $this->type = $oldType;
74 global $current_user, $app_list_strings;
77 //lets set the return values
78 if(isset($_REQUEST['return_module'])){
79 $this->ss->assign('RETURN_MODULE',$_REQUEST['return_module']);
82 $this->ss->assign('IS_ADMIN', $current_user->is_admin ? true : false);
84 //make sure we can populate user type dropdown. This usually gets populated in predisplay unless this is a quickeditform
85 if(!isset($this->fieldHelper)){
86 $this->fieldHelper = new UserViewHelper($this->ss, $this->bean, 'EditView');
87 $this->fieldHelper->setupAdditionalFields();
90 if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
91 $this->ss->assign('RETURN_MODULE', $_REQUEST['return_module']);
92 $this->ss->assign('RETURN_ACTION', $_REQUEST['return_action']);
93 $this->ss->assign('RETURN_ID', $_REQUEST['record']);
95 $this->bean->user_name = "";
96 $this->ss->assign('ID','');
98 if(isset($_REQUEST['return_module']))
100 $this->ss->assign('RETURN_MODULE', $_REQUEST['return_module']);
102 $this->ss->assign('RETURN_MODULE', $this->bean->module_dir);
105 $return_id = isset($_REQUEST['return_id'])?$_REQUEST['return_id']:$this->bean->id;
106 if (isset($return_id)) {
107 $return_action = isset($_REQUEST['return_action'])?$_REQUEST['return_action']:'DetailView';
108 $this->ss->assign('RETURN_ID', $return_id);
109 $this->ss->assign('RETURN_ACTION', $return_action);
114 ///////////////////////////////////////////////////////////////////////////////
115 //// REDIRECTS FROM COMPOSE EMAIL SCREEN
116 if(isset($_REQUEST['type']) && (isset($_REQUEST['return_module']) && $_REQUEST['return_module'] == 'Emails')) {
117 $this->ss->assign('REDIRECT_EMAILS_TYPE', $_REQUEST['type']);
119 //// END REDIRECTS FROM COMPOSE EMAIL SCREEN
120 ///////////////////////////////////////////////////////////////////////////////
122 ///////////////////////////////////////////////////////////////////////////////
123 //// NEW USER CREATION ONLY
124 if(empty($this->bean->id)) {
125 $this->ss->assign('SHOW_ADMIN_CHECKBOX','height="30"');
126 $this->ss->assign('NEW_USER','1');
128 $this->ss->assign('NEW_USER','0');
129 $this->ss->assign('NEW_USER_TYPE','DISABLED');
132 //// END NEW USER CREATION ONLY
133 ///////////////////////////////////////////////////////////////////////////////
136 // FIXME: Translate error prefix
137 if(isset($_REQUEST['error_string'])) $this->ss->assign('ERROR_STRING', '<span class="error">Error: '.$_REQUEST['error_string'].'</span>');
138 if(isset($_REQUEST['error_password'])) $this->ss->assign('ERROR_PASSWORD', '<span id="error_pwd" class="error">Error: '.$_REQUEST['error_password'].'</span>');
143 // Build viewable versions of a few fields for non-admins
144 if(!empty($this->bean->id)) {
145 if( !empty($this->bean->status) ) {
146 $this->ss->assign('STATUS_READONLY',$app_list_strings['user_status_dom'][$this->bean->status]); }
147 if( !empty($this->bean->employee_status) ) {
148 $this->ss->assign('EMPLOYEE_STATUS_READONLY', $app_list_strings['employee_status_dom'][$this->bean->employee_status]);
150 if( !empty($this->bean->reports_to_id) ) {
151 $reportsToUser = get_assigned_user_name($this->bean->reports_to_id);
152 $reportsToUserField = "<input type='text' name='reports_to_name' id='reports_to_name' value='{$reportsToUser}' disabled>\n";
153 $reportsToUserField .= "<input type='hidden' name='reports_to_id' id='reports_to_id' value='{$this->bean->reports_to_id}'>";
154 $this->ss->assign('REPORTS_TO_READONLY', $reportsToUserField);
156 if( !empty($this->bean->title) ) {
157 $this->ss->assign('TITLE_READONLY', $this->bean->title);
159 if( !empty($this->bean->department) ) {
160 $this->ss->assign('DEPT_READONLY', $this->bean->department);
164 $processSpecial = false;
165 $processFormName = '';
166 if ( isset($this->fieldHelper->usertype) && ($this->fieldHelper->usertype == 'GROUP'
168 $this->ev->formName = 'EditViewGroup';
170 $processSpecial = true;
171 $processFormName = 'EditViewGroup';
174 $this->ev->process($processSpecial,$processFormName);
176 echo $this->ev->display($this->showTitle);
184 * This is a protected function that returns the help text portion. It is called from getModuleTitle.
185 * We override the function from SugarView.php to make sure the create link only appears if the current user
186 * meets the valid criteria.
188 * @param $module String the formatted module name
189 * @return $theTitle String the HTML for the help text
191 protected function getHelpText($module)
195 if($GLOBALS['current_user']->isAdminForModule('Users')
197 $createImageURL = SugarThemeRegistry::current()->getImageURL('create-record.gif');
198 $url = ajaxLink("index.php?module=$module&action=EditView&return_module=$module&return_action=DetailView");
199 $theTitle = <<<EOHTML
201 <img src='{$createImageURL}' alt='{$GLOBALS['app_strings']['LNK_CREATE']}'>
202 <a href="{$url}" class="utilsLink">
203 {$GLOBALS['app_strings']['LNK_CREATE']}