19declare(strict_types=1);
23use ILIAS\User\BuildExportFieldArray;
41 use BuildExportFieldArray;
65 $this->
ilias = $DIC[
'ilias'];
66 $this->db =
$DIC[
'ilDB'];
67 $this->
lng = $DIC[
'lng'];
68 $this->user_id =
$DIC[
'ilUser']->getId();
70 $local_dic = LocalDIC::dic();
71 $this->user_profile = $local_dic[Profile::class];
72 $this->user_settings = LocalDIC::dic()[Settings::class];
73 $this->user_settings_data_repo = $local_dic[UserSettingsDataRepository::class];
76 $this->attach_roles =
false;
83 $this->attach_roles = $value;
94 if (!is_array($this->users)) {
100 foreach ($this->users as $user) {
117 $this->
xmlSetDtdDef(
'<!DOCTYPE Users PUBLIC "-//ILIAS//DTD UserImport//EN" "' . ILIAS_HTTP_PATH .
'/components/ILIAS/Export/xml/ilias_user_5_1.dtd">');
131 if ($this->fields_to_export === []) {
134 $this->getExportFieldArray(
144 $settings = $this->user_settings_data_repo->getFor($row[
'usr_id']);
146 if ($row[
'language'] ===
null
147 || $row[
'language'] ===
'') {
148 $row[
'language'] = $this->
lng->getDefaultLanguage();
152 'Id' =>
'il_' .
IL_INST_ID .
'_usr_' . $row[
'usr_id'],
153 'Language' => $row[
'language'],
159 $this->
xmlElement(
'Login',
null, $row[
'login']);
161 if ($this->attach_roles ==
true) {
163 'SELECT object_data.title, object_data.description, rbac_fa.* ' .
164 'FROM object_data, rbac_ua, rbac_fa WHERE rbac_ua.usr_id = %s ' .
165 'AND rbac_ua.rol_id = rbac_fa.rol_id AND object_data.obj_id = rbac_fa.rol_id',
166 $this->db->quote($row[
'usr_id'],
'integer')
168 $rbacresult = $this->db->query($query);
171 if ($rbacrow[
'assign'] !=
'y') {
185 [
'Id' =>
'il_' .
IL_INST_ID .
'_role_' . $rbacrow[
'rol_id'],
'Type' => $type],
196 if ($this->
canExport(
'PersonalPicture',
'upload')) {
199 $value = array_shift($imageData);
200 $this->
__addElement(
'PersonalPicture', $value, $imageData,
'upload');
207 $this->
__addElement(
'SecondEmail', $row[
'second_email'],
null,
'second_email');
209 $this->
__addElement(
'Institution', $row[
'institution']);
212 $this->
__addElement(
'PostalCode', $row[
'zipcode'],
null,
'zipcode');
214 $this->
__addElement(
'PhoneOffice', $row[
'phone_office'],
null,
'phone_office');
215 $this->
__addElement(
'PhoneHome', $row[
'phone_home'],
null,
'phone_home');
216 $this->
__addElement(
'PhoneMobile', $row[
'phone_mobile'],
null,
'phone_mobile');
220 $this->
__addElementMulti(
'GeneralInterest', $row[
'interests_general'] ?? [],
null,
'interests_general');
221 $this->
__addElementMulti(
'OfferingHelp', $row[
'interests_help_offered'] ?? [],
null,
'interests_help_offered');
222 $this->
__addElementMulti(
'LookingForHelp', $row[
'interests_help_looking'] ?? [],
null,
'interests_help_looking');
225 $this->
__addElement(
'Comment', $row[
'referral_comment'],
null,
'referral_comment');
226 $this->
__addElement(
'Matriculation', $row[
'matriculation']);
227 $this->
__addElement(
'Active', $row[
'active'] ?
'true' :
'false');
228 $this->
__addElement(
'ClientIP', $row[
'client_ip'],
null,
'client_ip');
229 $this->
__addElement(
'TimeLimitOwner', (
string) $row[
'time_limit_owner'],
null,
'time_limit_owner');
230 $this->
__addElement(
'TimeLimitUnlimited', (
string) $row[
'time_limit_unlimited'],
null,
'time_limit_unlimited');
232 if ($row[
'time_limit_from'] !==
null) {
233 $this->
__addElement(
'TimeLimitFrom', (
string) $row[
'time_limit_from'],
null,
'time_limit_from');
236 if ($row[
'time_limit_from'] !==
null) {
237 $this->
__addElement(
'TimeLimitUntil', (
string) $row[
'time_limit_until'],
null,
'time_limit_until');
240 $this->
__addElement(
'ApproveDate', $row[
'approve_date'],
null,
'approve_date');
241 $this->
__addElement(
'AgreeDate', $row[
'agree_date'],
null,
'agree_date');
243 if ($row[
'auth_mode'] !==
null
244 && $row[
'auth_mode'] !==
'') {
245 $this->
__addElement(
'AuthMode',
null, [
'type' => $row[
'auth_mode']],
'auth_mode',
true);
248 if ($row[
'ext_account'] !==
null
249 && $row[
'ext_account'] !==
'') {
250 $this->
__addElement(
'ExternalAccount', $row[
'ext_account'],
null,
'ext_account',
true);
253 if (isset($settings[
'skin'])
254 && isset($settings[
'style'])
255 && $this->
canExport(
'Look',
'skin_style')) {
260 'Skin' => $settings[
'skin'],
'Style' => $settings[
'style']
268 $this->
__addElement(
'LastUpdate', $row[
'last_update'],
null,
'last_update');
269 $this->
__addElement(
'LastLogin', $row[
'last_login'],
null,
'last_login');
273 $this->
__addElement(
'AccountInfo', $row[
'ext_account'], [
'Type' =>
'external']);
276 'longitude' => $row[
'longitude'],
277 'latitude' => $row[
'latitude'],
278 'zoom' => $row[
'loc_zoom']]);
282 if ($this->attach_preferences || $this->
canExport(
'prefs',
'preferences')) {
294 $prefs[
'mail_incoming_type'] = $mailOptions->getIncomingType();
295 $prefs[
'mail_address_option'] = $mailOptions->getEmailAddressMode();
296 $prefs[
'mail_signature'] = $mailOptions->getSignature();
299 foreach ($prefs as $key => $value) {
300 if (self::isPrefExportable($key)) {
301 $this->
xmlElement(
'Pref', [
'key' => $key], $value);
311 ?array $attrs =
null,
312 ?
string $settingsname =
null,
313 bool $requiredTag =
false
315 foreach ($value as $item) {
316 $this->
__addElement($tagname, $item, $attrs, $settingsname, $requiredTag);
323 ?array $attrs =
null,
324 ?
string $settingsname =
null,
325 bool $requiredTag =
false
327 if ($this->canExport($tagname, $settingsname)
330 || is_array($attrs) && count($attrs) > 0)) {
331 $this->xmlElement($tagname, $attrs, (
string) $value);
337 ?
string $settingsname =
null
339 return $this->fields_to_export === []
340 || in_array(strtolower($tagname), $this->fields_to_export) !== false
341 || in_array($settingsname, $this->fields_to_export) !== false;
346 $this->fields_to_export = $fields_to_export;
354 $this->attach_preferences = $attach_preferences;
364 $avatar_resolver->setForcePicture(
true);
365 if (!$avatar_resolver->hasProfilePicture()) {
369 [$image_data, $image_type] = $avatar_resolver->getUserPictureForVCard();
371 if ($image_data ===
null || $image_type ===
null) {
376 'value' => base64_encode($image_data),
377 'encoding' =>
'Base64',
378 'imagetype' => $image_type
388 foreach ($this->user_profile->getVisibleFields(Context::Export) as $field) {
389 if (!$field->isCustom()) {
395 'Id' => $field->getIdentifier(),
396 'Name' => $field->getLabel($this->lng)
398 json_encode($row[$field->getIdentifier()])
413 'public_second_email',
416 'public_institution',
417 'public_matriculation',
420 'public_phone_mobile',
421 'public_phone_office',
428 'hide_own_online_status',
429 'bs_allow_to_contact_me',
430 'chat_osc_accept_msg',
431 'chat_broadcast_typing',
434 'mail_incoming_type',
437 'public_interests_general',
438 'public_interests_help_offered',
439 'public_interests_help_looking'
448 return in_array($key, self::getExportablePreferences());
Class ilUserAvatarResolver.
XML writer class Class to simplify manual writing of xml documents.
setAttachPreferences(bool $attach_preferences)
if set to true, all preferences of a user will be set
getPictureValue(int $usr_id)
return array with base-encoded picture data as key value, encoding type as encoding,...
static isPrefExportable(string $key)
returns wether a key from db is exportable or not
array $fields_to_export
fields to be exported
canExport(string $tagname, ?string $settingsname=null)
readonly ilDBInterface $db
readonly SettingsImplementation $user_settings
__handlePreferences(array $prefs, array $row)
static getExportablePreferences()
return exportable preference keys as found in db
addUDFsToXML(array $row)
add user defined field data to xml (using usr dtd)
readonly Profile $user_profile
readonly UserSettingsDataRepository $user_settings_data_repo
setFieldsToExport(array $fields_to_export)
__addElementMulti(string $tagname, array $value, ?array $attrs=null, ?string $settingsname=null, bool $requiredTag=false)
setAttachRoles(bool $value)
__addElement(string $tagname, ?string $value, ?array $attrs=null, ?string $settingsname=null, bool $requiredTag=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
xmlSetGenCmt(string $genCmt)
Sets generated comment.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
__construct(string $version="1.0", string $outEnc="utf-8", string $inEnc="utf-8")
xmlHeader()
Writes xml header.
xmlEndTag(string $tag)
Writes an endtag.
xmlSetDtdDef(string $dtdDef)
Sets dtd definition.
xmlDumpMem(bool $format=true)
Returns xml document from memory.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
Class ilObjForumAdministration.
if(!file_exists('../ilias.ini.php'))