ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilGroupRegistrationGUI.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24include_once('./Services/Membership/classes/class.ilRegistrationGUI.php');
25include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
26
37{
44 public function __construct($a_container)
45 {
46 parent::__construct($a_container);
47 }
48
54 public function executeCommand()
55 {
56 global $ilUser,$ilTabs;
57
58 $next_class = $this->ctrl->getNextClass($this);
59
60 if ($this->getWaitingList()->isOnList($ilUser->getId())) {
61 $ilTabs->activateTab('leave');
62 }
63
64 switch ($next_class) {
65 default:
66 $cmd = $this->ctrl->getCmd("show");
67 $this->$cmd();
68 break;
69 }
70 return true;
71 }
72
73
80 protected function getFormTitle()
81 {
82 global $ilUser;
83
84 if ($this->getWaitingList()->isOnList($ilUser->getId())) {
85 return $this->lng->txt('member_status');
86 }
87 return $this->lng->txt('grp_registration');
88 }
89
97 protected function fillInformations()
98 {
99 if ($this->container->getInformation()) {
100 $imp = new ilNonEditableValueGUI($this->lng->txt('crs_important_info'), '', true);
101 $value = nl2br(ilUtil::makeClickable($this->container->getInformation(), true));
102 $imp->setValue($value);
103 $this->form->addItem($imp);
104 }
105 }
106
112 protected function fillRegistrationPeriod()
113 {
114 include_once('./Services/Calendar/classes/class.ilDateTime.php');
115 $now = new ilDateTime(time(), IL_CAL_UNIX, 'UTC');
116
117 if ($this->container->isRegistrationUnlimited()) {
118 $reg = new ilNonEditableValueGUI($this->lng->txt('mem_reg_period'));
119 $reg->setValue($this->lng->txt('mem_unlimited'));
120 $this->form->addItem($reg);
121 return true;
122 }
123
124 $start = $this->container->getRegistrationStart();
125 $end = $this->container->getRegistrationEnd();
126
127
128 if (ilDateTime::_before($now, $start)) {
129 $tpl = new ilTemplate('tpl.registration_period_form.html', true, true, 'Services/Membership');
130 $tpl->setVariable('TXT_FIRST', $this->lng->txt('mem_start'));
131 $tpl->setVariable('FIRST', ilDatePresentation::formatDate($start));
132
133 $tpl->setVariable('TXT_END', $this->lng->txt('mem_end'));
134 $tpl->setVariable('END', ilDatePresentation::formatDate($end));
135
136 $warning = $this->lng->txt('mem_reg_not_started');
137 } elseif (ilDateTime::_after($now, $end)) {
138 $tpl = new ilTemplate('tpl.registration_period_form.html', true, true, 'Services/Membership');
139 $tpl->setVariable('TXT_FIRST', $this->lng->txt('mem_start'));
140 $tpl->setVariable('FIRST', ilDatePresentation::formatDate($start));
141
142 $tpl->setVariable('TXT_END', $this->lng->txt('mem_end'));
143 $tpl->setVariable('END', ilDatePresentation::formatDate($end));
144
145 $warning = $this->lng->txt('mem_reg_expired');
146 } else {
147 $tpl = new ilTemplate('tpl.registration_period_form.html', true, true, 'Services/Membership');
148 $tpl->setVariable('TXT_FIRST', $this->lng->txt('mem_end'));
149 $tpl->setVariable('FIRST', ilDatePresentation::formatDate($end));
150 }
151
152 $reg = new ilCustomInputGUI($this->lng->txt('mem_reg_period'));
153 $reg->setHtml($tpl->get());
154 if (strlen($warning)) {
155 // Disable registration
156 $this->enableRegistration(false);
157 #$reg->setAlert($warning);
159 }
160 $this->form->addItem($reg);
161 return true;
162 }
163
170 protected function fillMaxMembers()
171 {
172 global $ilUser;
173
174 if (!$this->container->isMembershipLimited()) {
175 return true;
176 }
177
178 $tpl = new ilTemplate('tpl.max_members_form.html', true, true, 'Services/Membership');
179
180 if ($this->container->getMinMembers()) {
181 $tpl->setVariable('TXT_MIN', $this->lng->txt('mem_min_users'));
182 $tpl->setVariable('NUM_MIN', $this->container->getMinMembers());
183 }
184
185 if ($this->container->getMaxMembers()) {
186 $tpl->setVariable('TXT_MAX', $this->lng->txt('mem_max_users'));
187 $tpl->setVariable('NUM_MAX', $this->container->getMaxMembers());
188
189 include_once './Modules/Group/classes/class.ilObjGroupAccess.php';
190 $reg_info = ilObjGroupAccess::lookupRegistrationInfo($this->getContainer()->getId());
191 $free = $reg_info['reg_info_free_places'];
192
193
194 if ($free) {
195 $tpl->setVariable('NUM_FREE', $free);
196 } else {
197 $tpl->setVariable('WARN_FREE', $free);
198 }
199
200 include_once('./Modules/Group/classes/class.ilGroupWaitingList.php');
201 $waiting_list = new ilGroupWaitingList($this->container->getId());
202
203 if (
204 $this->container->isWaitingListEnabled() and
205 $this->container->isMembershipLimited() and
206 (!$free or $waiting_list->getCountUsers())) {
207 if ($waiting_list->isOnList($ilUser->getId())) {
208 $tpl->setVariable('TXT_WAIT', $this->lng->txt('mem_waiting_list_position'));
209 $tpl->setVariable('NUM_WAIT', $waiting_list->getPosition($ilUser->getId()));
210 } else {
211 $tpl->setVariable('TXT_WAIT', $this->lng->txt('mem_waiting_list'));
212 if ($free and $waiting_list->getCountUsers()) {
213 $tpl->setVariable('WARN_WAIT', $waiting_list->getCountUsers());
214 } else {
215 $tpl->setVariable('NUM_WAIT', $waiting_list->getCountUsers());
216 }
217 }
218 }
219
220 $alert = '';
221 if (
222 !$free and
223 !$this->container->isWaitingListEnabled()) {
224 // Disable registration
225 $this->enableRegistration(false);
226 $alert = $this->lng->txt('mem_alert_no_places');
227 } elseif (
228 $this->container->isWaitingListEnabled() and
229 $this->container->isMembershipLimited() and
230 $waiting_list->isOnList($ilUser->getId())) {
231 // Disable registration
232 $this->enableRegistration(false);
233 } elseif (
234 !$free and
235 $this->container->isWaitingListEnabled() and
236 $this->container->isMembershipLimited()) {
237 $alert = $this->lng->txt('grp_warn_no_max_set_on_waiting_list');
238 } elseif (
239 $free and
240 $this->container->isWaitingListEnabled() and
241 $this->container->isMembershipLimited() and
242 $this->getWaitingList()->getCountUsers()) {
243 $alert = $this->lng->txt('grp_warn_wl_set_on_waiting_list');
244 }
245 }
246
247 $max = new ilCustomInputGUI($this->lng->txt('mem_participants'));
248 $max->setHtml($tpl->get());
249 if (strlen($alert)) {
250 #$max->setAlert($alert);
251 ilUtil::sendFailure($alert);
252 }
253 $this->form->addItem($max);
254 }
255
263 protected function fillRegistrationType()
264 {
265 global $ilUser;
266
267 if ($this->getWaitingList()->isOnList($ilUser->getId())) {
268 return true;
269 }
270
271 switch ($this->container->getRegistrationType()) {
273 $reg = new ilNonEditableValueGUI($this->lng->txt('mem_reg_type'));
274 $reg->setValue($this->lng->txt('grp_reg_disabled'));
275 #$reg->setAlert($this->lng->txt('grp_reg_deactivated_alert'));
276 $this->form->addItem($reg);
277
278 // Disable registration
279 $this->enableRegistration(false);
280
281 break;
282
284 $txt = new ilNonEditableValueGUI($this->lng->txt('mem_reg_type'));
285 $txt->setValue($this->lng->txt('grp_pass_request'));
286
287
288 $pass = new ilTextInputGUI($this->lng->txt('passwd'), 'grp_passw');
289 $pass->setInputType('password');
290 $pass->setSize(12);
291 $pass->setMaxLength(32);
292 #$pass->setRequired(true);
293 $pass->setInfo($this->lng->txt('group_password_registration_msg'));
294
295 $txt->addSubItem($pass);
296 $this->form->addItem($txt);
297 break;
298
300
301 // no "request" info if waiting list is active
302 if ($this->isWaitingListActive()) {
303 return true;
304 }
305
306 $txt = new ilNonEditableValueGUI($this->lng->txt('mem_reg_type'));
307 $txt->setValue($this->lng->txt('grp_reg_request'));
308
309 $sub = new ilTextAreaInputGUI($this->lng->txt('grp_reg_subject'), 'subject');
310 $sub->setValue($_POST['subject']);
311 $sub->setInfo($this->lng->txt('group_req_registration_msg'));
312 $sub->setCols(40);
313 $sub->setRows(5);
314 if ($this->participants->isSubscriber($ilUser->getId())) {
315 $sub_data = $this->participants->getSubscriberData($ilUser->getId());
316 $sub->setValue($sub_data['subject']);
317 $sub->setInfo('');
318 ilUtil::sendFailure($this->lng->txt('grp_already_assigned'));
319 $this->enableRegistration(false);
320 }
321 $txt->addSubItem($sub);
322 $this->form->addItem($txt);
323 break;
324
326
327 // no "direct registration" info if waiting list is active
328 if ($this->isWaitingListActive()) {
329 return true;
330 }
331
332 $txt = new ilNonEditableValueGUI($this->lng->txt('mem_reg_type'));
333 $txt->setValue($this->lng->txt('group_req_direct'));
334
335 $this->form->addItem($txt);
336 break;
337
338 default:
339 return true;
340 }
341
342 return true;
343 }
344
349 protected function addCommandButtons()
350 {
351 global $ilUser;
352
353 parent::addCommandButtons();
354
355
356 switch ($this->container->getRegistrationType()) {
358 if ($this->participants->isSubscriber($ilUser->getId())) {
359 $this->form->clearCommandButtons();
360 $this->form->addCommandButton('updateSubscriptionRequest', $this->lng->txt('grp_update_subscr_request'));
361 $this->form->addCommandButton('cancelSubscriptionRequest', $this->lng->txt('grp_cancel_subscr_request'));
362 } else {
363 if (!$this->isRegistrationPossible()) {
364 return false;
365 }
366 $this->form->clearCommandButtons();
367 $this->form->addCommandButton('join', $this->lng->txt('grp_join_request'));
368 $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
369 }
370 break;
371 }
372 return true;
373 }
374
375
382 protected function validate()
383 {
384 global $ilUser;
385
386 if ($ilUser->getId() == ANONYMOUS_USER_ID) {
387 $this->join_error = $this->lng->txt('permission_denied');
388 return false;
389 }
390
391 if (!$this->isRegistrationPossible()) {
392 $this->join_error = $this->lng->txt('mem_error_preconditions');
393 return false;
394 }
395 if ($this->container->getRegistrationType() == GRP_REGISTRATION_PASSWORD) {
396 if (!strlen($pass = ilUtil::stripSlashes($_POST['grp_passw']))) {
397 $this->join_error = $this->lng->txt('err_wrong_password');
398 return false;
399 }
400 if (strcmp($pass, $this->container->getPassword()) !== 0) {
401 $this->join_error = $this->lng->txt('err_wrong_password');
402 return false;
403 }
404 }
405 if (!$this->validateCustomFields()) {
406 $this->join_error = $this->lng->txt('fill_out_all_required_fields');
407 return false;
408 }
409 if (!$this->validateAgreement()) {
410 $this->join_error = $this->lng->txt($this->type . '_agreement_required');
411 return false;
412 }
413
414 return true;
415 }
416
424 protected function add()
425 {
426 global $ilUser,$tree, $rbacreview, $lng, $ilCtrl;
427
428 // set aggreement accepted
429 $this->setAccepted(true);
430
431 include_once('./Modules/Group/classes/class.ilGroupWaitingList.php');
432 $free = max(0, $this->container->getMaxMembers() - $this->participants->getCountMembers());
433 $waiting_list = new ilGroupWaitingList($this->container->getId());
434 if (
435 $this->container->isMembershipLimited() and
436 $this->container->isWaitingListEnabled() and
437 (!$free or $waiting_list->getCountUsers())) {
438 $waiting_list->addToList($ilUser->getId());
439 $info = sprintf(
440 $this->lng->txt('grp_added_to_list'),
441 $this->container->getTitle(),
442 $waiting_list->getPosition($ilUser->getId())
443 );
444
445 $this->participants->sendNotification(
447 $ilUser->getId()
448 );
450 $ilCtrl->setParameterByClass(
451 "ilrepositorygui",
452 "ref_id",
453 $tree->getParentId($this->container->getRefId())
454 );
455 $ilCtrl->redirectByClass("ilrepositorygui", "");
456 }
457
458
459 switch ($this->container->getRegistrationType()) {
461
462 $this->participants->addSubscriber($ilUser->getId());
463 $this->participants->updateSubscriptionTime($ilUser->getId(), time());
464 $this->participants->updateSubject($ilUser->getId(), ilUtil::stripSlashes($_POST['subject']));
465
466 $this->participants->sendNotification(
468 $ilUser->getId()
469 );
470
471 ilUtil::sendSuccess($this->lng->txt("application_completed"), true);
472 $ilCtrl->setParameterByClass(
473 "ilrepositorygui",
474 "ref_id",
475 $tree->getParentId($this->container->getRefId())
476 );
477 $ilCtrl->redirectByClass("ilrepositorygui", "");
478 break;
479
480 default:
481
482 $this->participants->add($ilUser->getId(), IL_GRP_MEMBER);
483 $this->participants->sendNotification(
485 $ilUser->getId()
486 );
487 $this->participants->sendNotification(
489 $ilUser->getId()
490 );
491
492 include_once './Modules/Forum/classes/class.ilForumNotification.php';
493 ilForumNotification::checkForumsExistsInsert($this->container->getRefId(), $ilUser->getId());
494
495 if (!$_SESSION["pending_goto"]) {
496 ilUtil::sendSuccess($this->lng->txt("grp_registration_completed"), true);
497 $this->ctrl->returnToParent($this);
498 } else {
499 $tgt = $_SESSION["pending_goto"];
500 unset($_SESSION["pending_goto"]);
501 ilUtil::redirect($tgt);
502 }
503 break;
504 }
505 }
506
507
513 protected function initParticipants()
514 {
515 include_once('./Modules/Group/classes/class.ilGroupParticipants.php');
516 $this->participants = ilGroupParticipants::_getInstanceByObjId($this->obj_id);
517 }
518
523 protected function initWaitingList()
524 {
525 include_once './Modules/Group/classes/class.ilGroupWaitingList.php';
526 $this->waiting_list = new ilGroupWaitingList($this->container->getId());
527 }
528
532 protected function isWaitingListActive()
533 {
534 global $ilUser;
535 static $active = null;
536
537 if ($active !== null) {
538 return $active;
539 }
540 if (!$this->container->getMaxMembers()) {
541 return $active = false;
542 }
543 if (
544 !$this->container->isWaitingListEnabled() or
545 !$this->container->isMembershipLimited()) {
546 return $active = false;
547 }
548
549 $free = max(0, $this->container->getMaxMembers() - $this->participants->getCountMembers());
550 return $active = (!$free or $this->getWaitingList()->getCountUsers());
551 }
552}
sprintf('%.4f', $callTime)
$warning
Definition: X509warning.php:13
$_POST["username"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
const GRP_REGISTRATION_DIRECT
const GRP_REGISTRATION_PASSWORD
const GRP_REGISTRATION_DEACTIVATED
const GRP_REGISTRATION_REQUEST
const IL_GRP_MEMBER
This class represents a custom property in a property form.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date @access public.
@classDescription Date and time handling
static _after(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
compare two dates and check start is after end This method does not consider tz offsets.
static _before(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
compare two dates and check start is before end This method does not consider tz offsets.
static checkForumsExistsInsert($ref_id, $user_id=0)
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
GUI class for group registrations.
fillRegistrationType()
fill registration procedure
__construct($a_container)
Constructor.
fillMaxMembers()
fill max member informations
addCommandButtons()
Add group specific command buttons.
fillRegistrationPeriod()
show informations about the registration period
initParticipants()
Init course participants.
Waiting list for groups.
This class represents a non editable value in a property form.
static lookupRegistrationInfo($a_obj_id)
Lookup registration info @global ilDB $ilDB @global ilObjUser $ilUser @global ilLanguage $lng.
Base class for Course and Group registration.
getContainer()
Parent object.
validateAgreement()
Check Agreement.
setAccepted($a_status)
Set Agreement accepted.
validateCustomFields()
Check required course fields.
enableRegistration($a_status)
set registration disabled
getWaitingList()
Get waiting list object.
isRegistrationPossible()
check if registration is possible
special template class to simplify handling of ITX/PEAR
This class represents a text area property in a property form.
This class represents a text property in a property form.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static redirect($a_script)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static makeClickable($a_text, $detectGotoLinks=false)
makeClickable In Texten enthaltene URLs und Mail-Adressen klickbar machen
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
$txt
Definition: error.php:11
global $ilCtrl
Definition: ilias.php:18
$end
Definition: saml1-acs.php:18
$info
Definition: index.php:5
$ilUser
Definition: imgupload.php:18