ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 
48  const PARTICIPANT_VIEW = 1;
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  {
77 
78  $next_class = $ilCtrl->getNextClass($this);
79 
80  switch ($next_class) {
81  case 'ilrepositorysearchgui':
82  include_once('./Services/Search/classes/class.ilRepositorySearchGUI.php');
83  $rep_search = new ilRepositorySearchGUI();
84  $ref_id = $this->ref_id;
85  $rep_search->addUserAccessFilterCallable(function ($a_user_id) use ($ref_id) {
86  return $GLOBALS['DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
87  'render',
88  'render',
89  $this->ref_id,
90  $a_user_id
91  );
92  });
93  $rep_search->setTitle($this->lng->txt("exc_add_participant"));
94  $rep_search->setCallback($this, 'addParticipantObject');
95  $this->ctrl->setReturn($this, 'render');
96  $this->ctrl->forwardCommand($rep_search);
97  break;
98 
99  default:
100  $cmd = $ilCtrl->getCmd("render");
101  $this->$cmd();
102  break;
103  }
104  return true;
105  }
106 
112  public function render()
113  {
114  if ($this->access->checkAccess('edit_permission', '', $this->ref_id)) {
116  $this,
117  $this->toolbar,
118  array(
119  'auto_complete_name' => $this->lng->txt('user'),
120  'submit_name' => $this->lng->txt('add'),
121  'add_search' => true,
122  'add_from_container' => $this->ref_id
123  )
124  );
125 
126  include_once 'Modules/BookingManager/classes/class.ilBookingParticipantsTableGUI.php';
127  $table = new ilBookingParticipantsTableGUI($this, 'render', $this->ref_id, $this->pool_id);
128 
129  $this->tpl->setContent($table->getHTML());
130  }
131  }
132 
137  {
138  if (!strlen(trim($_POST['user_login']))) {
139  ilUtil::sendFailure($this->lng->txt('msg_no_search_string'));
140  $this->render();
141  return false;
142  }
143 
144  $users = explode(',', $_POST['user_login']);
145 
146  $user_ids = array();
147  foreach ($users as $user) {
148  $user_id = ilObjUser::_lookupId($user);
149 
150  if (!$user_id) {
151  ilUtil::sendFailure($this->lng->txt('user_not_known'));
152  $this->render();
153  }
154  $user_ids[] = $user_id;
155  }
156 
157  return $this->addParticipantObject($user_ids);
158  }
159 
165  public function addParticipantObject(array $a_user_ids)
166  {
167  foreach ($a_user_ids as $user_id) {
168  if (ilObject::_lookupType($user_id) === "usr") {
169  require_once("./Modules/BookingManager/classes/class.ilBookingParticipant.php");
170 
171  $participant_obj = new ilBookingParticipant($user_id, $this->pool_id);
172  if ($participant_obj->getIsNew()) {
173  ilUtil::sendSuccess($this->lng->txt("book_participant_assigned"), true);
174  } else {
175  ilUtil::sendFailure($this->lng->txt("book_participant_already_assigned"));
176  return false;
177  }
178  } else {
179  ilUtil::sendFailure("dummy error message, change me");
180  return false;
181  }
182  }
183 
184  $this->ctrl->redirect($this, "render");
185  return true;
186  }
187 
191  public function applyParticipantsFilter()
192  {
193  $this->applyFilterAction(self::FILTER_ACTION_APPLY);
194  }
195 
199  public function resetParticipantsFilter()
200  {
201  $this->applyFilterAction(self::FILTER_ACTION_RESET);
202  }
203 
204  protected function applyFilterAction($a_filter_action)
205  {
206  include_once 'Modules/BookingManager/classes/class.ilBookingParticipantsTableGUI.php';
207  $table = new ilBookingParticipantsTableGUI($this, 'render', $this->ref_id, $this->pool_id);
208  $table->resetOffset();
209  if ($a_filter_action === self::FILTER_ACTION_RESET) {
210  $table->resetFilter();
211  } else {
212  $table->writeFilterToSession();
213  }
214 
215  $this->render();
216  }
217 
218  public function assignObjects()
219  {
220  $this->tabs->clearTargets();
221  $this->tabs->setBackTarget($this->lng->txt('book_back_to_list'), $this->ctrl->getLinkTarget($this, 'render'));
222 
223  include_once("./Modules/BookingManager/classes/class.ilBookingAssignObjectsTableGUI.php");
224  $table = new ilBookingAssignObjectsTableGUI($this, 'assignObjects', $this->ref_id, $this->pool_id);
225 
226  $this->tpl->setContent($table->getHTML());
227  }
228 }
Class ilObjBookingPoolGUI.
addUserFromAutoCompleteObject()
Add user as member.
Class ilBookingParticipant.
__construct(ilObjBookingPoolGUI $a_parent_obj)
Constructor.
global $DIC
Definition: saml.php:7
render()
Render list of booking participants.
static _lookupId($a_user_str)
Lookup id by login.
List objects / booking pool assignment.
addParticipantObject(array $a_user_ids)
Add new partipant.
global $ilCtrl
Definition: ilias.php:18
Class ilBookingParticipantGUI.
applyParticipantsFilter()
Apply filter from participants table gui.
$user
Definition: migrateto20.php:57
static _lookupType($a_id, $a_reference=false)
lookup object type
$users
Definition: authpage.php:44
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static fillAutoCompleteToolbar($parent_object, ilToolbarGUI $toolbar=null, $a_options=array(), $a_sticky=false)
fill toolbar with
if(empty($password)) $table
Definition: pwgen.php:24
resetParticipantsFilter()
Reset filter in participants table gui.
$_POST["username"]
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.