]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Users/views/view.edit.php
Release 6.4.0
[Github/sugarcrm.git] / modules / Users / views / view.edit.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
42 class UsersViewEdit extends ViewEdit {
43 var $useForSubpanel = true;
44         function UsersViewEdit(){
45                 parent::ViewEdit();
46         }
47
48     function preDisplay() {
49         $this->fieldHelper = new UserViewHelper($this->ss, $this->bean, 'EditView');
50         $this->fieldHelper->setupAdditionalFields();
51
52         parent::preDisplay();
53     }
54
55     public function getMetaDataFile() {
56         $userType = 'Regular';
57         if($this->fieldHelper->usertype == 'GROUP'){
58             $userType = 'Group';
59         }
60
61         if ( $userType != 'Regular' ) {
62             $oldType = $this->type;
63             $this->type = $oldType.'group';
64         }
65         $metadataFile = parent::getMetaDataFile();
66         if ( $userType != 'Regular' ) {
67             $this->type = $oldType;
68         }
69
70         return $metadataFile;
71     }
72
73     function display() {
74         global $current_user, $app_list_strings;
75
76
77         //lets set the return values
78         if(isset($_REQUEST['return_module'])){
79             $this->ss->assign('RETURN_MODULE',$_REQUEST['return_module']);
80         }
81
82         $this->ss->assign('IS_ADMIN', $current_user->is_admin ? true : false);
83
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();
88         }
89
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']);
94             $this->bean->id = "";
95             $this->bean->user_name = "";
96             $this->ss->assign('ID','');
97         } else {
98             if(isset($_REQUEST['return_module']))
99             {
100                 $this->ss->assign('RETURN_MODULE', $_REQUEST['return_module']);
101             } else {
102                 $this->ss->assign('RETURN_MODULE', $this->bean->module_dir);
103             }
104
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);
110             }
111         }
112
113
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']);
118         }
119         ////    END REDIRECTS FROM COMPOSE EMAIL SCREEN
120         ///////////////////////////////////////////////////////////////////////////////
121
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');
127         }else{
128             $this->ss->assign('NEW_USER','0');
129             $this->ss->assign('NEW_USER_TYPE','DISABLED');
130         }
131
132         ////    END NEW USER CREATION ONLY
133         ///////////////////////////////////////////////////////////////////////////////
134
135
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>');
139
140
141
142
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]);
149             }
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);
155             }
156             if( !empty($this->bean->title) ) {
157                 $this->ss->assign('TITLE_READONLY', $this->bean->title);
158             }
159             if( !empty($this->bean->department) ) {
160                 $this->ss->assign('DEPT_READONLY', $this->bean->department);
161             }
162         }
163
164         $processSpecial = false;
165         $processFormName = '';
166         if ( isset($this->fieldHelper->usertype) && ($this->fieldHelper->usertype == 'GROUP'
167             )) {
168             $this->ev->formName = 'EditViewGroup';
169             
170             $processSpecial = true;
171             $processFormName = 'EditViewGroup';            
172         }
173
174         $this->ev->process($processSpecial,$processFormName);
175
176                 echo $this->ev->display($this->showTitle);
177         
178     }
179
180
181     /**
182      * getHelpText
183      *
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.
187      *
188      * @param $module String the formatted module name
189      * @return $theTitle String the HTML for the help text
190      */
191     protected function getHelpText($module)
192     {
193         $theTitle = '';
194
195         if($GLOBALS['current_user']->isAdminForModule('Users')
196         ) {
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
200 &nbsp;
201 <img src='{$createImageURL}' alt='{$GLOBALS['app_strings']['LNK_CREATE']}'>
202 <a href="{$url}" class="utilsLink">
203 {$GLOBALS['app_strings']['LNK_CREATE']}
204 </a>
205 EOHTML;
206         }
207         return $theTitle;
208     }
209 }