ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilContributorTableGUI.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
26 {
28  protected array $local_roles = [];
29  protected array $contributor_ids = [];
30 
31  public function __construct(
32  ilRbacReview $rbacreview,
33  object $a_parent_obj,
34  string $a_parent_cmd,
35  array $a_roles
36  ) {
37  $this->local_roles = $a_roles;
38  $this->rbacreview = $rbacreview;
39 
40  parent::__construct($a_parent_obj, $a_parent_cmd);
41 
42  $this->addColumn("", "", "1");
43  $this->addColumn($this->lng->txt("name"), "name");
44  $this->addColumn($this->lng->txt("obj_role"), "role");
45 
46  $this->setDefaultOrderField("name");
47 
48  $this->setRowTemplate("tpl.contributor_row.html", "Modules/Blog");
49  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
50 
51  $this->setSelectAllCheckbox("id"); // #16472
52 
53  if ($this->contributor_ids) {
54  $this->setTitle($this->lng->txt("blog_contributor_container_add"));
55  $this->addMultiCommand("addContributorContainerAction", $this->lng->txt("add"));
56  } else {
57  $this->setTitle($this->lng->txt("blog_contributors"));
58  $this->addMultiCommand("confirmRemoveContributor", $this->lng->txt("remove"));
59  }
60 
61  $this->getItems();
62  }
63 
64  protected function getItems(): void
65  {
66  $rbacreview = $this->rbacreview;
67 
68  $user_map = $assigned = array();
69  foreach ($this->local_roles as $id => $title) {
70  $local = $rbacreview->assignedUsers($id);
71  $assigned = array_merge($assigned, $local);
72  foreach ($local as $user_id) {
73  $user_map[$user_id][] = $title;
74  }
75  }
76 
77  $data = array();
78  foreach (array_unique($assigned) as $id) {
79  $data[] = array("id" => $id,
80  "name" => ilUserUtil::getNamePresentation($id, false, false, "", true),
81  "role" => $user_map[$id]);
82  }
83 
84  $this->setData($data);
85  }
86 
87  protected function fillRow(array $a_set): void
88  {
89  $this->tpl->setVariable("VAL_ID", $a_set["id"]);
90  $this->tpl->setVariable("TXT_NAME", $a_set["name"]);
91  $this->tpl->setVariable("TXT_ROLES", implode(", ", $a_set["role"]));
92  }
93 }
setData(array $a_data)
__construct(ilRbacReview $rbacreview, object $a_parent_obj, string $a_parent_cmd, array $a_roles)
assignedUsers(int $a_rol_id)
get all assigned users to a given role
setFormAction(string $a_form_action, bool $a_multipart=false)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
__construct(VocabulariesInterface $vocabularies)
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path='ilpublicuserprofilegui')
Default behaviour is:
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
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)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addMultiCommand(string $a_cmd, string $a_text)