ILIAS  trunk Revision v11.0_alpha-1861-g09f3d197f78
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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)
 ILIAS is moving towards UI components and plugins are expected to use these components. More...
 
 getStyleSheetLocation (string $a_css_file)
 ILIAS is moving towards UI components and plugins are expected to use these components. More...
 
 addBlockFile ($a_tpl, $a_var, $a_block, $a_tplname)
 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 ()
 If you cannot get rid of the requirement to use this, adjust the install method in your subclass instead. More...
 
 beforeUninstall ()
 If you cannot get rid of the requirement to use this, adjust the uninstall method in your subclass instead. More...
 
 afterUninstall ()
 If you cannot get rid of the requirement to use this, adjust the uninstall method in your subclass instead. More...
 
 beforeActivation ()
 If you cannot get rid of the requirement to use this, adjust the activate method in your subclass instead. More...
 
 afterActivation ()
 If you cannot get rid of the requirement to use this, adjust the activate method in your subclass instead. More...
 
 afterDeactivation ()
 If you cannot get rid of the requirement to use this, adjust the activate method in your subclass instead. More...
 
 updateDatabase ()
 
 beforeUpdate ()
 If you cannot get rid of the requirement to use this, adjust the update method in your subclass instead. More...
 
 afterUpdate ()
 
 getLanguageHandler ()
 
 buildLanguageHandler ()
 
- 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 26 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 211 of file class.ilAdvancedMDClaimingPlugin.php.

References $DIC, $ilDB, $res, IL_INST_ID, ilAdvancedMDFieldDefinition\isValidType(), null, ilDBConstants\T_INTEGER, ilDBConstants\T_TEXT, ilAdvancedMDFieldDefinition\TYPE_SELECT, and ilAdvancedMDFieldDefinition\TYPE_SELECT_MULTI.

218  : ?int {
219  global $DIC;
220 
221  $ilDB = $DIC->database();
222 
223  if (!self::hasDBRecord($a_record_id)) {
224  return null;
225  }
226 
227  $field_id = $ilDB->nextId("adv_mdf_definition");
228 
229  // validating type
231  return null;
232  }
233 
234  $options_in_different_table = $a_definition &&
237 
238  $pos = self::getDBFieldLastPosition($a_record_id) + 1;
239 
240  $fields = array(
241  "record_id" => array("integer", $a_record_id),
242  "field_id" => array("integer", $field_id),
243  "import_id" => array("text", "il_" . IL_INST_ID . "_adv_md_field_" . $field_id),
244  "field_type" => array("integer", $a_type),
245  "position" => array("integer", $pos),
246  "title" => array("text", trim($a_title)),
247  "description" => array("text", trim((string) $a_description)),
248  "searchable" => array("integer", (int) $a_searchable)
249  );
250  if ($a_definition && !$options_in_different_table) {
251  $fields["field_values"] = array("text", serialize($a_definition));
252  }
253  $ilDB->insert("adv_mdf_definition", $fields);
254 
255  if ($options_in_different_table) {
256  $ilDB->manipulate(
257  'DELETE FROM adv_mdf_enum WHERE field_id = ' .
258  $ilDB->quote($field_id, ilDBConstants::T_INTEGER)
259  );
260 
261  $default_language = '';
262  $res = $ilDB->query(
263  'SELECT lang_default FROM adv_md_record WHERE record_id = ' .
264  $ilDB->quote($a_record_id, 'integer')
265  );
266  if ($row = $res->fetchAssoc()) {
267  $default_language = (string) $row['lang_default'];
268  }
269 
270  $idx = 0;
271  foreach ($a_definition as $option) {
272  if (!is_string($option)) {
273  continue;
274  }
275  $ilDB->insert(
276  'adv_mdf_enum',
277  [
278  'field_id' => [ilDBConstants::T_INTEGER, $field_id],
279  'lang_code' => [ilDBConstants::T_TEXT, $default_language],
280  'idx' => [ilDBConstants::T_INTEGER, $idx],
281  'value' => [ilDBConstants::T_TEXT, $option],
282  'position' => [ilDBConstants::T_INTEGER, $idx]
283  ]
284  );
285  $idx++;
286  }
287  }
288 
289  return $field_id;
290  }
$res
Definition: ltiservices.php:66
const IL_INST_ID
Definition: constants.php:40
const TYPE_SELECT
TODO: put this in when minimum php version is set to 8.2.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

