ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilOrgUnitPositionTableGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
23 
29 {
30  protected array $columns = [
31  'title',
32  'description',
33  'authorities',
34  ];
35  protected \ilOrgUnitPositionDBRepository $positionRepo;
37 
44  {
45  parent::__construct($parent_obj, $parent_cmd);
46 
48  $this->positionRepo = $dic["repo.Positions"];
49  $this->dropdownbuilder = $dic['dropdownbuilder'];
50 
51  $this->setPrefix('orgu_types_table');
52  $this->setId('orgu_types_table');
53  $this->setRowTemplate('tpl.position_row.html', 'Modules/OrgUnit');
54  $this->initColumns();
55  $this->addColumn($this->lng->txt('action'), '', '100px', false, 'text-right');
56  $this->buildData();
57  $this->setFormAction($this->ctrl->getFormAction($this->parent_obj));
58  }
59 
64  public function fillRow(array $a_set): void
65  {
69  $position = $this->positionRepo->getSingle($a_set["id"], 'id');
70 
71  $this->tpl->setVariable('TITLE', $position->getTitle());
72  $this->tpl->setVariable('DESCRIPTION', $position->getDescription());
73  $this->tpl->setVariable('AUTHORITIES', implode("<br>", $this->getAuthorityDescription($position->getAuthorities())));
74 
75  $this->ctrl->setParameterByClass(ilOrgUnitPositionGUI::class, BaseCommands::AR_ID, $a_set['id']);
76 
77  $dropdownbuilder = $this->dropdownbuilder
78  ->withItem(
79  'edit',
80  $this->ctrl->getLinkTargetByClass(ilOrgUnitPositionGUI::class, ilOrgUnitPositionGUI::CMD_EDIT)
81  )
82  ->withItem(
83  'delete',
84  $this->ctrl->getLinkTargetByClass(ilOrgUnitPositionGUI::class, ilOrgUnitPositionGUI::CMD_CONFIRM_DELETION),
85  !$position->isCorePosition()
86  )
87  ->get();
88  $this->tpl->setVariable('ACTIONS', $dropdownbuilder);
89  }
90 
91  private function initColumns(): void
92  {
93  foreach ($this->columns as $column) {
94  $this->addColumn($this->lng->txt($column), $column);
95  }
96  }
97 
101  private function buildData(): void
102  {
103  $this->setData($this->positionRepo->getArray());
104  }
105 
111  private function getAuthorityDescription(array $authorities): array
112  {
113  $lang = $this->lng;
114  $lang->loadLanguageModule('orgu');
115  $lang_keys = array(
116  'in',
117  'over',
121  );
122  $t = [];
123  foreach ($lang_keys as $key) {
124  $t[$key] = $lang->txt($key);
125  }
126 
127  $authority_description = [];
128  foreach ($authorities as $authority) {
129  switch ($authority->getOver()) {
131  $over_txt = $t["over_" . $authority->getOver()];
132  break;
133  default:
134  $over_txt = $this->positionRepo
135  ->getSingle($authority->getOver(), 'id')
136  ->getTitle();
137  break;
138  }
139 
140  $authority_description[] = " " . $t["over"] . " " . $over_txt . " " . $t["in"] . " " . $t["scope_" . $authority->getScope()];
141  }
142 
143  return $authority_description;
144  }
145 }
setData(array $a_data)
setFormAction(string $a_form_action, bool $a_multipart=false)
__construct(BaseCommands $parent_obj, $parent_cmd)
ilOrgUnitPositionTableGUI constructor.
withItem(string $label_lang_var, string $url, bool $condition=true)
This is to construct/collect the entries (=Links) of a row&#39;s action-dropdown.
ilLanguage $lng
setId(string $a_val)
__construct(VocabulariesInterface $vocabularies)
fillRow(array $a_set)
Standard Version of Fill Row.
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
getAuthorityDescription(array $authorities)
Returns descriptions for authorities as an array of strings.
string $key
Consumer key/client ID value.
Definition: System.php:193
$lang
Definition: xapiexit.php:26
ilOrgUnitPositionDBRepository $positionRepo
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)
$dic
Definition: result.php:32
buildData()
Build and set data for table.
Class ilOrgUnitPositionTableGUI.
setPrefix(string $a_prefix)