ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilNotesDataSet.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/DataSet/classes/class.ilDataSet.php");
5 
16 {
23  public function getSupportedVersions()
24  {
25  return array("4.3.0");
26  }
27 
34  function getXmlNamespace($a_entity, $a_schema_version)
35  {
36  return "http://www.ilias.de/xml/Services/Notes/".$a_entity;
37  }
38 
45  protected function getTypes($a_entity, $a_version)
46  {
47  // user notes
48  if ($a_entity == "user_notes")
49  {
50  switch ($a_version)
51  {
52  case "4.3.0":
53  return array(
54  "Id" => "integer",
55  "RepObjId" => "integer",
56  "ObjId" => "integer",
57  "ObjType" => "text",
58  "ObjType" => "text",
59  "Type" => "integer",
60  "Author" => "integer",
61  "CreationDate" => "timestamp",
62  "NoteText" => "text",
63  "Label" => "integer",
64  "Subject" => "text",
65  "NoRepository" => "integer"
66  );
67  }
68  }
69  }
70 
77  function readData($a_entity, $a_version, $a_ids, $a_field = "")
78  {
79  global $ilDB;
80 
81  if (!is_array($a_ids))
82  {
83  $a_ids = array($a_ids);
84  }
85 
86  // user notes
87  if ($a_entity == "user_notes")
88  {
89  switch ($a_version)
90  {
91  case "4.3.0":
92  $this->getDirectDataFromQuery("SELECT id, rep_obj_id, obj_id, obj_type, type, ".
93  " author, note_text, creation_date, label, subject, no_repository ".
94  " FROM note ".
95  " WHERE ".
96  $ilDB->in("author", $a_ids, false, "integer").
97  " AND obj_type = ".$ilDB->quote("pd" ,"text"));
98  break;
99  }
100  }
101  }
102 
106  protected function getDependencies($a_entity, $a_version, $a_rec, $a_ids)
107  {
108  return false;
109  }
110 
114 
115 
122  function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
123  {
124  switch ($a_entity)
125  {
126  case "user_notes":
127  $usr_id = $a_mapping->getMapping("Services/User", "usr", $a_rec["Author"]);
128  if ($usr_id > 0)
129  {
130  include_once("./Services/Notes/classes/class.ilNote.php");
131 
132  // only import real user (assigned to personal desktop) notes
133  // here.
134  if ((int) $a_rec["RepObjId"] == 0 &&
135  $a_rec["ObjId"] == $a_rec["Author"] &&
136  $a_rec["Type"] == IL_NOTE_PRIVATE &&
137  $a_rec["ObjType"] == "pd")
138  {
139  $note = new ilNote();
140  $note->setObject("pd", 0, $usr_id);
141  $note->setType(IL_NOTE_PRIVATE);
142  $note->setAuthor($usr_id);
143  $note->setText($a_rec["NoteText"]);
144  $note->setSubject($a_rec["Subject"]);
145  $note->setCreationDate($a_rec["CreationDate"]);
146  $note->setLabel($a_rec["Label"]);
147  $note->create(true);
148  }
149  }
150  break;
151  }
152  }
153 }
154 ?>