ILIAS  Release_4_4_x_branch Revision 61816
 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, $local_roles, $limit, $limit_date)
static getCodesData ($order_field, $order_direction, $offset, $limit, $filter_code, $filter_role, $filter_generated, $filter_access_limitation)
static loadCodesByIds (array $ids)
static deleteCodes (array $ids)
static getGenerationDates ()
static getCodesForExport ($filter_code, $filter_role, $filter_generated, $filter_access_limitation)
static isUnusedCode ($code)
static useCode ($code)
static getCodeRole ($code)
static getCodeData ($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, $filter_access_limitation)

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,
  $local_roles,
  $limit,
  $limit_date 
)
static

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

References 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);
}
if(is_array($local_roles))
{
$local_roles = implode(";", $local_roles);
}
if($limit == "relative" && is_array($limit_date))
{
$limit_date = serialize($limit_date);
}
$data = array(
'code_id' => array('integer', $id),
'code' => array('text', $code),
'generated' => array('integer', $stamp),
'role' => array('integer', $role),
'role_local' => array('text', $local_roles),
'alimit' => array('text', $limit),
'alimitdt' => array('text', $limit_date)
);
$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 115 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,
  $filter_access_limitation 
)
staticprotected

Definition at line 139 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($filter_access_limitation)
{
$where[] ="alimit = ".$ilDB->quote($filter_access_limitation, "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 56 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::getCodeData (   $code)
static

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

References $row.

{
global $ilDB;
$set = $ilDB->query("SELECT role, role_local, alimit, alimitdt".
" FROM ".self::DB_TABLE.
" WHERE code = ".$ilDB->quote($code, "text"));
$row = $ilDB->fetchAssoc($set);
return $row;
}
static ilRegistrationCode::getCodeRole (   $code)
static

Definition at line 207 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,
  $filter_access_limitation 
)
static

Definition at line 70 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, $filter_access_limitation);
// 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,
  $filter_access_limitation 
)
static

Definition at line 170 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, $filter_access_limitation);
// 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 126 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 187 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 102 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 200 of file class.ilRegistrationCode.php.

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

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: