ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilRepositoryObjectResultTableGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
30 {
31  protected ilRbacAdmin $admin;
32 
33  protected ilRbacReview $review;
34 
35  public function __construct($a_parent_obj, $a_parent_cmd, $a_allow_object_selection = false)
36  {
37  global $DIC;
38 
39  $this->setId("group_table");
40 
41  parent::__construct($a_parent_obj, $a_parent_cmd);
42 
43  $this->admin = $DIC->rbac()->admin();
44  $this->review = $DIC->rbac()->review();
45 
46  $this->addColumn("", "", "1", true);
47  $this->addColumn($this->lng->txt("title"), "title", "80%");
48  $this->addColumn($this->lng->txt("members"), "member", "20%");
49 
50  $this->setFormAction($this->ctrl->getFormAction($this->parent_obj));
51  $this->setRowTemplate("tpl.rep_search_obj_result_row.html", "Services/Search");
52  $this->setTitle($this->lng->txt('search_results'));
53  $this->setEnableTitle(true);
54  $this->setDefaultOrderField("title");
55  $this->setDefaultOrderDirection("asc");
56  $this->enable('select_all');
57  $this->setSelectAllCheckbox("obj[]");
58 
59  switch ($this->parent_obj->getSearchType()) {
60  case 'grp':
61  case 'crs':
62  if ($this->parent_obj->getRoleCallback()) {
63  $this->addMultiCommand('addRole', $this->lng->txt('add_member_role'));
64  }
65  $this->addMultiCommand('listUsers', $this->lng->txt('grp_list_members'));
66  break;
67 
68  case 'role':
69  if ($this->parent_obj->getRoleCallback()) {
70  $this->addMultiCommand('addRole', $this->lng->txt('add_role'));
71  }
72  $this->addMultiCommand('listUsers', $this->lng->txt('grp_list_users'));
73  break;
74  }
75 
76  if ($a_allow_object_selection) {
77  $this->addMultiCommand('selectObject', $this->lng->txt('grp_select_object'));
78  }
79  }
80 
85  protected function fillRow(array $a_set): void
86  {
87  /*
88  TODO: Checkboxes must be always enabled now because of role assignment. An alternative to pretend showing
89  an empty list of users could be a warning message
90  */
91  //if($row['member'])
92  //{
93  $this->tpl->setVariable('VAL_ID', $a_set['id']);
94  //}
95  $this->tpl->setVariable('VAL_TITLE', $a_set['title']);
96  if (strlen($a_set['desc'])) {
97  $this->tpl->setVariable('VAL_DESC', $a_set['desc']);
98  }
99  $this->tpl->setVariable('VAL_MEMBER', $a_set['member']);
100  }
101 
102 
103  public function parseObjectIds(array $a_ids): void
104  {
105  $data = [];
106  foreach ($a_ids as $object_id) {
107  $row = array();
108  $type = ilObject::_lookupType($object_id);
109 
110  if ($type == 'role') {
111  if ($this->review->isRoleDeleted($object_id)) {
112  continue;
113  }
114  }
115 
116 
117  $row['title'] = ilObject::_lookupTitle($object_id);
118  $row['desc'] = ilObject::_lookupDescription($object_id);
119  $row['id'] = $object_id;
120 
121  switch ($type) {
122 
123  case 'crs':
124  case 'grp':
126  $row['member'] = count(ilParticipants::getInstanceByObjId($object_id)->getParticipants());
127  } else {
128  $row['member'] = 0;
129  }
130  break;
131 
132  case 'role':
133  $row['member'] = count(ilUserFilter::getInstance()->filter($this->review->assignedUsers($object_id)));
134  break;
135  }
136 
137  $data[] = $row;
138  }
139  $this->setData($data);
140  }
141 
145  public function numericOrdering(string $a_field): bool
146  {
147  if ($a_field == "member") {
148  return true;
149  }
150  return false;
151  }
152 }
setData(array $a_data)
enable(string $a_module_name)
setFormAction(string $a_form_action, bool $a_multipart=false)
$type
setEnableTitle(bool $a_enabletitle)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
static getInstanceByObjId(int $a_obj_id)
Get instance by obj type.
__construct($a_parent_obj, $a_parent_cmd, $a_allow_object_selection=false)
setId(string $a_val)
global $DIC
Definition: feed.php:28
static _lookupTitle(int $obj_id)
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setDefaultOrderDirection(string $a_defaultorderdirection)
static _lookupDescription(int $obj_id)
static hasParticipantListAccess(int $a_obj_id, int $a_usr_id=null)
Check if (current) user has access to the participant list.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
TableGUI class object (course,group and role) search results Used in member search.
__construct(Container $dic, ilPlugin $plugin)
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)
Class ilRbacAdmin Core functions for role based access control.
static _lookupType(int $id, bool $reference=false)
addMultiCommand(string $a_cmd, string $a_text)