19declare(strict_types=1);
43 $this->current_user =
$DIC[
'ilUser'];
47 $this->user_profile = LocalDIC::dic()[Profile::class];
52 parent::initByExporter($xml_exporter);
54 $config = $this->export->getExportConfigs()->getElementByClassName(
'ilUserExportConfig');
55 $this->export_config = $config;
60 return [
"4.3.0",
"4.5.0",
"5.1.0",
"5.2.0",
"5.3.0"];
63 protected function getXmlNamespace(
string $a_entity,
string $a_schema_version): string
65 return "https://www.ilias.de/xml/Services/User/" . $a_entity;
68 protected function getTypes(
string $a_entity,
string $a_version): array
71 if ($a_entity ==
"usr_profile") {
81 "Firstname" =>
"text",
86 "Institution" =>
"text",
87 "Department" =>
"text",
92 "PhoneOffice" =>
"text",
93 "PhoneHome" =>
"text",
94 "PhoneMobile" =>
"text",
97 "SecondEmail" =>
"text",
99 "ReferralComment" =>
"text",
100 "Matriculation" =>
"text",
101 "Latitude" =>
"text",
102 "Longitude" =>
"text",
104 "Picture" =>
"directory"
109 if ($a_entity ==
"usr_setting") {
110 switch ($a_version) {
117 "UserId" =>
"integer",
124 if ($this->export_config->getExportType() ==
"personal_data") {
125 switch ($a_version) {
137 if ($a_entity ==
"usr_multi") {
138 switch ($a_version) {
144 "UserId" =>
"integer",
153 public function getXmlRecord(
string $a_entity,
string $a_version, array $a_set): array
155 if ($a_entity ==
"usr_profile") {
170 $this->temp_picture_dirs[$a_set[
"Id"]] = $tmp_dir;
172 $a_set[
"Picture"] = $tmp_dir;
180 if ($a_entity ==
"usr_profile") {
182 $tmp_dir = $this->temp_picture_dirs[$a_set[
"Id"]];
183 if ($tmp_dir !=
"" && is_dir($tmp_dir)) {
189 public function readData(
string $a_entity,
string $a_version, array $a_ids): void
191 if (!is_array($a_ids)) {
195 if ($this->export_config->getExportType() ==
"personal_data") {
196 switch ($a_version) {
203 foreach ($a_ids as
$id) {
204 $this->data[] = [
"Id" =>
$id];
210 if ($a_entity ==
"usr_profile") {
211 switch ($a_version) {
216 " title, birthday, gender, institution, department, street, city, zipcode, country, " .
217 " phone_office, phone_home, phone_mobile, fax, email, hobby, referral_comment, matriculation, " .
218 " delicious, latitude, longitude, loc_zoom" .
219 " FROM usr_data u " .
221 $this->db->in(
"u.usr_id", $a_ids,
false,
"integer"));
226 " title, birthday, gender, institution, department, street, city, zipcode, country, " .
227 " phone_office, phone_home, phone_mobile, fax, email, hobby, referral_comment, matriculation, " .
228 " latitude, longitude, loc_zoom" .
229 " FROM usr_data u " .
231 $this->db->in(
"u.usr_id", $a_ids,
false,
"integer"));
235 " title, birthday, gender, institution, department, street, city, zipcode, country, " .
236 " phone_office, phone_home, phone_mobile, fax, email, second_email, hobby, referral_comment, matriculation, " .
237 " latitude, longitude, loc_zoom" .
238 " FROM usr_data u " .
240 $this->db->in(
"u.usr_id", $a_ids,
false,
"integer"));
245 if ($a_entity ==
"usr_setting") {
246 switch ($a_version) {
253 $prefs = [
"date_format",
"day_end",
"day_start",
"bs_allow_to_contact_me",
"chat_osc_accept_msg",
"hide_own_online_status",
"language",
254 "public_birthday",
"puplic_city",
"public_country",
"public_delicious",
"public_department",
"public_email",
"public_second_email",
255 "public_fax",
"public_gender",
"public_hobby",
"public_im_aim",
"public_im_icq",
"public_im_jabber",
256 "public_im_msn",
"public_im_skype",
"public_im_voip",
"public_im_yahoo",
"public_institution",
"public_location",
257 "public_matriculation",
"public_phone_home",
"public_phone_mobile",
"public_phone_office",
258 "public_profile",
"public_sel_country",
"public_street",
"public_title",
"public_upload",
"public_zipcode",
259 "screen_reader_optimization",
"show_users_online",
260 "store_last_visited",
"time_format",
"user_tz",
"weekstart",
261 "session_reminder_lead_time",
"usr_starting_point",
262 "chat_broadcast_typing"];
264 if (version_compare($a_version,
'5.2.0',
'>=')) {
266 $prefs[
'public_im_aim'], $prefs[
'public_im_icq'], $prefs[
'public_im_jabber'],
267 $prefs[
'public_im_msn'], $prefs[
'public_im_skype'], $prefs[
'public_im_voip'],
268 $prefs[
'public_im_yahoo'], $prefs[
'public_delicious']
273 $set = $this->db->query(
"SELECT * FROM usr_pref " .
274 " WHERE " . $this->db->in(
"keyword", $prefs,
false,
"text") .
275 " AND " . $this->db->in(
"usr_id", $a_ids,
false,
"integer"));
276 while ($rec = $this->db->fetchAssoc($set)) {
277 $this->data[] = [
"UserId" => $rec[
"usr_id"],
"Keyword" => $rec[
"keyword"],
"Value" => $rec[
"value"]];
283 if ($a_entity ==
"usr_multi") {
284 switch ($a_version) {
290 $set = $this->db->query(
"SELECT * FROM usr_profile_data" .
291 " WHERE " . $this->db->in(
"usr_id", $a_ids,
false,
"integer"));
292 while ($rec = $this->db->fetchAssoc($set)) {
293 $this->data[] = [
"UserId" => $rec[
"usr_id"],
"FieldId" => $rec[
"field_id"],
"Value" => $rec[
"value"]];
305 string $a_schema_version
311 $a_mapping->
addMapping(
'components/ILIAS/User',
'usr', $a_rec[
'Id'], $this->current_user->getId());
315 $usr_id = $a_mapping->
getMapping(
"components/ILIAS/User",
"usr", $a_rec[
"Id"]);
317 if (!isset($this->users[$usr_id])) {
318 $this->users[$usr_id] =
new ilObjUser($usr_id);
320 $user = array_reduce(
321 $fields = $this->user_profile->getFields([], [Alias::class, Roles::class]),
324 if (!$this->user_profile->userFieldVisibleToUser($k)
325 || !isset($a_rec[$up_k])) {
330 $this->users[$usr_id]
333 $user->setLatitude($a_rec[
"Latitude"] ??
null);
334 $user->setLongitude($a_rec[
"Longitude"] ??
null);
335 $zoom = isset($a_rec[
"LocZoom"]) ? (
int) $a_rec[
"LocZoom"] :
null;
336 $user->setLocationZoom($zoom);
341 $pic_dir = $this->
getImportDirectory() .
"/" . str_replace(
"..",
"", $a_rec[
"Picture"]);
342 if ($pic_dir !=
"" && is_dir($pic_dir)) {
343 $upload_file = $pic_dir .
"/usr_" . $a_rec[
"Id"] .
".jpg";
344 if (!is_file($upload_file)) {
345 $upload_file = $pic_dir .
"/upload_" . $a_rec[
"Id"] .
"pic";
347 if (is_file($upload_file)) {
348 $user->uploadPersonalPicture($upload_file);
355 $usr_id = $a_mapping->
getMapping(
"components/ILIAS/User",
"usr", $a_rec[
"UserId"]);
357 if (!isset($this->users[$usr_id])) {
358 $this->users[$usr_id] =
new ilObjUser($usr_id);
360 $user = $this->users[$usr_id];
366 $usr_id = $a_mapping->
getMapping(
"components/ILIAS/User",
"usr", $a_rec[
"UserId"]);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
A dataset contains in data in a common structure that can be shared and transformed for different pur...
convertToLeadingUpper(string $a_str)
Make xyz_abc a XyzAbc string.
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 ...
initByExporter(ilXmlExporter $xml_exporter)
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 delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
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)
static _getPersonalPicturePath(int $a_usr_id, string $a_size='small', bool $a_force_pic=false)
static copyProfilePicturesToDirectory(int $a_user_id, string $a_dir)
static _lookupType(int $id, bool $reference=false)
ilUserExportConfig $export_config
getXmlNamespace(string $a_entity, string $a_schema_version)
afterXmlRecordWriting(string $a_entity, string $a_version, array $a_set)
getXmlRecord(string $a_entity, string $a_version, array $a_set)
Get xml record for version.
getTypes(string $a_entity, string $a_version)
Get (abstract) types for (abstract) field names.
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.
readData(string $a_entity, string $a_version, array $a_ids)
Read data from DB.
static secureString(string $a_str, bool $a_strip_html=true, string $a_allow="")
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc