ILIAS  release_4-3 Revision
 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 73 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, ilLink\_getLink(), ilObject\_lookupObjId(), ilObject\_lookupType(), ilUtil\redirect(), and useCode().

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

{
include_once './Services/Link/classes/class.ilLink.php';
try
{
self::useCode($a_code,$a_ref_id);
}
catch(Exception $e)
{
$GLOBALS['ilLog']->logStack();
$GLOBALS['ilLog']->write($e->getMessage());
}
}

+ 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 92 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 51 of file class.ilMembershipRegistrationCodeUtils.php.

References $GLOBALS, $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))
{
{
$GLOBALS['ilLog']->logStack();
$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: