ILIAS  release_8 Revision v8.24
ilExternalFeedRemoveMigration Class Reference
+ Inheritance diagram for ilExternalFeedRemoveMigration:
+ Collaboration diagram for ilExternalFeedRemoveMigration:

Public Member Functions

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

Protected Member Functions

 log (string $str)
 
 manipulate (string $query)
 

Protected Attributes

ilDBInterface $db
 

Detailed Description

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

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

Member Function Documentation

◆ getDefaultAmountOfStepsPerRun()

ilExternalFeedRemoveMigration::getDefaultAmountOfStepsPerRun ( )

Definition at line 34 of file class.ilExternalFeedRemoveMigration.php.

34 : int
35 {
36 return 10;
37 }

◆ getLabel()

ilExternalFeedRemoveMigration::getLabel ( )

Definition at line 29 of file class.ilExternalFeedRemoveMigration.php.

29 : string
30 {
31 return "Remove external feeds from repository.";
32 }

◆ getPreconditions()

◆ getRemainingAmountOfSteps()

ilExternalFeedRemoveMigration::getRemainingAmountOfSteps ( )

Definition at line 223 of file class.ilExternalFeedRemoveMigration.php.

223 : int
224 {
225 $db = $this->db;
226
227 $set = $db->queryF(
228 "SELECT * FROM object_data d JOIN object_reference r ON (d.obj_id = r.obj_id) " .
229 " WHERE d.type = %s ",
230 ["text"],
231 ["feed"]
232 );
233 $obj_ids = [];
234 while ($rec = $db->fetchAssoc($set)) {
235 $obj_ids[$rec["obj_id"]] = $rec["obj_id"];
236 }
237
238 if (count($obj_ids) > 0) {
239 return 1;
240 }
241 return 0;
242 }
fetchAssoc(ilDBStatement $statement)
queryF(string $query, array $types, array $values)

References $db, ilDBInterface\fetchAssoc(), and ilDBInterface\queryF().

+ Here is the call graph for this function:

◆ log()

ilExternalFeedRemoveMigration::log ( string  $str)
protected

Definition at line 55 of file class.ilExternalFeedRemoveMigration.php.

55 : void
56 {
57 echo "\n" . $str;
58 }

Referenced by manipulate(), and step().

+ Here is the caller graph for this function:

◆ manipulate()

ilExternalFeedRemoveMigration::manipulate ( string  $query)
protected

Definition at line 216 of file class.ilExternalFeedRemoveMigration.php.

216 : void
217 {
218 $db = $this->db;
220 $this->log($query);
221 }
manipulate(string $query)
Run a (write) Query on the database.
$query

References $db, $query, log(), and ilDBInterface\manipulate().

Referenced by step().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ step()

ilExternalFeedRemoveMigration::step ( Environment  $environment)

Definition at line 60 of file class.ilExternalFeedRemoveMigration.php.

60 : void
61 {
62 $db = $this->db;
63
64 $ref_ids = [];
65 $obj_ids = [];
66
67 $set = $db->queryF(
68 "SELECT * FROM object_data d JOIN object_reference r ON (d.obj_id = r.obj_id) " .
69 " WHERE d.type = %s ",
70 ["text"],
71 ["feed"]
72 );
73 while ($rec = $db->fetchAssoc($set)) {
74 $this->log("Found title: " . $rec["title"] . ", ref id: " . $rec["ref_id"]);
75 $ref_ids[$rec["ref_id"]] = $rec["ref_id"];
76 $obj_ids[$rec["obj_id"]] = $rec["obj_id"];
77 }
78
79 // local roles of feed objects
80 $set = $db->queryF(
81 "SELECT * FROM rbac_fa " .
82 " WHERE " . $db->in("parent", $ref_ids, false, "integer"),
83 [],
84 []
85 );
86 $local_roles = [];
87 while ($rec = $db->fetchAssoc($set)) {
88 $local_roles[$rec["rol_id"]] = $rec["rol_id"];
89 }
90
91 // typ
92 $set = $db->queryF(
93 "SELECT * FROM object_data " .
94 " WHERE type = %s AND title = %s",
95 ["text", "text"],
96 ["typ", "feed"]
97 );
98 $typ_id = 0;
99 if ($rec = $db->fetchAssoc($set)) {
100 $typ_id = $rec["obj_id"];
101 }
102
103 // create ops id
104 $set = $db->queryF(
105 "SELECT * FROM rbac_operations " .
106 " WHERE operation = %s",
107 ["text"],
108 ["create_feed"]
109 );
110 $create_ops_id = 0;
111 if ($rec = $db->fetchAssoc($set)) {
112 $create_ops_id = $rec["ops_id"];
113 }
114
115
116 // ...tree
117 $this->log("Delete tree nodes of feed objects.");
118 $this->manipulate(
119 "DELETE FROM tree WHERE " .
120 " " . $db->in("child", $ref_ids, false, "integer")
121 );
122
123 // ...object_data (feed objects)
124 $this->log("Delete object_data entries of feed objects.");
125 $this->manipulate(
126 "DELETE FROM object_data WHERE " .
127 " " . $db->in("obj_id", $obj_ids, false, "integer")
128 );
129 // ...object_data (roles)
130 $this->log("Delete object_data entries of local roles of feed objects.");
131 $this->manipulate(
132 "DELETE FROM object_data WHERE " .
133 " " . $db->in("obj_id", $local_roles, false, "integer")
134 );
135 // ...object_data (type)
136 $this->log("Delete object_data entry of feed type.");
137 $this->manipulate(
138 "DELETE FROM object_data WHERE " .
139 " obj_id = " . $db->quote($typ_id, "integer")
140 );
141
142 // ...object_description (feed objects)
143 $this->log("Delete object_description entries of feed objects.");
144 $this->manipulate(
145 "DELETE FROM object_description WHERE " .
146 " " . $db->in("obj_id", $obj_ids, false, "integer")
147 );
148
149 //... role data of local roles
150 $this->log("Delete role_data entries of local roles of feed objects.");
151 $this->manipulate(
152 "DELETE FROM role_data WHERE " .
153 " " . $db->in("role_id", $local_roles, false, "integer")
154 );
155
156 // ...object_reference
157 $this->log("Delete object_reference entries of feed objects.");
158 $this->manipulate(
159 "DELETE FROM object_reference WHERE " .
160 " " . $db->in("ref_id", $ref_ids, false, "integer")
161 );
162
163 // ...rbac_pa (permissions on feeds)
164 $this->log("Delete permissions of feed objects.");
165 $this->manipulate(
166 "DELETE FROM rbac_pa WHERE " .
167 " " . $db->in("ref_id", $ref_ids, false, "integer")
168 );
169
170 // ...rbac_fa (local roles of feeds)
171 $this->log("Delete local roles of feed objects.");
172 $this->manipulate(
173 "DELETE FROM rbac_fa WHERE " .
174 " " . $db->in("rol_id", $local_roles, false, "integer")
175 );
176
177 // ...rbac_ta (operations per type)
178 $this->log("Delete operations of feed type.");
179 $this->manipulate(
180 "DELETE FROM rbac_ta WHERE " .
181 " typ_id = " . $db->quote($typ_id, "integer")
182 );
183
184 // ...rbac_templates (template for feed type)
185 $this->log("Delete permission templates of feed type.");
186 $this->manipulate(
187 "DELETE FROM rbac_templates WHERE " .
188 " type = " . $db->quote("feed", "text")
189 );
190
191 // ...rbac_templates (create_feed operation)
192 $this->log("Delete create_feed operation from permission templates.");
193 $this->manipulate(
194 "DELETE FROM rbac_templates WHERE " .
195 " ops_id = " . $db->quote($create_ops_id, "integer")
196 );
197
198
199 // ...conditions
200 $this->log("Delete conditions of feed objects.");
201 $this->manipulate(
202 "DELETE FROM conditions WHERE " .
203 " " . $db->in("target_ref_id", $ref_ids, false, "integer") .
204 " OR " . $db->in("trigger_ref_id", $ref_ids, false, "integer")
205 );
206
207 // ...il_external_feed_block
208 $this->log("Empty il_external_feed_block.");
209 $this->manipulate("DELETE FROM il_external_feed_block");
210
211 // ...il_custom_block
212 $this->log("Delete il_custom_block entries of type 'feed'.");
213 $this->manipulate("DELETE FROM il_custom_block WHERE type = " . $db->quote("feed", "text"));
214 }
quote($value, string $type)
in(string $field, array $values, bool $negate=false, string $type="")

References $db, ilDBInterface\fetchAssoc(), ilDBInterface\in(), log(), manipulate(), ilDBInterface\queryF(), and ilDBInterface\quote().

+ Here is the call graph for this function:

Field Documentation

◆ $db

ilDBInterface ilExternalFeedRemoveMigration::$db
protected

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