ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilGroupExporter.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
30 {
31  private ilLogger $logger;
32 
33  public function __construct()
34  {
35  global $DIC;
36 
37  $this->logger = $DIC->logger()->grp();
38  }
39 
43  public function init(): void
44  {
45  }
46 
50  public function getXmlExportHeadDependencies(string $a_entity, string $a_target_release, array $a_ids): array
51  {
52  // always trigger container because of co-page(s)
53  return array(
54  array(
55  'component' => 'components/ILIAS/Container',
56  'entity' => 'struct',
57  'ids' => $a_ids
58  )
59  );
60  }
61 
62  public function getXmlExportTailDependencies(string $a_entity, string $a_target_release, array $a_ids) : array
63  {
64  $deps = [];
65  $advmd_ids = [];
66  foreach ($a_ids as $id) {
67  $rec_ids = $this->getActiveAdvMDRecords($id);
68  foreach ($rec_ids as $rec_id) {
69  $advmd_ids[] = $id . ":" . $rec_id;
70  }
71  }
72 
73  if ($advmd_ids !== []) {
74  $deps[] = [
75  "component" => "components/ILIAS/AdvancedMetaData",
76  "entity" => "advmd",
77  "ids" => $advmd_ids
78  ];
79  }
80 
81  $md_ids = [];
82  foreach ($a_ids as $grp_id) {
83  $md_ids[] = $grp_id . ":0:grp";
84  }
85  if ($md_ids !== []) {
86  $deps[] =
87  array(
88  "component" => "components/ILIAS/MetaData",
89  "entity" => "md",
90  "ids" => $md_ids
91  );
92  }
93  return $deps;
94  }
95 
99  public function getXmlRepresentation(string $a_entity, string $a_schema_version, string $a_id): string
100  {
101  $refs = ilObject::_getAllReferences((int) $a_id);
102  $group_ref_id = end($refs);
103  $group = ilObjectFactory::getInstanceByRefId($group_ref_id, false);
104 
105  if (!$group instanceof ilObjGroup) {
106  $this->logger->warning($a_id . ' is not instance of type group');
107  return '';
108  }
109 
110  $writer = new ilGroupXMLWriter($group);
111  $writer->setMode(ilGroupXMLWriter::MODE_EXPORT);
112  $writer->start();
113  return $writer->getXML();
114  }
115 
116  protected function getActiveAdvMDRecords(int $a_id): array
117  {
118  $active = [];
119 
120  foreach (ilAdvancedMDRecord::_getActivatedRecordsByObjectType('grp') as $record_obj) {
121  foreach ($record_obj->getAssignedObjectTypes() as $obj_info) {
122  if ($obj_info['obj_type'] == 'grp' && $obj_info['optional'] == 0) {
123  $active[] = $record_obj->getRecordId();
124  }
125  // local activation
126  if (
127  $obj_info['obj_type'] == 'grp' &&
128  $obj_info['optional'] == 1 &&
129  $a_id == $record_obj->getParentObject()
130  ) {
131  $active[] = $record_obj->getRecordId();
132  }
133  }
134  }
135  return $active;
136  }
137 
138 
142  public function getValidSchemaVersions(string $a_entity): array
143  {
144  return [
145  "9.0" => [
146  "namespace" => 'http://www.ilias.de/Modules/Group/grp/9',
147  "xsd_file" => 'ilias_grp_9_0.xsd',
148  "uses_dataset" => false,
149  "min" => "9.0",
150  "max" => "9.99"
151  ],
152  "4.1.0" => [
153  "namespace" => "http://www.ilias.de/Modules/Group/grp/4_1",
154  "xsd_file" => "ilias_grp_4_1.xsd",
155  "uses_dataset" => false,
156  "min" => "4.1.0",
157  "max" => "4.4.999"
158  ],
159  "5.0.0" => [
160  "namespace" => "http://www.ilias.de/Modules/Group/grp/5_0",
161  "xsd_file" => "ilias_grp_5_0.xsd",
162  "uses_dataset" => false,
163  "min" => "5.0.0",
164  "max" => ""
165  ]
166  ];
167  }
168 }
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:22
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
XML writer class.
getXmlExportTailDependencies(string $a_entity, string $a_target_release, array $a_ids)
Class ilObjGroup.