@@ -72,8 +72,8 @@ discard block |
||
| 72 | 72 | $geolocalization = $gMapsPlugin->get('enable_api') === 'true'; |
| 73 | 73 | |
| 74 | 74 | if ($geolocalization) { |
| 75 | - $gmapsApiKey = $gMapsPlugin->get('api_key'); |
|
| 76 | - $htmlHeadXtra[] = '<script type="text/javascript" src="//maps.googleapis.com/maps/api/js?sensor=true&key='. $gmapsApiKey . '" ></script>'; |
|
| 75 | + $gmapsApiKey = $gMapsPlugin->get('api_key'); |
|
| 76 | + $htmlHeadXtra[] = '<script type="text/javascript" src="//maps.googleapis.com/maps/api/js?sensor=true&key='. $gmapsApiKey . '" ></script>'; |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | $htmlHeadXtra[] = api_get_css_asset('cropper/dist/cropper.min.css'); |
@@ -117,27 +117,27 @@ discard block |
||
| 117 | 117 | $form->addElement('hidden', 'user_id', $user_id); |
| 118 | 118 | |
| 119 | 119 | if (api_is_western_name_order()) { |
| 120 | - // Firstname |
|
| 121 | - $form->addElement('text', 'firstname', get_lang('FirstName')); |
|
| 122 | - $form->applyFilter('firstname', 'html_filter'); |
|
| 123 | - $form->applyFilter('firstname', 'trim'); |
|
| 124 | - $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required'); |
|
| 125 | - // Lastname |
|
| 126 | - $form->addElement('text', 'lastname', get_lang('LastName')); |
|
| 127 | - $form->applyFilter('lastname', 'html_filter'); |
|
| 128 | - $form->applyFilter('lastname', 'trim'); |
|
| 129 | - $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required'); |
|
| 120 | + // Firstname |
|
| 121 | + $form->addElement('text', 'firstname', get_lang('FirstName')); |
|
| 122 | + $form->applyFilter('firstname', 'html_filter'); |
|
| 123 | + $form->applyFilter('firstname', 'trim'); |
|
| 124 | + $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required'); |
|
| 125 | + // Lastname |
|
| 126 | + $form->addElement('text', 'lastname', get_lang('LastName')); |
|
| 127 | + $form->applyFilter('lastname', 'html_filter'); |
|
| 128 | + $form->applyFilter('lastname', 'trim'); |
|
| 129 | + $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required'); |
|
| 130 | 130 | } else { |
| 131 | - // Lastname |
|
| 132 | - $form->addElement('text', 'lastname', get_lang('LastName')); |
|
| 133 | - $form->applyFilter('lastname', 'html_filter'); |
|
| 134 | - $form->applyFilter('lastname', 'trim'); |
|
| 135 | - $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required'); |
|
| 136 | - // Firstname |
|
| 137 | - $form->addElement('text', 'firstname', get_lang('FirstName')); |
|
| 138 | - $form->applyFilter('firstname', 'html_filter'); |
|
| 139 | - $form->applyFilter('firstname', 'trim'); |
|
| 140 | - $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required'); |
|
| 131 | + // Lastname |
|
| 132 | + $form->addElement('text', 'lastname', get_lang('LastName')); |
|
| 133 | + $form->applyFilter('lastname', 'html_filter'); |
|
| 134 | + $form->applyFilter('lastname', 'trim'); |
|
| 135 | + $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required'); |
|
| 136 | + // Firstname |
|
| 137 | + $form->addElement('text', 'firstname', get_lang('FirstName')); |
|
| 138 | + $form->applyFilter('firstname', 'html_filter'); |
|
| 139 | + $form->applyFilter('firstname', 'trim'); |
|
| 140 | + $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required'); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | // Official code |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | |
| 160 | 160 | // OpenID |
| 161 | 161 | if (api_get_setting('openid_authentication') == 'true') { |
| 162 | - $form->addElement('text', 'openid', get_lang('OpenIDURL')); |
|
| 162 | + $form->addElement('text', 'openid', get_lang('OpenIDURL')); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | // Phone |
@@ -174,18 +174,18 @@ discard block |
||
| 174 | 174 | $allowed_picture_types = api_get_supported_image_extensions(false); |
| 175 | 175 | |
| 176 | 176 | $form->addRule( |
| 177 | - 'picture', |
|
| 178 | - get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', |
|
| 179 | - 'filetype', |
|
| 180 | - $allowed_picture_types |
|
| 177 | + 'picture', |
|
| 178 | + get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', |
|
| 179 | + 'filetype', |
|
| 180 | + $allowed_picture_types |
|
| 181 | 181 | ); |
| 182 | 182 | if (strlen($user_data['picture_uri']) > 0) { |
| 183 | - $form->addElement('checkbox', 'delete_picture', '', get_lang('DelImage')); |
|
| 183 | + $form->addElement('checkbox', 'delete_picture', '', get_lang('DelImage')); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | // Username |
| 187 | 187 | if (api_get_setting('login_is_email') != 'true') { |
| 188 | - $form->addElement('text', 'username', get_lang('LoginName'), array('maxlength' => USERNAME_MAX_LENGTH)); |
|
| 188 | + $form->addElement('text', 'username', get_lang('LoginName'), array('maxlength' => USERNAME_MAX_LENGTH)); |
|
| 189 | 189 | $form->addRule('username', get_lang('ThisFieldIsRequired'), 'required'); |
| 190 | 190 | $form->addRule('username', sprintf(get_lang('UsernameMaxXCharacters'), (string)USERNAME_MAX_LENGTH), 'maxlength', USERNAME_MAX_LENGTH); |
| 191 | 191 | $form->addRule('username', get_lang('OnlyLettersAndNumbersAllowed'), 'username'); |
@@ -257,15 +257,15 @@ discard block |
||
| 257 | 257 | |
| 258 | 258 | // Platform admin |
| 259 | 259 | if (api_is_platform_admin()) { |
| 260 | - $group = array(); |
|
| 261 | - $group[] =$form->createElement('radio', 'platform_admin', null, get_lang('Yes'), 1); |
|
| 262 | - $group[] =$form->createElement('radio', 'platform_admin', null, get_lang('No'), 0); |
|
| 260 | + $group = array(); |
|
| 261 | + $group[] =$form->createElement('radio', 'platform_admin', null, get_lang('Yes'), 1); |
|
| 262 | + $group[] =$form->createElement('radio', 'platform_admin', null, get_lang('No'), 0); |
|
| 263 | 263 | |
| 264 | - $user_data['status'] == 1 ? $display = 'block':$display = 'none'; |
|
| 264 | + $user_data['status'] == 1 ? $display = 'block':$display = 'none'; |
|
| 265 | 265 | |
| 266 | - $form->addElement('html', '<div id="id_platform_admin" style="display:'.$display.'">'); |
|
| 267 | - $form->addGroup($group, 'admin', get_lang('PlatformAdmin'), null, false); |
|
| 268 | - $form->addElement('html', '</div>'); |
|
| 266 | + $form->addElement('html', '<div id="id_platform_admin" style="display:'.$display.'">'); |
|
| 267 | + $form->addGroup($group, 'admin', get_lang('PlatformAdmin'), null, false); |
|
| 268 | + $form->addElement('html', '</div>'); |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | //Language |
@@ -283,16 +283,16 @@ discard block |
||
| 283 | 283 | $form->addElement('label', get_lang('RegistrationDate'), $date); |
| 284 | 284 | |
| 285 | 285 | if (!$user_data['platform_admin']) { |
| 286 | - // Expiration Date |
|
| 287 | - $form->addElement('radio', 'radio_expiration_date', get_lang('ExpirationDate'), get_lang('NeverExpires'), 0); |
|
| 288 | - $group = array (); |
|
| 289 | - $group[] = $form->createElement('radio', 'radio_expiration_date', null, get_lang('Enabled'), 1); |
|
| 290 | - $group[] = $form->createElement('DateTimePicker', 'expiration_date', null, array('onchange' => 'javascript: enable_expiration_date();')); |
|
| 291 | - $form->addGroup($group, 'max_member_group', null, null, false); |
|
| 292 | - |
|
| 293 | - // Active account or inactive account |
|
| 294 | - $form->addElement('radio', 'active', get_lang('ActiveAccount'), get_lang('Active'), 1); |
|
| 295 | - $form->addElement('radio', 'active', '', get_lang('Inactive'), 0); |
|
| 286 | + // Expiration Date |
|
| 287 | + $form->addElement('radio', 'radio_expiration_date', get_lang('ExpirationDate'), get_lang('NeverExpires'), 0); |
|
| 288 | + $group = array (); |
|
| 289 | + $group[] = $form->createElement('radio', 'radio_expiration_date', null, get_lang('Enabled'), 1); |
|
| 290 | + $group[] = $form->createElement('DateTimePicker', 'expiration_date', null, array('onchange' => 'javascript: enable_expiration_date();')); |
|
| 291 | + $form->addGroup($group, 'max_member_group', null, null, false); |
|
| 292 | + |
|
| 293 | + // Active account or inactive account |
|
| 294 | + $form->addElement('radio', 'active', get_lang('ActiveAccount'), get_lang('Active'), 1); |
|
| 295 | + $form->addElement('radio', 'active', '', get_lang('Inactive'), 0); |
|
| 296 | 296 | } |
| 297 | 297 | $studentBossList = UserManager::getStudentBossList($user_data['user_id']); |
| 298 | 298 | |
@@ -334,18 +334,18 @@ discard block |
||
| 334 | 334 | $expiration_date = $user_data['expiration_date']; |
| 335 | 335 | |
| 336 | 336 | if (empty($expiration_date)) { |
| 337 | - $user_data['radio_expiration_date'] = 0; |
|
| 338 | - $user_data['expiration_date'] = api_get_local_time(); |
|
| 337 | + $user_data['radio_expiration_date'] = 0; |
|
| 338 | + $user_data['expiration_date'] = api_get_local_time(); |
|
| 339 | 339 | } else { |
| 340 | - $user_data['radio_expiration_date'] = 1; |
|
| 341 | - $user_data['expiration_date'] = api_get_local_time($expiration_date); |
|
| 340 | + $user_data['radio_expiration_date'] = 1; |
|
| 341 | + $user_data['expiration_date'] = api_get_local_time($expiration_date); |
|
| 342 | 342 | } |
| 343 | 343 | $form->setDefaults($user_data); |
| 344 | 344 | |
| 345 | 345 | $error_drh = false; |
| 346 | 346 | // Validate form |
| 347 | 347 | if ($form->validate()) { |
| 348 | - $user = $form->getSubmitValues(1); |
|
| 348 | + $user = $form->getSubmitValues(1); |
|
| 349 | 349 | $reset_password = intval($user['reset_password']); |
| 350 | 350 | if ($reset_password == 2 && empty($user['password'])) { |
| 351 | 351 | Display::addFlash(Display::return_message(get_lang('PasswordIsTooShort'))); |
@@ -353,48 +353,48 @@ discard block |
||
| 353 | 353 | exit(); |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | - $is_user_subscribed_in_course = CourseManager::is_user_subscribed_in_course($user['user_id']); |
|
| 356 | + $is_user_subscribed_in_course = CourseManager::is_user_subscribed_in_course($user['user_id']); |
|
| 357 | 357 | |
| 358 | - if ($user['status'] == DRH && $is_user_subscribed_in_course) { |
|
| 359 | - $error_drh = true; |
|
| 360 | - } else { |
|
| 361 | - $picture_element = $form->getElement('picture'); |
|
| 362 | - $picture = $picture_element->getValue(); |
|
| 358 | + if ($user['status'] == DRH && $is_user_subscribed_in_course) { |
|
| 359 | + $error_drh = true; |
|
| 360 | + } else { |
|
| 361 | + $picture_element = $form->getElement('picture'); |
|
| 362 | + $picture = $picture_element->getValue(); |
|
| 363 | 363 | |
| 364 | - $picture_uri = $user_data['picture_uri']; |
|
| 365 | - if (isset($user['delete_picture']) && $user['delete_picture']) { |
|
| 366 | - $picture_uri = UserManager::delete_user_picture($user_id); |
|
| 367 | - } elseif (!empty($picture['name'])) { |
|
| 364 | + $picture_uri = $user_data['picture_uri']; |
|
| 365 | + if (isset($user['delete_picture']) && $user['delete_picture']) { |
|
| 366 | + $picture_uri = UserManager::delete_user_picture($user_id); |
|
| 367 | + } elseif (!empty($picture['name'])) { |
|
| 368 | 368 | $picture_uri = UserManager::update_user_picture( |
| 369 | 369 | $user_id, |
| 370 | 370 | $_FILES['picture']['name'], |
| 371 | 371 | $_FILES['picture']['tmp_name'], |
| 372 | 372 | $user['picture_crop_result'] |
| 373 | 373 | ); |
| 374 | - } |
|
| 374 | + } |
|
| 375 | 375 | |
| 376 | - $lastname = $user['lastname']; |
|
| 377 | - $firstname = $user['firstname']; |
|
| 376 | + $lastname = $user['lastname']; |
|
| 377 | + $firstname = $user['firstname']; |
|
| 378 | 378 | $password = $user['password']; |
| 379 | 379 | $auth_source = isset($user['auth_source']) ? $user['auth_source'] : $userInfo['auth_source']; |
| 380 | - $official_code = $user['official_code']; |
|
| 381 | - $email = $user['email']; |
|
| 382 | - $phone = $user['phone']; |
|
| 383 | - $username = isset($user['username']) ? $user['username'] : $userInfo['username']; |
|
| 384 | - $status = intval($user['status']); |
|
| 385 | - $platform_admin = intval($user['platform_admin']); |
|
| 386 | - $send_mail = intval($user['send_mail']); |
|
| 387 | - $reset_password = intval($user['reset_password']); |
|
| 388 | - $hr_dept_id = isset($user['hr_dept_id']) ? intval($user['hr_dept_id']) : null; |
|
| 389 | - $language = $user['language']; |
|
| 390 | - |
|
| 391 | - if ($user['radio_expiration_date'] == '1' && !$user_data['platform_admin']) { |
|
| 380 | + $official_code = $user['official_code']; |
|
| 381 | + $email = $user['email']; |
|
| 382 | + $phone = $user['phone']; |
|
| 383 | + $username = isset($user['username']) ? $user['username'] : $userInfo['username']; |
|
| 384 | + $status = intval($user['status']); |
|
| 385 | + $platform_admin = intval($user['platform_admin']); |
|
| 386 | + $send_mail = intval($user['send_mail']); |
|
| 387 | + $reset_password = intval($user['reset_password']); |
|
| 388 | + $hr_dept_id = isset($user['hr_dept_id']) ? intval($user['hr_dept_id']) : null; |
|
| 389 | + $language = $user['language']; |
|
| 390 | + |
|
| 391 | + if ($user['radio_expiration_date'] == '1' && !$user_data['platform_admin']) { |
|
| 392 | 392 | $expiration_date = $user['expiration_date']; |
| 393 | - } else { |
|
| 394 | - $expiration_date = null; |
|
| 395 | - } |
|
| 393 | + } else { |
|
| 394 | + $expiration_date = null; |
|
| 395 | + } |
|
| 396 | 396 | |
| 397 | - $active = $user_data['platform_admin'] ? 1 : intval($user['active']); |
|
| 397 | + $active = $user_data['platform_admin'] ? 1 : intval($user['active']); |
|
| 398 | 398 | |
| 399 | 399 | //If the user is set to admin the status will be overwrite by COURSEMANAGER = 1 |
| 400 | 400 | if ($platform_admin == 1) { |
@@ -426,40 +426,40 @@ discard block |
||
| 426 | 426 | null, |
| 427 | 427 | $send_mail, |
| 428 | 428 | $reset_password, |
| 429 | - $user['address'] |
|
| 429 | + $user['address'] |
|
| 430 | 430 | ); |
| 431 | 431 | |
| 432 | 432 | if (isset($user['student_boss'])) { |
| 433 | 433 | UserManager::subscribeUserToBossList($user_id, $user['student_boss']); |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | - if (api_get_setting('openid_authentication') == 'true' && !empty($user['openid'])) { |
|
| 437 | - $up = UserManager::update_openid($user_id, $user['openid']); |
|
| 438 | - } |
|
| 436 | + if (api_get_setting('openid_authentication') == 'true' && !empty($user['openid'])) { |
|
| 437 | + $up = UserManager::update_openid($user_id, $user['openid']); |
|
| 438 | + } |
|
| 439 | 439 | $currentUserId = api_get_user_id(); |
| 440 | 440 | |
| 441 | 441 | $userObj = api_get_user_entity($user_id); |
| 442 | 442 | |
| 443 | 443 | UserManager::add_user_as_admin($userObj); |
| 444 | 444 | |
| 445 | - if ($user_id != $currentUserId) { |
|
| 446 | - if ($platform_admin == 1) { |
|
| 447 | - $userObj = api_get_user_entity($user_id); |
|
| 445 | + if ($user_id != $currentUserId) { |
|
| 446 | + if ($platform_admin == 1) { |
|
| 447 | + $userObj = api_get_user_entity($user_id); |
|
| 448 | 448 | UserManager::add_user_as_admin($userObj); |
| 449 | - } else { |
|
| 449 | + } else { |
|
| 450 | 450 | UserManager::remove_user_admin($user_id); |
| 451 | - } |
|
| 452 | - } |
|
| 451 | + } |
|
| 452 | + } |
|
| 453 | 453 | |
| 454 | 454 | $extraFieldValue = new ExtraFieldValue('user'); |
| 455 | 455 | $extraFieldValue->saveFieldValues($user); |
| 456 | 456 | |
| 457 | - $tok = Security::get_token(); |
|
| 457 | + $tok = Security::get_token(); |
|
| 458 | 458 | |
| 459 | 459 | Display::addFlash(Display::return_message(get_lang('UserUpdated'))); |
| 460 | - header('Location: user_list.php?sec_token='.$tok); |
|
| 461 | - exit(); |
|
| 462 | - } |
|
| 460 | + header('Location: user_list.php?sec_token='.$tok); |
|
| 461 | + exit(); |
|
| 462 | + } |
|
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | if ($error_drh) { |