ILIAS  release_8 Revision v8.24
ilAdvancedMDClaimingPlugin Class Reference

Abstract parent class for all advanced md claiming plugin classes. More...

+ Inheritance diagram for ilAdvancedMDClaimingPlugin:
+ Collaboration diagram for ilAdvancedMDClaimingPlugin:

Public Member Functions

 checkPermission (int $a_user_id, int $a_context_type, int $a_context_id, int $a_action_id, int $a_action_sub_id)
 
- Public Member Functions inherited from ilPlugin
 getMessage ()
 
 __construct (\ilDBInterface $db, \ilComponentRepositoryWrite $component_repository, string $id)
 
 getPluginName ()
 
 getId ()
 
 getVersion ()
 Only very little classes seem to care about this: More...
 
 getDirectory ()
 Only very little classes seem to care about this: More...
 
 isActive ()
 Only very little classes seem to care about this: More...
 
 needsUpdate ()
 
 install ()
 
 uninstall ()
 
 activate ()
 This will update (if required) and activate the plugin. More...
 
 deactivate ()
 
 update ()
 
 loadLanguageModule ()
 Load language module for plugin. More...
 
 txt (string $a_var)
 Get Language Variable (prefix will be prepended automatically) More...
 
 getTemplate (string $a_template, bool $a_par1=true, bool $a_par2=true)
 @deprecate ILIAS is moving towards UI components and plugins are expected to use these components. More...
 
 getStyleSheetLocation (string $a_css_file)
 @deprecate ILIAS is moving towards UI components and plugins are expected to use these components. More...
 
 addBlockFile ($a_tpl, $a_var, $a_block, $a_tplname)
 @deprecate ILIAS is moving towards UI components and plugins are expected to use these components. More...
 
 getGlobalScreenProviderCollection ()
 
 exchangeUIRendererAfterInitialization (\ILIAS\DI\Container $dic)
 This methods allows to replace the UI Renderer (see src/UI) of ILIAS after initialization by returning a closure returning a custom renderer. More...
 
 exchangeUIFactoryAfterInitialization (string $dic_key, \ILIAS\DI\Container $dic)
 This methods allows to replace some factory for UI Components (see src/UI) of ILIAS after initialization by returning a closure returning a custom factory. More...
 

Static Public Member Functions

static hasDBRecord (int $a_record_id)
 
static createDBRecord (string $a_title, string $a_description, bool $a_active, array $a_obj_types)
 
static updateDBRecord (int $a_record_id, string $a_title, string $a_description, bool $a_active, array $a_obj_types)
 Update record db entry. More...
 
static deleteDBRecord (int $a_record_id)
 
static hasDBField (int $a_field_id)
 
static createDBField (int $a_record_id, int $a_type, string $a_title, ?string $a_description=null, bool $a_searchable=false, array $a_definition=null)
 
static updateDBField (int $a_field_id, string $a_title, ?string $a_description=null, bool $a_searchable=false, ?array $a_definition=null)
 
static deleteDBField (int $a_field_id)
 
static setDBSubstitution (string $a_obj_type, bool $a_show_description, bool $a_show_field_names)
 
static hasDBFieldSubstitution (string $a_obj_type, int $a_field_id)
 
static setDBFieldSubstitution (string $a_obj_type, int $a_field_id, bool $a_bold=false, bool $a_newline=false)
 
static removeDBFieldSubstitution (string $a_obj_type, int $a_field_id)
 

Static Protected Member Functions

static isValidObjType (string $a_obj_type, bool $a_is_substitution=false)
 Validate object type. More...
 
static saveRecordObjTypes (int $a_record_id, array $a_obj_types)
 Save object type assignments for record. More...
 
static getDBFieldLastPosition (int $a_record_id)
 
static getDBSubstitution (string $a_obj_type, bool $a_include_field_data=false)
 

Additional Inherited Members

- Protected Member Functions inherited from ilPlugin
 init ()
 Object initialization. More...
 
 getPluginInfo ()
 
 getComponentInfo ()
 
 getPluginSlotInfo ()
 
 afterInstall ()
 @deprecate If you cannot get rid of the requirement to use this, adjust the install method in your subclass instead. More...
 
 beforeUninstall ()
 @deprecate If you cannot get rid of the requirement to use this, adjust the uninstall method in your subclass instead. More...
 
 afterUninstall ()
 @deprecate If you cannot get rid of the requirement to use this, adjust the uninstall method in your subclass instead. More...
 
 beforeActivation ()
 @deprecate If you cannot get rid of the requirement to use this, adjust the activate method in your subclass instead. More...
 
 afterActivation ()
 @deprecate If you cannot get rid of the requirement to use this, adjust the activate method in your subclass instead. More...
 
 afterDeactivation ()
 @deprecate If you cannot get rid of the requirement to use this, adjust the activate method in your subclass instead. More...
 
 updateDatabase ()
 
 beforeUpdate ()
 @deprecate If you cannot get rid of the requirement to use this, adjust the update method in your subclass instead. More...
 
 afterUpdate ()
 
 getLanguageHandler ()
 
 buildLanguageHandler ()
 
 readEventListening ()
 
 clearEventListening ()
 
