/**
  * Import record
  *
  * @param
  * @return
  */
 function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
 {
     switch ($a_entity) {
         case "bookmarks":
             break;
         case "bookmark_tree":
             $usr_id = $a_mapping->getMapping("Services/User", "usr", $a_rec["UserId"]);
             if ($usr_id > 0 && ilObject::_lookupType($usr_id) == "usr") {
                 //echo "<br><br>";
                 //var_dump($a_rec);
                 switch ($a_rec["Type"]) {
                     case "bmf":
                         if ($a_rec["Parent"] > 0) {
                             $parent = (int) $a_mapping->getMapping("Services/Bookmarks", "bookmark_tree", $a_rec["Parent"]);
                             include_once "./Services/Bookmarks/classes/class.ilBookmarkFolder.php";
                             $bmf = new ilBookmarkFolder(0, $usr_id);
                             $bmf->setTitle($a_rec["Title"]);
                             $bmf->setParent($parent);
                             $bmf->create();
                             $fold_id = $bmf->getId();
                         } else {
                             $tree = new ilTree($usr_id);
                             $tree->setTableNames('bookmark_tree', 'bookmark_data');
                             $fold_id = $tree->readRootId();
                         }
                         $a_mapping->addMapping("Services/Bookmarks", "bookmark_tree", $a_rec["Child"], $fold_id);
                         break;
                     case "bm":
                         $parent = 0;
                         if ((int) $a_rec["Parent"] > 0) {
                             $parent = (int) $a_mapping->getMapping("Services/Bookmarks", "bookmark_tree", $a_rec["Parent"]);
                         } else {
                             return;
                         }
                         if ($parent == 0) {
                             $tree = new ilTree($usr_id);
                             $tree->setTableNames('bookmark_tree', 'bookmark_data');
                             $parent = $tree->readRootId();
                         }
                         //echo "-$parent-";
                         include_once "./Services/Bookmarks/classes/class.ilBookmark.php";
                         $bm = new ilBookmark(0, $usr_id);
                         $bm->setTitle($a_rec["Title"]);
                         $bm->setDescription($a_rec["Description"]);
                         $bm->setTarget($a_rec["Target"]);
                         $bm->setParent($parent);
                         $bm->create();
                         break;
                 }
             }
             break;
     }
 }
 /**
  * creates the bookmarks and folders
  * @param    array            array of objects
  * @param    array            stores the number of created objects
  * @param    folder_id        id where to store the bookmarks
  * @param    start_key        key of the objects array where to start
  * @access    private
  */
 function __importBookmarks(&$objects, &$num_create, $folder_id, $start_key = 0)
 {
     if (is_array($objects[$start_key])) {
         foreach ($objects[$start_key] as $obj_key => $object) {
             switch ($object['type']) {
                 case 'bm':
                     if (!$object["title"]) {
                         continue;
                     }
                     if (!$object["target"]) {
                         continue;
                     }
                     $bm = new ilBookmark();
                     $bm->setTitle($object["title"]);
                     $bm->setDescription($object["description"]);
                     $bm->setTarget($object["target"]);
                     $bm->setParent($folder_id);
                     $bm->create();
                     $num_create['bm']++;
                     break;
                 case 'bmf':
                     if (!$object["title"]) {
                         continue;
                     }
                     $bmf = new ilBookmarkFolder();
                     $bmf->setTitle($object["title"]);
                     $bmf->setParent($folder_id);
                     $bmf->create();
                     $num_create['bmf']++;
                     if (is_array($objects[$obj_key])) {
                         $this->__importBookmarks($objects, $num_create, $bmf->getId(), $obj_key);
                     }
                     break;
             }
         }
     }
 }