ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
9include_once "./Services/Xml/classes/class.ilSaxParser.php";
10include_once "./Services/Xml/exceptions/class.ilSaxParserException.php";
11include_once "./Services/CopyWizard/classes/class.ilCopyWizardOptions.php";
12
14{
15
16 private $options;
17 private $source_id;
18 private $target_id;
20
29 {
30 parent::ilSaxParser('', true);
31 $this->setXMLContent($xml);
32 }
33
40 function setHandlers($a_xml_parser)
41 {
42 xml_set_object($a_xml_parser,$this);
43 xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
44 xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
45 }
46
54 function handlerBeginTag($a_xml_parser,$a_name,$a_attribs)
55 {
56 global $objDefinition, $ilAccess, $tree;
57
58 switch($a_name)
59 {
60 case 'Settings':
61 $this->options = array();
62 $this->source_id = (int) $a_attribs["source_id"];
63 if(ilObject::_isInTrash($this->source_id))
64 {
65 throw new ilSaxParserException("Source id ".$this->source_id." is in trash");
66 }
67 $this->target_id = (int) $a_attribs["target_id"];
68 if(ilObject::_isInTrash($this->target_id))
69 {
70 throw new ilSaxParserException("target id".$this->target_id." is in trash");
71 }
72
73 $this->default_action = ilCopyWizardSettingsXMLParser::getActionForString($a_attribs["default_action"]);
74 break;
75 case 'Option':
76 $id = (int) $a_attribs["id"];
78 {
79 throw new ilSaxParserException("Id $id is in trash");
80 }
81 if(!$tree->isInTree($id))
82 {
83 throw new ilSaxParserException("Id $id does not exist");
84 }
85
86 $action = ilCopyWizardSettingsXMLParser::getActionForString($a_attribs["action"]);
88
89
90 switch ($action) {
92 $perm_copy = $ilAccess->checkAccess('copy','',$id);
93 $copy = $objDefinition->allowCopy($type);
94
95 if ($perm_copy && $copy)
96 $this->options [$id] = array("type" => $action);
97 elseif ($copy && !$perm_copy)
98 throw new ilSaxParserException("Missing copy permission for object ".$id);
99 elseif (!$copy)
100 throw new ilSaxParserException("Copy for object ".$id." of type ".$type." is not supported");
101 break;
103 $perm_link = $ilAccess->checkAccess('write','',$id);
104 $link = $objDefinition->allowLink($type);
105
106 if ($perm_link && $link)
107 $this->options [$id] = array("type" => $action);
108 elseif ($copy && !$perm_link)
109 throw new ilSaxParserException("Missing write permission for object ".$id);
110 elseif (!$link)
111 throw new ilSaxParserException("Link for object ".$id." of type ".$type." is not supported");
112 break;
113 }
114 }
115 }
116
117
123 function getOptions() {
124 return is_array($this->options) ? $this->options : array();
125 }
126
132 function getSourceId() {
133 return $this->source_id;
134 }
135
141 function getTargetId() {
142 return $this->target_id;
143 }
144
145 private static function getActionForString($s){
146 if ($s == "COPY")
148 if ($s == "LINK")
151 }
152
153 function handlerEndTag($a_xml_parser,$a_name)
154 {
155 }
156
163 function handlerCharacterData($a_xml_parser,$a_data) {
164 }
165}
166?>
setHandlers($a_xml_parser)
set event handlers
handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
handler for begin of element
handlerCharacterData($a_xml_parser, $a_data)
handler for character data
getTypeByRefId($a_ref_id, $stop_on_error=true)
get object type by reference id
_isInTrash($a_ref_id)
checks wether object is in trash
SaxParserException thrown by ilSaxParser if property throwException is set.
Base class for sax-based expat parsing extended classes need to overwrite the method setHandlers and ...
setXMLContent($a_xml_content)