ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilMembershipRegistrationCodeUtils Class Reference

Stores registration keys for key based registration on courses and groups. More...

+ Collaboration diagram for ilMembershipRegistrationCodeUtils:

Static Public Member Functions

static handleCode ($a_ref_id, $a_type, $a_code)
 Handle target parameter. More...
 
static generateCode ()
 Generate new registration key. More...
 

Data Fields

const CODE_LENGTH = 10
 

Static Protected Member Functions

static useCode ($a_code, $a_endnode)
 Use a registration code and assign the logged in user to the (parent) course/group that offer the code. More...
 
static lookupObjectsByCode ($a_code)
 Get all objects with enabled access codes. More...
 

Detailed Description

Stores registration keys for key based registration on courses and groups.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 13 of file class.ilMembershipRegistrationCodeUtils.php.

Member Function Documentation

◆ generateCode()

static ilMembershipRegistrationCodeUtils::generateCode ( )
static

Generate new registration key.

Returns

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

111 {
112 // missing : 01iloO
113 $map = "23456789abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ";
114
115 $code = "";
116 $max = strlen($map) - 1;
117 for ($loop = 1; $loop <= self::CODE_LENGTH; $loop++) {
118 $code .= $map[mt_rand(0, $max)];
119 }
120 return $code;
121 }
$code
Definition: example_050.php:99

References $code, $map, and CODE_LENGTH.

Referenced by ilObjCourse\__createDefaultSettings(), ilObjGroup\cloneObject(), ilObjCourse\cloneSettings(), ilObjCourseGUI\initEditForm(), and ilObjGroupGUI\initForm().

+ Here is the caller graph for this function:

◆ handleCode()

static ilMembershipRegistrationCodeUtils::handleCode (   $a_ref_id,
  $a_type,
  $a_code 
)
static

Handle target parameter.

Parameters
object$a_target
Returns

Definition at line 23 of file class.ilMembershipRegistrationCodeUtils.php.

24 {
25 global $DIC;
26
27 $lng = $DIC['lng'];
28 $tree = $DIC['tree'];
29 $ilUser = $DIC['ilUser'];
30 include_once './Services/Link/classes/class.ilLink.php';
31 $lng->loadLanguageModule($a_type);
32 try {
33 self::useCode($a_code, $a_ref_id);
35 ilUtil::sendSuccess(sprintf($lng->txt($a_type . "_admission_link_success_registration"), $title), true);
38 switch ($e->getCode()) {
40 ilUtil::sendSuccess($e->getMessage(), true);
41 break;
43 ilUtil::sendFailure($lng->txt($a_type . "_admission_link_failure_membership_limited"), true);
44 break;
46 ilUtil::sendFailure($lng->txt($a_type . "_admission_link_failure_registration_period"), true);
47 break;
49 ilUtil::sendFailure($lng->txt($a_type . "_admission_link_failure_invalid_code"), true);
50 break;
52 ilUtil::sendFailure($lng->txt($a_type . '_admission_link_failure_offline'), true);
53 break;
55 ilUtil::sendFailure($lng->txt($a_type . '_admission_link_failure_availability'), true);
56 break;
57 default:
58 ilUtil::sendFailure($e->getMessage(), true);
59 break;
60 }
61 $parent_id = $tree->getParentId($a_ref_id);
63 }
64 }
static useCode($a_code, $a_endnode)
Use a registration code and assign the logged in user to the (parent) course/group that offer the cod...
static _lookupTitle($a_id)
lookup object title
static _lookupObjectId($a_ref_id)
lookup object id
static redirect($a_script)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $DIC
Definition: saml.php:7
$lng
$ilUser
Definition: imgupload.php:18
$a_type
Definition: workflow.php:92

References $a_type, $DIC, $ilUser, $lng, $title, $tree, ilLink\_getLink(), ilObject\_lookupObjectId(), ilObject\_lookupTitle(), ilMembershipRegistrationException\ADDED_TO_WAITINGLIST, ilMembershipRegistrationException\ADMISSION_LINK_INVALID, ilMembershipRegistrationException\OBJECT_IS_FULL, ilMembershipRegistrationException\OUT_OF_REGISTRATION_PERIOD, ilUtil\redirect(), ilMembershipRegistrationException\REGISTRATION_INVALID_AVAILABILITY, ilMembershipRegistrationException\REGISTRATION_INVALID_OFFLINE, ilUtil\sendFailure(), and useCode().

Referenced by ilObjCourseGUI\_goto(), ilObjGroupGUI\_goto(), and ilObjLearningSequence\_goto().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookupObjectsByCode()

static ilMembershipRegistrationCodeUtils::lookupObjectsByCode (   $a_code)
staticprotected

Get all objects with enabled access codes.

Parameters
string$a_code
Returns

Definition at line 128 of file class.ilMembershipRegistrationCodeUtils.php.

129 {
130 include_once './Modules/Group/classes/class.ilObjGroup.php';
131 include_once './Modules/Course/classes/class.ilObjCourse.php';
132
133 return array_merge(
136 );
137 }
static lookupObjectsByCode($a_code)
static lookupObjectsByCode($a_code)

References ilObjCourse\lookupObjectsByCode(), and ilObjGroup\lookupObjectsByCode().

Referenced by useCode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ useCode()

static ilMembershipRegistrationCodeUtils::useCode (   $a_code,
  $a_endnode 
)
staticprotected

Use a registration code and assign the logged in user to the (parent) course/group that offer the code.

Todo:
: throw an error if registration fails (max members, availibility...)
Parameters
string$a_code
int$a_endnodeReference id of node in tree
Returns

Definition at line 78 of file class.ilMembershipRegistrationCodeUtils.php.

79 {
80 global $DIC;
81
82 $tree = $DIC['tree'];
83 $ilUser = $DIC['ilUser'];
84
85 $obj_ids = self::lookupObjectsByCode($a_code);
86
87 if (!$obj_ids) {
88 include_once './Services/Membership/exceptions/class.ilMembershipRegistrationException.php';
90 }
91
92 foreach ($tree->getPathId($a_endnode) as $ref_id) {
93 if (in_array(ilObject::_lookupObjId($ref_id), $obj_ids)) {
95 $member_obj = $factory->getInstanceByRefId($ref_id, false);
96 if ($member_obj instanceof ilObjCourse) {
97 $member_obj->register($ilUser->getId(), ilCourseConstants::CRS_MEMBER);
98 }
99 if ($member_obj instanceof ilObjGroup) {
100 $member_obj->register($ilUser->getId(), IL_GRP_MEMBER, true);
101 }
102 }
103 }
104 }
$factory
Definition: metadata.php:43
const IL_GRP_MEMBER
static lookupObjectsByCode($a_code)
Get all objects with enabled access codes.
Class ilObjCourse.
Class ilObjGroup.
Class ilObjectFactory.
static _lookupObjId($a_id)

References $DIC, $factory, $ilUser, $tree, ilObject\_lookupObjId(), ilMembershipRegistrationException\ADMISSION_LINK_INVALID, ilCourseConstants\CRS_MEMBER, IL_GRP_MEMBER, and lookupObjectsByCode().

Referenced by handleCode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ CODE_LENGTH

const ilMembershipRegistrationCodeUtils::CODE_LENGTH = 10

Definition at line 15 of file class.ilMembershipRegistrationCodeUtils.php.

Referenced by generateCode().


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