ILIAS  release_7 Revision v7.30-3-g800a261c036
PRGUpdateCRSRefLPSettingMigration Class Reference
+ Inheritance diagram for PRGUpdateCRSRefLPSettingMigration:
+ Collaboration diagram for PRGUpdateCRSRefLPSettingMigration:

Public Member Functions

 getLabel ()
 
 getDefaultAmountOfStepsPerRun ()
 
 getPreconditions (Environment $environment)
 
 prepare (Environment $environment)
 
 step (Environment $environment)
 
 getRemainingAmountOfSteps ()
 

Private Attributes

const DEFAULT_AMOUNT_OF_STEPS = 1000
 
ilDBInterface $db
 
mixed $io
 

Detailed Description

Definition at line 25 of file class.PRGUpdateCRSRefLPSettingMigration.php.

Member Function Documentation

◆ getDefaultAmountOfStepsPerRun()

PRGUpdateCRSRefLPSettingMigration::getDefaultAmountOfStepsPerRun ( )

◆ getLabel()

PRGUpdateCRSRefLPSettingMigration::getLabel ( )

Definition at line 35 of file class.PRGUpdateCRSRefLPSettingMigration.php.

35 : string
36 {
37 return "Update LP Settings of Course References";
38 }

◆ getPreconditions()

PRGUpdateCRSRefLPSettingMigration::getPreconditions ( Environment  $environment)

◆ getRemainingAmountOfSteps()

PRGUpdateCRSRefLPSettingMigration::getRemainingAmountOfSteps ( )

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

90 : int
91 {
92 $query = "SELECT count(distinct od.obj_id) AS cnt " . PHP_EOL .
93 "FROM object_reference oref " . PHP_EOL .
94 "JOIN object_data od ON od.obj_id = oref.obj_id AND od.type = 'crsr'" . PHP_EOL .
95 "JOIN tree ON oref.ref_id = tree.child" . PHP_EOL .
96 "JOIN tree t2 ON t2.path > tree.path" . PHP_EOL .
97 "JOIN object_reference oref2 ON oref2.ref_id = t2.child" . PHP_EOL .
98 "JOIN object_data od2 ON od2.obj_id = oref2.obj_id AND od2.type = 'prg'" . PHP_EOL .
99 "WHERE od.obj_id NOT IN (" . PHP_EOL .
100 "SELECT obj_id FROM ut_lp_settings WHERE obj_type = 'crsr' AND u_mode = "
102 ")";
103 $result = $this->db->query($query);
104 $row = $this->db->fetchAssoc($result);
105
106 return (int) $row['cnt'];
107 }
$result
$query

References $query, $result, and ilLPObjSettings\LP_MODE_COURSE_REFERENCE.

◆ prepare()

PRGUpdateCRSRefLPSettingMigration::prepare ( Environment  $environment)

Definition at line 53 of file class.PRGUpdateCRSRefLPSettingMigration.php.

53 : void
54 {
55 $this->db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
56 }
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.

References ILIAS\Setup\Environment\getResource().

+ Here is the call graph for this function:

◆ step()

PRGUpdateCRSRefLPSettingMigration::step ( Environment  $environment)
Exceptions
Exception

Definition at line 61 of file class.PRGUpdateCRSRefLPSettingMigration.php.

61 : void
62 {
63 $query = "SELECT distinct od.obj_id AS objid " . PHP_EOL .
64 "FROM object_reference oref " . PHP_EOL .
65 "JOIN object_data od ON od.obj_id = oref.obj_id AND od.type = 'crsr'" . PHP_EOL .
66 "JOIN tree ON oref.ref_id = tree.child" . PHP_EOL .
67 "JOIN tree t2 ON t2.path > tree.path" . PHP_EOL .
68 "JOIN object_reference oref2 ON oref2.ref_id = t2.child" . PHP_EOL .
69 "JOIN object_data od2 ON od2.obj_id = oref2.obj_id AND od2.type = 'prg'" . PHP_EOL .
70 "WHERE od.obj_id NOT IN (" . PHP_EOL .
71 "SELECT obj_id FROM ut_lp_settings WHERE obj_type = 'crsr' AND u_mode = "
73 ")" . PHP_EOL .
74 "LIMIT 1";
75
76 $result = $this->db->query($query);
77 $row = $this->db->fetchAssoc($result);
78 $q = 'DELETE FROM ut_lp_settings WHERE obj_id = ' . (int) $row['objid'];
79 $this->db->manipulate($q);
80
81 $q = 'INSERT INTO ut_lp_settings (obj_id, obj_type, u_mode)' . PHP_EOL .
82 'VALUES (' .
83 (int) $row['objid'] .
84 ', "crsr", ' .
86 ');';
87 $this->db->manipulate($q);
88 }

References $query, $result, and ilLPObjSettings\LP_MODE_COURSE_REFERENCE.

Field Documentation

◆ $db

ilDBInterface PRGUpdateCRSRefLPSettingMigration::$db
private

Definition at line 28 of file class.PRGUpdateCRSRefLPSettingMigration.php.

◆ $io

mixed PRGUpdateCRSRefLPSettingMigration::$io
private

Definition at line 33 of file class.PRGUpdateCRSRefLPSettingMigration.php.

◆ DEFAULT_AMOUNT_OF_STEPS

const PRGUpdateCRSRefLPSettingMigration::DEFAULT_AMOUNT_OF_STEPS = 1000
private

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