ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilUserDataSet Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

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

Public Member Functions

 __construct ()
 
 getSupportedVersions ()
 
 getXmlRecord (string $a_entity, string $a_version, array $a_set)
 
 afterXmlRecordWriting (string $a_entity, string $a_version, array $a_set)
 
 readData (string $a_entity, string $a_version, array $a_ids)
 
 importRecord (string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
 
- Public Member Functions inherited from ilDataSet
 __construct ()
 
 init (string $a_entity, string $a_schema_version)
 Init. More...
 
 getSupportedVersions ()
 
 readData (string $a_entity, string $a_version, array $a_ids)
 Read data from DB. More...
 
 initByExporter (ilXmlExporter $xml_exporter)
 
 setImportDirectory (string $a_val)
 
 getImportDirectory ()
 
 setDSPrefix (string $a_val)
 
 getDSPrefix ()
 
 getDSPrefixString ()
 
 getDirectDataFromQuery (string $a_query, bool $a_convert_to_leading_upper=true, bool $a_set=true)
 Get data from query.This is a standard procedure, all db field names are directly mapped to abstract fields. More...
 
 convertToLeadingUpper (string $a_str)
 Make xyz_abc a XyzAbc string. More...
 
 getXmlRepresentation (string $a_entity, string $a_schema_version, ?array $a_ids, string $a_field="", bool $a_omit_header=false, bool $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 (ilXmlWriter $a_writer, array $a_prefixes, string $a_entity, string $a_schema_version, array $a_ids, ?string $a_field="")
 
 afterXmlRecordWriting (string $a_entity, string $a_version, array $a_set)
 
 getNamespaces (array &$namespaces, string $a_entity, string $a_schema_version)
 
 getXmlRecord (string $a_entity, string $a_version, array $a_set)
 Get xml record for version. More...
 
 getXmlTypes (string $a_entity, string $a_version)
 Get xml types. More...
 
 getXMLEntityName (string $a_entity, string $a_version)
 Get entity name for xml (may be overwritten) More...
 
 getXMLEntityTag (string $a_entity, string $a_schema_version)
 Get entity tag. More...
 
 setImport (ilSurveyImporter $a_val)
 
 getImport ()
 
 setCurrentInstallationId (string $a_val)
 
 getCurrentInstallationId ()
 
 importRecord (string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
 Needs to be overwritten for import use case. More...
 
 getCollection (array $record, string $entity, string $schema_version, string $field, string $value)
 
 getContainerExportConfig (array $record, string $entity, string $schema_version, string $field, string $value)
 

Data Fields

array $multi = []
 
- Data Fields inherited from ilDataSet
const DATASET_NS = 'http://www.ilias.de/Services/DataSet/ds/4_3'
 
const DATASET_NS_PREFIX = 'ds'
 
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
 
int $dircnt = 0
 

Protected Member Functions

 getXmlNamespace (string $a_entity, string $a_schema_version)
 
 getTypes (string $a_entity, string $a_version)
 
- Protected Member Functions inherited from ilDataSet
 getTypes (string $a_entity, string $a_version)
 Get (abstract) types for (abstract) field names. More...
 
 getXmlNamespace (string $a_entity, string $a_schema_version)
 
 getExportDirInContainer (string $exp_dir)
 
 getIRSSContainerExportConfig (StorableResource $source_container, string $source_path, string $target_path="")
 
 getDependencies (string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
 
 createObjectExportId (string $a_type, string $a_id)
 Build ilias export id. More...
 
 parseObjectExportId (string $a_id, ?string $a_fallback_id=null)
 Parse export id. More...
 
 stripTags (array $rec, array $omit_keys=[])
 

Protected Attributes

array $temp_picture_dirs = []
 
array $users
 
- Protected Attributes inherited from ilDataSet
ILIAS ResourceStorage Services $irss
 
string $current_installation_id = ""
 
array $data = []
 
ilDBInterface $db
 
ilLogger $ds_log
 
string $import_directory = ""
 
string $entity = ""
 
string $schema_version = ""
 
string $component_export_dir = ""
 
string $ds_prefix = "ds"
 
string $version = ""
 
ilSurveyImporter $import
 
ilExport $export
 

Private Attributes

ilUserProfile $user_profile
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

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

Constructor & Destructor Documentation

◆ __construct()

ilUserDataSet::__construct ( )

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

References ILIAS\GlobalScreen\Provider\__construct().

30  {
32 
33  $this->user_profile = new ilUserProfile();
34  }
Class ilUserProfile.
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ afterXmlRecordWriting()

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

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

References ilFileUtils\delDir().

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

◆ getSupportedVersions()

ilUserDataSet::getSupportedVersions ( )

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

36  : array // Missing array type.
37  {
38  return ["4.3.0", "4.5.0", "5.1.0", "5.2.0", "5.3.0"];
39  }

◆ getTypes()

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

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

46  : array // Missing array type.
47  {
48  // user profile type
49  if ($a_entity == "usr_profile") {
50  switch ($a_version) {
51  case "4.3.0":
52  case "4.5.0":
53  case "5.1.0":
54  case "5.2.0":
55  case "5.3.0":
56  return [
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  "SecondEmail" => "text",
77  "Hobby" => "text",
78  "ReferralComment" => "text",
79  "Matriculation" => "text",
80  "Latitude" => "text",
81  "Longitude" => "text",
82  "LocZoom" => "text",
83  "Picture" => "directory"
84  ];
85  }
86  }
87 
88  if ($a_entity == "usr_setting") {
89  switch ($a_version) {
90  case "4.3.0":
91  case "4.5.0":
92  case "5.1.0":
93  case "5.2.0":
94  case "5.3.0":
95  return [
96  "UserId" => "integer",
97  "Keyword" => "text",
98  "Value" => "text"
99  ];
100  }
101  }
102 
103  if ($a_entity == "personal_data") {
104  switch ($a_version) {
105  case "4.3.0":
106  case "4.5.0":
107  case "5.1.0":
108  case "5.2.0":
109  case "5.3.0":
110  return [
111  "Id" => "integer"
112  ];
113  }
114  }
115 
116  if ($a_entity == "usr_multi") {
117  switch ($a_version) {
118  case "4.5.0":
119  case "5.1.0":
120  case "5.2.0":
121  case "5.3.0":
122  return [
123  "UserId" => "integer",
124  "FieldId" => "text",
125  "Value" => "text"
126  ];
127  }
128  }
129  return [];
130  }

◆ getXmlNamespace()

ilUserDataSet::getXmlNamespace ( string  $a_entity,
string  $a_schema_version 
)
protected

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

41  : string
42  {
43  return "https://www.ilias.de/xml/Services/User/" . $a_entity;
44  }

◆ getXmlRecord()

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

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

References $DIC, ilObjUser\_getPersonalPicturePath(), ilObjUser\copyProfilePicturesToDirectory(), ilFileUtils\ilTempnam(), and ilFileUtils\makeDir().

132  : array // Missing array type.
133  {
134  global $DIC;
135 
136  if ($a_entity == "usr_profile") {
137  $tmp_dir = ilFileUtils::ilTempnam();
138  ilFileUtils::makeDir($tmp_dir);
139 
141  $a_set["Id"],
142  "small",
143  true,
144  true
145  );
146 
147  if ($im != "") {
148  ilObjUser::copyProfilePicturesToDirectory($a_set["Id"], $tmp_dir);
149  }
150 
151  $this->temp_picture_dirs[$a_set["Id"]] = $tmp_dir;
152 
153  $a_set["Picture"] = $tmp_dir;
154  }
155 
156  return $a_set;
157  }
static copyProfilePicturesToDirectory(int $a_user_id, string $a_dir)
global $DIC
Definition: shib_login.php:22
static _getPersonalPicturePath(int $a_usr_id, string $a_size='small', bool $a_force_pic=false, bool $a_prevent_no_photo_image=false, bool $html_export=false)
static ilTempnam(?string $a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
static makeDir(string $a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
+ Here is the call graph for this function:

◆ importRecord()

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

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

References $DIC, Vendor\Package\$f, $ilSetting, ilObject\_lookupType(), ilObjUser\_uploadPersonalPicture(), ilImportMapping\addMapping(), ilDataSet\convertToLeadingUpper(), ilDataSet\getImportDirectory(), ilImportMapping\getMapping(), ILIAS\Repository\int(), null, and ilUtil\secureString().

291  : void {
292  global $DIC;
293 
294  $ilSetting = $DIC['ilSetting'];
295  $ilUser = $DIC['ilUser'];
296 
297  switch ($a_entity) {
298  case "personal_data":
299  // only users themselves import their profiles!
300  // thus we can map the import id of the dataset to the current user
301  $a_mapping->addMapping("components/ILIAS/User", "usr", $a_rec["Id"], $ilUser->getId());
302  break;
303 
304  case "usr_profile":
305  $usr_id = $a_mapping->getMapping("components/ILIAS/User", "usr", $a_rec["Id"]);
306  if ($usr_id > 0 && ilObject::_lookupType($usr_id) == "usr") {
307  if (!isset($this->users[$usr_id])) {
308  $this->users[$usr_id] = new ilObjUser($usr_id);
309  }
310  $user = $this->users[$usr_id];
311  $prof = new ilUserProfile();
312  $prof->skipField("username");
313  $prof->skipField("password");
314  $prof->skipField("roles");
315  $prof->skipGroup("settings");
316  $fields = $prof->getStandardFields();
317  foreach ($fields as $k => $f) {
318  $up_k = $this->convertToLeadingUpper($k);
319  // only change fields, when it is possible in profile
320  if ($this->user_profile->userSettingVisible($k) &&
321  !$ilSetting->get("usr_settings_disable_" . $k) &&
322  ($f["method"] ?? "") != "" && isset($a_rec[$up_k])) {
323  $set_method = "set" . substr($f["method"], 3);
324  $user->{$set_method}(ilUtil::secureString($a_rec[$up_k]));
325  }
326  }
327 
328  $user->setLatitude($a_rec["Latitude"] ?? null);
329  $user->setLongitude($a_rec["Longitude"] ?? null);
330  $zoom = isset($a_rec["LocZoom"]) ? (int) $a_rec["LocZoom"] : null;
331  $user->setLocationZoom($zoom);
332 
333  $user->update();
334 
335  // personal picture
336  $pic_dir = $this->getImportDirectory() . "/" . str_replace("..", "", $a_rec["Picture"]);
337  if ($pic_dir != "" && is_dir($pic_dir)) {
338  $upload_file = $pic_dir . "/usr_" . $a_rec["Id"] . ".jpg";
339  if (!is_file($upload_file)) {
340  $upload_file = $pic_dir . "/upload_" . $a_rec["Id"] . "pic";
341  }
342  if (is_file($upload_file)) {
343  ilObjUser::_uploadPersonalPicture($upload_file, $user->getId());
344  }
345  }
346  }
347  break;
348 
349  case "usr_setting":
350  $usr_id = $a_mapping->getMapping("components/ILIAS/User", "usr", $a_rec["UserId"]);
351  if ($usr_id > 0 && ilObject::_lookupType($usr_id) == "usr") {
352  if (!isset($this->users[$usr_id])) {
353  $this->users[$usr_id] = new ilObjUser($usr_id);
354  }
355  $user = $this->users[$usr_id];
356  $user->writePref($a_rec["Keyword"], ilUtil::secureString($a_rec["Value"]));
357  }
358  break;
359 
360  case "usr_multi":
361  $usr_id = $a_mapping->getMapping("components/ILIAS/User", "usr", $a_rec["UserId"]);
362  if ($usr_id > 0 && ilObject::_lookupType($usr_id) == "usr") {
363  $this->multi[$usr_id][$a_rec["FieldId"]][] = ilUtil::secureString($a_rec["Value"]);
364  }
365  break;
366  }
367  }
convertToLeadingUpper(string $a_str)
Make xyz_abc a XyzAbc string.
static secureString(string $a_str, bool $a_strip_html=true, string $a_allow="")
Class ilUserProfile.
addMapping(string $a_comp, string $a_entity, string $a_old_id, string $a_new_id)
static _uploadPersonalPicture(string $tmp_file, int $obj_id)
Create a personal picture image file from a temporary image file.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getMapping(string $a_comp, string $a_entity, string $a_old_id)
global $DIC
Definition: shib_login.php:22
global $ilSetting
Definition: privfeed.php:31
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

◆ readData()

ilUserDataSet::readData ( string  $a_entity,
string  $a_version,
array  $a_ids 
)

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

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

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

Field Documentation

◆ $multi

array ilUserDataSet::$multi = []

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

◆ $temp_picture_dirs

array ilUserDataSet::$temp_picture_dirs = []
protected

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

◆ $user_profile

ilUserProfile ilUserDataSet::$user_profile
private

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

◆ $users

array ilUserDataSet::$users
protected

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


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