19    public static function create($valid_until, $stamp)
 
   25        $id = 
$ilDB->nextId(self::DB_TABLE);
 
   31            $chk = 
$ilDB->queryF(
"SELECT code_id FROM " . self::DB_TABLE . 
" WHERE code = %s", array(
"text"), array($code));
 
   32            $found = (bool) 
$ilDB->numRows($chk);
 
   36            'code_id' => array(
'integer', $id),
 
   37            'code' => array(
'text', $code),
 
   38            'generated' => array(
'integer', $stamp),
 
   39            'valid_until' => array(
'text', $valid_until)
 
   49        $map = 
"23456789abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ";
 
   52        $max = strlen($map) - 1;
 
   54            $code .= $map[mt_rand(0, $max)];
 
   59    public static function getCodesData($order_field, $order_direction, $offset, $limit, $filter_code, $filter_valid_until, $filter_generated)
 
   69        $set = 
$ilDB->query(
"SELECT COUNT(*) AS cnt FROM " . self::DB_TABLE . $where);
 
   71        if ($rec = 
$ilDB->fetchAssoc($set)) {
 
   75        $sql = 
"SELECT * FROM " . self::DB_TABLE . $where;
 
   77            $sql .= 
" ORDER BY " . $order_field . 
" " . $order_direction;
 
   81        $ilDB->setLimit((
int) $limit, (
int) $offset);
 
   82        $set = 
$ilDB->query($sql);
 
   84        while ($rec = 
$ilDB->fetchAssoc($set)) {
 
   87        return array(
"cnt" => $cnt, 
"set" => 
$result);
 
   96        $set = 
$ilDB->query(
"SELECT * FROM " . self::DB_TABLE . 
" WHERE " . 
$ilDB->in(
"code_id", $ids, 
false, 
"integer"));
 
   98        while ($rec = 
$ilDB->fetchAssoc($set)) {
 
  111            return $ilDB->manipulate(
"DELETE FROM " . self::DB_TABLE . 
" WHERE " . 
$ilDB->in(
"code_id", $ids, 
false, 
"integer"));
 
  122        $set = 
$ilDB->query(
"SELECT DISTINCT(generated) AS generated FROM " . self::DB_TABLE . 
" ORDER BY generated");
 
  124        while ($rec = 
$ilDB->fetchAssoc($set)) {
 
  130    protected static function filterToSQL($filter_code, $filter_valid_until, $filter_generated)
 
  138            $where[] = 
$ilDB->like(
"code", 
"text", 
"%" . $filter_code . 
"%");
 
  140        if ($filter_valid_until) {
 
  141            $where[] = 
"valid_until = " . 
$ilDB->quote($filter_valid_until, 
"text");
 
  143        if ($filter_generated) {
 
  144            $where[] = 
"generated = " . 
$ilDB->quote($filter_generated, 
"text");
 
  146        if (
sizeof($where)) {
 
  147            return " WHERE " . implode(
" AND ", $where);
 
  160        $where = 
self::filterToSQL($filter_code, $filter_valid_until, $filter_generated);
 
  163        $set = 
$ilDB->query(
"SELECT code FROM " . self::DB_TABLE . $where . 
" ORDER BY code_id");
 
  165        while ($rec = 
$ilDB->fetchAssoc($set)) {
 
  177        include_once 
'./Services/Registration/classes/class.ilRegistrationCode.php';
 
  181        $set = 
$ilDB->query(
"SELECT used FROM " . self::DB_TABLE . 
" WHERE code = " . 
$ilDB->quote($code, 
"text"));
 
  182        $set = 
$ilDB->fetchAssoc($set);
 
  183        if ($set && !$set[
"used"]) {
 
  195        include_once 
'./Services/Registration/classes/class.ilRegistrationCode.php';
 
  198        return (
bool) 
$ilDB->update(self::DB_TABLE, array(
"used" => array(
"timestamp", time())), array(
"code" => array(
"text", $code)));
 
  207        include_once 
'./Services/Registration/classes/class.ilRegistrationCode.php';
 
  210        if ($code_data[
"alimit"]) {
 
  211            switch ($code_data[
"alimit"]) {
 
  213                    return $code_data[
'alimitdt'];
 
  218        $set = 
$ilDB->query(
"SELECT valid_until FROM " . self::DB_TABLE . 
" WHERE code = " . 
$ilDB->quote($code, 
"text"));
 
  219        $row = 
$ilDB->fetchAssoc($set);
 
  220        if (isset($row[
"valid_until"])) {
 
  221            return $row[
"valid_until"];
 
  227        include_once 
'./Services/Registration/classes/class.ilRegistrationCode.php';
 
  233            $GLOBALS[
'DIC'][
'rbacadmin']->assignUser($grole, $user->
getId());
 
  236        if ($code_data[
"role_local"]) {
 
  237            $code_local_roles = explode(
";", $code_data[
"role_local"]);
 
  238            foreach ((array) $code_local_roles as $role_id) {
 
  239                $GLOBALS[
'DIC'][
'rbacadmin']->assignUser($role_id, $user->
getId());
 
  242                $role_obj = 
$GLOBALS[
'DIC'][
'rbacreview']->getObjectOfRole($role_id);
 
  247                        $role_ref = end($role_refs);
 
  260        include_once 
'./Services/Registration/classes/class.ilRegistrationCode.php';
 
  263        if ($code_data[
"alimit"]) {
 
  264            switch ($code_data[
"alimit"]) {
 
  274                    $rel = unserialize($code_data[
"alimitdt"]);
 
  276                    include_once 
'./Services/Calendar/classes/class.ilDateTime.php';
 
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
An exception for terminatinating execution or to throw for unit testing.
static isUnusedCode($code)
static getGenerationDates()
static create($valid_until, $stamp)
static getCodeValidUntil($code)
static applyRoleAssignments(ilObjUser $user, $code)
static applyAccessLimits(ilObjUser $user, $code)
static getCodesData($order_field, $order_direction, $offset, $limit, $filter_code, $filter_valid_until, $filter_generated)
static generateRandomCode()
static loadCodesByIds(array $ids)
static filterToSQL($filter_code, $filter_valid_until, $filter_generated)
static deleteCodes(array $ids)
static getCodesForExport($filter_code, $filter_valid_until, $filter_generated)
@classDescription Date and time handling
setTimeLimitUntil($a_until)
setTimeLimitUnlimited($a_unlimited)
static _getAllReferences($a_id)
get all reference ids of object
getId()
get object id @access public
static _lookupType($a_id, $a_reference=false)
lookup object type
Recommended content manager (business logic)
static getCodeRole($code)
static getCodeData($code)
static isUnusedCode($code)
Check if code has been used already @global type $ilDB.