ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilObjUserGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once "./Services/Object/classes/class.ilObjectGUI.php";
5
18{
20 protected $uiFactory;
21
23 protected $uiRenderer;
24
25 public $ilCtrl;
26
32 public $gender;
33
39 public $type;
40
47
57 public function __construct(
58 $a_data,
59 $a_id,
60 $a_call_by_reference = false,
61 $a_prepare_output = true,
62 ILIAS\UI\Factory $uiFactory = null,
63 ILIAS\UI\Renderer $uiRenderer = null
64 ) {
65 global $DIC;
66
67 if (null === $uiFactory) {
68 $uiFactory = $DIC->ui()->factory();
69 }
70 $this->uiFactory = $uiFactory;
71
72 if (null === $uiRenderer) {
73 $uiRenderer = $DIC->ui()->renderer();
74 }
75 $this->uiRenderer = $uiRenderer;
76
77 $ilCtrl = $DIC['ilCtrl'];
78 $lng = $DIC['lng'];
79
80 define('USER_FOLDER_ID', 7);
81
82 $this->type = "usr";
83 parent::__construct($a_data, $a_id, $a_call_by_reference, false);
84 $this->usrf_ref_id = &$this->ref_id;
85
86 $this->ctrl = $ilCtrl;
87 $this->ctrl->saveParameter($this, array('obj_id', 'letter'));
88 $this->ctrl->setParameterByClass("ilobjuserfoldergui", "letter", $_GET["letter"]);
89 $this->ctrl->setContext($this->object->getId(), 'usr');
90 $lng->loadLanguageModule('user');
91
92 // for gender selection. don't change this
93 // maybe deprecated
94 $this->gender = array(
95 'n' => "salutation_n",
96 'm' => "salutation_m",
97 'f' => "salutation_f",
98 );
99 }
100
101 public function executeCommand()
102 {
103 global $DIC;
104
105 $rbacsystem = $DIC['rbacsystem'];
106
107 $next_class = $this->ctrl->getNextClass($this);
108 $cmd = $this->ctrl->getCmd();
109
110 $this->prepareOutput();
111
112 switch ($next_class) {
113 case "illearningprogressgui":
114 include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
116 $this->ctrl->forwardCommand($new_gui);
117 break;
118
119 case "ilobjectownershipmanagementgui":
120 include_once("Services/Object/classes/class.ilObjectOwnershipManagementGUI.php");
121 $gui = new ilObjectOwnershipManagementGUI($this->object->getId());
122 $this->ctrl->forwardCommand($gui);
123 break;
124
125 default:
126 if ($cmd == "" || $cmd == "view") {
127 $cmd = "edit";
128 }
129 $cmd .= "Object";
130 $return = $this->$cmd();
131
132 break;
133 }
134 return $return;
135 }
136
137 /* Overwritten from base class
138 */
139 public function setTitleAndDescription()
140 {
141 if (strtolower(get_class($this->object)) == 'ilobjuser') {
142 $this->tpl->setTitle('[' . $this->object->getLogin() . '] ' . $this->object->getTitle());
143 $this->tpl->setDescription($this->object->getLongDescription());
144 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_" . $this->object->getType() . ".svg"), $this->lng->txt("obj_" . $this->object->getType()));
145 } else {
146 parent::setTitleAndDescription();
147 }
148 }
149
150
151
152 public function cancelObject()
153 {
154 ilSession::clear("saved_post");
155
156 if (strtolower($_GET["baseClass"]) == 'iladministrationgui') {
157 $this->ctrl->redirectByClass("ilobjuserfoldergui", "view");
158 //$return_location = $_GET["cmd_return_location"];
159 //ilUtil::redirect($this->ctrl->getLinkTarget($this,$return_location));
160 } else {
161 $this->ctrl->redirectByClass('ilobjcategorygui', 'listUsers');
162 }
163 }
164
168 public function getAdminTabs()
169 {
170 $this->getTabs();
171 }
172
176 public function getTabs()
177 {
178 global $DIC;
179
180 $rbacsystem = $DIC['rbacsystem'];
181 $ilHelp = $DIC['ilHelp'];
182
183 $this->tabs_gui->clearTargets();
184
185 $ilHelp->setScreenIdComponent("usr");
186
187 if ($_GET["search"]) {
188 $this->tabs_gui->setBackTarget(
189 $this->lng->txt("search_results"),
190 $_SESSION["usr_search_link"]
191 );
192
193 $this->tabs_gui->addTarget(
194 "properties",
195 $this->ctrl->getLinkTarget($this, "edit"),
196 array("edit","","view"),
197 get_class($this),
198 "",
199 true
200 );
201 } else {
202 $this->tabs_gui->addTarget(
203 "properties",
204 $this->ctrl->getLinkTarget($this, "edit"),
205 array("edit","","view"),
206 get_class($this)
207 );
208 }
209
210 $this->tabs_gui->addTarget(
211 "role_assignment",
212 $this->ctrl->getLinkTarget($this, "roleassignment"),
213 array("roleassignment"),
214 get_class($this)
215 );
216
217 // learning progress
218 include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
219 if ($rbacsystem->checkAccess('read', $this->ref_id) and
222 $this->tabs_gui->addTarget(
223 'learning_progress',
224 $this->ctrl->getLinkTargetByClass('illearningprogressgui', ''),
225 '',
226 array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui')
227 );
228 }
229
230 $this->tabs_gui->addTarget(
231 'user_ownership',
232 $this->ctrl->getLinkTargetByClass('ilobjectownershipmanagementgui', ''),
233 '',
234 'ilobjectownershipmanagementgui'
235 );
236 }
237
241 public function setBackTarget($a_text, $a_link)
242 {
243 $this->back_target = array("text" => $a_text,
244 "link" => $a_link);
245 }
246
252 {
253 include_once './Services/User/classes/class.ilUserDefinedFields.php';
254 $this->user_defined_fields = &ilUserDefinedFields::_getInstance();
255
256 foreach ($this->user_defined_fields->getDefinitions() as $field_id => $definition) {
257 if ($definition['required'] and !strlen($_POST['udf'][$field_id])) {
258 return false;
259 }
260 }
261 return true;
262 }
263
264
265 public function __showUserDefinedFields()
266 {
267 include_once './Services/User/classes/class.ilUserDefinedFields.php';
268 $this->user_defined_fields = &ilUserDefinedFields::_getInstance();
269
270 if ($this->object->getType() == 'usr') {
271 $user_defined_data = $this->object->getUserDefinedData();
272 }
273 foreach ($this->user_defined_fields->getDefinitions() as $field_id => $definition) {
274 $old = isset($_SESSION["error_post_vars"]["udf"][$field_id]) ?
275 $_SESSION["error_post_vars"]["udf"][$field_id] : $user_defined_data[$field_id];
276
277 if ($definition['field_type'] == UDF_TYPE_TEXT) {
278 $this->tpl->setCurrentBlock("field_text");
279 $this->tpl->setVariable("FIELD_NAME", 'udf[' . $definition['field_id'] . ']');
280 $this->tpl->setVariable("FIELD_VALUE", ilUtil::prepareFormOutput($old));
281 $this->tpl->parseCurrentBlock();
282 } else {
283 $this->tpl->setCurrentBlock("field_select");
284 $this->tpl->setVariable("SELECT_BOX", ilUtil::formSelect(
285 $old,
286 'udf[' . $definition['field_id'] . ']',
287 $this->user_defined_fields->fieldValuesToSelectArray(
288 $definition['field_values']
289 ),
290 false,
291 true
292 ));
293 $this->tpl->parseCurrentBlock();
294 }
295 $this->tpl->setCurrentBlock("user_defined");
296
297 if ($definition['required']) {
298 $name = $definition['field_name'] . "<span class=\"asterisk\">*</span>";
299 } else {
300 $name = $definition['field_name'];
301 }
302 $this->tpl->setVariable("TXT_FIELD_NAME", $name);
303 $this->tpl->parseCurrentBlock();
304 }
305 return true;
306 }
307
308 public function initCreate()
309 {
310 global $DIC;
311
312 $tpl = $DIC['tpl'];
313 $rbacsystem = $DIC['rbacsystem'];
314 $rbacreview = $DIC['rbacreview'];
315 $ilUser = $DIC['ilUser'];
316
317 if ($this->usrf_ref_id != USER_FOLDER_ID) {
318 $this->tabs_gui->clearTargets();
319 }
320
321 // role selection
322 $obj_list = $rbacreview->getRoleListByObject(ROLE_FOLDER_ID);
323 $rol = array();
324 foreach ($obj_list as $obj_data) {
325 // allow only 'assign_users' marked roles if called from category
326 if ($this->object->getRefId() != USER_FOLDER_ID and !in_array(SYSTEM_ROLE_ID, $rbacreview->assignedRoles($ilUser->getId()))) {
327 include_once './Services/AccessControl/classes/class.ilObjRole.php';
328
329 if (!ilObjRole::_getAssignUsersStatus($obj_data['obj_id'])) {
330 continue;
331 }
332 }
333 // exclude anonymous role from list
334 if ($obj_data["obj_id"] != ANONYMOUS_ROLE_ID) {
335 // do not allow to assign users to administrator role if current user does not has SYSTEM_ROLE_ID
336 if ($obj_data["obj_id"] != SYSTEM_ROLE_ID or in_array(SYSTEM_ROLE_ID, $rbacreview->assignedRoles($ilUser->getId()))) {
337 $rol[$obj_data["obj_id"]] = $obj_data["title"];
338 }
339 }
340 }
341
342 // raise error if there is no global role user can be assigned to
343 if (!count($rol)) {
344 $this->ilias->raiseError($this->lng->txt("msg_no_roles_users_can_be_assigned_to"), $this->ilias->error_obj->MESSAGE);
345 }
346
347 $keys = array_keys($rol);
348
349 // set pre defined user role to default
350 if (in_array(4, $keys)) {
351 $this->default_role = 4;
352 } else {
353 if (count($keys) > 1 and in_array(2, $keys)) {
354 // remove admin role as preselectable role
355 foreach ($keys as $key => $val) {
356 if ($val == 2) {
357 unset($keys[$key]);
358 break;
359 }
360 }
361 }
362
363 $this->default_role = array_shift($keys);
364 }
365 $this->selectable_roles = $rol;
366 }
367
371 public function createObject()
372 {
373 global $DIC;
374
375 $tpl = $DIC['tpl'];
376 $rbacsystem = $DIC['rbacsystem'];
377 $rbacreview = $DIC['rbacreview'];
378 $ilUser = $DIC['ilUser'];
379
380 if (!$rbacsystem->checkAccess('create_usr', $this->usrf_ref_id)
381 && !$rbacsystem->checkAccess('cat_administrate_users', $this->usrf_ref_id)) {
382 $this->ilias->raiseError($this->lng->txt("permission_denied"), $this->ilias->error_obj->MESSAGE);
383 }
384
385 $this->initCreate();
386 $this->initForm("create");
387 return $tpl->setContent($this->form_gui->getHtml());
388 }
389
394 public function saveObject()
395 {
396 global $DIC;
397
398 $ilAccess = $DIC['ilAccess'];
399 $ilSetting = $DIC['ilSetting'];
400 $tpl = $DIC['tpl'];
401 $ilUser = $DIC['ilUser'];
402 $rbacadmin = $DIC['rbacadmin'];
403 $rbacsystem = $DIC['rbacsystem'];
404 $rbacreview = $DIC['rbacreview'];
405
406 include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
407
408 // User folder
409 if (!$rbacsystem->checkAccess('create_usr', $this->usrf_ref_id)
410 && !$ilAccess->checkAccess('cat_administrate_users', "", $this->usrf_ref_id)) {
411 $this->ilias->raiseError($this->lng->txt("permission_denied"), $this->ilias->error_obj->MESSAGE);
412 }
413
414 $this->initCreate();
415 $this->initForm("create");
416
417 // Manipulate form so ignore required fields are no more required. This has to be done before ilPropertyFormGUI::checkInput() is called.
418 $profileMaybeIncomplete = false;
419 if ($this->form_gui->getInput('ignore_rf', false)) {
420 $profileMaybeIncomplete = $this->handleIgnoredRequiredFields();
421 }
422
423 if ($this->form_gui->checkInput()) {
424 // @todo: external account; time limit check and savings
425
426 // checks passed. save user
427 $userObj = $this->loadValuesFromForm();
428
429 if ($ilUser->getId() === (int) SYSTEM_USER_ID
430 || !in_array(SYSTEM_ROLE_ID, $rbacreview->assignedRoles($this->object->getId()))
431 || in_array(SYSTEM_ROLE_ID, $rbacreview->assignedRoles($ilUser->getId()))) {
432 $userObj->setPasswd($this->form_gui->getInput('passwd'), IL_PASSWD_PLAIN);
433 }
434
435 $userObj->setTitle($userObj->getFullname());
436 $userObj->setDescription($userObj->getEmail());
437
438 $udf = array();
439 foreach ($_POST as $k => $v) {
440 if (substr($k, 0, 4) == "udf_") {
441 $udf[substr($k, 4)] = $v;
442 }
443 }
444 $userObj->setUserDefinedData($udf);
445
446 $userObj->create();
447
448 include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
450 $userObj->setExternalAccount($_POST["ext_account"]);
451 }
452
453 // set a timestamp for last_password_change
454 // this ts is needed by ilSecuritySettings
455 $userObj->setLastPasswordChangeTS(time());
456
457 //insert user data in table user_data
458 $userObj->saveAsNew();
459
460 // setup user preferences
461 if ($this->isSettingChangeable('language')) {
462 $userObj->setLanguage($_POST["language"]);
463 }
464
465 if ($this->isSettingChangeable('skin_style')) {
466 //set user skin and style
467 $sknst = explode(":", $_POST["skin_style"]);
468
469 if ($userObj->getPref("style") != $sknst[1] ||
470 $userObj->getPref("skin") != $sknst[0]) {
471 $userObj->setPref("skin", $sknst[0]);
472 $userObj->setPref("style", $sknst[1]);
473 }
474 }
475 if ($this->isSettingChangeable('hits_per_page')) {
476 $userObj->setPref("hits_per_page", $_POST["hits_per_page"]);
477 }
478 /*if($this->isSettingChangeable('show_users_online'))
479 {
480 $userObj->setPref("show_users_online", $_POST["show_users_online"]);
481 }*/
482 if ($this->isSettingChangeable('hide_own_online_status')) {
483 $userObj->setPref("hide_own_online_status", $_POST["hide_own_online_status"]);
484 }
485 if ($this->isSettingChangeable('bs_allow_to_contact_me')) {
486 $userObj->setPref('bs_allow_to_contact_me', $_POST['bs_allow_to_contact_me'] ? 'y' : 'n');
487 }
488 if ($this->isSettingChangeable('chat_osc_accept_msg')) {
489 $userObj->setPref('chat_osc_accept_msg', $_POST['chat_osc_accept_msg'] ? 'y' : 'n');
490 }
491 if ((int) $ilSetting->get('session_reminder_enabled')) {
492 $userObj->setPref('session_reminder_enabled', (int) $_POST['session_reminder_enabled']);
493 }
494 $userObj->writePrefs();
495
496 //set role entries
497 $rbacadmin->assignUser($_POST["default_role"], $userObj->getId(), true);
498
499 $msg = $this->lng->txt("user_added");
500
501 $ilUser->setPref('send_info_mails', ($_POST['send_mail'] == 'y') ? 'y' : 'n');
502 $ilUser->writePrefs();
503
504 $this->object = $userObj;
505
506 if ($this->isSettingChangeable('upload')) {
508 }
509
510 if ($profileMaybeIncomplete) {
511 include_once 'Services/User/classes/class.ilUserProfile.php';
512 if (ilUserProfile::isProfileIncomplete($this->object)) {
513 $this->object->setProfileIncomplete(true);
514 $this->object->update();
515 }
516 }
517
518 // send new account mail
519 if ($_POST['send_mail'] == 'y') {
520 include_once('Services/Mail/classes/class.ilAccountMail.php');
521 $acc_mail = new ilAccountMail();
522 $acc_mail->useLangVariablesAsFallback(true);
523 $acc_mail->setAttachConfiguredFiles(true);
524 $acc_mail->setUserPassword($_POST['passwd']);
525 $acc_mail->setUser($userObj);
526
527 if ($acc_mail->send()) {
528 $msg = $msg . '<br />' . $this->lng->txt('mail_sent');
529 ilUtil::sendSuccess($msg, true);
530 } else {
531 $msg = $msg . '<br />' . $this->lng->txt('mail_not_sent');
532 ilUtil::sendInfo($msg, true);
533 }
534 } else {
535 ilUtil::sendSuccess($msg, true);
536 }
537
538
539 if (strtolower($_GET["baseClass"]) == 'iladministrationgui') {
540 $this->ctrl->redirectByClass("ilobjuserfoldergui", "view");
541 } else {
542 $this->ctrl->redirectByClass('ilobjcategorygui', 'listUsers');
543 }
544 } else {
545 $this->form_gui->setValuesByPost();
546 $tpl->setContent($this->form_gui->getHtml());
547 }
548 }
549
555 public function editObject()
556 {
558 global $DIC;
559
560 $rbacsystem = $DIC->rbac()->system();
561 $access = $DIC->access();
562
563 if ($this->usrf_ref_id == USER_FOLDER_ID
564 && (
565 !$rbacsystem->checkAccess('visible,read', $this->usrf_ref_id)
566 || !$rbacsystem->checkAccess('write', $this->usrf_ref_id)
567 && !$access->checkPositionAccess(\ilObjUserFolder::ORG_OP_EDIT_USER_ACCOUNTS, $this->usrf_ref_id)
568 || $access->checkPositionAccess(\ilObjUserFolder::ORG_OP_EDIT_USER_ACCOUNTS, $this->usrf_ref_id)
569 && !in_array(
570 $this->object->getId(),
571 $access->filterUserIdsByPositionOfCurrentUser(
574 [$this->object->getId()]
575 )
576 )
577 )
578 ) {
579 $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"), $this->ilias->error_obj->MESSAGE);
580 }
581
582 if ($this->usrf_ref_id == USER_FOLDER_ID and !$rbacsystem->checkAccess('visible,read', $this->usrf_ref_id)) {
583 $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"), $this->ilias->error_obj->MESSAGE);
584 }
585 // if called from local administration $this->usrf_ref_id is category id
586 // Todo: this has to be fixed. Do not mix user folder id and category id
587 if ($this->usrf_ref_id != USER_FOLDER_ID) {
588 // check if user is assigned to category
589 if (!$rbacsystem->checkAccess('cat_administrate_users', $this->object->getTimeLimitOwner())) {
590 $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"), $this->ilias->error_obj->MESSAGE);
591 }
592 }
593
594 if ($this->usrf_ref_id != USER_FOLDER_ID) {
595 $this->tabs_gui->clearTargets();
596 }
597
598 // get form
599 $this->initForm("edit");
600 $this->getValues();
601 $this->showAcceptedTermsOfService();
602 $this->tpl->setContent($this->form_gui->getHTML());
603 }
604
609 protected function loadValuesFromForm($a_mode = 'create')
610 {
611 global $DIC;
612
613 $ilSetting = $DIC['ilSetting'];
614 $ilUser = $DIC['ilUser'];
615
616 switch ($a_mode) {
617 case 'create':
618 $user = new ilObjUser();
619 break;
620
621 case 'update':
623 break;
624 }
625
626 $from = $this->form_gui->getItemByPostVar('time_limit_from')->getDate();
627 $user->setTimeLimitFrom($from
628 ? $from->get(IL_CAL_UNIX)
629 : null);
630
631 $until = $this->form_gui->getItemByPostVar('time_limit_until')->getDate();
632 $user->setTimeLimitUntil($until
633 ? $until->get(IL_CAL_UNIX)
634 : null);
635
636 $user->setTimeLimitUnlimited($this->form_gui->getInput('time_limit_unlimited'));
637
638 if ($a_mode == 'create') {
639 $user->setTimeLimitOwner($this->usrf_ref_id);
640 }
641
642 // Birthday
643 if ($this->isSettingChangeable('birthday')) {
644 $bd = $this->form_gui->getItemByPostVar('birthday');
645 $bd = $bd->getDate();
646 $user->setBirthday($bd
647 ? $bd->get(IL_CAL_DATE)
648 : null);
649 }
650
651 // Login
652 $user->setLogin($this->form_gui->getInput('login'));
653
654
655 // Gender
656 if ($this->isSettingChangeable('gender')) {
657 $user->setGender($this->form_gui->getInput('gender'));
658 }
659
660 // Title
661 if ($this->isSettingChangeable('title')) {
662 $user->setUTitle($this->form_gui->getInput('title'));
663 }
664
665 // Firstname
666 if ($this->isSettingChangeable('firstname')) {
667 $user->setFirstname($this->form_gui->getInput('firstname'));
668 }
669 // Lastname
670 if ($this->isSettingChangeable('lastname')) {
671 $user->setLastname($this->form_gui->getInput('lastname'));
672 }
673 $user->setFullname();
674
675 // Institution
676 if ($this->isSettingChangeable('institution')) {
677 $user->setInstitution($this->form_gui->getInput('institution'));
678 }
679
680 // Department
681 if ($this->isSettingChangeable('department')) {
682 $user->setDepartment($this->form_gui->getInput('department'));
683 }
684 // Street
685 if ($this->isSettingChangeable('street')) {
686 $user->setStreet($this->form_gui->getInput('street'));
687 }
688 // City
689 if ($this->isSettingChangeable('city')) {
690 $user->setCity($this->form_gui->getInput('city'));
691 }
692 // Zipcode
693 if ($this->isSettingChangeable('zipcode')) {
694 $user->setZipcode($this->form_gui->getInput('zipcode'));
695 }
696 // Country
697 if ($this->isSettingChangeable('country')) {
698 $user->setCountry($this->form_gui->getInput('country'));
699 }
700 // Selected Country
701 if ($this->isSettingChangeable('sel_country')) {
702 $user->setSelectedCountry($this->form_gui->getInput('sel_country'));
703 }
704 // Phone Office
705 if ($this->isSettingChangeable('phone_office')) {
706 $user->setPhoneOffice($this->form_gui->getInput('phone_office'));
707 }
708 // Phone Home
709 if ($this->isSettingChangeable('phone_home')) {
710 $user->setPhoneHome($this->form_gui->getInput('phone_home'));
711 }
712 // Phone Mobile
713 if ($this->isSettingChangeable('phone_mobile')) {
714 $user->setPhoneMobile($this->form_gui->getInput('phone_mobile'));
715 }
716 // Fax
717 if ($this->isSettingChangeable('fax')) {
718 $user->setFax($this->form_gui->getInput('fax'));
719 }
720 // Matriculation
721 if ($this->isSettingChangeable('matriculation')) {
722 $user->setMatriculation($this->form_gui->getInput('matriculation'));
723 }
724 // Email
725 if ($this->isSettingChangeable('email')) {
726 $user->setEmail($this->form_gui->getInput('email'));
727 }
728 // Second Email
729 if ($this->isSettingChangeable('second_email')) {
730 $user->setSecondEmail($this->form_gui->getInput('second_email'));
731 }
732 // Hobby
733 if ($this->isSettingChangeable('hobby')) {
734 $user->setHobby($this->form_gui->getInput('hobby'));
735 }
736 // Referral Comment
737 if ($this->isSettingChangeable('referral_comment')) {
738 $user->setComment($this->form_gui->getInput('referral_comment'));
739 }
740
741 // interests
742 $user->setGeneralInterests($this->form_gui->getInput('interests_general'));
743 $user->setOfferingHelp($this->form_gui->getInput('interests_help_offered'));
744 $user->setLookingForHelp($this->form_gui->getInput('interests_help_looking'));
745
746 // ClientIP
747 $user->setClientIP($this->form_gui->getInput('client_ip'));
748
749 // Google maps
750 $user->setLatitude($this->form_gui->getInput('latitude'));
751 $user->setLongitude($this->form_gui->getInput('longitude'));
752 $user->setLocationZoom($this->form_gui->getInput('loc_zoom'));
753
754 // External account
755 $user->setAuthMode($this->form_gui->getInput('auth_mode'));
756 $user->setExternalAccount($this->form_gui->getInput('ext_account'));
757
758 if ((int) $user->getActive() != (int) $this->form_gui->getInput('active')) {
759 $user->setActive($this->form_gui->getInput('active'), $ilUser->getId());
760 }
761
762 return $user;
763 }
764
765
769 public function updateObject()
770 {
771 global $DIC;
772
773 $tpl = $DIC->ui()->mainTemplate();
774 $rbacsystem = $DIC->rbac()->system();
775 $ilUser = $DIC->user();
776 $access = $DIC->access();
777
778 // User folder && access granted by rbac or by org unit positions
779 if ($this->usrf_ref_id == USER_FOLDER_ID &&
780 (
781 !$rbacsystem->checkAccess('visible,read', USER_FOLDER_ID) ||
782 !$access->checkRbacOrPositionPermissionAccess('write', \ilObjUserFolder::ORG_OP_EDIT_USER_ACCOUNTS, USER_FOLDER_ID) ||
783 !in_array(
784 $this->object->getId(),
785 $access->filterUserIdsByRbacOrPositionOfCurrentUser(
786 'write',
789 [$this->object->getId()]
790 )
791 )
792 )
793 ) {
794 $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"), $this->ilias->error_obj->MESSAGE);
795 }
796 // if called from local administration $this->usrf_ref_id is category id
797 // Todo: this has to be fixed. Do not mix user folder id and category id
798 if ($this->usrf_ref_id != USER_FOLDER_ID) {
799 // check if user is assigned to category
800 if (!$rbacsystem->checkAccess('cat_administrate_users', $this->object->getTimeLimitOwner())) {
801 $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"), $this->ilias->error_obj->MESSAGE);
802 }
803 }
804 $this->initForm("edit");
805
806 // we do not want to store this dates, they are only printed out
807 unset($_POST['approve_date']);
808 $_POST['agree_date'] = $this->object->getAgreeDate();
809 unset($_POST['last_login']);
810
811 // Manipulate form so ignore required fields are no more required. This has to be done before ilPropertyFormGUI::checkInput() is called.
812 $profileMaybeIncomplete = false;
813 if ($this->form_gui->getInput('ignore_rf', false)) {
814 $profileMaybeIncomplete = $this->handleIgnoredRequiredFields();
815 }
816
817 if ($this->form_gui->checkInput()) {
818 // @todo: external account; time limit
819 // if not allowed or empty -> do no change password
821 && trim($_POST['passwd']) != ""
822 && ($this->user->getId() === (int) SYSTEM_USER_ID
823 || !in_array(SYSTEM_ROLE_ID, $this->rbacreview->assignedRoles($this->object->getId()))
824 || in_array(SYSTEM_ROLE_ID, $this->rbacreview->assignedRoles($this->user->getId())))
825 ) {
826 $this->object->setPasswd($_POST['passwd'], IL_PASSWD_PLAIN);
827 }
828
829 /*
830 * reset counter for failed logins
831 * if $_POST['active'] is set to 1
832 */
833 if ($_POST['active'] == 1) {
834 ilObjUser::_resetLoginAttempts($this->object->getId());
835 }
836
837 #$this->object->assignData($_POST);
838 $this->loadValuesFromForm('update');
839
840 $udf = array();
841 foreach ($_POST as $k => $v) {
842 if (substr($k, 0, 4) == "udf_") {
843 $udf[substr($k, 4)] = $v;
844 }
845 }
846 $this->object->setUserDefinedData($udf);
847
848 try {
849 $this->object->updateLogin($_POST['login']);
850 } catch (ilUserException $e) {
851 ilUtil::sendFailure($e->getMessage());
852 $this->form_gui->setValuesByPost();
853 return $tpl->setContent($this->form_gui->getHtml());
854 }
855
856 $this->object->setTitle($this->object->getFullname());
857 $this->object->setDescription($this->object->getEmail());
858
859 if ($this->isSettingChangeable('language')) {
860 $this->object->setLanguage($this->form_gui->getInput('language'));
861 }
862
863 if ($this->isSettingChangeable('skin_style')) {
864 //set user skin and style
865 $sknst = explode(":", $_POST["skin_style"]);
866
867 if ($this->object->getPref("style") != $sknst[1] ||
868 $this->object->getPref("skin") != $sknst[0]) {
869 $this->object->setPref("skin", $sknst[0]);
870 $this->object->setPref("style", $sknst[1]);
871 }
872 }
873 if ($this->isSettingChangeable('hits_per_page')) {
874 $this->object->setPref("hits_per_page", $_POST["hits_per_page"]);
875 }
876 /*if($this->isSettingChangeable('show_users_online'))
877 {
878 $this->object->setPref("show_users_online", $_POST["show_users_online"]);
879 }*/
880 if ($this->isSettingChangeable('hide_own_online_status')) {
881 $this->object->setPref("hide_own_online_status", $_POST["hide_own_online_status"]);
882 }
883 if ($this->isSettingChangeable('bs_allow_to_contact_me')) {
884 $this->object->setPref('bs_allow_to_contact_me', $_POST['bs_allow_to_contact_me'] ? 'y' : 'n');
885 }
886 if ($this->isSettingChangeable('chat_osc_accept_msg')) {
887 $this->object->setPref('chat_osc_accept_msg', $_POST['chat_osc_accept_msg'] ? 'y' : 'n');
888 }
889
890 // set a timestamp for last_password_change
891 // this ts is needed by ilSecuritySettings
892 $this->object->setLastPasswordChangeTS(time());
893
894 global $DIC;
895
896 $ilSetting = $DIC['ilSetting'];
897 if ((int) $ilSetting->get('session_reminder_enabled')) {
898 $this->object->setPref('session_reminder_enabled', (int) $_POST['session_reminder_enabled']);
899 }
900
901 // #10054 - profile may have been completed, check below is only for incomplete
902 $this->object->setProfileIncomplete(false);
903
904 $this->update = $this->object->update();
905
906
907 // If the current user is editing its own user account,
908 // we update his preferences.
909 if ($ilUser->getId() == $this->object->getId()) {
910 $ilUser->readPrefs();
911 }
912 $ilUser->setPref('send_info_mails', ($_POST['send_mail'] == 'y') ? 'y' : 'n');
913 $ilUser->writePrefs();
914
915 $mail_message = $this->__sendProfileMail();
916 $msg = $this->lng->txt('saved_successfully') . $mail_message;
917
918 // same personal image
919 if ($this->isSettingChangeable('upload')) {
921 }
922
923 if ($profileMaybeIncomplete) {
924 include_once 'Services/User/classes/class.ilUserProfile.php';
925 if (ilUserProfile::isProfileIncomplete($this->object)) {
926 $this->object->setProfileIncomplete(true);
927 $this->object->update();
928 }
929 }
930
931 // feedback
932 ilUtil::sendSuccess($msg, true);
933
934 if (strtolower($_GET["baseClass"]) == 'iladministrationgui') {
935 $this->ctrl->redirectByClass("ilobjuserfoldergui", "view");
936 } else {
937 $this->ctrl->redirectByClass('ilobjcategorygui', 'listUsers');
938 }
939 } else {
940 $this->form_gui->setValuesByPost();
941 $this->tabs_gui->activateTab('properties');
942 $tpl->setContent($this->form_gui->getHtml());
943 }
944 }
945
949 public function getValues()
950 {
951 global $DIC;
952
953 $ilUser = $DIC['ilUser'];
954 $ilSetting = $DIC['ilSetting'];
955
956 $data = array();
957
958 // login data
959 $data["auth_mode"] = $this->object->getAuthMode();
960 $data["login"] = $this->object->getLogin();
961 //$data["passwd"] = "********";
962 //$data["passwd2"] = "********";
963 $data["ext_account"] = $this->object->getExternalAccount();
964
965 // system information
966 $data["create_date"] = ilDatePresentation::formatDate(new ilDateTime($this->object->getCreateDate(), IL_CAL_DATETIME));
967 $data["owner"] = ilObjUser::_lookupLogin($this->object->getOwner());
968 $data["approve_date"] = ($this->object->getApproveDate() != "")
969 ? ilDatePresentation::formatDate(new ilDateTime($this->object->getApproveDate(), IL_CAL_DATETIME))
970 : null;
971 $data["agree_date"] = ($this->object->getAgreeDate() != "")
972 ? ilDatePresentation::formatDate(new ilDateTime($this->object->getAgreeDate(), IL_CAL_DATETIME))
973 : null;
974 $data["last_login"] = ($this->object->getLastLogin() != "")
975 ? ilDatePresentation::formatDate(new ilDateTime($this->object->getLastLogin(), IL_CAL_DATETIME))
976 : null;
977 $data["active"] = $this->object->getActive();
978 $data["time_limit_unlimited"] = $this->object->getTimeLimitUnlimited();
979
980 $data["time_limit_from"] = $this->object->getTimeLimitFrom()
981 ? new ilDateTime($this->object->getTimeLimitFrom(), IL_CAL_UNIX)
982 : null;
983 $data["time_limit_until"] = $this->object->getTimeLimitUntil()
984 ? new ilDateTime($this->object->getTimeLimitUntil(), IL_CAL_UNIX)
985 : null;
986
987 // personal data
988 $data["gender"] = $this->object->getGender();
989 $data["firstname"] = $this->object->getFirstname();
990 $data["lastname"] = $this->object->getLastname();
991 $data["title"] = $this->object->getUTitle();
992 $data['birthday'] = $this->object->getBirthday()
993 ? new ilDate($this->object->getBirthday(), IL_CAL_DATE)
994 : null;
995 $data["institution"] = $this->object->getInstitution();
996 $data["department"] = $this->object->getDepartment();
997 $data["street"] = $this->object->getStreet();
998 $data["city"] = $this->object->getCity();
999 $data["zipcode"] = $this->object->getZipcode();
1000 $data["country"] = $this->object->getCountry();
1001 $data["sel_country"] = $this->object->getSelectedCountry();
1002 $data["phone_office"] = $this->object->getPhoneOffice();
1003 $data["phone_home"] = $this->object->getPhoneHome();
1004 $data["phone_mobile"] = $this->object->getPhoneMobile();
1005 $data["fax"] = $this->object->getFax();
1006 $data["email"] = $this->object->getEmail();
1007 $data["second_email"] = $this->object->getSecondEmail();
1008 $data["hobby"] = $this->object->getHobby();
1009 $data["referral_comment"] = $this->object->getComment();
1010
1011 // interests
1012 $data["interests_general"] = $this->object->getGeneralInterests();
1013 $data["interests_help_offered"] = $this->object->getOfferingHelp();
1014 $data["interests_help_looking"] = $this->object->getLookingForHelp();
1015
1016 // other data
1017 $data["matriculation"] = $this->object->getMatriculation();
1018 $data["client_ip"] = $this->object->getClientIP();
1019
1020 // user defined fields
1021 include_once './Services/User/classes/class.ilUserDefinedFields.php';
1022 $this->user_defined_fields = ilUserDefinedFields::_getInstance();
1023 $user_defined_data = $this->object->getUserDefinedData();
1024 foreach ($this->user_defined_fields->getDefinitions() as $field_id => $definition) {
1025 $data["udf_" . $field_id] = $user_defined_data["f_" . $field_id];
1026 }
1027
1028 // settings
1029 $data["language"] = $this->object->getLanguage();
1030 $data["skin_style"] = $this->object->skin . ":" . $this->object->prefs["style"];
1031 $data["hits_per_page"] = $this->object->prefs["hits_per_page"];
1032 //$data["show_users_online"] = $this->object->prefs["show_users_online"];
1033 $data["hide_own_online_status"] = $this->object->prefs["hide_own_online_status"];
1034 $data['bs_allow_to_contact_me'] = $this->object->prefs['bs_allow_to_contact_me'] == 'y';
1035 $data['chat_osc_accept_msg'] = $this->object->prefs['chat_osc_accept_msg'] == 'y';
1036 $data["session_reminder_enabled"] = (int) $this->object->prefs["session_reminder_enabled"];
1037
1038 $data["send_mail"] = ($this->object->prefs['send_info_mails'] == 'y');
1039
1040
1041 $this->form_gui->setValuesByArray($data);
1042 }
1043
1047 public function initForm($a_mode)
1048 {
1049 global $DIC;
1050
1051 $lng = $DIC['lng'];
1052 $ilCtrl = $DIC['ilCtrl'];
1053 $styleDefinition = $DIC['styleDefinition'];
1054 $ilSetting = $DIC['ilSetting'];
1055 $ilClientIniFile = $DIC['ilClientIniFile'];
1056 $ilUser = $DIC['ilUser'];
1057
1058 $settings = $ilSetting->getAll();
1059
1060 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1061
1062 $this->form_gui = new ilPropertyFormGUI();
1063 $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
1064 if ($a_mode == "create") {
1065 $this->form_gui->setTitle($lng->txt("usr_new"));
1066 } else {
1067 $this->form_gui->setTitle($lng->txt("usr_edit"));
1068 }
1069
1070 // login data
1071 $sec_l = new ilFormSectionHeaderGUI();
1072 $sec_l->setTitle($lng->txt("login_data"));
1073 $this->form_gui->addItem($sec_l);
1074
1075 // authentication mode
1076 include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
1077 $active_auth_modes = ilAuthUtils::_getActiveAuthModes();
1078 $am = new ilSelectInputGUI($lng->txt("auth_mode"), "auth_mode");
1079 $option = array();
1080 foreach ($active_auth_modes as $auth_name => $auth_key) {
1081 if ($auth_name == 'default') {
1082 $name = $this->lng->txt('auth_' . $auth_name) . " (" . $this->lng->txt('auth_' . ilAuthUtils::_getAuthModeName($auth_key)) . ")";
1083 } else {
1084 // begin-patch ldap_multiple
1085 #$name = $this->lng->txt('auth_'.$auth_name);
1086 include_once './Services/Authentication/classes/class.ilAuthUtils.php';
1087 $name = ilAuthUtils::getAuthModeTranslation($auth_key, $auth_name);
1088 // end-patch ldap_multiple
1089 }
1090 $option[$auth_name] = $name;
1091 }
1092 $am->setOptions($option);
1093 $this->form_gui->addItem($am);
1094
1095 if ($a_mode == "edit") {
1096 $id = new ilNonEditableValueGUI($lng->txt("usr_id"), "id");
1097 $id->setValue($this->object->getId());
1098 $this->form_gui->addItem($id);
1099 }
1100
1101 // login
1102 $lo = new ilUserLoginInputGUI($lng->txt("login"), "login");
1103 $lo->setRequired(true);
1104 if ($a_mode == "edit") {
1105 $lo->setCurrentUserId($this->object->getId());
1106 try {
1107 include_once 'Services/Calendar/classes/class.ilDate.php';
1108
1109 $last_history_entry = ilObjUser::_getLastHistoryDataByUserId($this->object->getId());
1110 $lo->setInfo(
1111 sprintf(
1112 $this->lng->txt('usr_loginname_history_info'),
1113 ilDatePresentation::formatDate(new ilDateTime($last_history_entry[1], IL_CAL_UNIX)),
1114 $last_history_entry[0]
1115 )
1116 );
1117 } catch (ilUserException $e) {
1118 }
1119 }
1120
1121 $this->form_gui->addItem($lo);
1122
1123 if ($this->user->getId() === (int) SYSTEM_USER_ID
1124 || !in_array(SYSTEM_ROLE_ID, $this->rbacreview->assignedRoles($this->object->getId()))
1125 || in_array(SYSTEM_ROLE_ID, $this->rbacreview->assignedRoles($this->user->getId()))) {
1126
1127 // passwords
1128 // @todo: do not show passwords, if there is not a single auth, that
1129 // allows password setting
1130 $pw = new ilPasswordInputGUI($lng->txt("passwd"), "passwd");
1131 $pw->setUseStripSlashes(false);
1132 $pw->setSize(32);
1133 $pw->setMaxLength(80); // #17221
1134 $pw->setValidateAuthPost("auth_mode");
1135 if ($a_mode == "create") {
1136 $pw->setRequiredOnAuth(true);
1137 }
1139 $this->form_gui->addItem($pw);
1140 // @todo: invisible/hidden passwords
1141 }
1142
1143 // external account
1144 include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
1146 $ext = new ilTextInputGUI($lng->txt("user_ext_account"), "ext_account");
1147 $ext->setSize(40);
1148 $ext->setMaxLength(250);
1149 $ext->setInfo($lng->txt("user_ext_account_desc"));
1150 $this->form_gui->addItem($ext);
1151 }
1152
1153 // login data
1154 $sec_si = new ilFormSectionHeaderGUI();
1155 $sec_si->setTitle($this->lng->txt("system_information"));
1156 $this->form_gui->addItem($sec_si);
1157
1158 // create date, approve date, agreement date, last login
1159 if ($a_mode == "edit") {
1160 $sia = array("create_date", "approve_date", "agree_date", "last_login", "owner");
1161 foreach ($sia as $a) {
1162 $siai = new ilNonEditableValueGUI($lng->txt($a), $a);
1163 $this->form_gui->addItem($siai);
1164 }
1165 }
1166
1167 // active
1168 $ac = new ilCheckboxInputGUI($lng->txt("active"), "active");
1169 $ac->setChecked(true);
1170 $this->form_gui->addItem($ac);
1171
1172 // access @todo: get fields right (names change)
1173 $lng->loadLanguageModule('crs');
1174
1175 // access
1176 $radg = new ilRadioGroupInputGUI($lng->txt("time_limit"), "time_limit_unlimited");
1177 $radg->setValue(1);
1178 $op1 = new ilRadioOption($lng->txt("user_access_unlimited"), 1);
1179 $radg->addOption($op1);
1180 $op2 = new ilRadioOption($lng->txt("user_access_limited"), 0);
1181 $radg->addOption($op2);
1182
1183 // $ac = new ilCheckboxInputGUI($lng->txt("time_limit"), "time_limit_unlimited");
1184 // $ac->setChecked(true);
1185 // $ac->setOptionTitle($lng->txt("crs_unlimited"));
1186
1187 // access.from
1188 $acfrom = new ilDateTimeInputGUI($this->lng->txt("crs_from"), "time_limit_from");
1189 $acfrom->setRequired(true);
1190 $acfrom->setShowTime(true);
1191 $acfrom->setMinuteStepSize(1);
1192 $op2->addSubItem($acfrom);
1193
1194 // access.to
1195 $acto = new ilDateTimeInputGUI($this->lng->txt("crs_to"), "time_limit_until");
1196 $acto->setRequired(true);
1197 $acto->setShowTime(true);
1198 $acto->setMinuteStepSize(1);
1199 $op2->addSubItem($acto);
1200
1201 // $this->form_gui->addItem($ac);
1202 $this->form_gui->addItem($radg);
1203
1204 // personal data
1205 if (
1206 $this->isSettingChangeable('gender') or
1207 $this->isSettingChangeable('firstname') or
1208 $this->isSettingChangeable('lastname') or
1209 $this->isSettingChangeable('title') or
1210 $this->isSettingChangeable('personal_image') or
1211 $this->isSettingChangeable('birhtday')
1212 ) {
1213 $sec_pd = new ilFormSectionHeaderGUI();
1214 $sec_pd->setTitle($this->lng->txt("personal_data"));
1215 $this->form_gui->addItem($sec_pd);
1216 }
1217
1218 // gender
1219 if ($this->isSettingChangeable('gender')) {
1220 $gndr = new ilRadioGroupInputGUI($lng->txt("salutation"), "gender");
1221 $gndr->setRequired(isset($settings["require_gender"]) && $settings["require_gender"]);
1222 $neutral = new ilRadioOption($lng->txt("salutation_n"), "n");
1223 $gndr->addOption($neutral);
1224 $female = new ilRadioOption($lng->txt("salutation_f"), "f");
1225 $gndr->addOption($female);
1226 $male = new ilRadioOption($lng->txt("salutation_m"), "m");
1227 $gndr->addOption($male);
1228 $this->form_gui->addItem($gndr);
1229 }
1230
1231 // firstname, lastname, title
1232 $fields = array("firstname" => true, "lastname" => true,
1233 "title" => isset($settings["require_title"]) && $settings["require_title"]);
1234 foreach ($fields as $field => $req) {
1235 if ($this->isSettingChangeable($field)) {
1236 // #18795
1237 $caption = ($field == "title")
1238 ? "person_title"
1239 : $field;
1240 $inp = new ilTextInputGUI($lng->txt($caption), $field);
1241 $inp->setSize(32);
1242 $inp->setMaxLength(32);
1243 $inp->setRequired($req);
1244 $this->form_gui->addItem($inp);
1245 }
1246 }
1247
1248 // personal image
1249 if ($this->isSettingChangeable('upload')) {
1250 $pi = new ilImageFileInputGUI($lng->txt("personal_picture"), "userfile");
1251 if ($a_mode == "edit" || $a_mode == "upload") {
1253 $this->object->getId(),
1254 "small",
1255 true,
1256 true
1257 ));
1258 }
1259 $this->form_gui->addItem($pi);
1260 }
1261
1262 if ($this->isSettingChangeable('birthday')) {
1263 $birthday = new ilBirthdayInputGUI($lng->txt('birthday'), 'birthday');
1264 $birthday->setRequired(isset($settings["require_birthday"]) && $settings["require_birthday"]);
1265 $this->form_gui->addItem($birthday);
1266 }
1267
1268
1269 // institution, department, street, city, zip code, country, phone office
1270 // phone home, phone mobile, fax, e-mail
1271 $fields = array(
1272 array("institution", 40, 80),
1273 array("department", 40, 80),
1274 array("street", 40, 40),
1275 array("city", 40, 40),
1276 array("zipcode", 10, 10),
1277 array("country", 40, 40),
1278 array("sel_country"),
1279 array("phone_office", 30, 30),
1280 array("phone_home", 30, 30),
1281 array("phone_mobile", 30, 30),
1282 array("fax", 30, 30));
1283
1284 $counter = 0;
1285 foreach ($fields as $field) {
1286 if (!$counter++ and $this->isSettingChangeable($field[0])) {
1287 // contact data
1288 $sec_cd = new ilFormSectionHeaderGUI();
1289 $sec_cd->setTitle($this->lng->txt("contact_data"));
1290 $this->form_gui->addItem($sec_cd);
1291
1292 // org units
1293 if ($a_mode == "edit") {
1294 $orgus = new ilNonEditableValueGUI($lng->txt('objs_orgu'), 'org_units');
1295 $orgus->setValue($this->object->getOrgUnitsRepresentation());
1296 $this->form_gui->addItem($orgus);
1297 }
1298 }
1299 if ($this->isSettingChangeable($field[0])) {
1300 if ($field[0] != "sel_country") {
1301 $inp = new ilTextInputGUI($lng->txt($field[0]), $field[0]);
1302 $inp->setSize($field[1]);
1303 $inp->setMaxLength($field[2]);
1304 $inp->setRequired(isset($settings["require_" . $field[0]]) &&
1305 $settings["require_" . $field[0]]);
1306 $this->form_gui->addItem($inp);
1307 } else {
1308 // country selection
1309 include_once("./Services/Form/classes/class.ilCountrySelectInputGUI.php");
1310 $cs = new ilCountrySelectInputGUI($lng->txt($field[0]), $field[0]);
1311 $cs->setRequired(isset($settings["require_" . $field[0]]) &&
1312 $settings["require_" . $field[0]]);
1313 $this->form_gui->addItem($cs);
1314 }
1315 }
1316 }
1317
1318 // email
1319 if ($this->isSettingChangeable('email')) {
1320 $em = new ilEMailInputGUI($lng->txt("email"), "email");
1321 $em->setRequired(isset($settings["require_email"]) &&
1322 $settings["require_email"]);
1323 $this->form_gui->addItem($em);
1324 }
1325
1326 // second email
1327 if ($this->isSettingChangeable('second_email')) {
1328 $em = new ilEMailInputGUI($lng->txt("second_email"), "second_email");
1329
1330 $this->form_gui->addItem($em);
1331 }
1332
1333 // interests/hobbies
1334 if ($this->isSettingChangeable('hobby')) {
1335 $hob = new ilTextAreaInputGUI($lng->txt("hobby"), "hobby");
1336 $hob->setRows(3);
1337 $hob->setCols(40);
1338 $hob->setRequired(isset($settings["require_hobby"]) &&
1339 $settings["require_hobby"]);
1340 $this->form_gui->addItem($hob);
1341 }
1342
1343 // referral comment
1344 if ($this->isSettingChangeable('referral_comment')) {
1345 $rc = new ilTextAreaInputGUI($lng->txt("referral_comment"), "referral_comment");
1346 $rc->setRows(3);
1347 $rc->setCols(40);
1348 $rc->setRequired(isset($settings["require_referral_comment"]) &&
1349 $settings["require_referral_comment"]);
1350 $this->form_gui->addItem($rc);
1351 }
1352
1353
1354 // interests
1355
1356 $sh = new ilFormSectionHeaderGUI();
1357 $sh->setTitle($lng->txt("interests"));
1358 $this->form_gui->addItem($sh);
1359
1360 $multi_fields = array("interests_general", "interests_help_offered", "interests_help_looking");
1361 foreach ($multi_fields as $multi_field) {
1362 if ($this->isSettingChangeable($multi_field)) {
1363 // see ilUserProfile
1364 $ti = new ilTextInputGUI($lng->txt($multi_field), $multi_field);
1365 $ti->setMulti(true);
1366 $ti->setMaxLength(40);
1367 $ti->setSize(40);
1368 $ti->setRequired(isset($settings["require_" . $multi_field]) &&
1369 $settings["require_" . $multi_field]);
1370 $this->form_gui->addItem($ti);
1371 }
1372 }
1373
1374
1375 // other information
1376 if ($this->isSettingChangeable('user_profile_other')) {
1377 $sec_oi = new ilFormSectionHeaderGUI();
1378 $sec_oi->setTitle($this->lng->txt("user_profile_other"));
1379 $this->form_gui->addItem($sec_oi);
1380 }
1381
1382 // matriculation number
1383 if ($this->isSettingChangeable('matriculation')) {
1384 $mr = new ilTextInputGUI($lng->txt("matriculation"), "matriculation");
1385 $mr->setSize(40);
1386 $mr->setMaxLength(40);
1387 $mr->setRequired(isset($settings["require_matriculation"]) &&
1388 $settings["require_matriculation"]);
1389 $this->form_gui->addItem($mr);
1390 }
1391
1392 // client IP
1393 $ip = new ilTextInputGUI($lng->txt("client_ip"), "client_ip");
1394 $ip->setSize(40);
1395 $ip->setMaxLength(255);
1396 $ip->setInfo($this->lng->txt("current_ip") . " " . $_SERVER["REMOTE_ADDR"] . " <br />" .
1397 '<span class="warning">' . $this->lng->txt("current_ip_alert") . "</span>");
1398 $this->form_gui->addItem($ip);
1399
1400 // additional user defined fields
1401 include_once './Services/User/classes/class.ilUserDefinedFields.php';
1402 $user_defined_fields = ilUserDefinedFields::_getInstance();
1403
1404 if ($this->usrf_ref_id == USER_FOLDER_ID) {
1405 $all_defs = $user_defined_fields->getDefinitions();
1406 } else {
1407 $all_defs = $user_defined_fields->getChangeableLocalUserAdministrationDefinitions();
1408 }
1409
1410 foreach ($all_defs as $field_id => $definition) {
1411 include_once './Services/User/classes/class.ilCustomUserFieldsHelper.php';
1412 $f_property = ilCustomUserFieldsHelper::getInstance()->getFormPropertyForDefinition($definition, true);
1413 if ($f_property instanceof ilFormPropertyGUI) {
1414 $this->form_gui->addItem($f_property);
1415 }
1416 }
1417
1418 // settings
1419 if (
1420 $a_mode == 'create' or
1421 $this->isSettingChangeable('language') or
1422 $this->isSettingChangeable('skin_style') or
1423 $this->isSettingChangeable('hits_per_page') or
1424 $this->isSettingChangeable('hide_own_online_status') or
1425 $this->isSettingChangeable('bs_allow_to_contact_me') or
1426 $this->isSettingChangeable('chat_osc_accept_msg')
1427 ) {
1428 $sec_st = new ilFormSectionHeaderGUI();
1429 $sec_st->setTitle($this->lng->txt("settings"));
1430 $this->form_gui->addItem($sec_st);
1431 }
1432
1433 // role
1434 if ($a_mode == "create") {
1435 $role = new ilSelectInputGUI(
1436 $lng->txt("default_role"),
1437 'default_role'
1438 );
1439 $role->setRequired(true);
1440 $role->setValue($this->default_role);
1441 $role->setOptions($this->selectable_roles);
1442 $this->form_gui->addItem($role);
1443 }
1444
1445 // language
1446 if ($this->isSettingChangeable('language')) {
1447 $lang = new ilSelectInputGUI(
1448 $lng->txt("language"),
1449 'language'
1450 );
1451 $languages = $lng->getInstalledLanguages();
1452 $lng->loadLanguageModule("meta");
1453 $options = array();
1454 foreach ($languages as $l) {
1455 $options[$l] = $lng->txt("meta_l_" . $l);
1456 }
1457 $lang->setOptions($options);
1458 $lang->setValue($ilSetting->get("language"));
1459 $this->form_gui->addItem($lang);
1460 }
1461
1462 // skin/style
1463 if ($this->isSettingChangeable('skin_style')) {
1464 $sk = new ilSelectInputGUI(
1465 $lng->txt("skin_style"),
1466 'skin_style'
1467 );
1471 $skins = $styleDefinition->getAllSkins();
1472
1473 $options = array();
1474 if (is_array($skins)) {
1475 $sk = new ilSelectInputGUI($this->lng->txt("skin_style"), "skin_style");
1476
1477 $options = array();
1478 foreach ($skins as $skin) {
1479 foreach ($skin->getStyles() as $style) {
1480 include_once("./Services/Style/System/classes/class.ilSystemStyleSettings.php");
1481 if (!ilSystemStyleSettings::_lookupActivatedStyle($skin->getId(), $style->getId())) {
1482 continue;
1483 }
1484
1485 $options[$skin->getId() . ":" . $style->getId()] = $skin->getName() . " / " . $style->getName();
1486 }
1487 }
1488 }
1489 $sk->setOptions($options);
1490 $sk->setValue($ilClientIniFile->readVariable("layout", "skin") .
1491 ":" . $ilClientIniFile->readVariable("layout", "style"));
1492
1493 $this->form_gui->addItem($sk);
1494 }
1495
1496 // hits per page
1497 if ($this->isSettingChangeable('hits_per_page')) {
1498 $hpp = new ilSelectInputGUI(
1499 $lng->txt("hits_per_page"),
1500 'hits_per_page'
1501 );
1502 $options = array(10 => 10, 15 => 15, 20 => 20, 30 => 30, 40 => 40,
1503 50 => 50, 100 => 100, 9999 => $this->lng->txt("no_limit"));
1504 $hpp->setOptions($options);
1505 $hpp->setValue($ilSetting->get("hits_per_page"));
1506 $this->form_gui->addItem($hpp);
1507
1508 // users online
1509 /*$uo = new ilSelectInputGUI($lng->txt("users_online"),
1510 'show_users_online');
1511 $options = array(
1512 "y" => $lng->txt("users_online_show_y"),
1513 "associated" => $lng->txt("users_online_show_associated"),
1514 "n" => $lng->txt("users_online_show_n"));
1515 $uo->setOptions($options);
1516 $uo->setValue($ilSetting->get("show_users_online"));
1517 $this->form_gui->addItem($uo);*/
1518 }
1519
1520 // hide online status
1521 if ($this->isSettingChangeable('hide_own_online_status')) {
1522 $lng->loadLanguageModule("awrn");
1523
1524 $default = ($ilSetting->get('hide_own_online_status') == "n")
1525 ? $this->lng->txt("user_awrn_show")
1526 : $this->lng->txt("user_awrn_hide");
1527
1528 $options = array(
1529 "" => $this->lng->txt("user_awrn_default") . " (" . $default . ")",
1530 "n" => $this->lng->txt("user_awrn_show"),
1531 "y" => $this->lng->txt("user_awrn_hide"));
1532 $os = new ilSelectInputGUI($lng->txt("awrn_user_show"), "hide_own_online_status");
1533 $os->setOptions($options);
1534 $os->setDisabled($ilSetting->get("usr_settings_disable_hide_own_online_status"));
1535 $os->setInfo($lng->txt("awrn_hide_from_awareness_info"));
1536 $this->form_gui->addItem($os);
1537
1538
1539 //$os = new ilCheckboxInputGUI($lng->txt("awrn_hide_from_awareness"), "hide_own_online_status");
1540 //$this->form_gui->addItem($os);
1541 }
1542
1543 // allow to contact me
1544 if ($this->isSettingChangeable('bs_allow_to_contact_me')) {
1545 $lng->loadLanguageModule('buddysystem');
1546 $os = new ilCheckboxInputGUI($lng->txt('buddy_allow_to_contact_me'), 'bs_allow_to_contact_me');
1547 if ($a_mode == 'create') {
1548 $os->setChecked(ilUtil::yn2tf($ilSetting->get('bs_allow_to_contact_me', 'n')));
1549 }
1550 $this->form_gui->addItem($os);
1551 }
1552 if ($this->isSettingChangeable('chat_osc_accept_msg')) {
1553 $lng->loadLanguageModule('chatroom');
1554 $chat_osc_acm = new ilCheckboxInputGUI($lng->txt('chat_osc_accept_msg'), 'chat_osc_accept_msg');
1555 if ($a_mode == 'create') {
1556 $chat_osc_acm->setChecked(ilUtil::yn2tf($ilSetting->get('chat_osc_accept_msg', 'n')));
1557 }
1558 $this->form_gui->addItem($chat_osc_acm);
1559 }
1560
1561 if ((int) $ilSetting->get('session_reminder_enabled')) {
1562 $cb = new ilCheckboxInputGUI($this->lng->txt('session_reminder'), 'session_reminder_enabled');
1563 $cb->setValue(1);
1564 $this->form_gui->addItem($cb);
1565 }
1566
1567 // Options
1568 if ($this->isSettingChangeable('send_mail')) {
1569 $sec_op = new ilFormSectionHeaderGUI();
1570 $sec_op->setTitle($this->lng->txt("options"));
1571 $this->form_gui->addItem($sec_op);
1572 }
1573
1574 // send email
1575 $se = new ilCheckboxInputGUI($lng->txt('inform_user_mail'), 'send_mail');
1576 $se->setInfo($lng->txt('inform_user_mail_info'));
1577 $se->setValue('y');
1578 $se->setChecked(($ilUser->getPref('send_info_mails') == 'y'));
1579 $this->form_gui->addItem($se);
1580
1581 // ignore required fields
1582 $irf = new ilCheckboxInputGUI($lng->txt('ignore_required_fields'), 'ignore_rf');
1583 $irf->setInfo($lng->txt('ignore_required_fields_info'));
1584 $irf->setValue(1);
1585 $this->form_gui->addItem($irf);
1586
1587 // @todo: handle all required fields
1588
1589 // command buttons
1590 if ($a_mode == "create" || $a_mode == "save") {
1591 $this->form_gui->addCommandButton("save", $lng->txt("save"));
1592 }
1593 if ($a_mode == "edit" || $a_mode == "update") {
1594 $this->form_gui->addCommandButton("update", $lng->txt("save"));
1595 }
1596 $this->form_gui->addCommandButton("cancel", $lng->txt("cancel"));
1597 }
1598
1607 protected function isSettingChangeable($a_field)
1608 {
1609 // TODO: Allow mixed field parameter to support checks against an array of field names.
1610
1611 global $DIC;
1612
1613 $ilSetting = $DIC['ilSetting'];
1614 static $settings = null;
1615
1616
1617
1618 if ($this->usrf_ref_id == USER_FOLDER_ID) {
1619 return true;
1620 }
1621
1622 if ($settings == null) {
1623 $settings = $ilSetting->getAll();
1624 }
1625 return (bool) $settings['usr_settings_changeable_lua_' . $a_field];
1626 }
1627
1628
1634 public function uploadUserPictureObject()
1635 {
1636 global $DIC;
1637
1638 $ilUser = $DIC['ilUser'];
1639 $rbacsystem = $DIC['rbacsystem'];
1640
1641 // User folder
1642 if ($this->usrf_ref_id == USER_FOLDER_ID and
1643 !$rbacsystem->checkAccess('visible,read', $this->usrf_ref_id)) {
1644 $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"), $this->ilias->error_obj->MESSAGE);
1645 }
1646 // if called from local administration $this->usrf_ref_id is category id
1647 // Todo: this has to be fixed. Do not mix user folder id and category id
1648 if ($this->usrf_ref_id != USER_FOLDER_ID) {
1649 // check if user is assigned to category
1650 if (!$rbacsystem->checkAccess('cat_administrate_users', $this->object->getTimeLimitOwner())) {
1651 $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"), $this->ilias->error_obj->MESSAGE);
1652 }
1653 }
1654
1655 $userfile_input = $this->form_gui->getItemByPostVar("userfile");
1656
1657 if ($_FILES["userfile"]["tmp_name"] == "") {
1658 if ($userfile_input->getDeletionFlag()) {
1659 $this->object->removeUserPicture();
1660 }
1661 return;
1662 }
1663 if ($_FILES["userfile"]["size"] == 0) {
1664 ilUtil::sendFailure($this->lng->txt("msg_no_file"));
1665 } else {
1666 $webspace_dir = ilUtil::getWebspaceDir();
1667 $image_dir = $webspace_dir . "/usr_images";
1668 $store_file = "usr_" . $this->object->getId() . "." . "jpg";
1669
1670 // store filename
1671 $this->object->setPref("profile_image", $store_file);
1672 $this->object->update();
1673
1674 // move uploaded file
1675 $pi = pathinfo($_FILES["userfile"]["name"]);
1676 $uploaded_file = $image_dir . "/upload_" . $this->object->getId() . "." . $pi["extension"];
1678 $_FILES["userfile"]["tmp_name"],
1679 $_FILES["userfile"]["name"],
1680 $uploaded_file,
1681 false
1682 )) {
1683 ilUtil::sendFailure($this->lng->txt("upload_error", true));
1684 $this->ctrl->redirect($this, "showProfile");
1685 }
1686 chmod($uploaded_file, 0770);
1687
1688 // take quality 100 to avoid jpeg artefacts when uploading jpeg files
1689 // taking only frame [0] to avoid problems with animated gifs
1690 $show_file = "$image_dir/usr_" . $this->object->getId() . ".jpg";
1691 $thumb_file = "$image_dir/usr_" . $this->object->getId() . "_small.jpg";
1692 $xthumb_file = "$image_dir/usr_" . $this->object->getId() . "_xsmall.jpg";
1693 $xxthumb_file = "$image_dir/usr_" . $this->object->getId() . "_xxsmall.jpg";
1694 $uploaded_file = ilUtil::escapeShellArg($uploaded_file);
1695 $show_file = ilUtil::escapeShellArg($show_file);
1696 $thumb_file = ilUtil::escapeShellArg($thumb_file);
1697 $xthumb_file = ilUtil::escapeShellArg($xthumb_file);
1698 $xxthumb_file = ilUtil::escapeShellArg($xxthumb_file);
1699
1700 if (ilUtil::isConvertVersionAtLeast("6.3.8-3")) {
1701 ilUtil::execConvert($uploaded_file . "[0] -geometry 200x200^ -gravity center -extent 200x200 -quality 100 JPEG:" . $show_file);
1702 ilUtil::execConvert($uploaded_file . "[0] -geometry 100x100^ -gravity center -extent 100x100 -quality 100 JPEG:" . $thumb_file);
1703 ilUtil::execConvert($uploaded_file . "[0] -geometry 75x75^ -gravity center -extent 75x75 -quality 100 JPEG:" . $xthumb_file);
1704 ilUtil::execConvert($uploaded_file . "[0] -geometry 30x30^ -gravity center -extent 30x30 -quality 100 JPEG:" . $xxthumb_file);
1705 } else {
1706 ilUtil::execConvert($uploaded_file . "[0] -geometry 200x200 -quality 100 JPEG:" . $show_file);
1707 ilUtil::execConvert($uploaded_file . "[0] -geometry 100x100 -quality 100 JPEG:" . $thumb_file);
1708 ilUtil::execConvert($uploaded_file . "[0] -geometry 75x75 -quality 100 JPEG:" . $xthumb_file);
1709 ilUtil::execConvert($uploaded_file . "[0] -geometry 30x30 -quality 100 JPEG:" . $xxthumb_file);
1710 }
1711 }
1712 }
1713
1717 public function removeUserPictureObject()
1718 {
1719 $webspace_dir = ilUtil::getWebspaceDir();
1720 $image_dir = $webspace_dir . "/usr_images";
1721 $file = $image_dir . "/usr_" . $this->object->getID() . "." . "jpg";
1722 $thumb_file = $image_dir . "/usr_" . $this->object->getID() . "_small.jpg";
1723 $xthumb_file = $image_dir . "/usr_" . $this->object->getID() . "_xsmall.jpg";
1724 $xxthumb_file = $image_dir . "/usr_" . $this->object->getID() . "_xxsmall.jpg";
1725 $upload_file = $image_dir . "/upload_" . $this->object->getID();
1726
1727 // remove user pref file name
1728 $this->object->setPref("profile_image", "");
1729 $this->object->update();
1730 ilUtil::sendSuccess($this->lng->txt("user_image_removed"));
1731
1732 if (@is_file($file)) {
1733 unlink($file);
1734 }
1735 if (@is_file($thumb_file)) {
1736 unlink($thumb_file);
1737 }
1738 if (@is_file($xthumb_file)) {
1739 unlink($xthumb_file);
1740 }
1741 if (@is_file($xxthumb_file)) {
1742 unlink($xxthumb_file);
1743 }
1744 if (@is_file($upload_file)) {
1745 unlink($upload_file);
1746 }
1747
1748 $this->editObject();
1749 }
1750
1756 public function assignSaveObject()
1757 {
1758 global $DIC;
1759
1760 $rbacsystem = $DIC['rbacsystem'];
1761 $rbacadmin = $DIC['rbacadmin'];
1762 $rbacreview = $DIC['rbacreview'];
1763
1764 if (!$rbacsystem->checkAccess("edit_roleassignment", $this->usrf_ref_id)) {
1765 $this->ilias->raiseError($this->lng->txt("msg_no_perm_assign_role_to_user"), $this->ilias->error_obj->MESSAGE);
1766 }
1767
1768 $selected_roles = $_POST["role_id"] ? $_POST["role_id"] : array();
1769 $posted_roles = $_POST["role_id_ctrl"] ? $_POST["role_id_ctrl"] : array();
1770
1771 // prevent unassignment of system role from system user
1772 if ($this->object->getId() == SYSTEM_USER_ID and in_array(SYSTEM_ROLE_ID, $posted_roles)) {
1773 array_push($selected_roles, SYSTEM_ROLE_ID);
1774 }
1775
1776 $global_roles_all = $rbacreview->getGlobalRoles();
1777 $assigned_roles_all = $rbacreview->assignedRoles($this->object->getId());
1778 $assigned_roles = array_intersect($assigned_roles_all, $posted_roles);
1779 $assigned_global_roles_all = array_intersect($assigned_roles_all, $global_roles_all);
1780 $assigned_global_roles = array_intersect($assigned_global_roles_all, $posted_roles);
1781
1782 $user_not_allowed_to_change_admin_role_assginements =
1783 !in_array(SYSTEM_ROLE_ID, $rbacreview->assignedRoles($this->user->getId()));
1784
1785 if ($user_not_allowed_to_change_admin_role_assginements
1786 && in_array(SYSTEM_ROLE_ID, $assigned_roles_all)) {
1787 $selected_roles[] = SYSTEM_ROLE_ID;
1788 }
1789
1790 $posted_global_roles = array_intersect($selected_roles, $global_roles_all);
1791
1792 if (empty($selected_roles) && count($assigned_roles_all) === count($assigned_roles)
1793 || empty($posted_global_roles) && count($assigned_global_roles_all) === count($assigned_global_roles)) {
1794 ilUtil::sendFailure($this->lng->txt("msg_min_one_role") . "<br/>" . $this->lng->txt("action_aborted"), true);
1795 $this->ctrl->redirect($this, 'roleassignment');
1796 }
1797
1798 foreach (array_diff($assigned_roles, $selected_roles) as $role) {
1799 if ($this->object->getId() === (int) SYSTEM_USER_ID && $role === SYSTEM_ROLE_ID
1800 || $user_not_allowed_to_change_admin_role_assginements && $role === SYSTEM_ROLE_ID) {
1801 continue;
1802 }
1803 $rbacadmin->deassignUser($role, $this->object->getId());
1804 }
1805
1806 foreach (array_diff($selected_roles, $assigned_roles) as $role) {
1807 if ($this->object->getId() === (int) SYSTEM_USER_ID && $role === SYSTEM_ROLE_ID
1808 || $user_not_allowed_to_change_admin_role_assginements && $role === SYSTEM_ROLE_ID) {
1809 continue;
1810 }
1811 $rbacadmin->assignUser($role, $this->object->getId(), false);
1812 }
1813
1814 include_once "./Services/AccessControl/classes/class.ilObjRole.php";
1815
1816 // update object data entry (to update last modification date)
1817 $this->object->update();
1818
1819 ilUtil::sendSuccess($this->lng->txt("msg_roleassignment_changed"), true);
1820
1821 if (strtolower($_GET["baseClass"]) == 'iladministrationgui') {
1822 $this->ctrl->redirect($this, 'roleassignment');
1823 } else {
1824 $this->ctrl->redirectByClass('ilobjcategorygui', 'listUsers');
1825 }
1826 }
1827
1833 public function roleassignmentObject()
1834 {
1835 global $DIC;
1836
1837 $rbacreview = $DIC['rbacreview'];
1838 $rbacsystem = $DIC['rbacsystem'];
1839 $ilUser = $DIC['ilUser'];
1840 $ilTabs = $DIC['ilTabs'];
1841 $access = $DIC->access();
1842
1843 $ilTabs->activateTab("role_assignment");
1844
1845 if ($this->object->getId() === (int) ANONYMOUS_USER_ID
1846 || !$rbacsystem->checkAccess("edit_roleassignment", $this->usrf_ref_id)
1847 && !$access->isCurrentUserBasedOnPositionsAllowedTo("read_users", array($this->object->getId()))
1848 ) {
1849 $this->ilias->raiseError($this->lng->txt("msg_no_perm_assign_role_to_user"), $this->ilias->error_obj->MESSAGE);
1850 }
1851
1852 $_SESSION['filtered_roles'] = isset($_POST['filter']) ? $_POST['filter'] : $_SESSION['filtered_roles'];
1853
1854 if ($_SESSION['filtered_roles'] > 5) {
1855 $_SESSION['filtered_roles'] = 0;
1856 }
1857
1858 $this->tpl->addBlockfile('ADM_CONTENT', 'adm_content', 'tpl.usr_role_assignment.html', 'Services/User');
1859
1860 if (false) {
1861 $this->tpl->setCurrentBlock("form_filter");
1862 $this->tpl->setVariable("FILTER_TXT_FILTER", $this->lng->txt('filter'));
1863 $this->tpl->setVariable("SELECT_FILTER", $this->__buildFilterSelect());
1864 $this->tpl->setVariable("FILTER_ACTION", $this->ctrl->getFormAction($this));
1865 $this->tpl->setVariable("FILTER_NAME", 'roleassignment');
1866 $this->tpl->setVariable("FILTER_VALUE", $this->lng->txt('apply_filter'));
1867 $this->tpl->parseCurrentBlock();
1868 }
1869
1870 // init table
1871 include_once("./Services/User/classes/class.ilRoleAssignmentTableGUI.php");
1872 $tab = new ilRoleAssignmentTableGUI($this, "roleassignment");
1873
1874 $tab->parse($this->object->getId());
1875 $this->tpl->setVariable("ROLES_TABLE", $tab->getHTML());
1876 }
1877
1881 public function applyFilterObject()
1882 {
1883 include_once("./Services/User/classes/class.ilRoleAssignmentTableGUI.php");
1884 $table_gui = new ilRoleAssignmentTableGUI($this, "roleassignment");
1885 $table_gui->writeFilterToSession(); // writes filter to session
1886 $table_gui->resetOffset(); // sets record offest to 0 (first page)
1887 $this->roleassignmentObject();
1888 }
1889
1893 public function resetFilterObject()
1894 {
1895 include_once("./Services/User/classes/class.ilRoleAssignmentTableGUI.php");
1896 $table_gui = new ilRoleAssignmentTableGUI($this, "roleassignment");
1897 $table_gui->resetOffset(); // sets record offest to 0 (first page)
1898 $table_gui->resetFilter(); // clears filter
1899 $this->roleassignmentObject();
1900 }
1901
1902 public function __getDateSelect($a_type, $a_varname, $a_selected)
1903 {
1904 switch ($a_type) {
1905 case "minute":
1906 for ($i = 0;$i <= 60;$i++) {
1907 $days[$i] = $i < 10 ? "0" . $i : $i;
1908 }
1909 return ilUtil::formSelect($a_selected, $a_varname, $days, false, true);
1910
1911 case "hour":
1912 for ($i = 0;$i < 24;$i++) {
1913 $days[$i] = $i < 10 ? "0" . $i : $i;
1914 }
1915 return ilUtil::formSelect($a_selected, $a_varname, $days, false, true);
1916
1917 case "day":
1918 for ($i = 1;$i < 32;$i++) {
1919 $days[$i] = $i < 10 ? "0" . $i : $i;
1920 }
1921 return ilUtil::formSelect($a_selected, $a_varname, $days, false, true);
1922
1923 case "month":
1924 for ($i = 1;$i < 13;$i++) {
1925 $month[$i] = $i < 10 ? "0" . $i : $i;
1926 }
1927 return ilUtil::formSelect($a_selected, $a_varname, $month, false, true);
1928
1929 case "year":
1930 if ($a_selected < date('Y', time())) {
1931 $start = $a_selected;
1932 } else {
1933 $start = date('Y', time());
1934 }
1935
1936 for ($i = $start;$i < date("Y", time()) + 11;++$i) {
1937 $year[$i] = $i;
1938 }
1939 return ilUtil::formSelect($a_selected, $a_varname, $year, false, true);
1940 }
1941 }
1942
1943 public function __toUnix($a_time_arr)
1944 {
1945 return mktime(
1946 $a_time_arr["hour"],
1947 $a_time_arr["minute"],
1948 $a_time_arr["second"],
1949 $a_time_arr["month"],
1950 $a_time_arr["day"],
1951 $a_time_arr["year"]
1952 );
1953 }
1954
1955
1956
1957
1958 public function __unsetSessionVariables()
1959 {
1960 unset($_SESSION["filtered_roles"]);
1961 }
1962
1963 public function __buildFilterSelect()
1964 {
1965 $action[0] = $this->lng->txt('assigned_roles');
1966 $action[1] = $this->lng->txt('all_roles');
1967 $action[2] = $this->lng->txt('all_global_roles');
1968 $action[3] = $this->lng->txt('all_local_roles');
1969 $action[4] = $this->lng->txt('internal_local_roles_only');
1970 $action[5] = $this->lng->txt('non_internal_local_roles_only');
1971
1972 return ilUtil::formSelect($_SESSION['filtered_roles'], "filter", $action, false, true);
1973 }
1974
1975 public function hitsperpageObject()
1976 {
1977 parent::hitsperpageObject();
1978 $this->roleassignmentObject();
1979 }
1980
1985 public function addAdminLocatorItems($a_do_not_add_object = false)
1986 {
1987 global $DIC;
1988
1989 $ilLocator = $DIC['ilLocator'];
1990
1991 $ilLocator->clearItems();
1992
1993 if ($_GET["admin_mode"] == "settings") { // system settings
1994 $this->ctrl->setParameterByClass(
1995 "ilobjsystemfoldergui",
1996 "ref_id",
1998 );
1999 $ilLocator->addItem(
2000 $this->lng->txt("administration"),
2001 $this->ctrl->getLinkTargetByClass(array("iladministrationgui", "ilobjsystemfoldergui"), ""),
2002 ilFrameTargetInfo::_getFrame("MainContent")
2003 );
2004
2005 if ($_GET['ref_id'] == USER_FOLDER_ID) {
2006 $ilLocator->addItem(
2007 $this->lng->txt("obj_" . ilObject::_lookupType(
2008 ilObject::_lookupObjId($_GET["ref_id"])
2009 )),
2010 $this->ctrl->getLinkTargetByClass("ilobjuserfoldergui", "view")
2011 );
2012 } elseif ($_GET['ref_id'] == ROLE_FOLDER_ID) {
2013 $ilLocator->addItem(
2014 $this->lng->txt("obj_" . ilObject::_lookupType(
2015 ilObject::_lookupObjId($_GET["ref_id"])
2016 )),
2017 $this->ctrl->getLinkTargetByClass("ilobjrolefoldergui", "view")
2018 );
2019 }
2020
2021 if ($_GET["obj_id"] > 0) {
2022 $ilLocator->addItem(
2023 $this->object->getTitle(),
2024 $this->ctrl->getLinkTarget($this, "view")
2025 );
2026 }
2027 } else { // repository administration
2028 // ?
2029 }
2030 }
2031
2032 public function showUpperIcon()
2033 {
2034 }
2035
2036 public function __sendProfileMail()
2037 {
2038 global $DIC;
2039
2040 $ilUser = $DIC['ilUser'];
2041 $ilias = $DIC['ilias'];
2042
2043 if ($_POST['send_mail'] != 'y') {
2044 return '';
2045 }
2046 if (!strlen($this->object->getEmail())) {
2047 return '';
2048 }
2049
2050 // Choose language of user
2051 $usr_lang = new ilLanguage($this->object->getLanguage());
2052 $usr_lang->loadLanguageModule('crs');
2053 $usr_lang->loadLanguageModule('registration');
2054
2055 include_once "Services/Mail/classes/class.ilMimeMail.php";
2056
2058 $senderFactory = $GLOBALS['DIC']["mail.mime.sender.factory"];
2059
2060 $mmail = new ilMimeMail();
2061 $mmail->From($senderFactory->system());
2062
2063 $mailOptions = new \ilMailOptions($this->object->getId());
2064 $mmail->To($mailOptions->getExternalEmailAddresses());
2065
2066 // mail subject
2067 $subject = $usr_lang->txt("profile_changed");
2068
2069
2070 // mail body
2071 $body = $usr_lang->txt("reg_mail_body_salutation")
2072 . " " . $this->object->getFullname() . ",\n\n";
2073
2074 $date = $this->object->getApproveDate();
2075 // Approve
2076 if ((time() - strtotime($date)) < 10) {
2077 $body .= $usr_lang->txt('reg_mail_body_approve') . "\n\n";
2078 } else {
2079 $body .= $usr_lang->txt('reg_mail_body_profile_changed') . "\n\n";
2080 }
2081
2082 // Append login info only if password has been chacnged
2083 if ($_POST['passwd'] != '') {
2084 $body .= $usr_lang->txt("reg_mail_body_text2") . "\n" .
2085 ILIAS_HTTP_PATH . "/login.php?client_id=" . $ilias->client_id . "\n" .
2086 $usr_lang->txt("login") . ": " . $this->object->getLogin() . "\n" .
2087 $usr_lang->txt("passwd") . ": " . $_POST['passwd'] . "\n\n";
2088 }
2089 $body .= $usr_lang->txt("reg_mail_body_text3") . "\n";
2090 $body .= $this->object->getProfileAsString($usr_lang);
2092
2093
2094 $mmail->Subject($subject, true);
2095 $mmail->Body($body);
2096 $mmail->Send();
2097
2098
2099 return "<br/>" . $this->lng->txt("mail_sent");
2100 }
2101
2105 public static function _goto($a_target)
2106 {
2107 global $DIC;
2108
2109 $ilUser = $DIC['ilUser'];
2110
2112 $ilCtrl = $DIC['ilCtrl'];
2113
2114 if (strstr($a_target, ilPersonalProfileGUI::CHANGE_EMAIL_CMD) === $a_target
2115 && $ilUser->getId() !== ANONYMOUS_USER_ID) {
2116 $class = ilPersonalProfileGUI::class;
2118 $ilCtrl->clearParametersByClass($class);
2119 $ilCtrl->setParameterByClass($class, 'token', str_replace($cmd, '', $a_target));
2120 $ilCtrl->redirectByClass(['ildashboardgui', $class], $cmd);
2121 }
2122
2123 // #10888
2124 if ($a_target == md5("usrdelown")) {
2125 if ($ilUser->getId() != ANONYMOUS_USER_ID &&
2126 $ilUser->hasDeletionFlag()) {
2127 $ilCtrl->initBaseClass("ildashboardgui");
2128 $ilCtrl->redirectByClass(['ildashboardgui', 'ilpersonalsettingsgui'], "deleteOwnAccount3");
2129 }
2130 exit("This account is not flagged for deletion."); // #12160
2131 }
2132
2133 // badges
2134 if (substr($a_target, -4) == "_bdg") {
2135 $_GET["baseClass"] = "ilDashboardGUI";
2136 $_GET["cmd"] = "jumpToBadges";
2137 include("ilias.php");
2138 exit();
2139 }
2140
2141 if ('registration' == $a_target) {
2142 $_GET["baseClass"] = 'ilStartUpGUI';
2143 $ilCtrl->redirectByClass(array('ilStartUpGUI', 'ilAccountRegistrationGUI'), '');
2144 } elseif ('nameassist' == $a_target) {
2145 $_GET["baseClass"] = 'ilStartUpGUI';
2146 $ilCtrl->redirectByClass(array('ilStartUpGUI', 'ilPasswordAssistanceGUI'), 'showUsernameAssistanceForm');
2147 } elseif ('pwassist' == $a_target) {
2148 $_GET["baseClass"] = 'ilStartUpGUI';
2149 $ilCtrl->redirectByClass(array('ilStartUpGUI', 'ilPasswordAssistanceGUI'), '');
2150 } elseif ('agreement' == $a_target) {
2151 if ($ilUser->getId() > 0 && !$ilUser->isAnonymous()) {
2152 $ilCtrl->setTargetScript('ilias.php');
2153 $ilCtrl->initBaseClass('ildashboardgui');
2154 $ilCtrl->redirectByClass(array('ildashboardgui', 'ilpersonalprofilegui'), 'showUserAgreement');
2155 } else {
2156 $_GET['baseClass'] = 'ilStartUpGUI';
2157 $ilCtrl->setTargetScript('ilias.php');
2158 $ilCtrl->redirectByClass(array('ilStartUpGUI'), 'showTermsOfService');
2159 }
2160 }
2161
2162 if (substr($a_target, 0, 1) == "n") {
2163 $a_target = ilObjUser::_lookupId(ilUtil::stripSlashes(substr($a_target, 1)));
2164 }
2165
2166 if (strpos($a_target, 'contact_approved') !== false) {
2167 $_GET['cmd'] = 'approveContactRequest';
2168 } elseif (strpos($a_target, 'contact_ignored') !== false) {
2169 $_GET['cmd'] = 'ignoreContactRequest';
2170 } else {
2171 $_GET['cmd'] = 'view';
2172 }
2173
2174 $_GET["user_id"] = (int) $a_target;
2175 $_GET["baseClass"] = "ilPublicUserProfileGUI";
2176 $_GET["cmdClass"] = "ilpublicuserprofilegui";
2177 include("ilias.php");
2178 exit;
2179 }
2180
2189 protected function handleIgnoredRequiredFields()
2190 {
2191 $profile_maybe_incomplete = false;
2192
2193 require_once 'Services/User/classes/class.ilUserProfile.php';
2194
2195 foreach (ilUserProfile::getIgnorableRequiredSettings() as $fieldName) {
2196 $elm = $this->form_gui->getItemByPostVar($fieldName);
2197
2198 if (!$elm) {
2199 continue;
2200 }
2201
2202 if ($elm->getRequired()) {
2203 $profile_maybe_incomplete = true;
2204
2205 // Flag as optional
2206 $elm->setRequired(false);
2207 }
2208 }
2209
2210 include_once 'Services/User/classes/class.ilUserDefinedFields.php';
2211 $user_defined_fields = ilUserDefinedFields::_getInstance();
2212 foreach ($user_defined_fields->getDefinitions() as $field_id => $definition) {
2213 $elm = $this->form_gui->getItemByPostVar('udf_' . $definition['field_id']);
2214
2215 if (!$elm) {
2216 continue;
2217 }
2218 if ($elm->getRequired() && $definition['required']) {
2219 $profile_maybe_incomplete = true;
2220
2221 // Flag as optional
2222 $elm->setRequired(false);
2223 }
2224 }
2225
2226 return $profile_maybe_incomplete;
2227 }
2228
2232 protected function showAcceptedTermsOfService()
2233 {
2235 $agreeDate = $this->form_gui->getItemByPostVar('agree_date');
2236 if ($agreeDate && $agreeDate->getValue()) {
2237 $this->lng->loadLanguageModule('tos');
2238 $helper = new \ilTermsOfServiceHelper();
2239
2240 $entity = $helper->getCurrentAcceptanceForUser($this->object);
2241 if ($entity->getId()) {
2242 $modal = $this->uiFactory
2243 ->modal()
2244 ->lightbox([
2245 $this->uiFactory->modal()->lightboxTextPage($entity->getText(), $entity->getTitle())
2246 ]);
2247
2248 $titleLink = $this->uiFactory
2249 ->button()
2250 ->shy($entity->getTitle(), '#')
2251 ->withOnClick($modal->getShowSignal());
2252
2253 $agreementDocument = new ilNonEditableValueGUI(
2254 $this->lng->txt('tos_agreement_document'),
2255 '',
2256 true
2257 );
2258 $agreementDocument->setValue($this->uiRenderer->render([$titleLink, $modal]));
2259 $agreeDate->addSubItem($agreementDocument);
2260 }
2261 } elseif ($agreeDate) {
2262 $agreeDate->setValue($this->lng->txt('tos_not_accepted_yet'));
2263 }
2264 }
2265} // END class.ilObjUserGUI
user()
Definition: user.php:4
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
$_GET["client_id"]
$_POST["username"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATE
const IL_CAL_UNIX
const IL_CAL_DATETIME
const IL_PASSWD_PLAIN
const UDF_TYPE_TEXT
Class ilAccountMail.
static getAuthModeTranslation($a_auth_key, $auth_name='')
static _allowPasswordModificationByAuthMode($a_auth_mode)
Allow password modification.
static _getAuthMode($a_auth_mode, $a_db_handler='')
static _getActiveAuthModes()
static _isExternalAccountEnabled()
Check if an external account name is required.
static _getAuthModeName($a_auth_key)
This class represents a text property in a property form.
This class represents a checkbox property in a property form.
This class represents a selection list property in a property form.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
This class represents a date/time property in a property form.
@classDescription Date and time handling
Class for single dates.
This class represents a email property in a property form.
This class represents a property in a property form.
This class represents a section header in a property form.
static _getFrame($a_class, $a_type='')
Get content frame name.
This class represents an image file property in a property form.
language handling
Class ilObjUserTrackingGUI.
static _getInstallationSignature()
Class ilMimeMail.
This class represents a non editable value in a property form.
static _getAssignUsersStatus($a_role_id)
Class ilObjUserGUI.
saveObject()
save user data @access public
setBackTarget($a_text, $a_link)
set back tab target
__getDateSelect($a_type, $a_varname, $a_selected)
getAdminTabs()
admin and normal tabs are equal for roles
handleIgnoredRequiredFields()
Handles ignored required fields by changing the required flag of form elements.
applyFilterObject()
Apply filter.
cancelObject()
cancel action and go back to previous page @access public
__toUnix($a_time_arr)
resetFilterObject()
Reset filter.
updateObject()
Update user.
addAdminLocatorItems($a_do_not_add_object=false)
should be overwritten to add object specific items (repository items are preloaded)
roleassignmentObject()
display roleassignment panel
__construct( $a_data, $a_id, $a_call_by_reference=false, $a_prepare_output=true, ILIAS\UI\Factory $uiFactory=null, ILIAS\UI\Renderer $uiRenderer=null)
ilObjUserGUI constructor.
uploadUserPictureObject()
upload user image
loadValuesFromForm($a_mode='create')
removeUserPictureObject()
remove user image
createObject()
Display user create form.
getValues()
Get values from user object and put them into form.
assignSaveObject()
assign users to role
setTitleAndDescription()
called by prepare output
isSettingChangeable($a_field)
Check if setting is visible This is the case when called from user folder.
executeCommand()
execute command
__checkUserDefinedRequiredFields()
display user create form
static _enabledLearningProgress()
check wether learing progress is enabled or not
static _enabledUserRelatedData()
check wether user related tracking is enabled or not
static _resetLoginAttempts($a_usr_id)
static _getLastHistoryDataByUserId($a_usr_id)
Returns the last used loginname and the changedate of the passed user_id.
static _lookupLogin($a_user_id)
lookup login
static _getPersonalPicturePath( $a_usr_id, $a_size="small", $a_force_pic=false, $a_prevent_no_photo_image=false, $html_export=false)
Get path to personal picture.
static _lookupId($a_user_str)
Lookup id by login.
Class ilObjectGUI Basic methods of all Output classes.
prepareOutput($a_show_subobjects=true)
prepare output
editObject()
edit object
Class ilObjectOwnershipManagementGUI.
static _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
This class represents a password property in a property form.
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
TableGUI class for role assignment in user administration.
This class represents a selection list property in a property form.
static clear($a_var)
Unset a value.
static _lookupActivatedStyle($a_skin, $a_style)
lookup if a style is activated
This class represents a text area property in a property form.
This class represents a text property in a property form.
static _getInstance()
Get instance.
Class for user related exception handling in ILIAS.
This class represents a user login property in a property form.
static getIgnorableRequiredSettings()
Returns an array of all ignorable profiel fields.
static isProfileIncomplete($a_user, $a_include_udf=true, $a_personal_data_only=true)
Check if all required personal data fields are set.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static isConvertVersionAtLeast($a_version)
Compare convert version numbers.
static escapeShellArg($a_arg)
static getWebspaceDir($mode="filesystem")
get webspace directory
static execConvert($args)
execute convert command
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static getPasswordRequirementsInfo()
infotext for ilPasswordInputGUI setInfo()
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static yn2tf($a_yn)
convert "y"/"n" to true/false
static formSelect( $selected, $varname, $options, $multiple=false, $direct_text=false, $size="0", $style_class="", $attribs="", $disabled=false)
Builds a select form field with options and shows the selected option first.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
const SYSTEM_ROLE_ID
Definition: constants.php:27
const ANONYMOUS_ROLE_ID
Definition: constants.php:26
const USER_FOLDER_ID
Definition: constants.php:31
const SYSTEM_USER_ID
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: constants.php:24
const ANONYMOUS_USER_ID
Definition: constants.php:25
const SYSTEM_FOLDER_ID
Definition: constants.php:33
const ROLE_FOLDER_ID
Definition: constants.php:32
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
exit
Definition: login.php:29
if($format !==null) $name
Definition: metadata.php:230
$i
Definition: metadata.php:24
$keys
Definition: metadata.php:187
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
redirection script todo: (a better solution should control the processing via a xml file)
global $ilSetting
Definition: privfeed.php:17
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
$lang
Definition: xapiexit.php:8