ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilStudyProgrammeRepositorySearchGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
28{
29 public function addUser(): void
30 {
31 global $DIC;
32 $post_wrapper = $DIC->http()->wrapper()->post();
33 $refinery = $DIC->refinery();
34 $class = $this->callback['class'];
35 $method = $this->callback['method'];
36
37 // call callback if that function does give a return value => show error message
38 // listener redirects if everything is ok.
39 $class->$method($post_wrapper->retrieve('user', $refinery->kindlyTo()->listOf($refinery->kindlyTo()->string())));
40 // Removed this from overwritten class, as we do not want to show the
41 // results again...
42 //$this->showSearchResults();
43 }
44
48 public static function fillAutoCompleteToolbar(
49 $parent_object,
50 ?ilToolbarGUI $toolbar = null,
51 $a_options = array(),
52 $a_sticky = false
53 ): ilToolbarGUI {
54 global $DIC;
55 $ilToolbar = $DIC['ilToolbar'];
56 $lng = $DIC['lng'];
57 $ilCtrl = $DIC['ilCtrl'];
58 $tree = $DIC['tree'];
59 $ui_factory = $DIC['ui.factory'];
60
61 if (!$toolbar instanceof ilToolbarGUI) {
62 $toolbar = $ilToolbar;
63 }
64
65 // Fill default options
66 if (!isset($a_options['auto_complete_name'])) {
67 $a_options['auto_complete_name'] = $lng->txt('obj_user');
68 }
69 if (!isset($a_options['auto_complete_size'])) {
70 $a_options['auto_complete_size'] = 15;
71 }
72 if (!isset($a_options['submit_name'])) {
73 $a_options['submit_name'] = $lng->txt('btn_add');
74 }
75
76 $ajax_url = $ilCtrl->getLinkTargetByClass(
77 array(get_class($parent_object),'ilStudyProgrammeRepositorySearchGUI'),
78 'doUserAutoComplete',
79 '',
80 true,
81 false
82 );
83
84 $ul = new ilTextInputGUI($a_options['auto_complete_name'], 'user_login');
85 $ul->setDataSource($ajax_url);
86 $ul->setSize($a_options['auto_complete_size']);
87 if (!$a_sticky) {
88 $toolbar->addInputItem($ul, true);
89 } else {
90 $toolbar->addStickyItem($ul, true);
91 }
92
93 if (count($a_options['user_type'] ?? [])) {
94 $si = new ilSelectInputGUI("", "user_type");
95 $si->setOptions($a_options['user_type']);
96 if (!$a_sticky) {
97 $toolbar->addInputItem($si);
98 } else {
99 $toolbar->addStickyItem($si);
100 }
101 }
102
103 $button = $ui_factory->button()->standard($a_options['submit_name'], '#')
104 ->withOnLoadCode(
105 fn($id) => "
106 document.getElementById('$id').addEventListener('click',
107 function() {
108 let frm = this.closest('form');
109 frm.action = frm.action + '&cmd=addUserFromAutoComplete';
110 frm.submit();
111 return false;
112 });
113 "
114 );
115 $toolbar->addComponent($button);
116
117 if ((bool) $a_options['add_search'] ||
118 is_numeric($a_options['add_from_container'])) {
119 $lng->loadLanguageModule("search");
120
121 $toolbar->addSeparator();
122
123 if ((bool) $a_options['add_search']) {
124 $link = $ui_factory->link()->standard(
125 $lng->txt('search_users'),
126 $ilCtrl->getLinkTargetByClass('ilStudyProgrammeRepositorySearchGUI', '')
127 );
128 $toolbar->addComponent($link);
129 }
130
131 if (isset($a_options['add_from_container']) && is_numeric($a_options['add_from_container'])) {
132 $parent_ref_id = (int) $a_options['add_from_container'];
133 $parent_container_ref_id = $tree->checkForParentType($parent_ref_id, "grp");
134 $parent_container_type = "grp";
135 if (!$parent_container_ref_id) {
136 $parent_container_ref_id = $tree->checkForParentType($parent_ref_id, "crs");
137 $parent_container_type = "crs";
138 }
139 if ($parent_container_ref_id) {
140 if ((bool) $a_options['add_search']) {
141 $toolbar->addSpacer();
142 }
143
144 $ilCtrl->setParameterByClass(
145 'ilStudyProgrammeRepositorySearchGUI',
146 "list_obj",
147 ilObject::_lookupObjId($parent_container_ref_id)
148 );
149
150 $link = $ui_factory->link()->standard(
151 $lng->txt('search_add_members_from_container_' . $parent_container_type),
152 $ilCtrl->getLinkTargetByClass(
153 [get_class($parent_object),'ilStudyProgrammeRepositorySearchGUI'],
154 'listUsers'
155 )
156 );
157 $toolbar->addComponent($link);
158 }
159 }
160 }
161
162 $toolbar->setFormAction(
163 $ilCtrl->getFormActionByClass(
164 array(
165 get_class($parent_object),
166 'ilStudyProgrammeRepositorySearchGUI')
167 )
168 );
169 return $toolbar;
170 }
171}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
loadLanguageModule(string $a_module)
Load language module.
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...
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