]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Users/views/view.edit.php
Release 6.4.0beta4
[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('include/MVC/View/views/view.edit.php');
40 require_once('modules/Users/UserViewHelper.php');
41
42
43 class UsersViewEdit extends ViewEdit {
44
45         function UsersViewEdit(){
46                 parent::ViewEdit();
47         }
48
49     function preDisplay() {
50         $this->fieldHelper = new UserViewHelper($this->ss, $this->bean, 'EditView');
51         $this->fieldHelper->setupAdditionalFields();
52
53         parent::preDisplay();
54     }
55
56     public function getMetaDataFile() {
57         $userType = 'Regular';
58         if($this->fieldHelper->usertype == 'GROUP'){
59             $userType = 'Group';
60         }
61
62         if ( $userType != 'Regular' ) {
63             $oldType = $this->type;
64             $this->type = $oldType.'group';
65         }
66         $metadataFile = parent::getMetaDataFile();
67         if ( $userType != 'Regular' ) {
68             $this->type = $oldType;
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         //Set the return_action if it is provided
83         if(!empty($_REQUEST['return_action'])){
84             $this->ss->assign('RETURN_ACTION',$_REQUEST['return_action']);
85             //Set the return_id form value if record entry was provided
86             if(!empty($_REQUEST['record']))
87             {
88                 $this->ss->assign('RETURN_ID', $_REQUEST['record']);
89             }
90         }
91
92         //reset the id if this is a duplicate bean
93         if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
94             $this->bean->id = "";
95             $this->bean->user_name = "";
96             $this->ss->assign('ID','');
97         }
98
99         ///////////////////////////////////////////////////////////////////////////////
100         ////    REDIRECTS FROM COMPOSE EMAIL SCREEN
101         if(isset($_REQUEST['type']) && (isset($_REQUEST['return_module']) && $_REQUEST['return_module'] == 'Emails')) {
102             $this->ss->assign('REDIRECT_EMAILS_TYPE', $_REQUEST['type']);
103         }
104         ////    END REDIRECTS FROM COMPOSE EMAIL SCREEN
105         ///////////////////////////////////////////////////////////////////////////////
106
107         ///////////////////////////////////////////////////////////////////////////////
108         ////    NEW USER CREATION ONLY
109         if(empty($this->bean->id)) {
110             $this->ss->assign('SHOW_ADMIN_CHECKBOX','height="30"');
111             $this->ss->assign('NEW_USER','1');
112         }else{
113             $this->ss->assign('NEW_USER','0');
114             $this->ss->assign('NEW_USER_TYPE','DISABLED');
115         }
116
117         ////    END NEW USER CREATION ONLY
118         ///////////////////////////////////////////////////////////////////////////////
119
120
121
122
123
124         // FIXME: Translate error prefix
125         if(isset($_REQUEST['error_string'])) $this->ss->assign('ERROR_STRING', '<span class="error">Error: '.$_REQUEST['error_string'].'</span>');
126         if(isset($_REQUEST['error_password'])) $this->ss->assign('ERROR_PASSWORD', '<span id="error_pwd" class="error">Error: '.$_REQUEST['error_password'].'</span>');
127
128
129
130
131         // Build viewable versions of a few fields for non-admins
132         if(!empty($this->bean->id)) {
133             if( !empty($this->bean->status) ) {
134                 $this->ss->assign('STATUS_READONLY',$app_list_strings['user_status_dom'][$this->bean->status]); }
135             if( !empty($this->bean->employee_status) ) {
136                 $this->ss->assign('EMPLOYEE_STATUS_READONLY', $app_list_strings['employee_status_dom'][$this->bean->employee_status]);
137             }
138             if( !empty($this->bean->reports_to_id) ) {
139                 $this->ss->assign('REPORTS_TO_READONLY', get_assigned_user_name($this->bean->reports_to_id));
140             }
141         }
142
143         $processSpecial = false;
144         $processFormName = '';
145         if ( $this->fieldHelper->usertype == 'GROUP'
146             ) {
147             $this->ev->formName = 'EditViewGroup';
148             
149             $processSpecial = true;
150             $processFormName = 'EditViewGroup';            
151         }
152
153         $this->ev->process($processSpecial,$processFormName);
154
155                 echo $this->ev->display($this->showTitle);
156         
157     }
158
159 }