00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 class UserEditView extends EditView
00038 {
00039 public static function getDefaultMetadata()
00040 {
00041 $metadata = array(
00042 'global' => array(
00043 'toolbar' => array(
00044 'elements' => array(
00045 array('type' => 'SaveButton'),
00046 array('type' => 'CancelLink'),
00047 ),
00048 ),
00049 'derivedAttributeTypes' => array(
00050 'DateTimeCreatedUser',
00051 'DateTimeModifiedUser',
00052 'TitleFullName',
00053 'DerivedUserStatus',
00054 ),
00055 'nonPlaceableAttributeNames' => array(
00056 'title',
00057 'firstName',
00058 'lastName',
00059 ),
00060 'panelsDisplayType' => FormLayout::PANELS_DISPLAY_TYPE_ALL,
00061 'panels' => array(
00062 array(
00063 'rows' => array(
00064 array('cells' =>
00065 array(
00066 array(
00067 'elements' => array(
00068 array('attributeName' => 'null', 'type' => 'TitleFullName'),
00069 ),
00070 ),
00071 )
00072 ),
00073 array('cells' =>
00074 array(
00075 array(
00076 'elements' => array(
00077 array('attributeName' => 'username', 'type' => 'Text'),
00078 ),
00079 ),
00080 )
00081 ),
00082 array('cells' =>
00083 array(
00084 array(
00085 'elements' => array(
00086 array('attributeName' => 'jobTitle', 'type' => 'Text'),
00087 ),
00088 ),
00089 ),
00090 ),
00091 array('cells' =>
00092 array(
00093 array(
00094 'elements' => array(
00095 array('attributeName' => 'officePhone', 'type' => 'Phone'),
00096 ),
00097 ),
00098 ),
00099 ),
00100 array('cells' =>
00101 array(
00102 array(
00103 'elements' => array(
00104 array('attributeName' => 'manager', 'type' => 'User'),
00105 ),
00106 ),
00107 )
00108 ),
00109 array('cells' =>
00110 array(
00111 array(
00112 'elements' => array(
00113 array('attributeName' => 'role', 'type' => 'Role'),
00114 ),
00115 ),
00116 )
00117 ),
00118 array('cells' =>
00119 array(
00120 array(
00121 'elements' => array(
00122 array('attributeName' => 'mobilePhone', 'type' => 'Phone'),
00123 ),
00124 ),
00125 )
00126 ),
00127 array('cells' =>
00128 array(
00129 array(
00130 'elements' => array(
00131 array('attributeName' => 'department', 'type' => 'Text'),
00132 ),
00133 ),
00134 )
00135 ),
00136 array('cells' =>
00137 array(
00138 array(
00139 'elements' => array(
00140 array('attributeName' => 'primaryEmail',
00141 'type' => 'EmailAddressInformation',
00142 'hideOptOut' => true),
00143 ),
00144 ),
00145 )
00146 ),
00147 array('cells' =>
00148 array(
00149 array(
00150 'elements' => array(
00151 array('attributeName' => 'secondaryEmail',
00152 'type' => 'EmailAddressInformation',
00153 'hideOptOut' => true),
00154 ),
00155 ),
00156 )
00157 ),
00158 array('cells' =>
00159 array(
00160 array(
00161 'elements' => array(
00162 array('attributeName' => 'primaryAddress', 'type' => 'Address'),
00163 ),
00164 ),
00165 )
00166 ),
00167 ),
00168 ),
00169 array(
00170 'rows' => array(
00171 array('cells' =>
00172 array(
00173 array(
00174 'elements' => array(
00175 array('attributeName' => 'language', 'type' => 'LanguageStaticDropDown',
00176 'addBlank' => true),
00177 ),
00178 ),
00179 )
00180 ),
00181 array('cells' =>
00182 array(
00183 array(
00184 'elements' => array(
00185 array('attributeName' => 'locale', 'type' => 'LocaleStaticDropDown',
00186 'addBlank' => true),
00187 ),
00188 ),
00189 )
00190 ),
00191 array('cells' =>
00192 array(
00193 array(
00194 'elements' => array(
00195 array('attributeName' => 'timeZone', 'type' => 'TimeZoneStaticDropDown',
00196 'addBlank' => true),
00197 ),
00198 ),
00199 )
00200 ),
00201 array('cells' =>
00202 array(
00203 array(
00204 'elements' => array(
00205 array('attributeName' => 'currency', 'type' => 'CurrencyDropDown',
00206 'addBlank' => true),
00207 ),
00208 ),
00209 )
00210 ),
00211 array('cells' =>
00212 array(
00213 array(
00214 'elements' => array(
00215 array('attributeName' => 'null', 'type' => 'DerivedUserStatus'),
00216 ),
00217 ),
00218 )
00219 ),
00220 ),
00221 ),
00222 ),
00223 ),
00224 );
00225 return $metadata;
00226 }
00227
00228 protected function resolveActiveFormAjaxValidationOptions()
00229 {
00230 return array('enableAjaxValidation' => true,
00231 'clientOptions' => array(
00232 'beforeValidate' => 'js:$(this).beforeValidateAction',
00233 'afterValidate' => 'js:$(this).afterValidateAction',
00234 'validateOnSubmit' => true,
00235 'validateOnChange' => false,
00236 'inputContainer' => 'td',
00237 )
00238 );
00239 }
00240
00241 public static function getDesignerRulesType()
00242 {
00243 return 'UserEditAndDetailsView';
00244 }
00245
00250 protected function resolveElementInformationDuringFormLayoutRender(& $elementInformation)
00251 {
00252 if ($elementInformation['type'] == 'DerivedUserStatus' &&
00253 !UserStatusUtil::canUserEditStatusOnAnotherUser(Yii::app()->user->userModel, $this->model))
00254 {
00255 $elementInformation['type'] = 'ReadOnlyDerivedUserStatus';
00256 }
00257 if ($elementInformation['attributeName'] == 'role' &&
00258 !RightsUtil::canUserAccessModule('RolesModule', Yii::app()->user->userModel))
00259 {
00260 $elementInformation['type'] = 'ReadOnlyModel';
00261 }
00262 }
00263
00264 public function getTitle()
00265 {
00266 if ($this->model->id > 0)
00267 {
00268 return strval($this->model);
00269 }
00270 else
00271 {
00272 throw new NotSupportedException();
00273 }
00274 }
00275 }
00276 ?>