◆ 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 53 of file class.ilAdvancedMDClaimingPlugin.php.

References $DIC, $ilDB, and IL_INST_ID.

58  : int {
59  global $DIC;
60 
61  $ilDB = $DIC->database();
62 
63  $record_id = $ilDB->nextId("adv_md_record");
64 
65  $fields = array(
66  "record_id" => array("integer", $record_id),
67  "import_id" => array("text", 'il_' . IL_INST_ID . '_adv_md_record_' . $record_id),
68  "title" => array("text", trim($a_title)),
69  "description" => array("text", trim($a_description)),
70  "active" => array("integer", (int) $a_active)
71  );
72  $ilDB->insert("adv_md_record", $fields);
73  self::saveRecordObjTypes($record_id, $a_obj_types);
74  return $record_id;
75  }
const IL_INST_ID
Definition: constants.php:40
global $DIC
Definition: shib_login.php:22

◆ deleteDBField()

static ilAdvancedMDClaimingPlugin::deleteDBField ( int  $a_field_id)
static

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

References $DIC, and $ilDB.

324  : bool
325  {
326  global $DIC;
327 
328  $ilDB = $DIC['ilDB'];
329 
330  if (self::hasDBField($a_field_id)) {
331  $ilDB->manipulate("DELETE FROM adv_mdf_definition" .
332  " WHERE field_id = " . $ilDB->quote($a_field_id, "integer"));
333  return true;
334  }
335 
336  return false;
337  }
global $DIC
Definition: shib_login.php:22

◆ deleteDBRecord()

static ilAdvancedMDClaimingPlugin::deleteDBRecord ( int  $a_record_id)
static

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

References $DIC, and $ilDB.

166  : bool
167  {
168  global $DIC;
169 
170  $ilDB = $DIC->database();
171 
172  if (self::hasDBRecord($a_record_id)) {
173  $ilDB->manipulate("DELETE FROM adv_md_record" .
174  " WHERE record_id = " . $ilDB->quote($a_record_id, "integer"));
175  return true;
176  }
177 
178  return false;
179  }
global $DIC
Definition: shib_login.php:22

◆ getDBFieldLastPosition()

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

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

References $DIC, and $ilDB.

194  : int
195  {
196  global $DIC;
197 
198  $ilDB = $DIC->database();
199 
200  $sql = "SELECT max(position) pos" .
201  " FROM adv_mdf_definition" .
202  " WHERE record_id = " . $ilDB->quote($a_record_id, "integer");
203  $set = $ilDB->query($sql);
204  if ($ilDB->numRows($set)) {
205  $pos = $ilDB->fetchAssoc($set);
206  return (int) $pos["pos"];
207  }
208  return 0;
209  }
global $DIC
Definition: shib_login.php:22

◆ getDBSubstitution()

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

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

References $DIC, $ilDB, and $res.

339  : array
340  {
341  global $DIC;
342 
343  $ilDB = $DIC->database();
344 
345  $set = $ilDB->query("SELECT * FROM adv_md_substitutions" .
346  " WHERE obj_type = " . $ilDB->quote($a_obj_type, "text"));
347  if ($ilDB->numRows($set)) {
348  $res = $ilDB->fetchAssoc($set);
349  $res["hide_description"] = array("integer", (bool) $res["hide_description"]);
350  $res["hide_field_names"] = array("integer", (bool) $res["hide_field_names"]);
351 
352  if ($a_include_field_data) {
353  $res["substitution"] = array("text", (array) unserialize($res["substitution"]));
354  } else {
355  unset($res["substitution"]);
356  }
357  unset($res["obj_type"]);
358 
359  return $res;
360  }
361  return [];
362  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22

◆ hasDBField()

static ilAdvancedMDClaimingPlugin::hasDBField ( int  $a_field_id)
static

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

References $DIC, and $ilDB.

181  : bool
182  {
183  global $DIC;
184  $ilDB = $DIC->database();
185 
186  $set = $ilDB->query("SELECT field_id FROM adv_mdf_definition" .
187  " WHERE field_id = " . $ilDB->quote($a_field_id, "integer"));
188  return (bool) $ilDB->numRows($set);
189  }
global $DIC
Definition: shib_login.php:22

◆ hasDBFieldSubstitution()

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

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

400  : bool
401  {
402  if (self::isValidObjType($a_obj_type, true)) {
403  $fields = self::getDBSubstitution($a_obj_type, true);
404  $fields = $fields["substitution"][1];
405  foreach ($fields as $field) {
406  if ($field["field_id"] == $a_field_id) {
407  return true;
408  }
409  }
410  }
411  return false;
412  }

◆ hasDBRecord()

static ilAdvancedMDClaimingPlugin::hasDBRecord ( int  $a_record_id)
static

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

References $DIC, and $ilDB.

36  : bool
37  {
38  global $DIC;
39  $ilDB = $DIC->database();
40 
41  $set = $ilDB->query("SELECT record_id FROM adv_md_record" .
42  " WHERE record_id = " . $ilDB->quote($a_record_id, "integer"));
43  return (bool) $ilDB->numRows($set);
44  }
global $DIC
Definition: shib_login.php:22

◆ isValidObjType()

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

Validate object type.

Todo:
support ecs type

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

References $valid.

81  : bool
82  {
83  // ecs not supported yet
84  $valid = ["crs", "cat", "book", "wiki", "glo", "orgu", "prg", 'grp', 'iass'];
85 
86  if (!$a_is_substitution) {
87  $valid[] = "orgu";
88  $valid[] = "prg";
89  }
90 
91  return in_array($a_obj_type, $valid);
92  }
$valid

◆ removeDBFieldSubstitution()

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

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

References $DIC, and $ilDB.

462  : bool
463  {
464  global $DIC;
465 
466  $ilDB = $DIC->database();
467 
468  if (self::isValidObjType($a_obj_type, true)) {
469  $fields = self::getDBSubstitution($a_obj_type, true);
470  if (!$fields) {
471  return true;
472  } else {
473  $fields = $fields["substitution"][1];
474  }
475 
476  $found = false;
477  foreach ($fields as $idx => $field) {
478  if ($field["field_id"] == $a_field_id) {
479  unset($fields[$idx]);
480  $found = true;
481  break;
482  }
483  }
484  if ($found) {
485  $fields = array("substitution" => array("text", serialize($fields)));
486  $ilDB->update(
487  "adv_md_substitutions",
488  $fields,
489  array("obj_type" => array("text", $a_obj_type))
490  );
491  }
492  return true;
493  }
494  return false;
495  }
global $DIC
Definition: shib_login.php:22

◆ 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 99 of file class.ilAdvancedMDClaimingPlugin.php.

References $DIC, and $ilDB.

99  : void
100  {
101  global $DIC;
102  $ilDB = $DIC->database();
103 
104  foreach ($a_obj_types as $type) {
105  if (!is_array($type)) {
106  $type = strtolower(trim($type));
107  $subtype = "-";
108  } else {
109  $subtype = strtolower(trim($type[1]));
110  $type = strtolower(trim($type[0]));
111  }
112 
113  if (self::isValidObjType($type)) {
114  $fields = array(
115  "record_id" => array("integer", $a_record_id),
116  "obj_type" => array("text", $type),
117  "sub_type" => array("text", $subtype)
118  );
119  $ilDB->insert("adv_md_record_objs", $fields);
120  }
121  }
122  }
global $DIC
Definition: shib_login.php:22

◆ setDBFieldSubstitution()

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

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

References $DIC, and $ilDB.

419  : bool {
420  global $DIC;
421 
422  $ilDB = $DIC->database();
423 
424  if (self::isValidObjType($a_obj_type, true)) {
425  $fields = self::getDBSubstitution($a_obj_type, true);
426  if (!$fields) {
427  self::setDBSubstitution($a_obj_type, true, true);
428  $fields = array();
429  } else {
430  $fields = $fields["substitution"][1];
431  }
432 
433  $found = false;
434  foreach ($fields as $idx => $field) {
435  if ($field["field_id"] == $a_field_id) {
436  $fields[$idx]["bold"] = $a_bold;
437  $fields[$idx]["newline"] = $a_newline;
438  $found = true;
439  break;
440  }
441  }
442  if (!$found) {
443  $fields[] = array(
444  "field_id" => $a_field_id
445  ,
446  "bold" => $a_bold
447  ,
448  "newline" => $a_newline
449  );
450  }
451 
452  $fields = array("substitution" => array("text", serialize($fields)));
453  $ilDB->update(
454  "adv_md_substitutions",
455  $fields,
456  array("obj_type" => array("text", $a_obj_type))
457  );
458  }
459  return false;
460  }
global $DIC
Definition: shib_login.php:22

◆ setDBSubstitution()

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

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

References $DIC, and $ilDB.

368  : bool {
369  global $DIC;
370 
371  $ilDB = $DIC->database();
372 
373  if (self::isValidObjType($a_obj_type, true)) {
374  $fields = self::getDBSubstitution($a_obj_type);
375 
376  $create = false;
377  if (!$fields) {
378  $create = true;
379  $fields = array("obj_type" => array("text", $a_obj_type));
380  }
381 
382  $fields["hide_description"] = array("integer", !$a_show_description);
383  $fields["hide_field_names"] = array("integer", !$a_show_field_names);
384 
385  if ($create) {
386  $ilDB->insert("adv_md_substitutions", $fields);
387  } else {
388  $ilDB->update(
389  "adv_md_substitutions",
390  $fields,
391  array("obj_type" => array("text", $a_obj_type))
392  );
393  }
394 
395  return true;
396  }
397  return false;
398  }
global $DIC
Definition: shib_login.php:22

◆ 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 292 of file class.ilAdvancedMDClaimingPlugin.php.

References $DIC, and $ilDB.

298  : bool {
299  global $DIC;
300 
301  $ilDB = $DIC->database();
302 
303  if (self::hasDBField($a_field_id)) {
304  $fields = array(
305  "field_id" => array("integer", $a_field_id),
306  "title" => array("text", trim($a_title)),
307  "description" => array("text", trim($a_description)),
308  "searchable" => array("integer", (int) $a_searchable)
309  );
310  if ($a_definition) {
311  $fields["field_values"] = array("text", serialize($a_definition));
312  }
313  $ilDB->update(
314  "adv_mdf_definition",
315  $fields,
316  array("field_id" => array("integer", $a_field_id))
317  );
318  return true;
319  }
320 
321  return false;
322  }
global $DIC
Definition: shib_login.php:22

◆ 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 133 of file class.ilAdvancedMDClaimingPlugin.php.

References $DIC, and $ilDB.

139  : bool {
140  global $DIC;
141 
142  $ilDB = $DIC->database();
143 
144  if (self::hasDBRecord($a_record_id)) {
145  $fields = array(
146  "title" => array("text", trim($a_title)),
147  "description" => array("text", trim($a_description)),
148  "active" => array("integer", (int) $a_active)
149  );
150  $ilDB->update(
151  "adv_md_record",
152  $fields,
153  array("record_id" => array("integer", $a_record_id))
154  );
155 
156  $ilDB->manipulate("DELETE FROM adv_md_record_objs" .
157  " WHERE record_id = " . $ilDB->quote($a_record_id, "integer"));
158 
159  self::saveRecordObjTypes($a_record_id, $a_obj_types);
160 
161  return true;
162  }
163  return false;
164  }
global $DIC
Definition: shib_login.php:22

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