1<?php 2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */ 3 4include_once("./Services/DataSet/classes/class.ilDataSet.php"); 5 6/** 7 * Rating Data set class 8 * 9 * This class implements the following entities: 10 * - rating_category: data from il_rating_cat 11 * 12 * @author Jörg Lützenkirchen <luetzenkirchen@leifos.com> 13 * @version $Id$ 14 * @ingroup ingroup ServicesRating 15 */ 16class ilRatingDataSet extends ilDataSet 17{ 18 /** 19 * Get supported versions 20 * 21 * @param 22 * @return 23 */ 24 public function getSupportedVersions() 25 { 26 return array("4.3.0"); 27 } 28 29 /** 30 * Get xml namespace 31 * 32 * @param 33 * @return 34 */ 35 public function getXmlNamespace($a_entity, $a_schema_version) 36 { 37 return "http://www.ilias.de/xml/Services/Rating/" . $a_entity; 38 } 39 40 /** 41 * Get field types for entity 42 * 43 * @param 44 * @return 45 */ 46 protected function getTypes($a_entity, $a_version) 47 { 48 if ($a_entity == "rating_category") { 49 switch ($a_version) { 50 case "4.3.0": 51 return array( 52 "Id" => "integer", 53 "ParentId" => "integer", 54 "Title" => "text", 55 "Description" => "text", 56 "Pos" => "integer"); 57 } 58 } 59 } 60 61 /** 62 * Read data 63 * 64 * @param 65 * @return 66 */ 67 public function readData($a_entity, $a_version, $a_ids, $a_field = "") 68 { 69 $ilDB = $this->db; 70 71 if (!is_array($a_ids)) { 72 $a_ids = array($a_ids); 73 } 74 75 if ($a_entity == "rating_category") { 76 switch ($a_version) { 77 case "4.3.0": 78 $this->getDirectDataFromQuery("SELECT id, parent_id, title," . 79 " description, pos" . 80 " FROM il_rating_cat" . 81 " WHERE " . $ilDB->in("parent_id", $a_ids, false, "integer")); 82 break; 83 } 84 } 85 } 86 87 /** 88 * Determine the dependent sets of data 89 */ 90 protected function getDependencies($a_entity, $a_version, $a_rec, $a_ids) 91 { 92 return false; 93 } 94 95 /** 96 * Import record 97 * 98 * @param 99 * @return 100 */ 101 public function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version) 102 { 103 //echo $a_entity; 104 //var_dump($a_rec); 105 106 switch ($a_entity) { 107 case "rating_category": 108 if ($parent_id = $a_mapping->getMapping('Services/Rating', 'rating_category_parent_id', $a_rec['ParentId'])) { 109 include_once("./Services/Rating/classes/class.ilRatingCategory.php"); 110 $newObj = new ilRatingCategory(); 111 $newObj->setParentId($parent_id); 112 $newObj->save(); 113 114 $newObj->setTitle($a_rec["Title"]); 115 $newObj->setDescription($a_rec["Description"]); 116 $newObj->setPosition($a_rec["Pos"]); 117 $newObj->update(); 118 } 119 break; 120 } 121 } 122} 123