ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilContProfileTableGUI.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
25 
34 {
38  protected $tpl;
39  protected Factory $ui_factory;
43  protected int $cont_member_role_id = 0;
44 
45  public function __construct(
46  $a_parent_obj,
47  string $a_parent_cmd,
48  int $cont_ref_id
49  ) {
50  global $DIC;
51 
52  $this->ctrl = $DIC->ctrl();
53  $this->lng = $DIC->language();
54  $this->tpl = $DIC["tpl"];
55  $this->ui_factory = $DIC->ui()->factory();
56  $this->ui_renderer = $DIC->ui()->renderer();
57 
58  $this->skmg_settings = new ilSkillManagementSettings();
59  $this->profile_service = $DIC->skills()->profile();
60  $this->cont_member_role_id = ilParticipants::getDefaultMemberRole($cont_ref_id);
61 
62  parent::__construct($a_parent_obj, $a_parent_cmd);
63  $this->setData($this->getProfiles());
64  $this->setTitle($this->lng->txt("cont_skill_ass_profiles"));
65 
66  $this->addColumn("", "", "1", true);
67  $this->addColumn($this->lng->txt("cont_skill_profile"), "", "1");
68  $this->addColumn($this->lng->txt("context"), "", "1");
69  $this->addColumn($this->lng->txt("actions"), "", "1");
70 
71  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
72  $this->setRowTemplate("tpl.cont_profile_row.html", "Services/Container/Skills");
73  $this->setSelectAllCheckbox("id");
74 
75  if ($this->skmg_settings->getLocalAssignmentOfProfiles()) {
76  $this->addMultiCommand("confirmRemoveSelectedGlobalProfiles", $this->lng->txt("remove"));
77  }
78  if ($this->skmg_settings->getAllowLocalProfiles()) {
79  $this->addMultiCommand("confirmDeleteSelectedLocalProfiles", $this->lng->txt("delete"));
80  }
81  }
82 
83  public function getProfiles(): array
84  {
85  $profiles = [];
86  if ($this->skmg_settings->getLocalAssignmentOfProfiles()) {
87  foreach ($this->profile_service->getGlobalProfilesOfRole($this->cont_member_role_id) as $gp) {
88  $profiles[] = $gp;
89  }
90  }
91  if ($this->skmg_settings->getAllowLocalProfiles()) {
92  foreach ($this->profile_service->getLocalProfilesOfRole($this->cont_member_role_id) as $lp) {
93  $profiles[] = $lp;
94  }
95  }
96 
97  // convert profiles to array structure, because tables can only handle arrays
98  $profiles_array = [];
99  foreach ($profiles as $profile) {
100  $profiles_array[$profile->getId()] = [
101  "profile_id" => $profile->getId(),
102  "title" => $profile->getTitle(),
103  ];
104  }
105  ksort($profiles_array);
106 
107  return $profiles_array;
108  }
109 
110  protected function fillRow(array $a_set): void
111  {
112  $tpl = $this->tpl;
113  $ctrl = $this->ctrl;
114  $lng = $this->lng;
115  $ui_factory = $this->ui_factory;
116  $ui_renderer = $this->ui_renderer;
117 
118  $tpl->setVariable("TITLE", $a_set["title"]);
119  $tpl->setVariable("ID", $a_set["profile_id"]);
120 
121  if ($this->profile_service->lookupProfileRefId($a_set["profile_id"]) > 0) {
122  $tpl->setVariable("CONTEXT", $lng->txt("skmg_context_local"));
123  } else {
124  $tpl->setVariable("CONTEXT", $lng->txt("skmg_context_global"));
125  }
126 
127  $ctrl->setParameter($this->parent_obj, "profile_id", $a_set["profile_id"]);
128  $ctrl->setParameterByClass("ilskillprofilegui", "sprof_id", $a_set["profile_id"]);
129  $ctrl->setParameterByClass("ilskillprofilegui", "local_context", true);
130 
131  if ($this->profile_service->lookupProfileRefId($a_set["profile_id"]) > 0) {
132  $items = [
133  $ui_factory->link()->standard(
134  $lng->txt("edit"),
135  $ctrl->getLinkTargetByClass("ilskillprofilegui", "showLevelsWithLocalContext")
136  ),
137  $ui_factory->link()->standard(
138  $lng->txt("delete"),
139  $ctrl->getLinkTarget($this->parent_obj, "confirmDeleteSingleLocalProfile")
140  )
141  ];
142  } else {
143  $items = [
144  $ui_factory->link()->standard(
145  $lng->txt("remove"),
146  $ctrl->getLinkTarget($this->parent_obj, "confirmRemoveSingleGlobalProfile")
147  )
148  ];
149  }
150 
151  $dropdown = $this->ui_factory->dropdown()->standard($items)->withLabel($lng->txt("actions"));
152  $tpl->setVariable("ACTIONS", $ui_renderer->render($dropdown));
153  }
154 }
setData(array $a_data)
An entity that renders components to a string output.
Definition: Renderer.php:30
link()
description: purpose: > Links are used navigate to other resources or views of the system by clickin...
getLinkTargetByClass( $a_class, string $a_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
render($component, ?Renderer $root=null)
Render given component.
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)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
setParameterByClass(string $a_class, string $a_parameter, $a_value)
static getDefaultMemberRole(int $a_ref_id)
ilLanguage $lng
global $DIC
Definition: feed.php:28
TableGUI class for competence profiles in containers.
__construct( $a_parent_obj, string $a_parent_cmd, int $cont_ref_id)
__construct(VocabulariesInterface $vocabularies)
ilSkillManagementSettings $skmg_settings
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
getLinkTarget(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
SkillProfileService $profile_service
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)
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
addMultiCommand(string $a_cmd, string $a_text)