ILIAS  release_8 Revision v8.24
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

 getSupportedVersions ()
 
 getXmlRecord (string $a_entity, string $a_version, array $a_set)
 Get xml record for version. More...
 
 afterXmlRecordWriting (string $a_entity, string $a_version, array $a_set)
 
 readData (string $a_entity, string $a_version, array $a_ids)
 Read data from DB. More...
 
 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...
 
- 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...
 
 setExportDirectories (string $a_relative, string $a_absolute)
 
 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 ...> ... </types> <set entity="table_name"> <rec> <field_1>content</field_1> <field_2>my_date</field_2> <field_3>my_number</field_3> </rec> ... </set> </dataset> 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...
 

Data Fields

array $multi = array()
 
- Data Fields inherited from ilDataSet
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)
 Get (abstract) types for (abstract) field names. More...
 
- 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)
 
 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()
 
array $users
 
- Protected Attributes inherited from ilDataSet
string $current_installation_id = ""
 
array $data = []
 
ilDBInterface $db
 
ilLogger $ds_log
 
string $import_directory = ""
 
string $entity = ""
 
string $schema_version = ""
 
string $relative_export_dir = ""
 
string $absolute_export_dir = ""
 
string $ds_prefix = "ds"
 
string $version = ""
 
ilSurveyImporter $import
 

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.

Member Function Documentation

◆ afterXmlRecordWriting()

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

Reimplemented from ilDataSet.

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

151 : void // Missing array type.
152 {
153 if ($a_entity == "usr_profile") {
154 // cleanup temp dirs for pictures
155 $tmp_dir = $this->temp_picture_dirs[$a_set["Id"]];
156 if ($tmp_dir != "" && is_dir($tmp_dir)) {
157 ilFileUtils::delDir($tmp_dir);
158 }
159 }
160 }
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively

References ilFileUtils\delDir().

+ Here is the call graph for this function:

◆ getSupportedVersions()

ilUserDataSet::getSupportedVersions ( )

Reimplemented from ilDataSet.

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

28 : array // Missing array type.
29 {
30 return array("4.3.0", "4.5.0", "5.1.0", "5.2.0", "5.3.0");
31 }

◆ getTypes()

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

Get (abstract) types for (abstract) field names.

Please note that the abstract fields/types only depend on the version! Not on a choosen representation!

Returns
array types array, e.g. array("field_1" => "text", "field_2" => "integer", ...)

Reimplemented from ilDataSet.

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

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

◆ getXmlNamespace()

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

Reimplemented from ilDataSet.

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

33 : string
34 {
35 return "https://www.ilias.de/xml/Services/User/" . $a_entity;
36 }

◆ getXmlRecord()

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

Get xml record for version.

Parameters
array$a_setabstract data record

Reimplemented from ilDataSet.

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

124 : array // Missing array type.
125 {
126 global $DIC;
127
128 if ($a_entity == "usr_profile") {
129 $tmp_dir = ilFileUtils::ilTempnam();
130 ilFileUtils::makeDir($tmp_dir);
131
133 $a_set["Id"],
134 "small",
135 true,
136 true
137 );
138
139 if ($im != "") {
140 ilObjUser::copyProfilePicturesToDirectory($a_set["Id"], $tmp_dir);
141 }
142
143 $this->temp_picture_dirs[$a_set["Id"]] = $tmp_dir;
144
145 $a_set["Picture"] = $tmp_dir;
146 }
147
148 return $a_set;
149 }
static makeDir(string $a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static ilTempnam(?string $a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
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 copyProfilePicturesToDirectory(int $a_user_id, string $a_dir)
global $DIC
Definition: feed.php:28

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

+ 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 
)

Needs to be overwritten for import use case.

Reimplemented from ilDataSet.

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

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

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

+ Here is the call graph for this function:

◆ readData()

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

Read data from DB.

This should result in the abstract field structure of the version set in the constructor.

Reimplemented from ilDataSet.

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

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

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

+ Here is the call graph for this function:

Field Documentation

◆ $multi

array ilUserDataSet::$multi = array()

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

◆ $temp_picture_dirs

array ilUserDataSet::$temp_picture_dirs = array()
protected

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

◆ $users

array ilUserDataSet::$users
protected

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


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