ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilGroupExporter.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
5 
6 
7 
18 {
19  private ilLogger $logger;
20 
21  public function __construct()
22  {
23  global $DIC;
24 
25  $this->logger = $DIC->logger()->grp();
26  }
27 
31  public function init(): void
32  {
33  }
34 
38  public function getXmlExportHeadDependencies(string $a_entity, string $a_target_release, array $a_ids): array
39  {
40  // always trigger container because of co-page(s)
41  return array(
42  array(
43  'component' => 'components/ILIAS/Container',
44  'entity' => 'struct',
45  'ids' => $a_ids
46  )
47  );
48  }
49 
50  public function getXmlExportTailDependencies(string $a_entity, string $a_target_release, array $a_ids) : array
51  {
52  $deps = [];
53  $advmd_ids = [];
54  foreach ($a_ids as $id) {
55  $rec_ids = $this->getActiveAdvMDRecords($id);
56  foreach ($rec_ids as $rec_id) {
57  $advmd_ids[] = $id . ":" . $rec_id;
58  }
59  }
60 
61  if ($advmd_ids !== []) {
62  $deps[] = [
63  "component" => "components/ILIAS/AdvancedMetaData",
64  "entity" => "advmd",
65  "ids" => $advmd_ids
66  ];
67  }
68 
69  $md_ids = [];
70  foreach ($a_ids as $grp_id) {
71  $md_ids[] = $grp_id . ":0:grp";
72  }
73  if ($md_ids !== []) {
74  $deps[] =
75  array(
76  "component" => "components/ILIAS/MetaData",
77  "entity" => "md",
78  "ids" => $md_ids
79  );
80  }
81  return $deps;
82  }
83 
87  public function getXmlRepresentation(string $a_entity, string $a_schema_version, string $a_id): string
88  {
89  $refs = ilObject::_getAllReferences((int) $a_id);
90  $group_ref_id = end($refs);
91  $group = ilObjectFactory::getInstanceByRefId($group_ref_id, false);
92 
93  if (!$group instanceof ilObjGroup) {
94  $this->logger->warning($a_id . ' is not instance of type group');
95  return '';
96  }
97 
98  $writer = new ilGroupXMLWriter($group);
99  $writer->setMode(ilGroupXMLWriter::MODE_EXPORT);
100  $writer->start();
101  return $writer->getXML();
102  }
103 
104  protected function getActiveAdvMDRecords(int $a_id): array
105  {
106  $active = [];
107 
108  foreach (ilAdvancedMDRecord::_getActivatedRecordsByObjectType('grp') as $record_obj) {
109  foreach ($record_obj->getAssignedObjectTypes() as $obj_info) {
110  if ($obj_info['obj_type'] == 'grp' && $obj_info['optional'] == 0) {
111  $active[] = $record_obj->getRecordId();
112  }
113  // local activation
114  if (
115  $obj_info['obj_type'] == 'grp' &&
116  $obj_info['optional'] == 1 &&
117  $a_id == $record_obj->getParentObject()
118  ) {
119  $active[] = $record_obj->getRecordId();
120  }
121  }
122  }
123  return $active;
124  }
125 
126 
130  public function getValidSchemaVersions(string $a_entity): array
131  {
132  return [
133  "9.0" => [
134  "namespace" => 'http://www.ilias.de/Modules/Group/grp/9',
135  "xsd_file" => 'ilias_grp_9_0.xsd',
136  "uses_dataset" => false,
137  "min" => "9.0",
138  "max" => "9.99"
139  ],
140  "4.1.0" => [
141  "namespace" => "http://www.ilias.de/Modules/Group/grp/4_1",
142  "xsd_file" => "ilias_grp_4_1.xsd",
143  "uses_dataset" => false,
144  "min" => "4.1.0",
145  "max" => "4.4.999"
146  ],
147  "5.0.0" => [
148  "namespace" => "http://www.ilias.de/Modules/Group/grp/5_0",
149  "xsd_file" => "ilias_grp_5_0.xsd",
150  "uses_dataset" => false,
151  "min" => "5.0.0",
152  "max" => ""
153  ]
154  ];
155  }
156 }
getActiveAdvMDRecords(int $a_id)
getXmlRepresentation(string $a_entity, string $a_schema_version, string $a_id)
static _getActivatedRecordsByObjectType(string $a_obj_type, string $a_sub_type="", bool $a_only_optional=false)
Get activated records by object type.
static _getAllReferences(int $id)
get all reference ids for object ID
getXmlExportHeadDependencies(string $a_entity, string $a_target_release, array $a_ids)
getValidSchemaVersions(string $a_entity)
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
global $DIC
Definition: shib_login.php:25
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:24
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getXmlExportTailDependencies(string $a_entity, string $a_target_release, array $a_ids)
Class ilObjGroup.