ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilCourseRegistrationGUI Class Reference

GUI class for course registrations. More...

+ Inheritance diagram for ilCourseRegistrationGUI:
+ Collaboration diagram for ilCourseRegistrationGUI:

Public Member Functions

 __construct ($a_container, $a_parent_gui)
 Constructor.
 executeCommand ()
 Execute command.
- Public Member Functions inherited from ilRegistrationGUI
 __construct ($a_container)
 Constructor.
 getContainer ()
 Parent object.
 getRefId ()
 Get ref.
 cancel ()
 cancel subscription
 show ()
 show registration form
 join ()
 join

Protected Member Functions

 getFormTitle ()
 get form title
 fillInformations ()
 fill informations
 fillRegistrationPeriod ()
 show informations about the registration period
 fillMaxMembers ()
 fill max members
 fillRegistrationType ()
 fill registration type
 addCommandButtons ()
 Add group specific command buttons.
 validate ()
 Validate subscription request.
 add ()
 add user
 initParticipants ()
 Init course participants.
 initWaitingList ()
 isWaitingListActive ()
- Protected Member Functions inherited from ilRegistrationGUI
 isRegistrationPossible ()
 check if registration is possible
 enableRegistration ($a_status)
 set registration disabled
 getWaitingList ()
 Get waiting list object.
 leaveWaitingList ()
 fillMembershipLimitation ()
 Show membership limitations.
 fillAgreement ()
 Show user agreement.
 showCustomFields ()
 Show course defined fields.
 validateAgreement ()
 Check Agreement.
 validateCustomFields ()
 Check required course fields.
 setAccepted ($a_status)
 Set Agreement accepted.
 initForm ()
 init registration form
 updateSubscriptionRequest ()
 Update subscription message.
 cancelSubscriptionRequest ()

Private Attributes

 $parent_gui = null

Additional Inherited Members

- Protected Attributes inherited from ilRegistrationGUI
 $privacy = null
 $container = null
 $ref_id
 $obj_id
 $participants
 $waiting_list = null
 $form
 $registration_possible = true
 $join_error = ''
 $tpl
 $lng
 $ctrl

Detailed Description

GUI class for course registrations.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

ilCourseRegistrationGUI:

Definition at line 37 of file class.ilCourseRegistrationGUI.php.

Constructor & Destructor Documentation

ilCourseRegistrationGUI::__construct (   $a_container,
  $a_parent_gui 
)

Constructor.

public

Parameters
objectcourse object

Definition at line 47 of file class.ilCourseRegistrationGUI.php.

{
parent::__construct($a_container);
$this->parent_gui = $a_parent_gui;
}

Member Function Documentation

ilCourseRegistrationGUI::add ( )
protected

add user

protected

Parameters
@return

Definition at line 482 of file class.ilCourseRegistrationGUI.php.

References $_POST, $_SESSION, $GLOBALS, $ilCtrl, $ilUser, $success, ilRegistrationGUI\$waiting_list, ilCourseWaitingList\addToList(), ilForumNotification\checkForumsExistsInsert(), ilParticipants\getDefaultMemberRole(), IL_CRS_MEMBER, IL_CRS_SUBSCRIPTION_CONFIRMATION, ilUtil\redirect(), ilUtil\sendFailure(), ilUtil\sendSuccess(), ilRegistrationGUI\setAccepted(), ilRegistrationGUI\show(), and ilUtil\stripSlashes().

{
global $ilUser,$tree, $ilCtrl;
// TODO: language vars
// set aggreement accepted
$this->setAccepted(true);
include_once('./Modules/Course/classes/class.ilCourseWaitingList.php');
$free = max(0,$this->container->getSubscriptionMaxMembers() - $this->participants->getCountMembers());
$waiting_list = new ilCourseWaitingList($this->container->getId());
if($this->container->isSubscriptionMembershipLimited() and $this->container->enabledWaitingList() and (!$free or $waiting_list->getCountUsers()))
{
$waiting_list->addToList($ilUser->getId());
$info = sprintf($this->lng->txt('crs_added_to_list'),
$waiting_list->getPosition($ilUser->getId()));
ilUtil::sendSuccess($info,true);
$this->participants->sendNotification($this->participants->NOTIFY_SUBSCRIPTION_REQUEST,$ilUser->getId());
$this->participants->sendNotification($this->participants->NOTIFY_WAITING_LIST,$ilUser->getId());
$ilCtrl->setParameterByClass("ilrepositorygui", "ref_id",
$tree->getParentId($this->container->getRefId()));
$ilCtrl->redirectByClass("ilrepositorygui", "");
}
switch($this->container->getSubscriptionType())
{
$this->participants->addSubscriber($ilUser->getId());
$this->participants->updateSubscriptionTime($ilUser->getId(),time());
$this->participants->updateSubject($ilUser->getId(),ilUtil::stripSlashes($_POST['subject']));
$this->participants->sendNotification($this->participants->NOTIFY_SUBSCRIPTION_REQUEST,$ilUser->getId());
ilUtil::sendSuccess($this->lng->txt("application_completed"),true);
$ilCtrl->setParameterByClass("ilrepositorygui", "ref_id",
$tree->getParentId($this->container->getRefId()));
$ilCtrl->redirectByClass("ilrepositorygui", "");
break;
default:
if($this->container->isSubscriptionMembershipLimited() && $this->container->getSubscriptionMaxMembers())
{
$success = $GLOBALS['rbacadmin']->assignUserLimited(
ilParticipants::getDefaultMemberRole($this->container->getRefId()),
$ilUser->getId(),
$this->container->getSubscriptionMaxMembers(),
array(ilParticipants::getDefaultMemberRole($this->container->getRefId()))
);
if(!$success)
{
ilUtil::sendFailure($this->lng->txt('crs_subscription_failed_limit'));
$this->show();
return FALSE;
}
}
$this->participants->add($ilUser->getId(),IL_CRS_MEMBER);
$this->participants->sendNotification($this->participants->NOTIFY_ADMINS,$ilUser->getId());
$this->participants->sendNotification($this->participants->NOTIFY_REGISTERED,$ilUser->getId());
include_once './Modules/Forum/classes/class.ilForumNotification.php';
ilForumNotification::checkForumsExistsInsert($this->container->getRefId(), $ilUser->getId());
if($this->container->getType() == "crs")
{
$this->container->checkLPStatusSync($ilUser->getId());
}
if(!$_SESSION["pending_goto"])
{
ilUtil::sendSuccess($this->lng->txt("crs_subscription_successful"),true);
$this->ctrl->returnToParent($this);
}
else
{
$tgt = $_SESSION["pending_goto"];
unset($_SESSION["pending_goto"]);
}
break;
}
}

+ Here is the call graph for this function:

ilCourseRegistrationGUI::addCommandButtons ( )
protected

Add group specific command buttons.

Returns

Reimplemented from ilRegistrationGUI.

Definition at line 391 of file class.ilCourseRegistrationGUI.php.

References $ilUser, IL_CRS_SUBSCRIPTION_CONFIRMATION, and ilRegistrationGUI\isRegistrationPossible().

{
global $ilUser;
switch($this->container->getSubscriptionType())
{
if($this->participants->isSubscriber($ilUser->getId()))
{
$this->form->clearCommandButtons();
$this->form->addCommandButton('updateSubscriptionRequest', $this->lng->txt('crs_update_subscr_request'));
$this->form->addCommandButton('cancelSubscriptionRequest', $this->lng->txt('crs_cancel_subscr_request'));
}
elseif($this->isRegistrationPossible())
{
$this->form->clearCommandButtons();
$this->form->addCommandButton('join', $this->lng->txt('crs_join_request'));
$this->form->addCommandButton('cancel',$this->lng->txt('cancel'));
}
break;
}
if(!$this->isRegistrationPossible())
{
return false;
}
return true;
}

+ Here is the call graph for this function:

ilCourseRegistrationGUI::executeCommand ( )

Execute command.

public

Definition at line 59 of file class.ilCourseRegistrationGUI.php.

References $cmd, $GLOBALS, $ilUser, ilRegistrationGUI\getRefId(), and ilRegistrationGUI\getWaitingList().

{
global $ilTabs,$ilUser;
if($this->getWaitingList()->isOnList($ilUser->getId()))
{
$ilTabs->activateTab('leave');
}
if(!$GLOBALS['ilAccess']->checkAccess('join','',$this->getRefId()))
{
$this->ctrl->setReturn($this->parent_gui,'infoScreen');
$this->ctrl->returnToParent($this);
return FALSE;
}
$next_class = $this->ctrl->getNextClass($this);
switch($next_class)
{
default:
$cmd = $this->ctrl->getCmd("show");
$this->$cmd();
break;
}
return true;
}

+ Here is the call graph for this function:

ilCourseRegistrationGUI::fillInformations ( )
protected

fill informations

protected

Parameters
@return

Reimplemented from ilRegistrationGUI.

Definition at line 110 of file class.ilCourseRegistrationGUI.php.

References ilUtil\makeClickable().

{
if($this->container->getImportantInformation())
{
$imp = new ilNonEditableValueGUI($this->lng->txt('crs_important_info'), "", true);
$value = nl2br(ilUtil::makeClickable($this->container->getImportantInformation(), true));
$imp->setValue($value);
$this->form->addItem($imp);
}
if($this->container->getSyllabus())
{
$syl = new ilNonEditableValueGUI($this->lng->txt('crs_syllabus'), "", true);
$value = nl2br(ilUtil::makeClickable ($this->container->getSyllabus(), true));
$syl->setValue($value);
$this->form->addItem($syl);
}
}

+ Here is the call graph for this function:

ilCourseRegistrationGUI::fillMaxMembers ( )
protected

fill max members

protected

Parameters
@return

Reimplemented from ilRegistrationGUI.

Definition at line 205 of file class.ilCourseRegistrationGUI.php.

References $ilUser, ilRegistrationGUI\$tpl, ilRegistrationGUI\$waiting_list, ilRegistrationGUI\enableRegistration(), ilRegistrationGUI\getWaitingList(), ilUtil\sendFailure(), and ilCustomInputGUI\setHtml().

{
global $ilUser;
if(!$this->container->isSubscriptionMembershipLimited())
{
return true;
}
$tpl = new ilTemplate('tpl.max_members_form.html',true,true,'Services/Membership');
$tpl->setVariable('TXT_MAX',$this->lng->txt('mem_max_users'));
$tpl->setVariable('NUM_MAX',$this->container->getSubscriptionMaxMembers());
$tpl->setVariable('TXT_FREE',$this->lng->txt('mem_free_places').":");
$free = max(0,$this->container->getSubscriptionMaxMembers() - $this->participants->getCountMembers());
if($free)
$tpl->setVariable('NUM_FREE',$free);
else
$tpl->setVariable('WARN_FREE',$free);
include_once('./Modules/Course/classes/class.ilCourseWaitingList.php');
$waiting_list = new ilCourseWaitingList($this->container->getId());
if(
$this->container->isSubscriptionMembershipLimited() and
$this->container->enabledWaitingList() and
(!$free or $waiting_list->getCountUsers()))
{
if($waiting_list->isOnList($ilUser->getId()))
{
$tpl->setVariable('TXT_WAIT',$this->lng->txt('mem_waiting_list_position'));
$tpl->setVariable('NUM_WAIT',$waiting_list->getPosition($ilUser->getId()));
}
else
{
$tpl->setVariable('TXT_WAIT',$this->lng->txt('mem_waiting_list'));
if($free and $waiting_list->getCountUsers())
$tpl->setVariable('WARN_WAIT',$waiting_list->getCountUsers());
else
$tpl->setVariable('NUM_WAIT',$waiting_list->getCountUsers());
}
}
$alert = '';
if(
!$free and
!$this->container->enabledWaitingList())
{
// Disable registration
$this->enableRegistration(false);
ilUtil::sendFailure($this->lng->txt('mem_alert_no_places'));
#$alert = $this->lng->txt('mem_alert_no_places');
}
elseif(
$this->container->enabledWaitingList() and
$this->container->isSubscriptionMembershipLimited() and
$waiting_list->isOnList($ilUser->getId())
)
{
// Disable registration
$this->enableRegistration(false);
}
elseif(
!$free and
$this->container->enabledWaitingList() and
$this->container->isSubscriptionMembershipLimited())
{
ilUtil::sendFailure($this->lng->txt('crs_warn_no_max_set_on_waiting_list'));
#$alert = $this->lng->txt('crs_warn_no_max_set_on_waiting_list');
}
elseif(
$free and
$this->container->enabledWaitingList() and
$this->container->isSubscriptionMembershipLimited() and
$this->getWaitingList()->getCountUsers())
{
ilUtil::sendFailure($this->lng->txt('crs_warn_wl_set_on_waiting_list'));
#$alert = $this->lng->txt('crs_warn_wl_set_on_waiting_list');
}
$max = new ilCustomInputGUI($this->lng->txt('mem_participants'));
$max->setHtml($tpl->get());
if(strlen($alert))
{
$max->setAlert($alert);
}
$this->form->addItem($max);
return true;
}

+ Here is the call graph for this function:

ilCourseRegistrationGUI::fillRegistrationPeriod ( )
protected

show informations about the registration period

protected

Reimplemented from ilRegistrationGUI.

Definition at line 134 of file class.ilCourseRegistrationGUI.php.

References ilRegistrationGUI\$tpl, ilDateTime\_after(), ilDateTime\_before(), ilRegistrationGUI\enableRegistration(), ilDatePresentation\formatDate(), IL_CAL_UNIX, IL_CRS_SUBSCRIPTION_DEACTIVATED, ilUtil\sendFailure(), ilCustomInputGUI\setHtml(), and ilNonEditableValueGUI\setValue().

{
include_once('./Services/Calendar/classes/class.ilDateTime.php');
$now = new ilDateTime(time(),IL_CAL_UNIX,'UTC');
if($this->container->getSubscriptionUnlimitedStatus())
{
$reg = new ilNonEditableValueGUI($this->lng->txt('mem_reg_period'));
$reg->setValue($this->lng->txt('mem_unlimited'));
$this->form->addItem($reg);
return true;
}
elseif($this->container->getSubscriptionLimitationType() == IL_CRS_SUBSCRIPTION_DEACTIVATED)
{
return true;
}
$start = new ilDateTime($this->container->getSubscriptionStart(),IL_CAL_UNIX,'UTC');
$end = new ilDateTime($this->container->getSubscriptionEnd(),IL_CAL_UNIX,'UTC');
if(ilDateTime::_before($now,$start))
{
$tpl = new ilTemplate('tpl.registration_period_form.html',true,true,'Services/Membership');
$tpl->setVariable('TXT_FIRST',$this->lng->txt('mem_start'));
$tpl->setVariable('FIRST',ilDatePresentation::formatDate($start));
$tpl->setVariable('TXT_END',$this->lng->txt('mem_end'));
$tpl->setVariable('END',ilDatePresentation::formatDate($end));
$warning = $this->lng->txt('mem_reg_not_started');
}
elseif(ilDateTime::_after($now,$end))
{
$tpl = new ilTemplate('tpl.registration_period_form.html',true,true,'Services/Membership');
$tpl->setVariable('TXT_FIRST',$this->lng->txt('mem_start'));
$tpl->setVariable('FIRST',ilDatePresentation::formatDate($start));
$tpl->setVariable('TXT_END',$this->lng->txt('mem_end'));
$tpl->setVariable('END',ilDatePresentation::formatDate($end));
$warning = $this->lng->txt('mem_reg_expired');
}
else
{
$tpl = new ilTemplate('tpl.registration_period_form.html',true,true,'Services/Membership');
$tpl->setVariable('TXT_FIRST',$this->lng->txt('mem_end'));
$tpl->setVariable('FIRST',ilDatePresentation::formatDate($end));
}
$reg = new ilCustomInputGUI($this->lng->txt('mem_reg_period'));
$reg->setHtml($tpl->get());
if(strlen($warning))
{
// Disable registration
$this->enableRegistration(false);
#$reg->setAlert($warning);
}
$this->form->addItem($reg);
return true;
}

+ Here is the call graph for this function:

ilCourseRegistrationGUI::fillRegistrationType ( )
protected

fill registration type

protected

Returns

Reimplemented from ilRegistrationGUI.

Definition at line 303 of file class.ilCourseRegistrationGUI.php.

References $_POST, $ilUser, $pass, $txt, ilRegistrationGUI\enableRegistration(), IL_CRS_SUBSCRIPTION_CONFIRMATION, IL_CRS_SUBSCRIPTION_DEACTIVATED, IL_CRS_SUBSCRIPTION_DIRECT, IL_CRS_SUBSCRIPTION_PASSWORD, isWaitingListActive(), ilUtil\sendFailure(), ilFormPropertyGUI\setAlert(), and ilTextAreaInputGUI\setValue().

{
global $ilUser;
if($this->container->getSubscriptionLimitationType() == IL_CRS_SUBSCRIPTION_DEACTIVATED)
{
$reg = new ilCustomInputGUI($this->lng->txt('mem_reg_type'));
#$reg->setHtml($this->lng->txt('crs_info_reg_deactivated'));
$reg->setAlert($this->lng->txt('crs_info_reg_deactivated'));
#ilUtil::sendFailure($this->lng->txt('crs_info_reg_deactivated'));
#$reg = new ilNonEditableValueGUI($this->lng->txt('mem_reg_type'));
#$reg->setValue($this->lng->txt('crs_info_reg_deactivated'));
#$reg->setAlert($this->lng->txt('grp_reg_deactivated_alert'));
$this->form->addItem($reg);
// Disable registration
$this->enableRegistration(false);
return true;
}
switch($this->container->getSubscriptionType())
{
// no "request" info if waiting list is active
if($this->isWaitingListActive())
return true;
$txt = new ilNonEditableValueGUI($this->lng->txt('mem_reg_type'));
$txt->setValue($this->lng->txt('crs_info_reg_direct'));
$this->form->addItem($txt);
break;
$txt = new ilNonEditableValueGUI($this->lng->txt('mem_reg_type'));
$txt->setValue($this->lng->txt('crs_subscription_options_password'));
$pass = new ilTextInputGUI($this->lng->txt('passwd'),'grp_passw');
$pass->setInputType('password');
$pass->setSize(12);
$pass->setMaxLength(32);
#$pass->setRequired(true);
$pass->setInfo($this->lng->txt('crs_info_reg_password'));
$txt->addSubItem($pass);
$this->form->addItem($txt);
break;
// no "request" info if waiting list is active
if($this->isWaitingListActive())
return true;
$txt = new ilNonEditableValueGUI($this->lng->txt('mem_reg_type'));
$txt->setValue($this->lng->txt('crs_subscription_options_confirmation'));
$sub = new ilTextAreaInputGUI($this->lng->txt('crs_reg_subject'),'subject');
$sub->setValue($_POST['subject']);
$sub->setInfo($this->lng->txt('crs_info_reg_confirmation'));
$sub->setCols(40);
$sub->setRows(5);
if($this->participants->isSubscriber($ilUser->getId()))
{
$sub_data = $this->participants->getSubscriberData($ilUser->getId());
$sub->setValue($sub_data['subject']);
$sub->setInfo('');
ilUtil::sendFailure($this->lng->txt('crs_reg_user_already_subscribed'));
$this->enableRegistration(false);
}
$txt->addSubItem($sub);
$this->form->addItem($txt);
break;
default:
return true;
}
return true;
}

+ Here is the call graph for this function:

ilCourseRegistrationGUI::getFormTitle ( )
protected

get form title

protected

Returns
string title

Reimplemented from ilRegistrationGUI.

Definition at line 92 of file class.ilCourseRegistrationGUI.php.

References $ilUser, and ilRegistrationGUI\getWaitingList().

{
global $ilUser;
if($this->getWaitingList()->isOnList($ilUser->getId()))
{
return $this->lng->txt('member_status');
}
return $this->lng->txt('crs_registration');
}

+ Here is the call graph for this function:

ilCourseRegistrationGUI::initParticipants ( )
protected

Init course participants.

protected

Reimplemented from ilRegistrationGUI.

Definition at line 575 of file class.ilCourseRegistrationGUI.php.

References ilCourseParticipants\_getInstanceByObjId().

{
include_once('./Modules/Course/classes/class.ilCourseParticipants.php');
$this->participants = ilCourseParticipants::_getInstanceByObjId($this->obj_id);
}

+ Here is the call graph for this function:

ilCourseRegistrationGUI::initWaitingList ( )
protected
See Also
ilRegistrationGUI::initWaitingList() protected

Reimplemented from ilRegistrationGUI.

Definition at line 586 of file class.ilCourseRegistrationGUI.php.

{
include_once './Modules/Course/classes/class.ilCourseWaitingList.php';
$this->waiting_list = new ilCourseWaitingList($this->container->getId());
}
ilCourseRegistrationGUI::isWaitingListActive ( )
protected
See Also
ilRegistrationGUI::isWaitingListActive()

Reimplemented from ilRegistrationGUI.

Definition at line 595 of file class.ilCourseRegistrationGUI.php.

References $ilUser, and ilRegistrationGUI\getWaitingList().

Referenced by fillRegistrationType().

{
global $ilUser;
static $active = null;
if($active !== null)
{
return $active;
}
if(!$this->container->enabledWaitingList() or !$this->container->isSubscriptionMembershipLimited())
{
return $active = false;
}
if(!$this->container->getSubscriptionMaxMembers())
{
return $active = false;
}
$free = max(0,$this->container->getSubscriptionMaxMembers() - $this->participants->getCountMembers());
return $active = (!$free or $this->getWaitingList()->getCountUsers());
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCourseRegistrationGUI::validate ( )
protected

Validate subscription request.

protected

Parameters
@return

Reimplemented from ilRegistrationGUI.

Definition at line 430 of file class.ilCourseRegistrationGUI.php.

References $_POST, $ilUser, $pass, IL_CRS_SUBSCRIPTION_PASSWORD, ilRegistrationGUI\isRegistrationPossible(), ilRegistrationGUI\setAccepted(), ilUtil\stripSlashes(), ilRegistrationGUI\validateAgreement(), and ilRegistrationGUI\validateCustomFields().

{
global $ilUser;
if($ilUser->getId() == ANONYMOUS_USER_ID)
{
$this->join_error = $this->lng->txt('permission_denied');
return false;
}
// Set aggrement to not accepted
$this->setAccepted(false);
if(!$this->isRegistrationPossible())
{
$this->join_error = $this->lng->txt('mem_error_preconditions');
return false;
}
if($this->container->getSubscriptionType() == IL_CRS_SUBSCRIPTION_PASSWORD)
{
if(!strlen($pass = ilUtil::stripSlashes($_POST['grp_passw'])))
{
$this->join_error = $this->lng->txt('crs_password_required');
return false;
}
if(strcmp($pass,$this->container->getSubscriptionPassword()) !== 0)
{
$this->join_error = $this->lng->txt('crs_password_not_valid');
return false;
}
}
if(!$this->validateCustomFields())
{
$this->join_error = $this->lng->txt('fill_out_all_required_fields');
return false;
}
if(!$this->validateAgreement())
{
$this->join_error = $this->lng->txt('crs_agreement_required');
return false;
}
return true;
}

+ Here is the call graph for this function:

Field Documentation

ilCourseRegistrationGUI::$parent_gui = null
private

Definition at line 39 of file class.ilCourseRegistrationGUI.php.


The documentation for this class was generated from the following file: