ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilCopyWizardSettingsXMLParser.php
Go to the documentation of this file.
1 <?php
2 
20 {
21  private array $options = [];
22  private int $source_id = 0;
23  private int $target_id = 0;
24 
25  public function __construct(string $xml)
26  {
27  parent::__construct('', true);
28  $this->setXMLContent($xml);
29  }
30 
35  public function setHandlers($a_xml_parser): void
36  {
37  xml_set_element_handler($a_xml_parser, $this->handlerBeginTag(...), $this->handlerEndTag(...));
38  xml_set_character_data_handler($a_xml_parser, $this->handlerCharacterData(...));
39  }
40 
44  public function handlerBeginTag($a_xml_parser, string $a_name, array $a_attribs): void
45  {
46  global $DIC;
47 
48  $objDefinition = $DIC['objDefinition'];
49  $ilAccess = $DIC['ilAccess'];
50  $tree = $DIC['tree'];
51 
52  switch ($a_name) {
53  case 'Settings':
54  $this->options = array();
55  $this->source_id = (int) $a_attribs["source_id"];
56  if (ilObject::_isInTrash($this->source_id)) {
57  throw new ilSaxParserException("Source id " . $this->source_id . " is in trash");
58  }
59  $this->target_id = (int) $a_attribs["target_id"];
60  if (ilObject::_isInTrash($this->target_id)) {
61  throw new ilSaxParserException("target id" . $this->target_id . " is in trash");
62  }
63  break;
64  case 'Option':
65  $id = (int) $a_attribs["id"];
67  throw new ilSaxParserException("Id $id is in trash");
68  }
69  if (!$tree->isInTree($id)) {
70  throw new ilSaxParserException("Id $id does not exist");
71  }
72 
73  $action = self::getActionForString($a_attribs["action"]);
75 
76  switch ($action) {
78  $perm_copy = $ilAccess->checkAccess('copy', '', $id);
79  $copy = $objDefinition->allowCopy($type);
80 
81  if ($perm_copy && $copy) {
82  $this->options [$id] = array("type" => $action);
83  } elseif ($copy && !$perm_copy) {
84  throw new ilSaxParserException("Missing copy permission for object " . $id);
85  } elseif (!$copy) {
86  throw new ilSaxParserException("Copy for object " . $id . " of type " . $type . " is not supported");
87  }
88  break;
90  $perm_link = $ilAccess->checkAccess('write', '', $id);
91  $link = $objDefinition->allowLink($type);
92 
93  if ($perm_link && $link) {
94  $this->options [$id] = array("type" => $action);
95  } elseif ($link && !$perm_link) {
96  throw new ilSaxParserException("Missing write permission for object " . $id);
97  } elseif (!$link) {
98  throw new ilSaxParserException("Link for object " . $id . " of type " . $type . " is not supported");
99  }
100  break;
101  }
102  }
103  }
104 
105  public function getOptions(): array
106  {
107  return $this->options;
108  }
109 
110  public function getSourceId(): ?int
111  {
112  return $this->source_id;
113  }
114 
115  public function getTargetId(): ?int
116  {
117  return $this->target_id;
118  }
119 
120  private static function getActionForString($s): int
121  {
122  if ($s === "COPY") {
124  }
125 
126  if ($s === "LINK") {
128  }
129 
131  }
132 
136  public function handlerEndTag($a_xml_parser, string $a_name): void
137  {
138  }
139 
143  public function handlerCharacterData($a_xml_parser, string $a_data): void
144  {
145  }
146 }
handlerBeginTag($a_xml_parser, string $a_name, array $a_attribs)
handlerCharacterData($a_xml_parser, string $a_data)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getTypeByRefId(int $ref_id, bool $stop_on_error=true)
get object type by reference id
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _isInTrash(int $ref_id)
global $DIC
Definition: shib_login.php:26
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
__construct(Container $dic, ilPlugin $plugin)
setXMLContent(string $a_xml_content)