Class ilRegistrationCode.
More...
|
static | create (int $role, int $stamp, array $local_roles, ?string $limit, ?string $limit_date, bool $reg_type, bool $ext_type) |
|
static | getCodesData (string $order_field, string $order_direction, int $offset, int $limit, string $filter_code, int $filter_role, string $filter_generated, string $filter_access_limitation) |
|
static | loadCodesByIds (array $ids) |
|
static | deleteCodes (array $ids) |
|
static | getGenerationDates () |
|
static | getCodesForExport (string $filter_code, ?int $filter_role, string $filter_generated, string $filter_access_limitation) |
|
static | isUnusedCode (string $code) |
|
static | isValidRegistrationCode (string $a_code) |
|
static | useCode (string $code) |
|
static | getCodeRole (string $code) |
|
static | getCodeData (string $code) |
|
|
const | DB_TABLE = 'reg_registration_codes' |
|
|
static | filterToSQL (string $filter_code, ?int $filter_role, string $filter_generated, string $filter_access_limitation) |
|
◆ create()
static ilRegistrationCode::create |
( |
int |
$role, |
|
|
int |
$stamp, |
|
|
array |
$local_roles, |
|
|
?string |
$limit, |
|
|
?string |
$limit_date, |
|
|
bool |
$reg_type, |
|
|
bool |
$ext_type |
|
) |
| |
|
static |
Definition at line 32 of file class.ilRegistrationCode.php.
References $data, $DIC, $id, and $ilDB.
Referenced by ilRegistrationSettingsGUI\createCodes().
43 $ilDB = $DIC->database();
50 $code = self::generateRandomCode();
52 "SELECT code_id FROM " . self::DB_TABLE .
" WHERE code = %s",
56 $found = (bool)
$ilDB->numRows($chk);
60 'code_id' => [
'integer',
$id],
61 'code' => [
'text', $code],
62 'generated_on' => [
'integer', $stamp],
63 'role' => [
'integer', $role],
64 'role_local' => [
'text', implode(
";", $local_roles)],
65 'alimit' => [
'text', $limit],
66 'alimitdt' => [
'text', $limit_date],
67 'reg_enabled' => [
'integer', $reg_type],
68 'ext_enabled' => [
'integer', $ext_type]
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
◆ deleteCodes()
static ilRegistrationCode::deleteCodes |
( |
array |
$ids | ) |
|
|
static |
◆ filterToSQL()
static ilRegistrationCode::filterToSQL |
( |
string |
$filter_code, |
|
|
?int |
$filter_role, |
|
|
string |
$filter_generated, |
|
|
string |
$filter_access_limitation |
|
) |
| |
|
staticprivate |
Definition at line 180 of file class.ilRegistrationCode.php.
References $DIC, and $ilDB.
188 $ilDB = $DIC[
'ilDB'];
192 $where[] =
$ilDB->like(
"code",
"text",
"%" . $filter_code .
"%");
195 $where[] =
"role = " .
$ilDB->quote($filter_role,
"integer");
197 if ($filter_generated) {
198 $where[] =
"generated_on = " .
$ilDB->quote($filter_generated,
"text");
200 if ($filter_access_limitation) {
201 $where[] =
"alimit = " .
$ilDB->quote($filter_access_limitation,
"text");
204 return " WHERE " . implode(
" AND ", $where);
◆ generateRandomCode()
static ilRegistrationCode::generateRandomCode |
( |
| ) |
|
|
staticprotected |
Definition at line 75 of file class.ilRegistrationCode.php.
78 $map =
"23456789abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ";
81 $max = strlen($map) - 1;
82 for ($loop = 1; $loop <= self::CODE_LENGTH; $loop++) {
83 $code .= $map[random_int(0, $max)];
◆ getCodeData()
static ilRegistrationCode::getCodeData |
( |
string |
$code | ) |
|
|
static |
Definition at line 299 of file class.ilRegistrationCode.php.
References $DIC, and $ilDB.
Referenced by ilAccountCode\applyAccessLimits(), ilAccountCode\applyRoleAssignments(), ilAccountCode\getCodeValidUntil(), and ilAccountRegistrationGUI\saveForm().
303 $ilDB = $DIC->database();
304 $set =
$ilDB->query(
"SELECT role, role_local, alimit, alimitdt, reg_enabled, ext_enabled" .
305 " FROM " . self::DB_TABLE .
306 " WHERE code = " .
$ilDB->quote($code,
"text"));
307 return $ilDB->fetchAssoc($set);
◆ getCodeRole()
static ilRegistrationCode::getCodeRole |
( |
string |
$code | ) |
|
|
static |
◆ getCodesData()
static ilRegistrationCode::getCodesData |
( |
string |
$order_field, |
|
|
string |
$order_direction, |
|
|
int |
$offset, |
|
|
int |
$limit, |
|
|
string |
$filter_code, |
|
|
int |
$filter_role, |
|
|
string |
$filter_generated, |
|
|
string |
$filter_access_limitation |
|
) |
| |
|
static |
Definition at line 88 of file class.ilRegistrationCode.php.
References $DIC, and $ilDB.
Referenced by ilRegistrationCodesTableGUI\getItems().
100 $ilDB = $DIC->database();
103 $where = self::filterToSQL($filter_code, $filter_role, $filter_generated, $filter_access_limitation);
106 $set =
$ilDB->query(
"SELECT COUNT(*) AS cnt FROM " . self::DB_TABLE . $where);
108 if ($rec =
$ilDB->fetchAssoc($set)) {
112 $sql =
"SELECT * FROM " . self::DB_TABLE . $where;
114 if ($order_field ===
'generated') {
115 $order_field =
'generated_on';
117 $sql .=
" ORDER BY " . $order_field .
" " . $order_direction;
121 $ilDB->setLimit($limit, $offset);
122 $set =
$ilDB->query($sql);
124 while ($rec =
$ilDB->fetchAssoc($set)) {
125 $rec[
'generated'] = $rec[
'generated_on'];
128 return [
"cnt" => $cnt,
"set" => $result];
◆ getCodesForExport()
static ilRegistrationCode::getCodesForExport |
( |
string |
$filter_code, |
|
|
?int |
$filter_role, |
|
|
string |
$filter_generated, |
|
|
string |
$filter_access_limitation |
|
) |
| |
|
static |
◆ getGenerationDates()
static ilRegistrationCode::getGenerationDates |
( |
| ) |
|
|
static |
◆ isUnusedCode()
static ilRegistrationCode::isUnusedCode |
( |
string |
$code | ) |
|
|
static |
◆ isValidRegistrationCode()
static ilRegistrationCode::isValidRegistrationCode |
( |
string |
$a_code | ) |
|
|
static |
Definition at line 243 of file class.ilRegistrationCode.php.
References $DIC, $ilDB, $query, and $res.
Referenced by ilAccountRegistrationGUI\saveForm().
247 $ilDB = $DIC->database();
249 $query =
'SELECT alimit, alimitdt FROM reg_registration_codes ' .
250 'WHERE used = ' .
$ilDB->quote(0,
'integer') .
' ' .
251 'AND reg_enabled = ' .
$ilDB->quote(1,
'integer') .
' ' .
252 'AND code = ' .
$ilDB->quote($a_code,
'text');
261 if ($row[
'alimit'] ===
'absolute') {
262 $clock_factory = (new \ILIAS\Data\Factory())->clock();
265 $clock_factory->system()->now()->getTimezone()
268 $is_valid = $right_interval >= $clock_factory->system()->now();
◆ loadCodesByIds()
static ilRegistrationCode::loadCodesByIds |
( |
array |
$ids | ) |
|
|
static |
◆ useCode()
static ilRegistrationCode::useCode |
( |
string |
$code | ) |
|
|
static |
◆ CODE_LENGTH
const ilRegistrationCode::CODE_LENGTH = 10 |
◆ DB_TABLE
const ilRegistrationCode::DB_TABLE = 'reg_registration_codes' |
|
protected |
The documentation for this class was generated from the following file: