ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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, $a_set=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...
 
 setCurrentInstallationId ($a_val)
 Set current installation id. More...
 
 getCurrentInstallationId ()
 Get current installation id. 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()
 
- Protected Attributes inherited from ilDataSet
 $current_installation_id = ""
 
 $db
 
 $ds_log
 

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 175 of file class.ilUserDataSet.php.

References ilUtil\delDir().

176  {
177  if ($a_entity == "usr_profile") {
178  // cleanup temp dirs for pictures
179  $tmp_dir = $this->temp_picture_dirs[$a_set["Id"]];
180  if ($tmp_dir != "" && is_dir($tmp_dir)) {
181  ilUtil::delDir($tmp_dir);
182  }
183  }
184  }
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 310 of file class.ilUserDataSet.php.

311  {
312  return false;
313  switch ($a_entity) {
314  case "personal_data":
315  return array(
316  "usr_profile" => array("ids" => $a_rec["Id"]),
317  "usr_setting" => array("ids" => $a_rec["Id"]),
318  "usr_multi" => array("ids" => $a_rec["Id"])
319  );
320  }
321  return false;
322  }

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

◆ 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 139 of file class.ilUserDataSet.php.

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

140  {
141  global $DIC;
142 
143  $ilLog = $DIC['ilLog'];
144 
145  if ($a_entity == "usr_profile") {
146  $tmp_dir = ilUtil::ilTempnam();
147  ilUtil::makeDir($tmp_dir);
148  include_once("./Services/User/classes/class.ilObjUser.php");
149 
150  $im = ilObjUser::_getPersonalPicturePath(
151  $a_set["Id"],
152  "small",
153  true,
154  true
155  );
156 
157  if ($im != "") {
158  ilObjUser::copyProfilePicturesToDirectory($a_set["Id"], $tmp_dir);
159  }
160 
161  $this->temp_picture_dirs[$a_set["Id"]] = $tmp_dir;
162 
163  $a_set["Picture"] = $tmp_dir;
164  }
165 
166  return $a_set;
167  }
global $DIC
Definition: saml.php:7
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($a_temp_path=null)
Returns a unique and non existing Path for e temporary file or 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 331 of file class.ilUserDataSet.php.

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

332  {
333  global $DIC;
334 
335  $ilSetting = $DIC['ilSetting'];
336  $ilUser = $DIC['ilUser'];
337  //echo $a_entity;
338  //var_dump($a_rec);
339 
340  switch ($a_entity) {
341  case "personal_data":
342  // only users themselves import their profiles!
343  // thus we can map the import id of the dataset to the current user
344  $a_mapping->addMapping("Services/User", "usr", $a_rec["Id"], $ilUser->getId());
345  break;
346 
347  case "usr_profile":
348  $usr_id = $a_mapping->getMapping("Services/User", "usr", $a_rec["Id"]);
349  if ($usr_id > 0 && ilObject::_lookupType($usr_id) == "usr") {
350  if (!isset($this->users[$usr_id])) {
351  $this->users[$usr_id] = new ilObjUser($usr_id);
352  }
353  $user = $this->users[$usr_id];
354  include_once("./Services/User/classes/class.ilUserProfile.php");
355  $prof = new ilUserProfile();
356  $prof->skipField("username");
357  $prof->skipField("password");
358  $prof->skipField("roles");
359  $prof->skipGroup("settings");
360  $fields = $prof->getStandardFields();
361  foreach ($fields as $k => $f) {
362  $up_k = $this->convertToLeadingUpper($k);
363  // only change fields, when it is possible in profile
365  !$ilSetting->get("usr_settings_disable_" . $k) &&
366  $f["method"] != "" && isset($a_rec[$up_k])) {
367  $set_method = "set" . substr($f["method"], 3);
368  $user->{$set_method}(ilUtil::secureString($a_rec[$up_k]));
369  }
370  }
371 
372  $user->setLatitude($a_rec["Latitude"]);
373  $user->setLongitude($a_rec["Longitude"]);
374  $user->setLocationZoom($a_rec["LocZoom"]);
375 
376  $user->update();
377 
378  // personal picture
379  $pic_dir = $this->getImportDirectory() . "/" . str_replace("..", "", $a_rec["Picture"]);
380  if ($pic_dir != "" && is_dir($pic_dir)) {
381  $upload_file = $pic_dir . "/upload_" . $a_rec["Id"] . "pic";
382  if (is_file($upload_file)) {
383  ilObjUser::_uploadPersonalPicture($upload_file, $user->getId());
384  }
385  }
386  }
387  break;
388 
389  case "usr_setting":
390  $usr_id = $a_mapping->getMapping("Services/User", "usr", $a_rec["UserId"]);
391  if ($usr_id > 0 && ilObject::_lookupType($usr_id) == "usr") {
392  if (!isset($this->users[$usr_id])) {
393  $this->users[$usr_id] = new ilObjUser($usr_id);
394  }
395  $user = $this->users[$usr_id];
396  $user->writePref($a_rec["Keyword"], ilUtil::secureString($a_rec["Value"]));
397  }
398  break;
399 
400  case "usr_multi":
401  $usr_id = $a_mapping->getMapping("Services/User", "usr", $a_rec["UserId"]);
402  if ($usr_id > 0 && ilObject::_lookupType($usr_id) == "usr") {
403  $this->multi[$usr_id][$a_rec["FieldId"]][] = ilUtil::secureString($a_rec["Value"]);
404  }
405  break;
406  }
407  }
global $DIC
Definition: saml.php:7
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.
$ilUser
Definition: imgupload.php:18
static _uploadPersonalPicture($tmp_file, $obj_id)
Create a personal picture image file from a temporary image file.
$user
Definition: migrateto20.php:57
static _lookupType($a_id, $a_reference=false)
lookup object type
global $ilSetting
Definition: privfeed.php:17
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 192 of file class.ilUserDataSet.php.

