ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
class.ilStudyProgrammeRepositorySearchGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
28{
29 public function addUser(int ...$users): void
30 {
31 $class = $this->callback['class'];
32 $method = $this->callback['method'];
33
34 // call callback if that function does give a return value => show error message
35 // listener redirects if everything is ok.
36 $class->$method($users);
37 // Removed this from overwritten class, as we do not want to show the
38 // results again...
39 //$this->showSearchResults();
40 }
41
45 public static function fillAutoCompleteToolbar(
46 $parent_object,
47 ?ilToolbarGUI $toolbar = null,
48 $a_options = array(),
49 $a_sticky = false
50 ): ilToolbarGUI {
51 global $DIC;
52 $ilToolbar = $DIC['ilToolbar'];
53 $lng = $DIC['lng'];
54 $ilCtrl = $DIC['ilCtrl'];
55 $tree = $DIC['tree'];
56 $ui_factory = $DIC['ui.factory'];
57
58 if (!$toolbar instanceof ilToolbarGUI) {
59 $toolbar = $ilToolbar;
60 }
61
62 // Fill default options
63 if (!isset($a_options['auto_complete_name'])) {
64 $a_options['auto_complete_name'] = $lng->txt('obj_user');
65 }
66 if (!isset($a_options['auto_complete_size'])) {
67 $a_options['auto_complete_size'] = 15;
68 }
69 if (!isset($a_options['submit_name'])) {
70 $a_options['submit_name'] = $lng->txt('btn_add');
71 }
72
73 $ajax_url = $ilCtrl->getLinkTargetByClass(
74 array(get_class($parent_object),'ilStudyProgrammeRepositorySearchGUI'),
75 'doUserAutoComplete',
76 '',
77 true,
78 false
79 );
80
81 $ul = new ilTextInputGUI($a_options['auto_complete_name'], 'user_login');
82 $ul->setDataSource($ajax_url);
83 $ul->setSize($a_options['auto_complete_size']);
84 if (!$a_sticky) {
85 $toolbar->addInputItem($ul, true);
86 } else {
87 $toolbar->addStickyItem($ul, true);
88 }
89
90 if (count($a_options['user_type'] ?? [])) {
91 $si = new ilSelectInputGUI("", "user_type");
92 $si->setOptions($a_options['user_type']);
93 if (!$a_sticky) {
94 $toolbar->addInputItem($si);
95 } else {
96 $toolbar->addStickyItem($si);
97 }
98 }
99
100 $button = $ui_factory->button()->standard($a_options['submit_name'], '#')
101 ->withOnLoadCode(
102 fn($id) => "
103 document.getElementById('$id').addEventListener('click',
104 function() {
105 let frm = this.closest('form');
106 frm.action = frm.action + '&cmd=addUserFromAutoComplete';
107 frm.submit();
108 return false;
109 });
110 "
111 );
112 $toolbar->addComponent($button);
113
114 if ((bool) $a_options['add_search'] ||
115 is_numeric($a_options['add_from_container'])) {
116 $lng->loadLanguageModule("search");
117
118 $toolbar->addSeparator();
119
120 if ((bool) $a_options['add_search']) {
121 $link = $ui_factory->link()->standard(
122 $lng->txt('search_users'),
123 $ilCtrl->getLinkTargetByClass('ilStudyProgrammeRepositorySearchGUI', '')
124 );
125 $toolbar->addComponent($link);
126 }
127
128 if (isset($a_options['add_from_container']) && is_numeric($a_options['add_from_container'])) {
129 $parent_ref_id = (int) $a_options['add_from_container'];
130 $parent_container_ref_id = $tree->checkForParentType($parent_ref_id, "grp");
131 $parent_container_type = "grp";
132 if (!$parent_container_ref_id) {
133 $parent_container_ref_id = $tree->checkForParentType($parent_ref_id, "crs");
134 $parent_container_type = "crs";
135 }
136 if ($parent_container_ref_id) {
137 if ((bool) $a_options['add_search']) {
138 $toolbar->addSpacer();
139 }
140
141 $ilCtrl->setParameterByClass(
142 'ilStudyProgrammeRepositorySearchGUI',
143 "list_obj",
144 ilObject::_lookupObjId($parent_container_ref_id)
145 );
146
147 $link = $ui_factory->link()->standard(
148 $lng->txt('search_add_members_from_container_' . $parent_container_type),
149 $ilCtrl->getLinkTargetByClass(
150 [get_class($parent_object),'ilStudyProgrammeRepositorySearchGUI'],
151 'listUsers'
152 )
153 );
154 $toolbar->addComponent($link);
155 }
156 }
157 }
158
159 $toolbar->setFormAction(
160 $ilCtrl->getFormActionByClass(
161 array(
162 get_class($parent_object),
163 'ilStudyProgrammeRepositorySearchGUI')
164 )
165 );
166 return $toolbar;
167 }
168}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
loadLanguageModule(string $a_module)
Load language module.
txt(string|LanguageIdentifier $a_topic, ?int $n=null)
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static _lookupObjId(int $ref_id)
This class represents a selection list property in a property form.
Custom repository search gui class for study programme to make it possible to get a handle on users s...
static fillAutoCompleteToolbar( $parent_object, ?ilToolbarGUI $toolbar=null, $a_options=array(), $a_sticky=false)
This is just the same as in the parent class, except for the hardcoded class name.
This class represents a text property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
checkForParentType(int $a_ref_id, string $a_type, bool $a_exclude_source_check=false)
Check for parent type e.g check if a folder (ref_id 3) is in a parent course obj => checkForParentTyp...
global $DIC
Definition: shib_login.php:26