19 declare(strict_types=1);
35 bool $a_call_by_reference =
true 42 public function delete():
bool 48 string $a_mode = self::FILE_TYPE_EXCEL
56 case self::FILE_TYPE_EXCEL:
57 $filename = $date .
"__" . $inst_id .
"__xls_usrf";
59 case self::FILE_TYPE_CSV:
60 $filename = $date .
"__" . $inst_id .
"__csv_usrf.csv";
62 case self::FILE_TYPE_XML:
63 $filename = $date .
"__" . $inst_id .
"__xml_usrf.xml";
97 while ($entry = $dir->read()) {
100 preg_match(
"/^[0-9]{10}_{2}[0-9]+_{2}([a-z0-9]{3})_usrf\.[a-z]{1,4}\$/", $entry, $matches)) {
101 $filearray[
"filename"] = $entry;
103 $file[] = $filearray;
118 return str_replace([
'&',
'<',
'>'], [
'&',
'<',
'>'], $value);
127 $xml_writer->setObjects($data);
128 $xml_writer->setSettings($settings);
129 $xml_writer->setAttachRoles(
true);
131 if ($xml_writer->start()) {
132 fwrite(fopen($filename,
'wb'), $xml_writer->getXML());
140 if ($definition[
'export'] !=
false) {
141 $udf_ex_fields[] = [
'name' => $definition[
'field_name'],
142 'id' => $definition[
'field_id']];
146 return $udf_ex_fields;
156 foreach ($settings as $value) {
157 $headerrow[] = $this->
lng->txt($value);
159 foreach ($udf_ex_fields as
$f) {
160 $headerrow[] = $f[
"name"];
164 $file = fopen($filename,
'wb');
166 foreach ($data as $row) {
168 foreach ($settings as $header) {
170 if (isset($row[$header]) && is_array($row[$header])) {
171 $row[$header] = implode(
", ", $row[$header]);
174 $csvrow[] = $row[$header] ??
'';
178 reset($udf_ex_fields);
179 if (count($udf_ex_fields) > 0) {
181 foreach ($udf_ex_fields as $f) {
182 $csvrow[] = $udf->get(
"f_" . $f[
"id"]);
197 $worksheet->addSheet($this->
lng->txt(
"users"));
205 foreach ($settings as $value) {
206 if ($value ==
'ext_account') {
207 $value =
'user_ext_account';
209 $worksheet->setCell($row, $col, $this->
lng->txt($value));
212 foreach ($udf_ex_fields as
$f) {
213 $worksheet->setCell($row, $col, $f[
"name"]);
216 $worksheet->setBold(
"A1:" . $worksheet->getColumnCoord($col - 1) .
"1");
218 $this->
lng->loadLanguageModule(
"meta");
219 foreach ($data as $index => $rowdata) {
224 foreach ($settings as $fieldname) {
225 $value = $rowdata[$fieldname] ??
"";
226 switch ($fieldname) {
228 $worksheet->setCell($row, $col, $this->
lng->txt(
"meta_l_" . $value));
230 case "time_limit_from":
231 case "time_limit_until":
235 $worksheet->setCell($row, $col, $value);
245 $worksheet->setCell($row, $col, $value);
248 case "interests_general":
249 case "interests_help_offered":
250 case "interests_help_looking":
251 if (is_array($value) && count($value)) {
252 $value = implode(
", ", $value);
260 $worksheet->setCell($row, $col, $value);
267 reset($udf_ex_fields);
268 if (count($udf_ex_fields) > 0) {
270 foreach ($udf_ex_fields as $f) {
271 $worksheet->setCell($row, $col, $udf->get(
"f_" . $f[
"id"]));
277 $worksheet->writeToFile($filename);
287 $ilDB = $DIC[
'ilDB'];
292 $up->skipField(
"roles");
293 $profile_fields = $up->getStandardFields();
295 $query =
"SELECT * FROM settings WHERE " .
296 $ilDB->like(
"keyword",
"text",
'%usr_settings_export_%');
297 $result =
$ilDB->query($query);
299 if ($row[
"value"] ==
"1") {
300 if (preg_match(
"/usr_settings_export_(.*)/", $row[
"keyword"], $setting)) {
301 $db_settings[] = $setting[1];
305 $export_settings = [];
306 foreach ($profile_fields as $key => $value) {
307 if (in_array($key, $db_settings)) {
308 if (strcmp($key,
"password") == 0) {
312 $export_settings[] = $key;
316 $export_settings[] =
"usr_id";
317 $export_settings[] =
"login";
318 $export_settings[] =
"last_login";
319 $export_settings[] =
"last_update";
320 $export_settings[] =
"create_date";
321 $export_settings[] =
"time_limit_owner";
322 $export_settings[] =
"time_limit_unlimited";
323 $export_settings[] =
"time_limit_from";
324 $export_settings[] =
"time_limit_until";
325 $export_settings[] =
"time_limit_message";
326 $export_settings[] =
"active";
327 $export_settings[] =
"approve_date";
328 $export_settings[] =
"agree_date";
329 $export_settings[] =
"client_ip";
330 $export_settings[] =
"auth_mode";
331 $export_settings[] =
"ext_account";
332 $export_settings[] =
"feedhash";
333 return $export_settings;
340 string $a_mode = self::FILE_TYPE_EXCEL,
341 ?array $user_data_filter =
null,
342 bool $use_temp_dir =
false 346 $ilDB = $DIC[
'ilDB'];
361 $settings = self::getExportSettings();
364 $query =
"SELECT * FROM usr_pref WHERE keyword = " .
$ilDB->quote(
'language',
'text');
368 $languages[$row[
'usr_id']] = $row[
'value'];
373 $set =
$ilDB->query(
"SELECT * FROM usr_data_multi");
374 while ($row =
$ilDB->fetchAssoc($set)) {
375 if (!is_array($user_data_filter) ||
376 in_array($row[
"usr_id"], $user_data_filter)) {
377 $multi[$row[
"usr_id"]][$row[
"field_id"]][] = $row[
"value"];
382 $query =
"SELECT usr_data.* FROM usr_data " .
383 " ORDER BY usr_data.lastname, usr_data.firstname";
384 $result =
$ilDB->query($query);
385 while ($row =
$ilDB->fetchAssoc($result)) {
386 if (isset($languages[$row[
'usr_id']])) {
387 $row[
'language'] = $languages[$row[
'usr_id']];
392 if (isset($multi[$row[
"usr_id"]])) {
393 $row = array_merge($row, $multi[$row[
"usr_id"]]);
396 if (is_array($user_data_filter)) {
397 if (in_array($row[
"usr_id"], $user_data_filter)) {
407 case self::FILE_TYPE_EXCEL:
410 case self::FILE_TYPE_CSV:
413 case self::FILE_TYPE_XML:
423 foreach ($row as $rowindex => $entry) {
424 $resultarray[$rowindex] = iconv(
427 '"' . str_replace(chr(13) . chr(10), chr(10), $entry) .
'"' 430 return implode(
';', $resultarray);
442 if (!is_writable($usrf_data_dir)) {
443 $this->
ilias->raiseError(
"Userfolder data directory (" . $usrf_data_dir
444 .
") not writeable.", $this->
ilias->error_obj->MESSAGE);
448 $export_dir = $usrf_data_dir .
"/export";
450 if (!is_dir($export_dir)) {
451 $this->
ilias->raiseError(
"Creation of Userfolder Export Directory failed.", $this->
ilias->error_obj->MESSAGE);
464 $up->skipField(
"username");
465 $up->skipField(
"roles");
466 $up->skipGroup(
"preferences");
467 $fds = $up->getStandardFields();
468 $profile_fields = [];
469 foreach ($fds as $k =>
$f) {
470 $profile_fields[] = $k;
473 return $profile_fields;
486 $ilDB = $DIC[
'ilDB'];
488 if (self::_lookupNewAccountMail($a_lang)) {
490 'subject' => [
'text',$a_subject],
491 'body' => [
'clob',$a_body],
492 'sal_g' => [
'text',$a_sal_g],
493 'sal_f' => [
'text',$a_sal_f],
494 'sal_m' => [
'text',$a_sal_m]
499 [
'lang' => [
'text',$a_lang],
'type' => [
'text',
'nacc']]
503 'subject' => [
'text',$a_subject],
504 'body' => [
'clob',$a_body],
505 'sal_g' => [
'text',$a_sal_g],
506 'sal_f' => [
'text',$a_sal_f],
507 'sal_m' => [
'text',$a_sal_m],
508 'lang' => [
'text',$a_lang],
509 'type' => [
'text',
'nacc']
511 $ilDB->insert(
'mail_template', $values);
526 $ilDB = $DIC[
'ilDB'];
530 $path = $fs->getAbsolutePath() .
"/";
536 [
'att_file' => [
'text', $a_name]],
537 [
'lang' => [
'text',$a_lang],
'type' => [
'text',
'nacc']]
549 $ilDB = $DIC[
'ilDB'];
552 $path = $fs->getAbsolutePath() .
"/";
554 if (file_exists(
$path . $a_lang)) {
555 unlink(
$path . $a_lang);
560 [
'att_file' => [
'text',
'']],
561 [
'lang' => [
'text',$a_lang],
'type' => [
'text',
'nacc']]
573 $ilDB = $DIC[
'ilDB'];
575 $set =
$ilDB->query(
"SELECT * FROM mail_template " .
576 " WHERE type='nacc' AND lang = " .
$ilDB->quote($a_lang,
'text'));
596 $ilDB = $DIC[
'ilDB'];
598 $query =
"UPDATE usr_data SET time_limit_owner = " .
$ilDB->quote($a_new_id,
"integer") .
" " .
599 "WHERE time_limit_owner = " .
$ilDB->quote($a_old_id,
"integer") .
" ";
600 $ilDB->manipulate($query);
createXMLExport(array $settings, array $data, string $filename)
static _writeNewAccountMail(string $a_lang, string $a_subject, string $a_sal_g, string $a_sal_f, string $a_sal_m, string $a_body)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _updateUserFolderAssignment(int $a_old_id, int $a_new_id)
Update user folder assignment Typically called after deleting a category with local user accounts...
getDefaultLanguage()
Return default language.
getExportFiles()
Get a list of the already exported files in the export directory.
static getProfileFields()
Get profile fields.
static _updateAccountMailAttachment(string $a_lang, string $a_tmp_name, string $a_name)
Update account mail attachment.
processCSVRow(array $row)
createExportDirectory()
creates data directory for export files
createExcelExport(array $settings, array $data, string $filename)
sort()
description: > Example for rendering a Sort Glyph.
static getExportSettings()
createCSVExport(array $settings, array $data, string $filename)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
const ORG_OP_EDIT_USER_ACCOUNTS
getExportFilename(string $a_mode=self::FILE_TYPE_EXCEL)
buildExportFile(string $a_mode=self::FILE_TYPE_EXCEL, ?array $user_data_filter=null, bool $use_temp_dir=false)
build xml export file
static _lookupNewAccountMail(string $a_lang)
XML writer class Class to simplify manual writing of xml documents.
Class ilObjForumAdministration.
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
static _deleteAccountMailAttachment(string $a_lang)
Delete account mail attachment.
static getDataDir()
get data directory (outside webspace)
static ilTempnam(?string $a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
__construct(Container $dic, ilPlugin $plugin)
getUserDefinedExportFields()
__construct(int $a_id, bool $a_call_by_reference=true)
static makeDir(string $a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...