ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilRegistrationCode Class Reference

Class ilRegistrationCode. More...

+ Collaboration diagram for ilRegistrationCode:

Static Public Member Functions

static create ($role, $stamp)
static getCodesData ($order_field, $order_direction, $offset, $limit, $filter_code, $filter_role, $filter_generated)
static loadCodesByIds (array $ids)
static deleteCodes (array $ids)
static getGenerationDates ()
static getCodesForExport ($filter_code, $filter_role, $filter_generated)
static isUnusedCode ($code)
static useCode ($code)
static getCodeRole ($code)

Data Fields

const DB_TABLE = 'reg_registration_codes'
const CODE_LENGTH = 10

Static Protected Member Functions

static generateRandomCode ()
static filterToSQL ($filter_code, $filter_role, $filter_generated)

Detailed Description

Class ilRegistrationCode.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Version
Id:
class.ilRegistrationSettingsGUI.php 23797 2010-05-07 15:54:03Z jluetzen

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

Member Function Documentation

static ilRegistrationCode::create (   $role,
  $stamp 
)
static

Definition at line 18 of file class.ilRegistrationCode.php.

References $data, and generateRandomCode().

Referenced by ilRegistrationSettingsGUI\createCodes().

{
global $ilDB;
$id = $ilDB->nextId(self::DB_TABLE);
// create unique code
$found = true;
while ($found)
{
$chk = $ilDB->queryF("SELECT code_id FROM ".self::DB_TABLE." WHERE code = %s", array("text"), array($code));
$found = (bool)$ilDB->numRows($chk);
}
$data = array(
'code_id' => array('integer', $id),
'code' => array('text', $code),
'generated' => array('integer', $stamp),
'role' => array('integer', $role)
);
$ilDB->insert(self::DB_TABLE, $data);
return $id;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilRegistrationCode::deleteCodes ( array  $ids)
static

Definition at line 103 of file class.ilRegistrationCode.php.

{
global $ilDB;
if(sizeof($ids))
{
return $ilDB->manipulate("DELETE FROM ".self::DB_TABLE." WHERE ".$ilDB->in("code_id", $ids, false, "integer"));
}
return false;
}
static ilRegistrationCode::filterToSQL (   $filter_code,
  $filter_role,
  $filter_generated 
)
staticprotected

Definition at line 127 of file class.ilRegistrationCode.php.

Referenced by getCodesData(), and getCodesForExport().

{
global $ilDB;
$where = array();
if($filter_code)
{
$where[] = $ilDB->like("code", "text", "%".$filter_code."%");
}
if($filter_role)
{
$where[] ="role = ".$ilDB->quote($filter_role, "integer");
}
if($filter_generated)
{
$where[] ="generated = ".$ilDB->quote($filter_generated, "text");
}
if(sizeof($where))
{
return " WHERE ".implode(" AND ", $where);
}
else
{
return "";
}
}

+ Here is the caller graph for this function:

static ilRegistrationCode::generateRandomCode ( )
staticprotected

Definition at line 44 of file class.ilRegistrationCode.php.

References CODE_LENGTH.

Referenced by create().

{
// 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 ilRegistrationCode::getCodeRole (   $code)
static

Definition at line 191 of file class.ilRegistrationCode.php.

References $row.

Referenced by ilAccountRegistrationGUI\saveForm().

{
global $ilDB;
$set = $ilDB->query("SELECT role FROM ".self::DB_TABLE." WHERE code = ".$ilDB->quote($code, "text"));
$row = $ilDB->fetchAssoc($set);
if(isset($row["role"]))
{
return $row["role"];
}
}

+ Here is the caller graph for this function:

static ilRegistrationCode::getCodesData (   $order_field,
  $order_direction,
  $offset,
  $limit,
  $filter_code,
  $filter_role,
  $filter_generated 
)
static

Definition at line 58 of file class.ilRegistrationCode.php.

References $result, and filterToSQL().

Referenced by ilRegistrationCodesTableGUI\getItems().

{
global $ilDB;
// filter
$where = self::filterToSQL($filter_code, $filter_role, $filter_generated);
// count query
$set = $ilDB->query("SELECT COUNT(*) AS cnt FROM ".self::DB_TABLE.$where);
$cnt = 0;
if ($rec = $ilDB->fetchAssoc($set))
{
$cnt = $rec["cnt"];
}
$sql = "SELECT * FROM ".self::DB_TABLE.$where;
if($order_field)
{
$sql .= " ORDER BY ".$order_field." ".$order_direction;
}
// set query
$ilDB->setLimit((int)$limit, (int)$offset);
$set = $ilDB->query($sql);
$result = array();
while($rec = $ilDB->fetchAssoc($set))
{
$result[] = $rec;
}
return array("cnt" => $cnt, "set" => $result);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilRegistrationCode::getCodesForExport (   $filter_code,
  $filter_role,
  $filter_generated 
)
static

Definition at line 154 of file class.ilRegistrationCode.php.

References $result, and filterToSQL().

Referenced by ilRegistrationSettingsGUI\exportCodes().

{
global $ilDB;
// filter
$where = self::filterToSQL($filter_code, $filter_role, $filter_generated);
// set query
$set = $ilDB->query("SELECT code FROM ".self::DB_TABLE.$where." ORDER BY code_id");
$result = array();
while($rec = $ilDB->fetchAssoc($set))
{
$result[] = $rec["code"];
}
return $result;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilRegistrationCode::getGenerationDates ( )
static

Definition at line 114 of file class.ilRegistrationCode.php.

References $result.

Referenced by ilRegistrationCodesTableGUI\initFilter().

{
global $ilDB;
$set = $ilDB->query("SELECT DISTINCT(generated) AS generated FROM ".self::DB_TABLE." ORDER BY generated");
$result = array();
while($rec = $ilDB->fetchAssoc($set))
{
$result[] = $rec["generated"];
}
return $result;
}

+ Here is the caller graph for this function:

static ilRegistrationCode::isUnusedCode (   $code)
static

Definition at line 171 of file class.ilRegistrationCode.php.

Referenced by ilAccountRegistrationGUI\saveForm().

{
global $ilDB;
$set = $ilDB->query("SELECT used FROM ".self::DB_TABLE." WHERE code = ".$ilDB->quote($code, "text"));
$set = $ilDB->fetchAssoc($set);
if($set && !$set["used"])
{
return true;
}
return false;
}

+ Here is the caller graph for this function:

static ilRegistrationCode::loadCodesByIds ( array  $ids)
static

Definition at line 90 of file class.ilRegistrationCode.php.

References $result.

Referenced by ilRegistrationSettingsGUI\deleteConfirmation().

{
global $ilDB;
$set = $ilDB->query("SELECT * FROM ".self::DB_TABLE." WHERE ".$ilDB->in("code_id", $ids, false, "integer"));
$result = array();
while($rec = $ilDB->fetchAssoc($set))
{
$result[] = $rec;
}
return $result;
}

+ Here is the caller graph for this function:

static ilRegistrationCode::useCode (   $code)
static

Definition at line 184 of file class.ilRegistrationCode.php.

Referenced by ilAccountRegistrationGUI\__createUser().

{
global $ilDB;
return (bool)$ilDB->update(self::DB_TABLE, array("used"=>array("timestamp", time())), array("code"=>array("text", $code)));
}

+ Here is the caller graph for this function:

Field Documentation

const ilRegistrationCode::CODE_LENGTH = 10
const ilRegistrationCode::DB_TABLE = 'reg_registration_codes'

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


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