- Protected Attributes inherited from ilPlugin
ilDBInterface $db
 
ilComponentRepositoryWrite $component_repository
 
string $id
 
ilPluginLanguage $language_handler = null
 
bool $lang_initialised = false
 
ProviderCollection $provider_collection
 
string $message = ''
 

Detailed Description

Abstract parent class for all advanced md claiming plugin classes.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 12 of file class.ilAdvancedMDClaimingPlugin.php.

Member Function Documentation

◆ checkPermission()

ilAdvancedMDClaimingPlugin::checkPermission ( int  $a_user_id,
int  $a_context_type,
int  $a_context_id,
int  $a_action_id,
int  $a_action_sub_id 
)
abstract

◆ createDBField()

static ilAdvancedMDClaimingPlugin::createDBField ( int  $a_record_id,
int  $a_type,
string  $a_title,
?string  $a_description = null,
bool  $a_searchable = false,
array  $a_definition = null 
)
static

Definition at line 197 of file class.ilAdvancedMDClaimingPlugin.php.

204 : ?int {
205 global $DIC;
206
207 $ilDB = $DIC->database();
208
209 if (!self::hasDBRecord($a_record_id)) {
210 return null;
211 }
212
213 $field_id = $ilDB->nextId("adv_mdf_definition");
214
215 // validating type
217 return null;
218 }
219
220 $options_in_different_table = $a_definition &&
223
224 $pos = self::getDBFieldLastPosition($a_record_id) + 1;
225
226 $fields = array(
227 "record_id" => array("integer", $a_record_id),
228 "field_id" => array("integer", $field_id),
229 "import_id" => array("text", "il_" . IL_INST_ID . "_adv_md_field_" . $field_id),
230 "field_type" => array("integer", $a_type),
231 "position" => array("integer", $pos),
232 "title" => array("text", trim($a_title)),
233 "description" => array("text", trim((string) $a_description)),
234 "searchable" => array("integer", (int) $a_searchable)
235 );
236 if ($a_definition && !$options_in_different_table) {
237 $fields["field_values"] = array("text", serialize($a_definition));
238 }
239 $ilDB->insert("adv_mdf_definition", $fields);
240
241 if ($options_in_different_table) {
242 $ilDB->manipulate(
243 'DELETE FROM adv_mdf_enum WHERE field_id = ' .
244 $ilDB->quote($field_id, ilDBConstants::T_INTEGER)
245 );
246
247 $default_language = '';
248 $res = $ilDB->query(
249 'SELECT lang_default FROM adv_md_record WHERE record_id = ' .
250 $ilDB->quote($a_record_id, 'integer')
251 );
252 if ($row = $res->fetchAssoc()) {
253 $default_language = (string) $row['lang_default'];
254 }
255
256 $idx = 0;
257 foreach ($a_definition as $option) {
258 if (!is_string($option)) {
259 continue;
260 }
261 $ilDB->insert(
262 'adv_mdf_enum',
263 [
264 'field_id' => [ilDBConstants::T_INTEGER, $field_id],
265 'lang_code' => [ilDBConstants::T_TEXT, $default_language],
266 'idx' => [ilDBConstants::T_INTEGER, $idx],
267 'value' => [ilDBConstants::T_TEXT, $option],
268 ]
269 );
270 $idx++;
271 }
272 }
273
274 return $field_id;
275 }
const IL_INST_ID
Definition: constants.php:40
global $DIC
Definition: feed.php:28
$res
Definition: ltiservices.php:69

◆ createDBRecord()

static ilAdvancedMDClaimingPlugin::createDBRecord ( string  $a_title,
string  $a_description,
bool  $a_active,
array  $a_obj_types 
)
static
Parameters
string$a_title
string$a_description
bool$a_active
string[]$a_obj_types
Returns
int

Definition at line 39 of file class.ilAdvancedMDClaimingPlugin.php.

