ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilCourseEditParticipantsTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=0);
26{
30
32 protected ilObjUser $user;
33
42 private array $localCourseRoles;
43
44 public function __construct(object $a_parent_obj, ilObjCourse $rep_object)
45 {
46 global $DIC;
47
48 $this->rep_object = $rep_object;
49 $this->privacy = ilPrivacySettings::getInstance();
50 $this->participants = ilCourseParticipants::_getInstanceByObjId($this->rep_object->getId());
51
52 $this->access = $DIC->access();
53 $this->user = $DIC->user();
54
55 parent::__construct($a_parent_obj, 'editMembers');
56 $this->lng->loadLanguageModule('crs');
57 $this->setFormName('participants');
58 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
59
60 $this->addColumn($this->lng->txt('name'), 'name', '20%');
61 $this->addColumn($this->lng->txt('login'), 'login', '25%');
62
63 if ($this->privacy->enabledCourseAccessTimes()) {
64 $this->addColumn($this->lng->txt('last_access'), 'access_time');
65 }
66 $this->addColumn($this->lng->txt('crs_passed'), 'passed');
67 $this->addColumn($this->lng->txt('crs_blocked'), 'blocked');
68 $this->addColumn($this->lng->txt('crs_mem_contact'), 'contact');
69 $this->addColumn($this->lng->txt('crs_notification'), 'notification');
70 $this->addColumn($this->lng->txt('objs_role'), 'roles');
71
72 $this->addCommandButton('updateParticipants', $this->lng->txt('save'));
73 $this->addCommandButton('participants', $this->lng->txt('cancel'));
74 $this->setRowTemplate("tpl.edit_participants_row.html", "components/ILIAS/Course");
75 $this->disable('sort');
76 $this->enable('header');
77 $this->enable('numinfo');
78 $this->disable('select_all');
79
80 // Performance improvement: We read the local course roles
81 // only once, instead of reading them for each row in method fillRow().
82 $this->localCourseRoles = array();
83 foreach ($this->rep_object->getLocalCourseRoles(false) as $title => $role_id) {
84 $this->localCourseRoles[ilObjRole::_getTranslation($title)] = array('role_id' => $role_id,
85 'title' => $title
86 );
87 }
88 }
89
90 protected function fillRow(array $a_set): void
91 {
92 $hasEditPermissionAccess =
93 (
94 $this->access->checkAccess('edit_permission', '', $this->rep_object->getRefId()) || $this->participants->isAdmin($this->user->getId())
95 );
96
97 $this->tpl->setVariable('VAL_ID', $a_set['usr_id']);
98 $this->tpl->setVariable('VAL_NAME', $a_set['lastname'] . ', ' . $a_set['firstname']);
99
100 $this->tpl->setVariable('VAL_LOGIN', $a_set['login']);
101
102 if ($this->privacy->enabledCourseAccessTimes()) {
103 $this->tpl->setVariable('VAL_ACCESS', $a_set['access_time']);
104 }
105 $this->tpl->setVariable('VAL_CONTACT_CHECKED', $a_set['contact'] ? 'checked="checked"' : '');
106 $this->tpl->setVariable('VAL_NOTIFICATION_CHECKED', $a_set['notification'] ? 'checked="checked"' : '');
107 $this->tpl->setVariable('VAL_PASSED_CHECKED', $a_set['passed'] ? 'checked="checked"' : '');
108 $this->tpl->setVariable('VAL_BLOCKED_CHECKED', $a_set['blocked'] ? 'checked="checked"' : '');
109
110 $this->tpl->setVariable('NUM_ROLES', count($this->participants->getRoles()));
111
112 $assigned = $this->participants->getAssignedRoles($a_set['usr_id']);
113 foreach ($this->localCourseRoles as $localizedTitle => $roleData) {
114 if ($hasEditPermissionAccess || substr($roleData['title'], 0, 12) != 'il_crs_admin') {
115 $this->tpl->setCurrentBlock('roles');
116 $this->tpl->setVariable('ROLE_ID', $roleData['role_id']);
117 $this->tpl->setVariable('ROLE_NAME', $localizedTitle);
118
119 if (in_array($roleData['role_id'], $assigned)) {
120 $this->tpl->setVariable('ROLE_CHECKED', 'selected="selected"');
121 }
122 $this->tpl->parseCurrentBlock();
123 }
124 }
125 }
126}
array $localCourseRoles
Holds the local roles of the course object.
fillRow(array $a_set)
Standard Version of Fill Row.
__construct(object $a_parent_obj, ilObjCourse $rep_object)
static _getInstanceByObjId(int $a_obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getTranslation(string $a_role_title)
User class.
Singleton class that stores all privacy settings.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
setFormName(string $a_name="")
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
enable(string $a_module_name)
disable(string $a_module_name)
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26