References $DIC, $id, $ilDB, data, and ilDataSet\getDirectDataFromQuery().

193  {
194  global $DIC;
195 
196  $ilDB = $DIC['ilDB'];
197 
198  if (!is_array($a_ids)) {
199  $a_ids = array($a_ids);
200  }
201 
202  if ($a_entity == "personal_data") {
203  switch ($a_version) {
204  case "4.3.0":
205  case "4.5.0":
206  case "5.1.0":
207  case "5.2.0":
208  case "5.3.0":
209  $this->data = array();
210  foreach ($a_ids as $id) {
211  $this->data[] = array("Id" => $id);
212  }
213  break;
214  }
215  }
216 
217  if ($a_entity == "usr_profile") {
218  switch ($a_version) {
219  case "4.3.0":
220  case "4.5.0":
221  case "5.1.0":
222  $this->getDirectDataFromQuery("SELECT usr_id id, login username, firstname, lastname, " .
223  " title, birthday, gender, institution, department, street, city, zipcode, country, sel_country, " .
224  " phone_office, phone_home, phone_mobile, fax, email, hobby, referral_comment, matriculation, " .
225  " delicious, latitude, longitude, loc_zoom" .
226  " FROM usr_data u " .
227  "WHERE " .
228  $ilDB->in("u.usr_id", $a_ids, false, "integer"));
229  break;
230 
231  case "5.2.0":
232  $this->getDirectDataFromQuery("SELECT usr_id id, login username, firstname, lastname, " .
233  " title, birthday, gender, institution, department, street, city, zipcode, country, sel_country, " .
234  " phone_office, phone_home, phone_mobile, fax, email, hobby, referral_comment, matriculation, " .
235  " latitude, longitude, loc_zoom" .
236  " FROM usr_data u " .
237  "WHERE " .
238  $ilDB->in("u.usr_id", $a_ids, false, "integer"));
239  break;
240  case "5.3.0":
241  $this->getDirectDataFromQuery("SELECT usr_id id, login username, firstname, lastname, " .
242  " title, birthday, gender, institution, department, street, city, zipcode, country, sel_country, " .
243  " phone_office, phone_home, phone_mobile, fax, email, second_email, hobby, referral_comment, matriculation, " .
244  " latitude, longitude, loc_zoom" .
245  " FROM usr_data u " .
246  "WHERE " .
247  $ilDB->in("u.usr_id", $a_ids, false, "integer"));
248  break;
249  }
250  }
251 
252  if ($a_entity == "usr_setting") {
253  switch ($a_version) {
254  case "4.3.0":
255  case "4.5.0":
256  case "5.1.0":
257  case "5.2.0":
258  case "5.3.0":
259  // for all user ids get data from usr_pref and mail options, create records user_id/name/value
260  $prefs = array("date_format", "day_end", "day_start", "bs_allow_to_contact_me", "chat_osc_accept_msg", "hide_own_online_status", "hits_per_page", "language",
261  "public_birthday", "puplic_city", "public_country", "public_delicious", "public_department", "public_email", "public_second_email",
262  "public_fax", "public_gender", "public_hobby", "public_im_aim", "public_im_icq", "public_im_jabber",
263  "public_im_msn", "public_im_skype", "public_im_voip", "public_im_yahoo", "public_institution", "public_location",
264  "public_matriculation", "public_phone_home", "public_phone_mobile", "public_phone_office",
265  "public_profile", "public_sel_country", "public_street", "public_title", "public_upload", "public_zipcode",
266  "screen_reader_optimization", "show_users_online",
267  "store_last_visited", "time_format", "user_tz", "weekstart",
268  "session_reminder_enabled", "session_reminder_lead_time", "usr_starting_point",
269  "char_selector_availability", "char_selector_definition");
270 
271  if (version_compare($a_version, '5.2.0', '>=')) {
272  unset(
273  $prefs['public_im_aim'], $prefs['public_im_icq'], $prefs['public_im_jabber'],
274  $prefs['public_im_msn'], $prefs['public_im_skype'], $prefs['public_im_voip'],
275  $prefs['public_im_yahoo'], $prefs['public_delicious']
276  );
277  }
278 
279  $this->data = array();
280  $set = $ilDB->query("SELECT * FROM usr_pref " .
281  " WHERE " . $ilDB->in("keyword", $prefs, false, "text") .
282  " AND " . $ilDB->in("usr_id", $a_ids, false, "integer"));
283  while ($rec = $ilDB->fetchAssoc($set)) {
284  $this->data[] = array("UserId" => $rec["usr_id"], "Keyword" => $rec["keyword"], "Value" => $rec["value"]);
285  }
286  break;
287  }
288  }
289 
290  if ($a_entity == "usr_multi") {
291  switch ($a_version) {
292  case "4.5.0":
293  case "5.1.0":
294  case "5.2.0":
295  case "5.3.0":
296  $this->data = array();
297  $set = $ilDB->query("SELECT * FROM usr_data_multi" .
298  " WHERE " . $ilDB->in("usr_id", $a_ids, false, "integer"));
299  while ($rec = $ilDB->fetchAssoc($set)) {
300  $this->data[] = array("UserId" => $rec["usr_id"], "FieldId" => $rec["field_id"], "Value" => $rec["value"]);
301  }
302  break;
303  }
304  }
305  }
getDirectDataFromQuery($a_query, $a_convert_to_leading_upper=true, $a_set=true)
Get data from query.This is a standard procedure, all db field names are directly mapped to abstract ...
global $DIC
Definition: saml.php:7
if(!array_key_exists('StateId', $_REQUEST)) $id
$this data['403_header']
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: