ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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.
static generateCode ()
 Generate new registration key.

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.
static lookupObjectsByCode ($a_code)
 Get all objects with enabled access codes.

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

static ilMembershipRegistrationCodeUtils::generateCode ( )
static

Generate new registration key.

Returns

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

References CODE_LENGTH.

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

{
// missing : 01iloO
$map = "23456789abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ";
$code = "";
$max = strlen($map)-1;
for($loop = 1; $loop <= self::CODE_LENGTH; $loop++)
{
$code .= $map[mt_rand(0, $max)];
}
return $code;
}

+ Here is the caller graph for this function:

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.

References $GLOBALS, $ilUser, $lng, ilLink\_getLink(), ilObject\_lookupObjectId(), ilObject\_lookupTitle(), ilUtil\redirect(), ilUtil\sendFailure(), ilUtil\sendSuccess(), and useCode().

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

{
global $lng, $tree, $ilUser;
include_once './Services/Link/classes/class.ilLink.php';
$lng->loadLanguageModule($a_type);
try
{
self::useCode($a_code,$a_ref_id);
ilUtil::sendSuccess(sprintf($lng->txt($a_type."_admission_link_success_registration"),$title),true);
}
{
switch($e->getCode())
{
case 124://added to waiting list
ilUtil::sendSuccess($e->getMessage(),true);
break;
case 123://object is full
ilUtil::sendFailure($lng->txt($a_type."_admission_link_failure_membership_limited"), true);
break;
case 789://out of registration period
ilUtil::sendFailure($lng->txt($a_type."_admission_link_failure_registration_period"), true);
break;
default:
ilUtil::sendFailure($e->getMessage(), true);
break;
}
$GLOBALS['ilLog']->logStack();
$GLOBALS['ilLog']->write($e->getCode().': '.$e->getMessage());
$parent_id = $tree->getParentId($a_ref_id);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilMembershipRegistrationCodeUtils::lookupObjectsByCode (   $a_code)
staticprotected

Get all objects with enabled access codes.

Parameters
string$a_code
Returns

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

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

Referenced by useCode().

{
include_once './Modules/Group/classes/class.ilObjGroup.php';
include_once './Modules/Course/classes/class.ilObjCourse.php';
return array_merge(ilObjGroup::lookupObjectsByCode($a_code), ilObjCourse::lookupObjectsByCode($a_code));
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 72 of file class.ilMembershipRegistrationCodeUtils.php.

References $ilUser, $ref_id, ilObject\_lookupObjId(), ilObjectFactory\getInstanceByRefId(), and lookupObjectsByCode().

Referenced by handleCode().

{
global $tree,$ilUser;
$obj_ids = self::lookupObjectsByCode($a_code);
foreach($tree->getPathId($a_endnode) as $ref_id)
{
if(in_array(ilObject::_lookupObjId($ref_id), $obj_ids))
{
{
$obj->register($ilUser->getId());
}
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

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: