ILIAS  release_4-4 Revision
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 93 of file class.ilMembershipRegistrationCodeUtils.php.

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

94  {
95  // missing : 01iloO
96  $map = "23456789abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ";
97 
98  $code = "";
99  $max = strlen($map)-1;
100  for($loop = 1; $loop <= self::CODE_LENGTH; $loop++)
101  {
102  $code .= $map[mt_rand(0, $max)];
103  }
104  return $code;
105  }
+ 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.

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

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

24  {
25  global $lng, $tree, $ilUser;
26  include_once './Services/Link/classes/class.ilLink.php';
27  $lng->loadLanguageModule($a_type);
28  try
29  {
30  self::useCode($a_code,$a_ref_id);
32  ilUtil::sendSuccess(sprintf($lng->txt($a_type."_admission_link_success_registration"),$title),true);
34  }
36  {
37  switch($e->getCode())
38  {
39  case 124://added to waiting list
40  ilUtil::sendSuccess($e->getMessage(),true);
41  break;
42  case 123://object is full
43  ilUtil::sendFailure($lng->txt($a_type."_admission_link_failure_membership_limited"), true);
44  break;
45  case 789://out of registration period
46  ilUtil::sendFailure($lng->txt($a_type."_admission_link_failure_registration_period"), true);
47  break;
48  default:
49  ilUtil::sendFailure($e->getMessage(), true);
50  break;
51  }
52  $GLOBALS['ilLog']->logStack();
53  $GLOBALS['ilLog']->write($e->getCode().': '.$e->getMessage());
54 
55  $parent_id = $tree->getParentId($a_ref_id);
57  }
58  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static _lookupTitle($a_id)
lookup object title
static _lookupObjectId($a_ref_id)
lookup object id
$GLOBALS['ct_recipient']
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $ilUser
Definition: imgupload.php:15
global $lng
Definition: privfeed.php:40
static redirect($a_script)
http redirect to other script
+ 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 112 of file class.ilMembershipRegistrationCodeUtils.php.

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

113  {
114  include_once './Modules/Group/classes/class.ilObjGroup.php';
115  include_once './Modules/Course/classes/class.ilObjCourse.php';
116 
117  return array_merge(ilObjGroup::lookupObjectsByCode($a_code), ilObjCourse::lookupObjectsByCode($a_code));
118  }
static lookupObjectsByCode($a_code)
static lookupObjectsByCode($a_code)
+ Here is the call 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 72 of file class.ilMembershipRegistrationCodeUtils.php.

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

73  {
74  global $tree,$ilUser;
75 
76  $obj_ids = self::lookupObjectsByCode($a_code);
77  foreach($tree->getPathId($a_endnode) as $ref_id)
78  {
79  if(in_array(ilObject::_lookupObjId($ref_id), $obj_ids))
80  {
82  {
83  $obj->register($ilUser->getId());
84  }
85  }
86  }
87  }
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static _lookupObjId($a_id)
global $ilUser
Definition: imgupload.php:15
$ref_id
Definition: sahs_server.php:39
+ Here is the call graph for this function:

Field Documentation

◆ CODE_LENGTH

const ilMembershipRegistrationCodeUtils::CODE_LENGTH = 10

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


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