ILIAS  Release_3_10_x_branch Revision 61812
 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)
 Constructor.
 executeCommand ()
 Execute command.
- Public Member Functions inherited from ilRegistrationGUI
 cancel ()
 cancel subscription
 show ()
 show registration form
 join ()
 join
 ilRegistrationGUI ()
 login ()
 displayForm ()
 showUserDefinedFields ()
 checkUserDefinedRequiredFields ()
 saveForm ()
 __validateRole ()
 __assignRole ()
 __showRoleSelection ()
 __distributeMails ()

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
 fillAgreement ()
 Show user agreement.
 showCourseDefinedFields ()
 Show course defined fields.
 validate ()
 Validate subscription request.
 add ()
 add user
 initParticipants ()
 Init course participants.
- Protected Member Functions inherited from ilRegistrationGUI
 isRegistrationPossible ()
 check if registration is possible
 enableRegistration ($a_status)
 set registration disabled
 fillMembershipLimitation ()
 Show membership limitations.
 initForm ()
 init registration form

Protected Attributes

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

Private Member Functions

 validateAgreement ()
 Check Agreement.
 validateCourseDefinedFields ()
 Check required course fields.
 setAccepted ($a_status)
 Set Agreement accepted.

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 38 of file class.ilCourseRegistrationGUI.php.

Constructor & Destructor Documentation

ilCourseRegistrationGUI::__construct (   $a_container)

Constructor.

public

Parameters
objectcourse object

Reimplemented from ilRegistrationGUI.

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

References ilPrivacySettings\_getInstance().

{
parent::__construct($a_container);
$this->privacy = ilPrivacySettings::_getInstance();
}

+ Here is the call graph for this function:

Member Function Documentation

ilCourseRegistrationGUI::add ( )
protected

add user

protected

Parameters
@return

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

References ilWaitingList\addToList(), IL_CRS_MEMBER, IL_CRS_SUBSCRIPTION_CONFIRMATION, ilUtil\redirect(), ilUtil\sendInfo(), setAccepted(), and ilUtil\stripSlashes().

{
global $ilUser,$tree;
// 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()));
$this->participants->sendNotification($this->participants->NOTIFY_SUBSCRIPTION_REQUEST,$ilUser->getId());
ilUtil::sendInfo($info,true);
ilUtil::redirect("repository.php?ref_id=".$tree->getParentId($this->container->getRefId()));
}
switch($this->container->getSubscriptionType())
{
$this->participants->addSubscriber($ilUser->getId());
$this->participants->updateSubscriptionTime($ilUser->getId(),time());
$this->participants->updateSubject($ilUser->getId(),ilUtil::stripSlashes($_POST['grp_subject']));
$this->participants->sendNotification($this->participants->NOTIFY_SUBSCRIPTION_REQUEST,$ilUser->getId());
ilUtil::sendInfo($this->lng->txt("application_completed"),true);
ilUtil::redirect("repository.php?ref_id=".$tree->getParentId($this->container->getRefId()));
break;
default:
$this->participants->add($ilUser->getId(),IL_CRS_MEMBER);
$this->participants->sendNotification($this->participants->NOTIFY_ADMINS,$ilUser->getId());
ilUtil::sendInfo($this->lng->txt("crs_subscription_successful"),true);
$this->ctrl->returnToParent($this);
break;
}
}

+ Here is the call graph for this function:

ilCourseRegistrationGUI::executeCommand ( )

Execute command.

public

Reimplemented from ilRegistrationGUI.

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

References $cmd.

{
$next_class = $this->ctrl->getNextClass($this);
switch($next_class)
{
default:
$cmd = $this->ctrl->getCmd("show");
$this->$cmd();
break;
}
return true;
}
ilCourseRegistrationGUI::fillAgreement ( )
protected

Show user agreement.

protected

Returns

Reimplemented from ilRegistrationGUI.

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

References $section, ilRegistrationGUI\$tpl, ilExportFieldsInfo\_getInstance(), ilPrivacySettings\_getInstance(), ilCourseDefinedFieldDefinition\_hasFields(), ilRegistrationGUI\isRegistrationPossible(), ilCustomInputGUI\setHtml(), ilFormPropertyGUI\setRequired(), and showCourseDefinedFields().

{
global $ilUser;
if(!$this->isRegistrationPossible())
{
return true;
}
$this->privacy = ilPrivacySettings::_getInstance();
include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
if(!$this->privacy->confirmationRequired() and !ilCourseDefinedFieldDefinition::_hasFields($this->container->getId()))
{
return true;
}
$this->lng->loadLanguageModule('ps');
include_once('Services/PrivacySecurity/classes/class.ilExportFieldsInfo.php');
if(!count($fields_info->getExportableFields()))
{
return true;
}
$section->setTitle($this->lng->txt('usr_agreement'));
$this->form->addItem($section);
$fields = new ilCustomInputGUI($this->lng->txt('crs_user_agreement'),'');
$tpl = new ilTemplate('tpl.agreement_form.html',true,true,'Services/Membership');
$tpl->setVariable('TXT_INFO_AGREEMENT',$this->lng->txt('crs_info_agreement'));
foreach($fields_info->getExportableFields() as $field)
{
$tpl->setCurrentBlock('field_item');
$tpl->setVariable('FIELD_NAME',$this->lng->txt($field));
$tpl->parseCurrentBlock();
}
$fields->setHtml($tpl->get());
$this->form->addItem($fields);
// Checkbox agreement
$agreement = new ilCheckboxInputGUI($this->lng->txt('crs_agree'),'agreement');
$agreement->setRequired(true);
$agreement->setOptionTitle($this->lng->txt('crs_info_agree'));
$agreement->setValue(1);
$this->form->addItem($agreement);
return true;
}

+ Here is the call graph for this function:

ilCourseRegistrationGUI::fillInformations ( )
protected

fill informations

protected

Parameters
@return

Reimplemented from ilRegistrationGUI.

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

References ilUtil\makeClickable().

{
if($this->container->getImportantInformation())
{
$imp = new ilNonEditableValueGUI($this->lng->txt('crs_important_info'));
$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'));
$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 185 of file class.ilCourseRegistrationGUI.php.

References ilRegistrationGUI\$tpl, ilRegistrationGUI\enableRegistration(), 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());
$tpl->setVariable('NUM_FREE',$free);
include_once('./Modules/Course/classes/class.ilCourseWaitingList.php');
$waiting_list = new ilCourseWaitingList($this->container->getId());
if($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'));
$tpl->setVariable('NUM_WAIT',$waiting_list->getCountUsers());
}
}
$alert = '';
if(!$free and !$this->container->enabledWaitingList())
{
// Disable registration
$this->enableRegistration(false);
$alert = $this->lng->txt('mem_alert_no_places');
}
elseif($this->container->enabledWaitingList() and $waiting_list->isOnList($ilUser->getId()))
{
// Disable registration
$this->enableRegistration(false);
$alert = $this->lng->txt('mem_already_on_list');
}
elseif(!$free and $this->container->enabledWaitingList())
{
$alert = $this->lng->txt('crs_set_on_waiting_list');
}
elseif($waiting_list->getCountUsers() and $this->container->enabledWaitingList())
{
$alert = $this->lng->txt('crs_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 115 of file class.ilCourseRegistrationGUI.php.

References ilRegistrationGUI\$tpl, ilDateTime\_after(), ilDateTime\_before(), ilRegistrationGUI\enableRegistration(), ilDatePresentation\formatDate(), IL_CAL_UNIX, IL_CRS_SUBSCRIPTION_DEACTIVATED, 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 256 of file class.ilCourseRegistrationGUI.php.

References $pass, ilRegistrationGUI\enableRegistration(), IL_CRS_SUBSCRIPTION_CONFIRMATION, IL_CRS_SUBSCRIPTION_DEACTIVATED, IL_CRS_SUBSCRIPTION_DIRECT, IL_CRS_SUBSCRIPTION_PASSWORD, ilFormPropertyGUI\setAlert(), ilTextAreaInputGUI\setValue(), and ilNonEditableValueGUI\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'));
#$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())
{
$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;
$txt = new ilNonEditableValueGUI($this->lng->txt('mem_reg_type'));
$txt->setValue($this->lng->txt('crs_subscription_options_confirmation'));
$sub = new ilTextAreaInputGUI($this->lng->txt('subject'),'grp_subject');
$sub->setValue($_POST['grp_subject']);
$sub->setInfo($this->lng->txt('crs_info_reg_confirmation'));
$sub->setCols(40);
$sub->setRows(5);
if($this->participants->isSubscriber($ilUser->getId()))
{
$sub->setAlert($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 79 of file class.ilCourseRegistrationGUI.php.

{
return $this->lng->txt('crs_registration');
}
ilCourseRegistrationGUI::initParticipants ( )
protected

Init course participants.

protected

Reimplemented from ilRegistrationGUI.

Definition at line 642 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::setAccepted (   $a_status)
private

Set Agreement accepted.

private

Parameters
bool

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

References ilCourseDefinedFieldDefinition\_hasFields(), and ilCourseAgreement\setAccepted().

Referenced by add(), and validate().

{
global $ilUser;
include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
if(!$this->privacy->confirmationRequired() and !ilCourseDefinedFieldDefinition::_hasFields($this->container->getId()))
{
return true;
}
include_once('Modules/Course/classes/class.ilCourseAgreement.php');
$this->agreement = new ilCourseAgreement($ilUser->getId(),$this->container->getId());
$this->agreement->setAccepted($a_status);
$this->agreement->setAcceptanceTime(time());
$this->agreement->save();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCourseRegistrationGUI::showCourseDefinedFields ( )
protected

Show course defined fields.

protected

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

References ilCourseDefinedFieldDefinition\_getFields(), IL_CDF_TYPE_SELECT, IL_CDF_TYPE_TEXT, ilNonEditableValueGUI\setValue(), and ilUtil\stripSlashes().

Referenced by fillAgreement().

{
global $ilUser;
include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
include_once('Modules/Course/classes/Export/class.ilCourseUserData.php');
if(!count($cdf_fields = ilCourseDefinedFieldDefinition::_getFields($this->container->getId())))
{
return true;
}
$cdf = new ilNonEditableValueGUI($this->lng->txt('ps_crs_user_fields'));
$cdf->setValue($this->lng->txt('ps_cdf_info'));
$cdf->setRequired(true);
foreach($cdf_fields as $field_obj)
{
$course_user_data = new ilCourseUserData($ilUser->getId(),$field_obj->getId());
switch($field_obj->getType())
{
$select = new ilSelectInputGUI($field_obj->getName(),'cdf['.$field_obj->getId().']');
$select->setValue(ilUtil::stripSlashes($_POST['cdf'][$field_obj->getId()]));
$select->setOptions($field_obj->prepareSelectBox());
if($field_obj->isRequired())
{
$select->setRequired(true);
}
$cdf->addSubItem($select);
break;
$text = new ilTextInputGUI($field_obj->getName(),'cdf['.$field_obj->getId().']');
$text->setValue(ilUtil::stripSlashes($_POST['cdf'][$field_obj->getId()]));
$text->setSize(32);
$text->setMaxLength(255);
if($field_obj->isRequired())
{
$text->setRequired(true);
}
$cdf->addSubItem($text);
break;
}
}
$this->form->addItem($cdf);
return true;
}

+ 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 456 of file class.ilCourseRegistrationGUI.php.

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

{
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;
}
}
{
$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:

ilCourseRegistrationGUI::validateAgreement ( )
private

Check Agreement.

protected

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

References ilCourseDefinedFieldDefinition\_hasFields().

Referenced by validate().

{
global $ilUser;
if($_POST['agreement'])
{
return true;
}
include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
if(!$this->privacy->confirmationRequired() and !ilCourseDefinedFieldDefinition::_hasFields($this->container->getId()))
{
return true;
}
return false;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCourseRegistrationGUI::validateCourseDefinedFields ( )
private

Check required course fields.

protected

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

References ilCourseDefinedFieldDefinition\_getFields(), IL_CDF_TYPE_SELECT, IL_CDF_TYPE_TEXT, ilCourseUserData\setValue(), and ilUtil\stripSlashes().

Referenced by validate().

{
global $ilUser;
include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
include_once('Modules/Course/classes/Export/class.ilCourseUserData.php');
$all_required = true;
foreach(ilCourseDefinedFieldDefinition::_getFields($this->container->getId()) as $field_obj)
{
switch($field_obj->getType())
{
$value = ilUtil::stripSlashes($_POST['cdf'][$field_obj->getId()]);
break;
$value = ilUtil::stripSlashes($_POST['cdf'][$field_obj->getId()]);
break;
}
$course_user_data = new ilCourseUserData($ilUser->getId(),$field_obj->getId());
$course_user_data->setValue($value);
$course_user_data->update();
if($field_obj->isRequired() and (!strlen($value) or $value == -1))
{
$all_required = false;
}
}
return $all_required;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilCourseRegistrationGUI::$privacy = null
protected

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


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