ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilBookingParticipantGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3
14{
18 protected $tpl;
19
23 protected $tabs;
24
28 protected $ctrl;
29
33 protected $lng;
34
38 protected $access;
39
43 protected $toolbar;
44
47
49
54 public function __construct(ilObjBookingPoolGUI $a_parent_obj)
55 {
56 global $DIC;
57
58 $this->tpl = $DIC["tpl"];
59 $this->tabs = $DIC->tabs();
60 $this->ctrl = $DIC->ctrl();
61 $this->lng = $DIC->language();
62 $this->access = $DIC->access();
63 $this->toolbar = $DIC->toolbar();
64
65 $this->ref_id = $a_parent_obj->ref_id;
66 $this->pool_id = $a_parent_obj->object->getId();
67
68 $this->lng->loadLanguageModule("book");
69 }
70
74 public function executeCommand()
75 {
76 $ilCtrl = $this->ctrl;
77
78 $next_class = $ilCtrl->getNextClass($this);
79
80 switch ($next_class) {
81 case 'ilrepositorysearchgui':
82 $rep_search = new ilRepositorySearchGUI();
83 $ref_id = $this->ref_id;
84 $rep_search->addUserAccessFilterCallable(function ($a_user_id) use ($ref_id) {
85 return $GLOBALS['DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
86 'render',
87 'render',
88 $this->ref_id,
89 $a_user_id
90 );
91 });
92 $rep_search->setTitle($this->lng->txt("exc_add_participant"));
93 $rep_search->setCallback($this, 'addParticipantObject');
94 $this->ctrl->setReturn($this, 'render');
95 $this->ctrl->forwardCommand($rep_search);
96 break;
97
98 default:
99 $cmd = $ilCtrl->getCmd("render");
100 $this->$cmd();
101 break;
102 }
103 return true;
104 }
105
111 public function render()
112 {
113 if ($this->access->checkAccess('write', '', $this->ref_id)) {
115 $this,
116 $this->toolbar,
117 array(
118 'auto_complete_name' => $this->lng->txt('user'),
119 'submit_name' => $this->lng->txt('add'),
120 'add_search' => true,
121 'add_from_container' => $this->ref_id
122 )
123 );
124
125 $table = new ilBookingParticipantsTableGUI($this, 'render', $this->ref_id, $this->pool_id);
126
127 $this->tpl->setContent($table->getHTML());
128 }
129 }
130
135 {
136 if (!strlen(trim($_POST['user_login']))) {
137 ilUtil::sendFailure($this->lng->txt('msg_no_search_string'));
138 $this->render();
139 return false;
140 }
141
142 $users = explode(',', $_POST['user_login']);
143
144 $user_ids = array();
145 foreach ($users as $user) {
146 $user_id = ilObjUser::_lookupId($user);
147
148 if (!$user_id) {
149 ilUtil::sendFailure($this->lng->txt('user_not_known'));
150 $this->render();
151 }
152 $user_ids[] = $user_id;
153 }
154
155 return $this->addParticipantObject($user_ids);
156 }
157
163 public function addParticipantObject(array $a_user_ids)
164 {
165 foreach ($a_user_ids as $user_id) {
166 if (ilObject::_lookupType($user_id) === "usr") {
167 $participant_obj = new ilBookingParticipant($user_id, $this->pool_id);
168 if ($participant_obj->getIsNew()) {
169 ilUtil::sendSuccess($this->lng->txt("book_participant_assigned"), true);
170 } else {
171 ilUtil::sendFailure($this->lng->txt("book_participant_already_assigned"));
172 return false;
173 }
174 } else {
175 ilUtil::sendFailure("dummy error message, change me");
176 return false;
177 }
178 }
179
180 $this->ctrl->redirect($this, "render");
181 return true;
182 }
183
187 public function applyParticipantsFilter()
188 {
189 $this->applyFilterAction(self::FILTER_ACTION_APPLY);
190 }
191
195 public function resetParticipantsFilter()
196 {
197 $this->applyFilterAction(self::FILTER_ACTION_RESET);
198 }
199
200 protected function applyFilterAction($a_filter_action)
201 {
202 $table = new ilBookingParticipantsTableGUI($this, 'render', $this->ref_id, $this->pool_id);
203 $table->resetOffset();
204 if ($a_filter_action === self::FILTER_ACTION_RESET) {
205 $table->resetFilter();
206 } else {
207 $table->writeFilterToSession();
208 }
209
210 $this->render();
211 }
212
216 public function assignObjects()
217 {
218 $this->tabs->clearTargets();
219 $this->tabs->setBackTarget($this->lng->txt('book_back_to_list'), $this->ctrl->getLinkTarget($this, 'render'));
220
221 $table = new ilBookingAssignObjectsTableGUI($this, 'assignObjects', $this->ref_id, $this->pool_id);
222
223 $this->tpl->setContent($table->getHTML());
224 }
225}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
List objects / booking pool assignment.
Class ilBookingParticipantGUI.
addParticipantObject(array $a_user_ids)
Add new partipant.
__construct(ilObjBookingPoolGUI $a_parent_obj)
Constructor.
assignObjects()
Book objects for other users.
resetParticipantsFilter()
Reset filter in participants table gui.
render()
Render list of booking participants.
addUserFromAutoCompleteObject()
Add user as member.
applyParticipantsFilter()
Apply filter from participants table gui.
Class ilBookingParticipant.
Class ilObjBookingPoolGUI.
static _lookupId($a_user_str)
Lookup id by login.
static _lookupType($a_id, $a_reference=false)
lookup object type
static fillAutoCompleteToolbar($parent_object, ilToolbarGUI $toolbar=null, $a_options=array(), $a_sticky=false)
fill toolbar with
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $DIC
Definition: goto.php:24