44 : int {
45 global $DIC;
46
47 $ilDB = $DIC->database();
48
49 $record_id = $ilDB->nextId("adv_md_record");
50
51 $fields = array(
52 "record_id" => array("integer", $record_id),
53 "import_id" => array("text", 'il_' . IL_INST_ID . '_adv_md_record_' . $record_id),
54 "title" => array("text", trim($a_title)),
55 "description" => array("text", trim($a_description)),
56 "active" => array("integer", (int) $a_active)
57 );
58 $ilDB->insert("adv_md_record", $fields);
59 self::saveRecordObjTypes($record_id, $a_obj_types);
60 return $record_id;
61 }
static saveRecordObjTypes(int $a_record_id, array $a_obj_types)
Save object type assignments for record.

◆ deleteDBField()

static ilAdvancedMDClaimingPlugin::deleteDBField ( int  $a_field_id)
static

Definition at line 309 of file class.ilAdvancedMDClaimingPlugin.php.

309 : bool
310 {
311 global $DIC;
312
313 $ilDB = $DIC['ilDB'];
314
315 if (self::hasDBField($a_field_id)) {
316 $ilDB->manipulate("DELETE FROM adv_mdf_definition" .
317 " WHERE field_id = " . $ilDB->quote($a_field_id, "integer"));
318 return true;
319 }
320
321 return false;
322 }

References $DIC, and $ilDB.

◆ deleteDBRecord()

static ilAdvancedMDClaimingPlugin::deleteDBRecord ( int  $a_record_id)
static

Definition at line 152 of file class.ilAdvancedMDClaimingPlugin.php.

152 : bool
153 {
154 global $DIC;
155
156 $ilDB = $DIC->database();
157
158 if (self::hasDBRecord($a_record_id)) {
159 $ilDB->manipulate("DELETE FROM adv_md_record" .
160 " WHERE record_id = " . $ilDB->quote($a_record_id, "integer"));
161 return true;
162 }
163
164 return false;
165 }

References $DIC, and $ilDB.

◆ getDBFieldLastPosition()

static ilAdvancedMDClaimingPlugin::getDBFieldLastPosition ( int  $a_record_id)
staticprotected
See also
ilAdvancedMDFieldDefinition::getLastPosition()

Definition at line 180 of file class.ilAdvancedMDClaimingPlugin.php.

180 : int
181 {
182 global $DIC;
183
184 $ilDB = $DIC->database();
185
186 $sql = "SELECT max(position) pos" .
187 " FROM adv_mdf_definition" .
188 " WHERE record_id = " . $ilDB->quote($a_record_id, "integer");
189 $set = $ilDB->query($sql);
190 if ($ilDB->numRows($set)) {
191 $pos = $ilDB->fetchAssoc($set);
192 return (int) $pos["pos"];
193 }
194 return 0;
195 }

References $DIC, and $ilDB.

◆ getDBSubstitution()

static ilAdvancedMDClaimingPlugin::getDBSubstitution ( string  $a_obj_type,
bool  $a_include_field_data = false 
)
staticprotected

Definition at line 324 of file class.ilAdvancedMDClaimingPlugin.php.

324 : array
325 {
326 global $DIC;
327
328 $ilDB = $DIC->database();
329
330 $set = $ilDB->query("SELECT * FROM adv_md_substitutions" .
331 " WHERE obj_type = " . $ilDB->quote($a_obj_type, "text"));
332 if ($ilDB->numRows($set)) {
333 $res = $ilDB->fetchAssoc($set);
334 $res["hide_description"] = array("integer", (bool) $res["hide_description"]);
335 $res["hide_field_names"] = array("integer", (bool) $res["hide_field_names"]);
336
337 if ($a_include_field_data) {
338 $res["substitution"] = array("text", (array) unserialize($res["substitution"]));
339 } else {
340 unset($res["substitution"]);
341 }
342 unset($res["obj_type"]);
343
344 return $res;
345 }
346 return [];
347 }

References $DIC, $ilDB, and $res.

◆ hasDBField()

static ilAdvancedMDClaimingPlugin::hasDBField ( int  $a_field_id)
static

Definition at line 167 of file class.ilAdvancedMDClaimingPlugin.php.

167 : bool
168 {
169 global $DIC;
170 $ilDB = $DIC->database();
171
172 $set = $ilDB->query("SELECT field_id FROM adv_mdf_definition" .
173 " WHERE field_id = " . $ilDB->quote($a_field_id, "integer"));
174 return (bool) $ilDB->numRows($set);
175 }

References $DIC, and $ilDB.

◆ hasDBFieldSubstitution()

static ilAdvancedMDClaimingPlugin::hasDBFieldSubstitution ( string  $a_obj_type,
int  $a_field_id 
)
static

Definition at line 385 of file class.ilAdvancedMDClaimingPlugin.php.

385 : bool
386 {
387 if (self::isValidObjType($a_obj_type, true)) {
388 $fields = self::getDBSubstitution($a_obj_type, true);
389 $fields = $fields["substitution"][1];
390 foreach ($fields as $field) {
391 if ($field["field_id"] == $a_field_id) {
392 return true;
393 }
394 }
395 }
396 return false;
397 }
static getDBSubstitution(string $a_obj_type, bool $a_include_field_data=false)

◆ hasDBRecord()

static ilAdvancedMDClaimingPlugin::hasDBRecord ( int  $a_record_id)
static

Definition at line 22 of file class.ilAdvancedMDClaimingPlugin.php.

22 : bool
23 {
24 global $DIC;
25 $ilDB = $DIC->database();
26
27 $set = $ilDB->query("SELECT record_id FROM adv_md_record" .
28 " WHERE record_id = " . $ilDB->quote($a_record_id, "integer"));
29 return (bool) $ilDB->numRows($set);
30 }

References $DIC, and $ilDB.

◆ isValidObjType()

static ilAdvancedMDClaimingPlugin::isValidObjType ( string  $a_obj_type,
bool  $a_is_substitution = false 
)
staticprotected

Validate object type.

Todo:
support ecs type

Definition at line 67 of file class.ilAdvancedMDClaimingPlugin.php.

67 : bool
68 {
69 // ecs not supported yet
70 $valid = ["crs", "cat", "book", "wiki", "glo", "orgu", "prg", 'grp', 'iass'];
71
72 if (!$a_is_substitution) {
73 $valid[] = "orgu";
74 $valid[] = "prg";
75 }
76
77 return in_array($a_obj_type, $valid);
78 }
$valid

References $valid.

◆ removeDBFieldSubstitution()

static ilAdvancedMDClaimingPlugin::removeDBFieldSubstitution ( string  $a_obj_type,
int  $a_field_id 
)
static

Definition at line 447 of file class.ilAdvancedMDClaimingPlugin.php.

447 : bool
448 {
449 global $DIC;
450
451 $ilDB = $DIC->database();
452
453 if (self::isValidObjType($a_obj_type, true)) {
454 $fields = self::getDBSubstitution($a_obj_type, true);
455 if (!$fields) {
456 return true;
457 } else {
458 $fields = $fields["substitution"][1];
459 }
460
461 $found = false;
462 foreach ($fields as $idx => $field) {
463 if ($field["field_id"] == $a_field_id) {
464 unset($fields[$idx]);
465 $found = true;
466 break;
467 }
468 }
469 if ($found) {
470 $fields = array("substitution" => array("text", serialize($fields)));
471 $ilDB->update(
472 "adv_md_substitutions",
473 $fields,
474 array("obj_type" => array("text", $a_obj_type))
475 );
476 }
477 return true;
478 }
479 return false;
480 }

References $DIC, and $ilDB.

◆ saveRecordObjTypes()

static ilAdvancedMDClaimingPlugin::saveRecordObjTypes ( int  $a_record_id,
array  $a_obj_types 
)
staticprotected

Save object type assignments for record.

Parameters
int$a_record_id
string[]$a_obj_types

Definition at line 85 of file class.ilAdvancedMDClaimingPlugin.php.

85 : void
86 {
87 global $DIC;
88 $ilDB = $DIC->database();
89
90 foreach ($a_obj_types as $type) {
91 if (!is_array($type)) {
92 $type = strtolower(trim($type));
93 $subtype = "-";
94 } else {
95 $subtype = strtolower(trim($type[1]));
96 $type = strtolower(trim($type[0]));
97 }
98
99 if (self::isValidObjType($type)) {
100 $fields = array(
101 "record_id" => array("integer", $a_record_id),
102 "obj_type" => array("text", $type),
103 "sub_type" => array("text", $subtype)
104 );
105 $ilDB->insert("adv_md_record_objs", $fields);
106 }
107 }
108 }
$type

References $DIC, $ilDB, and $type.

◆ setDBFieldSubstitution()

static ilAdvancedMDClaimingPlugin::setDBFieldSubstitution ( string  $a_obj_type,
int  $a_field_id,
bool  $a_bold = false,
bool  $a_newline = false 
)
static

Definition at line 399 of file class.ilAdvancedMDClaimingPlugin.php.

404 : bool {
405 global $DIC;
406
407 $ilDB = $DIC->database();
408
409 if (self::isValidObjType($a_obj_type, true)) {
410 $fields = self::getDBSubstitution($a_obj_type, true);
411 if (!$fields) {
412 self::setDBSubstitution($a_obj_type, true, true);
413 $fields = array();
414 } else {
415 $fields = $fields["substitution"][1];
416 }
417
418 $found = false;
419 foreach ($fields as $idx => $field) {
420 if ($field["field_id"] == $a_field_id) {
421 $fields[$idx]["bold"] = $a_bold;
422 $fields[$idx]["newline"] = $a_newline;
423 $found = true;
424 break;
425 }
426 }
427 if (!$found) {
428 $fields[] = array(
429 "field_id" => $a_field_id
430 ,
431 "bold" => $a_bold
432 ,
433 "newline" => $a_newline
434 );
435 }
436
437 $fields = array("substitution" => array("text", serialize($fields)));
438 $ilDB->update(
439 "adv_md_substitutions",
440 $fields,
441 array("obj_type" => array("text", $a_obj_type))
442 );
443 }
444 return false;
445 }
static setDBSubstitution(string $a_obj_type, bool $a_show_description, bool $a_show_field_names)

References $ilDB.

◆ setDBSubstitution()

static ilAdvancedMDClaimingPlugin::setDBSubstitution ( string  $a_obj_type,
bool  $a_show_description,
bool  $a_show_field_names 
)
static

Definition at line 349 of file class.ilAdvancedMDClaimingPlugin.php.

353 : bool {
354 global $DIC;
355
356 $ilDB = $DIC->database();
357
358 if (self::isValidObjType($a_obj_type, true)) {
359 $fields = self::getDBSubstitution($a_obj_type);
360
361 $create = false;
362 if (!$fields) {
363 $create = true;
364 $fields = array("obj_type" => array("text", $a_obj_type));
365 }
366
367 $fields["hide_description"] = array("integer", !$a_show_description);
368 $fields["hide_field_names"] = array("integer", !$a_show_field_names);
369
370 if ($create) {
371 $ilDB->insert("adv_md_substitutions", $fields);
372 } else {
373 $ilDB->update(
374 "adv_md_substitutions",
375 $fields,
376 array("obj_type" => array("text", $a_obj_type))
377 );
378 }
379
380 return true;
381 }
382 return false;
383 }

References $ilDB.

◆ updateDBField()

static ilAdvancedMDClaimingPlugin::updateDBField ( int  $a_field_id,
string  $a_title,
?string  $a_description = null,
bool  $a_searchable = false,
?array  $a_definition = null 
)
static

Definition at line 277 of file class.ilAdvancedMDClaimingPlugin.php.

283 : bool {
284 global $DIC;
285
286 $ilDB = $DIC->database();
287
288 if (self::hasDBField($a_field_id)) {
289 $fields = array(
290 "field_id" => array("integer", $a_field_id),
291 "title" => array("text", trim($a_title)),
292 "description" => array("text", trim($a_description)),
293 "searchable" => array("integer", (int) $a_searchable)
294 );
295 if ($a_definition) {
296 $fields["field_values"] = array("text", serialize($a_definition));
297 }
298 $ilDB->update(
299 "adv_mdf_definition",
300 $fields,
301 array("field_id" => array("integer", $a_field_id))
302 );
303 return true;
304 }
305
306 return false;
307 }

References $ilDB.

◆ updateDBRecord()

static ilAdvancedMDClaimingPlugin::updateDBRecord ( int  $a_record_id,
string  $a_title,
string  $a_description,
bool  $a_active,
array  $a_obj_types 
)
static

Update record db entry.

Parameters
int$a_record_id
string$a_title
string$a_description
bool$a_active
string[]$a_obj_types
Returns
bool

Definition at line 119 of file class.ilAdvancedMDClaimingPlugin.php.

125 : bool {
126 global $DIC;
127
128 $ilDB = $DIC->database();
129
130 if (self::hasDBRecord($a_record_id)) {
131 $fields = array(
132 "title" => array("text", trim($a_title)),
133 "description" => array("text", trim($a_description)),
134 "active" => array("integer", (int) $a_active)
135 );
136 $ilDB->update(
137 "adv_md_record",
138 $fields,
139 array("record_id" => array("integer", $a_record_id))
140 );
141
142 $ilDB->manipulate("DELETE FROM adv_md_record_objs" .
143 " WHERE record_id = " . $ilDB->quote($a_record_id, "integer"));
144
145 self::saveRecordObjTypes($a_record_id, $a_obj_types);
146
147 return true;
148 }
149 return false;
150 }

References $ilDB.


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