ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
ilUserDataSet Class Reference

Exercise data set class. More...

+ Inheritance diagram for ilUserDataSet:
+ Collaboration diagram for ilUserDataSet:

Public Member Functions

 getSupportedVersions ()
 Get supported versions. More...
 
 getXmlNamespace ($a_entity, $a_schema_version)
 Get xml namespace. More...
 
 getXmlRecord ($a_entity, $a_version, $a_set)
 Get xml record. More...
 
 afterXmlRecordWriting ($a_entity, $a_version, $a_set)
 After xml record writing hook record. More...
 
 readData ($a_entity, $a_version, $a_ids, $a_field="")
 Read data. More...
 
 importRecord ($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
 Import record. More...
 
- Public Member Functions inherited from ilDataSet
 __construct ()
 Constructor. More...
 
 init ($a_entity, $a_schema_version)
 Init. More...
 
 getSupportedVersions ()
 Get supported version. More...
 
 readData ($a_entity, $a_version, $a_ids)
 Read data from DB. More...
 
 setExportDirectories ($a_relative, $a_absolute)
 Set export directories. More...
 
 setImportDirectory ($a_val)
 Set import directory. More...
 
 getImportDirectory ()
 Get import directory. More...
 
 setDSPrefix ($a_val)
 Set XML dataset namespace prefix. More...
 
 getDSPrefix ()
 Get XML dataset namespace prefix. More...
 
 getDSPrefixString ()
 
 getDirectDataFromQuery ($a_query, $a_convert_to_leading_upper=true)
 Get data from query.This is a standard procedure, all db field names are directly mapped to abstract fields. More...
 
 convertToLeadingUpper ($a_str)
 Make xyz_abc a XyzAbc string. More...
 
 getJsonRepresentation ()
 Get json representation. More...
 
 getXmlRepresentation ($a_entity, $a_schema_version, $a_ids, $a_field="", $a_omit_header=false, $a_omit_types=false)
 Get xml representation <dataset install_id="123" install_url="..."> <types entity="table_name" version="4.0.1"> <ftype name="field_1" type="text"> <ftype name="field_2" type="date"> <ftype name="field_3" type="integer"> </types> <types ...> ... More...
 
 addRecordsXml ($a_writer, $a_prefixes, $a_entity, $a_schema_version, $a_ids, $a_field="")
 Add records xml. More...
 
 afterXmlRecordWriting ($a_entity, $a_version, $a_set)
 After xml record writing hook record. More...
 
 getNamespaces (&$namespaces, $a_entity, $a_schema_version)
 Get xml namespaces. More...
 
 getXmlRecord ($a_entity, $a_version, $a_set)
 Get xml record for version. More...
 
 getJsonRecord ($a_set)
 Get json record for version. More...
 
 getXmlTypes ($a_entity, $a_version)
 Get xml types. More...
 
 getJsonTypes ($a_entity, $a_version)
 Get json types. More...
 
 getXMLEntityName ($a_entity, $a_version)
 Get entity name for xml (may be overwritten) More...
 
 getXMLEntityTag ($a_entity, $a_schema_version)
 Get entity tag. More...
 
 getJsonEntityName ($a_entity, $a_version)
 Get entity name for json (may be overwritten) More...
 
 setImport ($a_val)
 Set import object. More...
 
 getImport ()
 Get import object. More...
 

Data Fields

 $multi = array()
 
- Data Fields inherited from ilDataSet
 $dircnt
 
const EXPORT_NO_INST_ID = 1
 
const EXPORT_ID_ILIAS_LOCAL = 2
 
const EXPORT_ID_ILIAS_LOCAL_INVALID = 3
 
const EXPORT_ID_ILIAS_REMOTE = 4
 
const EXPORT_ID_ILIAS_REMOTE_INVALID = 5
 
const EXPORT_ID = 6
 
const EXPORT_ID_INVALID = 7
 

Protected Member Functions

 getTypes ($a_entity, $a_version)
 Get field types for entity. More...
 
 getDependencies ($a_entity, $a_version, $a_rec, $a_ids)
 Determine the dependent sets of data. More...
 
- Protected Member Functions inherited from ilDataSet
 getTypes ($a_entity, $a_version)
 Get (abstract) types for (abstract) field names. More...
 
 getXmlNamespace ($a_entity, $a_schema_version)
 Get xml namespace. More...
 
 createObjectExportId ($a_type, $a_id)
 Build ilias export id. More...
 
 parseObjectExportId ($a_id, $a_fallback_id=NULL)
 Parse export id. More...
 

Protected Attributes

 $temp_picture_dirs = array()
 

Detailed Description

Exercise data set class.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 13 of file class.ilUserDataSet.php.

Member Function Documentation

◆ afterXmlRecordWriting()

ilUserDataSet::afterXmlRecordWriting (   $a_entity,
  $a_version,
  $a_set 
)

After xml record writing hook record.

Parameters

Definition at line 159 of file class.ilUserDataSet.php.

References ilUtil\delDir().

160  {
161  if ($a_entity == "usr_profile")
162  {
163  // cleanup temp dirs for pictures
164  $tmp_dir = $this->temp_picture_dirs[$a_set["Id"]];
165  if ($tmp_dir != "" && is_dir($tmp_dir))
166  {
167  ilUtil::delDir($tmp_dir);
168  }
169  }
170  }
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ Here is the call graph for this function:

◆ getDependencies()

ilUserDataSet::getDependencies (   $a_entity,
  $a_version,
  $a_rec,
  $a_ids 
)
protected

Determine the dependent sets of data.

Definition at line 278 of file class.ilUserDataSet.php.

279  {
280  return false;
281  switch ($a_entity)
282  {
283  case "personal_data":
284  return array (
285  "usr_profile" => array("ids" => $a_rec["Id"]),
286  "usr_setting" => array("ids" => $a_rec["Id"]),
287  "usr_multi" => array("ids" => $a_rec["Id"])
288  );
289  }
290  return false;
291  }

◆ getSupportedVersions()

ilUserDataSet::getSupportedVersions ( )

Get supported versions.

Parameters

Definition at line 25 of file class.ilUserDataSet.php.

26  {
27  return array("4.3.0", "4.5.0");
28  }

◆ getTypes()

ilUserDataSet::getTypes (   $a_entity,
  $a_version 
)
protected

Get field types for entity.

Parameters

Definition at line 47 of file class.ilUserDataSet.php.

48  {
49  // user profile type
50  if ($a_entity == "usr_profile")
51  {
52  switch ($a_version)
53  {
54  case "4.3.0":
55  case "4.5.0":
56  return array(
57  "Id" => "integer",
58  "Username" => "text",
59  "Firstname" => "text",
60  "Lastname" => "text",
61  "Title" => "text",
62  "Birthday" => "text",
63  "Gender" => "text",
64  "Institution" => "text",
65  "Department" => "text",
66  "Street" => "text",
67  "Zipcode" => "text",
68  "City" => "text",
69  "Country" => "text",
70  "SelCountry" => "text",
71  "PhoneOffice" => "text",
72  "PhoneHome" => "text",
73  "PhoneMobile" => "text",
74  "Fax" => "text",
75  "Email" => "text",
76  "Hobby" => "text",
77  "ReferralComment" => "text",
78  "Matriculation" => "text",
79  "Delicious" => "text",
80  "Latitude" => "text",
81  "Longitude" => "text",
82  "Picture" => "directory"
83  );
84  }
85  }
86 
87  if ($a_entity == "usr_setting")
88  {
89  switch ($a_version)
90  {
91  case "4.3.0":
92  case "4.5.0":
93  return array(
94  "UserId" => "integer",
95  "Keyword" => "text",
96  "Value" => "text"
97  );
98  }
99  }
100 
101  if ($a_entity == "personal_data")
102  {
103  switch ($a_version)
104  {
105  case "4.3.0":
106  case "4.5.0":
107  return array(
108  "Id" => "integer"
109  );
110  }
111  }
112 
113  if ($a_entity == "usr_multi")
114  {
115  switch ($a_version)
116  {
117  case "4.5.0":
118  return array(
119  "UserId" => "integer",
120  "FieldId" => "text",
121  "Value" => "text"
122  );
123  }
124  }
125  }

◆ getXmlNamespace()

ilUserDataSet::getXmlNamespace (   $a_entity,
  $a_schema_version 
)

Get xml namespace.

Parameters

Definition at line 36 of file class.ilUserDataSet.php.

37  {
38  return "http://www.ilias.de/xml/Services/User/".$a_entity;
39  }

◆ getXmlRecord()

ilUserDataSet::getXmlRecord (   $a_entity,
  $a_version,
  $a_set 
)

Get xml record.

Parameters

Definition at line 134 of file class.ilUserDataSet.php.

References $ilLog, ilObjUser\copyProfilePicturesToDirectory(), ilUtil\ilTempnam(), and ilUtil\makeDir().

135  {
136  global $ilLog;
137 
138  if ($a_entity == "usr_profile")
139  {
140  $tmp_dir = ilUtil::ilTempnam();
141  ilUtil::makeDir($tmp_dir);
142  include_once("./Services/User/classes/class.ilObjUser.php");
143  ilObjUser::copyProfilePicturesToDirectory($a_set["Id"], $tmp_dir);
144 
145  $this->temp_picture_dirs[$a_set["Id"]] = $tmp_dir;
146 
147  $a_set["Picture"] = $tmp_dir;
148  }
149 
150  return $a_set;
151  }
static copyProfilePicturesToDirectory($a_user_id, $a_dir)
Get profile picture direcotory.
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static ilTempnam()
Create a temporary file in an ILIAS writable directory.
+ Here is the call graph for this function:

◆ importRecord()

ilUserDataSet::importRecord (   $a_entity,
  $a_types,
  $a_rec,
  $a_mapping,
  $a_schema_version 
)

Import record.

Parameters

Definition at line 300 of file class.ilUserDataSet.php.

References $ilSetting, $ilUser, ilObject\_lookupType(), ilObjUser\_uploadPersonalPicture(), ilDataSet\convertToLeadingUpper(), ilDataSet\getImportDirectory(), ilUtil\secureString(), and ilUserProfile\userSettingVisible().

301  {
302  global $ilSetting, $ilUser;
303 //echo $a_entity;
304 //var_dump($a_rec);
305 
306  switch ($a_entity)
307  {
308  case "personal_data":
309  // only users themselves import their profiles!
310  // thus we can map the import id of the dataset to the current user
311  $a_mapping->addMapping("Services/User", "usr", $a_rec["Id"], $ilUser->getId());
312  break;
313 
314  case "usr_profile":
315  $usr_id = $a_mapping->getMapping("Services/User", "usr", $a_rec["Id"]);
316  if ($usr_id > 0 && ilObject::_lookupType($usr_id) == "usr")
317  {
318  if (!isset($this->users[$usr_id]))
319  {
320  $this->users[$usr_id] = new ilObjUser($usr_id);
321  }
322  $user = $this->users[$usr_id];
323  include_once("./Services/User/classes/class.ilUserProfile.php");
324  $prof = new ilUserProfile();
325  $prof->skipField("username");
326  $prof->skipField("password");
327  $prof->skipField("roles");
328  $prof->skipGroup("settings");
329  $fields = $prof->getStandardFields();
330  foreach ($fields as $k => $f)
331  {
332  $up_k = $this->convertToLeadingUpper($k);
333  // only change fields, when it is possible in profile
335  !$ilSetting->get("usr_settings_disable_".$k) &&
336  $f["method"] != "" && isset($a_rec[$up_k]))
337  {
338  $set_method = "set".substr($f["method"], 3);
339  $user->{$set_method}(ilUtil::secureString($a_rec[$up_k]));
340 // echo "<br>-setting-".$set_method."-".$a_rec[$up_k]."-";
341  }
342  }
343  $user->update();
344 
345  // personal picture
346  $pic_dir = $this->getImportDirectory()."/".str_replace("..", "", $a_rec["Picture"]);
347  if ($pic_dir != "" && is_dir($pic_dir))
348  {
349  $upload_file = $pic_dir."/upload_".$a_rec["Id"]."pic";
350  if (is_file($upload_file))
351  {
352  ilObjUser::_uploadPersonalPicture($upload_file, $user->getId());
353  }
354  }
355  }
356  break;
357 
358  case "usr_setting":
359  $usr_id = $a_mapping->getMapping("Services/User", "usr", $a_rec["UserId"]);
360  if ($usr_id > 0 && ilObject::_lookupType($usr_id) == "usr")
361  {
362  if (!isset($this->users[$usr_id]))
363  {
364  $this->users[$usr_id] = new ilObjUser($usr_id);
365  }
366  $user = $this->users[$usr_id];
367  $user->writePref($a_rec["Keyword"], ilUtil::secureString($a_rec["Value"]));
368  }
369  break;
370 
371  case "usr_multi":
372  $usr_id = $a_mapping->getMapping("Services/User", "usr", $a_rec["UserId"]);
373  if ($usr_id > 0 && ilObject::_lookupType($usr_id) == "usr")
374  {
375  $this->multi[$usr_id][$a_rec["FieldId"]][] = ilUtil::secureString($a_rec["Value"]);
376  }
377  break;
378  }
379  }
static userSettingVisible($a_setting)
Checks whether user setting is visible.
Class ilUserProfile.
getImportDirectory()
Get import directory.
convertToLeadingUpper($a_str)
Make xyz_abc a XyzAbc string.
_uploadPersonalPicture($tmp_file, $obj_id)
Create a personal picture image file from a temporary image file.
static _lookupType($a_id, $a_reference=false)
lookup object type
global $ilUser
Definition: imgupload.php:15
global $ilSetting
Definition: privfeed.php:40
static secureString($a_str, $a_strip_html=true, $a_allow="")
Remove unsecure tags.
+ Here is the call graph for this function:

◆ readData()

ilUserDataSet::readData (   $a_entity,
  $a_version,
  $a_ids,
  $a_field = "" 
)

Read data.

Parameters

Definition at line 178 of file class.ilUserDataSet.php.

References $ilDB, and ilDataSet\getDirectDataFromQuery().

179  {
180  global $ilDB;
181 
182  if (!is_array($a_ids))
183  {
184  $a_ids = array($a_ids);
185  }
186 
187  if ($a_entity == "personal_data")
188  {
189  switch ($a_version)
190  {
191  case "4.3.0":
192  case "4.5.0":
193  $this->data = array();
194  foreach ($a_ids as $id)
195  {
196  $this->data[] = array("Id" => $id);
197  }
198  break;
199  }
200  }
201 
202  if ($a_entity == "usr_profile")
203  {
204  switch ($a_version)
205  {
206  case "4.3.0":
207  case "4.5.0":
208  $this->getDirectDataFromQuery("SELECT usr_id id, login username, firstname, lastname, ".
209  " title, birthday, gender, institution, department, street, city, zipcode, country, sel_country, ".
210  " phone_office, phone_home, phone_mobile, fax, email, hobby, referral_comment, matriculation, ".
211  " delicious, latitude, longitude".
212  " FROM usr_data u ".
213  "WHERE ".
214  $ilDB->in("u.usr_id", $a_ids, false, "integer"));
215  break;
216  }
217  }
218 
219  if ($a_entity == "usr_setting")
220  {
221  switch ($a_version)
222  {
223  case "4.3.0":
224  case "4.5.0":
225  // for all user ids get data from usr_pref and mail options, create records user_id/name/value
226  $prefs = array("date_format", "day_end", "day_start", "hide_own_online_status", "hits_per_page", "language",
227  "public_birthday", "puplic_city", "public_country", "public_delicious", "public_department", "public_email",
228  "public_fax", "public_gender", "public_hobby", "public_im_aim", "public_im_icq", "public_im_jabber",
229  "public_im_msn", "public_im_skype", "public_im_voip", "public_im_yahoo", "public_institution", "public_location",
230  "public_matriculation", "public_phone_home", "public_phone_mobile", "public_phone_office", "public_profile",
231  "public_sel_country", "public_street", "public_title", "public_upload", "public_zipcode",
232  "screen_reader_optimization", "show_users_online",
233  "store_last_visited", "time_format", "user_tz", "weekstart");
234  $this->data = array();
235  $set = $ilDB->query("SELECT * FROM usr_pref ".
236  " WHERE ".$ilDB->in("keyword", $prefs, false, "text").
237  " AND ".$ilDB->in("usr_id", $a_ids, false, "integer"));
238  while ($rec = $ilDB->fetchAssoc($set))
239  {
240  $this->data[] = array("UserId" => $rec["usr_id"], "Keyword" => $rec["keyword"], "Value" => $rec["value"]);
241  }
242 
243  /*
244  require_once 'Services/Mail/classes/class.ilMailOptions.php';
245  $mailOptions = new ilMailOptions($ilUser->getId());
246 
247  /*$this->getDirectDataFromQuery("SELECT usr_id id, login username, firstname, lastname, ".
248  " title, birthday, gender, institution, department, street, city, zipcode, country, sel_country, ".
249  " phone_office, phone_home, phone_mobile, fax, email, hobby, referral_comment, matriculation, ".
250  " delicious, latitude, longitude".
251  " FROM usr_data u ".
252  "WHERE ".
253  $ilDB->in("u.usr_id", $a_ids, false, "integer"));*/
254  break;
255  }
256  }
257 
258  if ($a_entity == "usr_multi")
259  {
260  switch ($a_version)
261  {
262  case "4.5.0":
263  $this->data = array();
264  $set = $ilDB->query("SELECT * FROM usr_data_multi".
265  " WHERE ".$ilDB->in("usr_id", $a_ids, false, "integer"));
266  while ($rec = $ilDB->fetchAssoc($set))
267  {
268  $this->data[] = array("UserId" => $rec["usr_id"], "FieldId" => $rec["field_id"], "Value" => $rec["value"]);
269  }
270  break;
271  }
272  }
273  }
getDirectDataFromQuery($a_query, $a_convert_to_leading_upper=true)
Get data from query.This is a standard procedure, all db field names are directly mapped to abstract ...
global $ilDB
+ Here is the call graph for this function:

Field Documentation

◆ $multi

ilUserDataSet::$multi = array()

Definition at line 17 of file class.ilUserDataSet.php.

◆ $temp_picture_dirs

ilUserDataSet::$temp_picture_dirs = array()
protected

Definition at line 15 of file class.ilUserDataSet.php.


The documentation for this class was generated from the following file: