ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilGroupImporter.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/Export/classes/class.ilXmlImporter.php");
5 
16 {
17  private $group = null;
18 
19 
20  public function init()
21  {
22  }
23 
30  function importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
31  {
32  include_once './Modules/Group/classes/class.ilObjGroup.php';
33  if($new_id = $a_mapping->getMapping('Services/Container','objs',$a_id))
34  {
35  $refs = ilObject::_getAllReferences($new_id);
36  $this->group = ilObjectFactory::getInstanceByRefId(end($refs),false);
37  #$this->group = ilObjectFactory::getInstanceByObjId($new_id,false);
38  }
39  // Mapping for containers without subitems
40  elseif($new_id = $a_mapping->getMapping('Services/Container','refs',0))
41  {
42  $this->group = ilObjectFactory::getInstanceByRefId($new_id,false);
43  }
44  elseif(!$this->group instanceof ilObjGroup)
45  {
46  $this->group = new ilObjGroup();
47  $this->group->create(true);
48  }
49 
50  include_once './Modules/Group/classes/class.ilGroupXMLParser.php';
51  #$GLOBALS['ilLog']->write($a_xml);
52 
53  try
54  {
55  $parser = new ilGroupXMLParser($a_xml,0);
56  $parser->setGroup($this->group);
57  $parser->setMode(ilGroupXMLParser::$UPDATE);
58  $parser->startParsing();
59  $a_mapping->addMapping('Modules/Group','grp',$a_id,$this->group->getId());
60  }
61  catch(ilSaxParserException $e)
62  {
63  $GLOBALS['ilLog']->write(__METHOD__.': Parsing failed with message, "'.$e->getMessage().'".');
64  }
65  catch(ilWebLinkXMLParserException $e)
66  {
67  $GLOBALS['ilLog']->write(__METHOD__.': Parsing failed with message, "'.$e->getMessage().'".');
68  }
69  }
70 }
71 ?>