ILIAS  trunk Revision v11.0_alpha-1689-g66c127b4ae8
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilContSkillMemberTableGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
23 
30 {
32  protected UIServices $ui;
34 
35  public function __construct(ilContSkillAdminGUI $a_parent_obj, string $a_parent_cmd, ilContainer $cont_obj)
36  {
37  global $DIC;
38 
39  $this->ctrl = $DIC->ctrl();
40  $this->lng = $DIC->language();
41  $this->tpl = $DIC["tpl"];
42  $this->ui = $DIC->ui();
43 
44  $this->cont_obj = $cont_obj;
45  $this->setId("cont_skll_mem_" . $this->cont_obj->getId());
46  $this->cont_skill_manager = $DIC->skills()->internalContainer()->manager()->getSkillManager(
47  $this->cont_obj->getId(),
48  $this->cont_obj->getRefId()
49  );
50 
51  parent::__construct($a_parent_obj, $a_parent_cmd);
52  $this->setData($this->getMembers());
53  $this->setTitle($this->lng->txt("cont_cont_skills"));
54 
55  $this->addColumn("", "", "1", true);
56  $this->addColumn($this->lng->txt("name"), "name");
57  $this->addColumn($this->lng->txt("login"), "login");
58  $this->addColumn($this->lng->txt("cont_mem_skills"), "");
59  $this->addColumn($this->lng->txt("cont_published"), "");
60  $this->addColumn($this->lng->txt("actions"));
61 
62  $this->setDefaultOrderField("name");
63  $this->setDefaultOrderDirection("asc");
64  $this->setSelectAllCheckbox("usr_ids");
65 
66  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
67  $this->setRowTemplate("tpl.cont_member_skill_row.html", "components/ILIAS/Container/Skills");
68 
69  if (ilContainer::_lookupContainerSetting($this->cont_obj->getId(), "cont_skill_publish", '0')) {
70  $this->addMultiCommand("publishAssignments", $this->lng->txt("cont_publish_assignment"));
71  }
72  $this->addMultiCommand("deassignCompetencesConfirm", $this->lng->txt("cont_deassign_competence"));
73  }
74 
75  public function getMembers(): array
76  {
77  $p = ilCourseParticipants::getInstanceByObjId($this->cont_obj->getId());
78 
79  $members = [];
80  foreach ($p->getMembers() as $m) {
81  $name = ilObjUser::_lookupName($m);
82  $members[] = [
83  "id" => $m,
84  "name" => $name["lastname"] . ", " . $name["firstname"],
85  "login" => $name["login"],
86  "skills" => []
87  ];
88  }
89  return $members;
90  }
91 
92  protected function fillRow(array $a_set): void
93  {
94  $tpl = $this->tpl;
96  $lng = $this->lng;
97  $ui = $this->ui;
98 
99  $user_id = (int) $a_set["id"];
100 
101  // levels
102  foreach ($this->cont_skill_manager->getMemberSkillLevelsForContainerOrdered($user_id) as $sk) {
103  $tpl->setCurrentBlock("level");
104  $tpl->setVariable("TXT_SKILL", ilBasicSkill::_lookupTitle($sk->getBaseSkillId(), $sk->getTrefId()));
105  $tpl->setVariable("TXT_LEVEL", ilBasicSkill::lookupLevelTitle($sk->getLevelId()));
106  $tpl->setVariable("PATH", $this->getParentObject()->getPathString($sk->getBaseSkillId(), $sk->getTrefId()));
107  $tpl->parseCurrentBlock();
108  }
109 
110  // published
111  if ($this->cont_skill_manager->getPublished($user_id)) {
112  $tpl->setVariable("PUBLISHED", $lng->txt("yes"));
113  } else {
114  $tpl->setVariable("PUBLISHED", $lng->txt("no"));
115  }
116 
117 
118  $tpl->setVariable("NAME", $a_set["name"]);
119  $tpl->setVariable("ID", $a_set["id"]);
120  $tpl->setVariable("LOGIN", $a_set["login"]);
121 
122  $ctrl->setParameter($this->parent_obj, "usr_id", $a_set["id"]);
123 
124  $items = [];
125  $b = $ui->factory()->button();
126  if (!$this->cont_skill_manager->getPublished($user_id) || (!ilContainer::_lookupContainerSetting($this->cont_obj->getId(), "cont_skill_publish", '0'))) {
127  $items[] = $b->shy($lng->txt("cont_assign_competence"), $ctrl->getLinkTarget($this->parent_obj, "assignCompetences"));
128  }
129  if (!$this->cont_skill_manager->getPublished($user_id)) {
130  $items[] = $b->shy($lng->txt("cont_publish_assignment"), $ctrl->getLinkTarget($this->parent_obj, "publishAssignments"));
131  }
132  $items[] = $b->shy($lng->txt("cont_deassign_competence"), $ctrl->getLinkTarget($this->parent_obj, "deassignCompetencesConfirm"));
133  $dd = $ui->factory()->dropdown()->standard($items);
134 
135  $tpl->setVariable("ACTIONS", $ui->renderer()->render($dd));
136  }
137 }
setData(array $a_data)
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
setFormAction(string $a_form_action, bool $a_multipart=false)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
static getInstanceByObjId(int $a_obj_id)
Get instance by obj type.
getLinkTarget(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
static _lookupTitle(int $a_obj_id, int $a_tref_id=0)
static _lookupName(int $a_user_id)
lookup user name
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static lookupLevelTitle(int $a_id)
TableGUI class for container members / skill assignments.
ilLanguage $lng
setId(string $a_val)
Provides fluid interface to RBAC services.
Definition: UIServices.php:24
setDefaultOrderField(string $a_defaultorderfield)
renderer()
Get a renderer for UI components.
Definition: UIServices.php:44
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
__construct(ilContSkillAdminGUI $a_parent_obj, string $a_parent_cmd, ilContainer $cont_obj)
global $DIC
Definition: shib_login.php:22
setDefaultOrderDirection(string $a_defaultorderdirection)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
Container skills administration.
__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)
factory()
Get the factory that crafts UI components.
Definition: UIServices.php:36
static _lookupContainerSetting(int $a_id, string $a_keyword, ?string $a_default_value=null)
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
addMultiCommand(string $a_cmd, string $a_text)