ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilCopyWizardSettingsXMLParser.php
Go to the documentation of this file.
1 <?php
2 /*
3  * Created on 26.02.2008
4  *
5  * To change the template for this generated file go to
6  * Window - Preferences - PHPeclipse - PHP - Code Templates
7  */
8 
9 include_once "./Services/Xml/classes/class.ilSaxParser.php";
10 include_once "./Services/Xml/exceptions/class.ilSaxParserException.php";
11 include_once "./Services/CopyWizard/classes/class.ilCopyWizardOptions.php";
12 
14 {
15  private $options;
16  private $source_id;
17  private $target_id;
18  private $default_action;
19 
27  public function __construct($xml)
28  {
29  parent::__construct('', true);
30  $this->setXMLContent($xml);
31  }
32 
39  public function setHandlers($a_xml_parser)
40  {
41  xml_set_object($a_xml_parser, $this);
42  xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag');
43  xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData');
44  }
45 
53  public function handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
54  {
55  global $objDefinition, $ilAccess, $tree;
56 
57  switch ($a_name) {
58  case 'Settings':
59  $this->options = array();
60  $this->source_id = (int) $a_attribs["source_id"];
61  if (ilObject::_isInTrash($this->source_id)) {
62  throw new ilSaxParserException("Source id " . $this->source_id . " is in trash");
63  }
64  $this->target_id = (int) $a_attribs["target_id"];
65  if (ilObject::_isInTrash($this->target_id)) {
66  throw new ilSaxParserException("target id" . $this->target_id . " is in trash");
67  }
68 
69  $this->default_action = ilCopyWizardSettingsXMLParser::getActionForString($a_attribs["default_action"]);
70  break;
71  case 'Option':
72  $id = (int) $a_attribs["id"];
74  throw new ilSaxParserException("Id $id is in trash");
75  }
76  if (!$tree->isInTree($id)) {
77  throw new ilSaxParserException("Id $id does not exist");
78  }
79 
82 
83 
84  switch ($action) {
86  $perm_copy = $ilAccess->checkAccess('copy', '', $id);
87  $copy = $objDefinition->allowCopy($type);
88 
89  if ($perm_copy && $copy) {
90  $this->options [$id] = array("type" => $action);
91  } elseif ($copy && !$perm_copy) {
92  throw new ilSaxParserException("Missing copy permission for object " . $id);
93  } elseif (!$copy) {
94  throw new ilSaxParserException("Copy for object " . $id . " of type " . $type . " is not supported");
95  }
96  break;
98  $perm_link = $ilAccess->checkAccess('write', '', $id);
99  $link = $objDefinition->allowLink($type);
100 
101  if ($perm_link && $link) {
102  $this->options [$id] = array("type" => $action);
103  } elseif ($copy && !$perm_link) {
104  throw new ilSaxParserException("Missing write permission for object " . $id);
105  } elseif (!$link) {
106  throw new ilSaxParserException("Link for object " . $id . " of type " . $type . " is not supported");
107  }
108  break;
109  }
110  }
111  }
112 
113 
119  public function getOptions()
120  {
121  return is_array($this->options) ? $this->options : array();
122  }
123 
129  public function getSourceId()
130  {
131  return $this->source_id;
132  }
133 
139  public function getTargetId()
140  {
141  return $this->target_id;
142  }
143 
144  private static function getActionForString($s)
145  {
146  if ($s == "COPY") {
148  }
149  if ($s == "LINK") {
151  }
153  }
154 
155  public function handlerEndTag($a_xml_parser, $a_name)
156  {
157  }
158 
165  public function handlerCharacterData($a_xml_parser, $a_data)
166  {
167  }
168 }
handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
handler for begin of element
$action
$type
if(!array_key_exists('StateId', $_REQUEST)) $id
static _isInTrash($a_ref_id)
checks wether object is in trash
SaxParserException thrown by ilSaxParser if property throwException is set.
$s
Definition: pwgen.php:45
Base class for sax-based expat parsing extended classes need to overwrite the method setHandlers and ...
$xml
Definition: metadata.php:240
static getTypeByRefId($a_ref_id, $stop_on_error=true)
get object type by reference id
setHandlers($a_xml_parser)
set event handlers
Create styles array
The data for the language used.
handlerCharacterData($a_xml_parser, $a_data)
handler for character data
setXMLContent($a_xml_content)