ILIAS  trunk Revision v12.0_alpha-16-g3e876e53c80
ILIAS\Registration\DualOptIn\Setup\DualOptInDatabaseUpdateSteps Class Reference
+ Inheritance diagram for ILIAS\Registration\DualOptIn\Setup\DualOptInDatabaseUpdateSteps:
+ Collaboration diagram for ILIAS\Registration\DualOptIn\Setup\DualOptInDatabaseUpdateSteps:

Public Member Functions

 prepare (\ilDBInterface $db)
 Prepare the execution of the steps. More...
 
 step_1 ()
 
 step_2 ()
 
 step_3 ()
 
 step_4 ()
 
 prepare (\ilDBInterface $db)
 Prepare the execution of the steps. More...
 

Protected Attributes

ilDBInterface $db
 

Detailed Description

Definition at line 25 of file DualOptInDatabaseUpdateSteps.php.

Member Function Documentation

◆ prepare()

ILIAS\Registration\DualOptIn\Setup\DualOptInDatabaseUpdateSteps::prepare ( \ilDBInterface  $db)

Prepare the execution of the steps.

Do not use anything from the globals or the DIC inside your steps, only use the instance of the database provided here.

Implements ilDatabaseUpdateSteps.

Definition at line 29 of file DualOptInDatabaseUpdateSteps.php.

References ILIAS\Registration\DualOptIn\Setup\DualOptInDatabaseUpdateSteps\$db.

◆ step_1()

ILIAS\Registration\DualOptIn\Setup\DualOptInDatabaseUpdateSteps::step_1 ( )

Definition at line 34 of file DualOptInDatabaseUpdateSteps.php.

34 : void
35 {
36 if ($this->db->tableExists('reg_dual_opt_in')) {
37 return;
38 }
39
40 $fields = [
41 'id' => [
42 'type' => \ilDBConstants::T_TEXT,
43 'length' => 36,
44 'fixed' => true,
45 'notnull' => true,
46 ],
47 'usr_id' => [
49 'length' => 8,
50 'notnull' => true
51 ],
52 'reg_hash' => [
53 'type' => \ilDBConstants::T_TEXT,
54 'length' => 16,
55 'fixed' => true,
56 'notnull' => true
57 ],
58 'creation_date' => [
60 'length' => 8,
61 'notnull' => true
62 ]
63 ];
64
65 $this->db->createTable('reg_dual_opt_in', $fields);
66 $this->db->addPrimaryKey('reg_dual_opt_in', ['id']);
67 }
return true

References ilDBConstants\T_INTEGER, ilDBConstants\T_TEXT, and true.

◆ step_2()

ILIAS\Registration\DualOptIn\Setup\DualOptInDatabaseUpdateSteps::step_2 ( )

Definition at line 69 of file DualOptInDatabaseUpdateSteps.php.

69 : void
70 {
71 if (!$this->db->tableExists('usr_data') ||
72 !$this->db->tableColumnExists('usr_data', 'reg_hash')) {
73 return;
74 }
75
76 $res = $this->db->query(
77 <<<SQL
78 SELECT ud.usr_id, ud.reg_hash, ud.create_date
79 FROM usr_data ud
80 INNER JOIN object_data od ON od.obj_id = ud.usr_id
81 WHERE ud.reg_hash IS NOT NULL AND ud.reg_hash <> ''
82SQL
83 );
84
85 while ($row = $res->fetchRow(\ilDBConstants::FETCHMODE_OBJECT)) {
86 $this->db->manipulateF(
87 'INSERT INTO reg_dual_opt_in (id, usr_id, reg_hash, creation_date) VALUES (%s, %s, %s, %s)',
88 [
93 ],
94 [
95 (new UUIDFactory())->uuid4(),
96 $row->usr_id,
97 $row->reg_hash,
98 (new \DateTimeImmutable($row->create_date, new \DateTimeZone('UTC')))->getTimestamp()
99 ]
100 );
101 }
102 }
$res
Definition: ltiservices.php:69

References $res, ilDBConstants\FETCHMODE_OBJECT, ILIAS\Data\Description\NULL, ilDBConstants\T_INTEGER, and ilDBConstants\T_TEXT.

◆ step_3()

ILIAS\Registration\DualOptIn\Setup\DualOptInDatabaseUpdateSteps::step_3 ( )

Definition at line 104 of file DualOptInDatabaseUpdateSteps.php.

104 : void
105 {
106 if (!$this->db->tableExists('usr_data') ||
107 !$this->db->tableColumnExists('usr_data', 'reg_hash')) {
108 return;
109 }
110
111 $this->db->dropTableColumn('usr_data', 'reg_hash');
112 }

◆ step_4()

ILIAS\Registration\DualOptIn\Setup\DualOptInDatabaseUpdateSteps::step_4 ( )

Definition at line 114 of file DualOptInDatabaseUpdateSteps.php.

114 : void
115 {
116 if ($this->db->tableExists('reg_dual_opt_in') &&
117 !$this->db->indexExistsByFields('reg_dual_opt_in', ['reg_hash'])) {
118 $this->db->addIndex('reg_dual_opt_in', ['reg_hash'], 'i1');
119 }
120
121 if ($this->db->tableExists('reg_dual_opt_in') &&
122 !$this->db->indexExistsByFields('reg_dual_opt_in', ['usr_id'])) {
123 $this->db->addIndex('reg_dual_opt_in', ['usr_id'], 'i2');
124 }
125 }

Field Documentation

◆ $db

ilDBInterface ILIAS\Registration\DualOptIn\Setup\DualOptInDatabaseUpdateSteps::$db
protected

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