33 bool $a_call_by_reference =
true
40 public function delete():
bool
46 string $a_mode = self::FILE_TYPE_EXCEL
55 $filename = $date .
"__" . $inst_id .
"__xls_usrf";
58 $filename = $date .
"__" . $inst_id .
"__csv_usrf.csv";
61 $filename = $date .
"__" . $inst_id .
"__xml_usrf.xml";
80 $dir = $this->getExportDirectory();
95 while ($entry = $dir->read()) {
98 preg_match(
"/^[0-9]{10}_{2}[0-9]+_{2}([a-z0-9]{3})_usrf\.[a-z]{1,4}\$/", $entry, $matches)) {
99 $filearray[
"filename"] = $entry;
100 $filearray[
"filesize"] = filesize($this->getExportDirectory() .
"/" . $entry);
101 $file[] = $filearray;
116 $value = str_replace([
"&",
"<",
">"], [
"&",
"<",
">"], $value);
127 $rbacreview =
$DIC[
'rbacreview'];
133 if (is_array(
$data)) {
135 $xmlWriter->setObjects(
$data);
137 $xmlWriter->setAttachRoles(
true);
139 if ($xmlWriter->start()) {
140 fwrite($file, $xmlWriter->getXML());
153 $udf_ex_fields = array();
154 foreach ($udf_obj->getDefinitions() as $definition) {
155 if ($definition[
"export"] !=
false) {
156 $udf_ex_fields[] = array(
"name" => $definition[
"field_name"],
157 "id" => $definition[
"field_id"]);
161 return $udf_ex_fields;
171 $headerrow = array();
172 $udf_ex_fields = $this->getUserDefinedExportFields();
174 $headerrow[] = $this->
lng->txt($value);
176 foreach ($udf_ex_fields as
$f) {
177 $headerrow[] =
$f[
"name"];
183 fwrite($file, implode($separator, $formattedrow) .
"\n");
184 foreach (
$data as $row) {
188 if (isset($row[$header]) && is_array($row[$header])) {
189 $row[$header] = implode(
", ", $row[$header]);
192 $csvrow[] = $row[$header] ??
'';
196 reset($udf_ex_fields);
197 if (count($udf_ex_fields) > 0) {
199 foreach ($udf_ex_fields as
$f) {
200 $csvrow[] = $udf->get(
"f_" .
$f[
"id"]);
205 fwrite($file, implode($separator, $formattedrow) .
"\n");
221 $udf_ex_fields = $this->getUserDefinedExportFields();
225 if ($value ==
'ext_account') {
226 $value =
'user_ext_account';
228 $worksheet->setCell($row, $col, $this->
lng->txt($value));
231 foreach ($udf_ex_fields as
$f) {
232 $worksheet->setCell($row, $col,
$f[
"name"]);
235 $worksheet->setBold(
"A1:" . $worksheet->getColumnCoord($col - 1) .
"1");
237 $this->
lng->loadLanguageModule(
"meta");
238 foreach ($data as
$index => $rowdata) {
244 $value = $rowdata[$fieldname] ??
"";
245 switch ($fieldname) {
247 $worksheet->setCell($row, $col, $this->
lng->txt(
"meta_l_" . $value));
249 case "time_limit_from":
250 case "time_limit_until":
254 $worksheet->setCell($row, $col, $value);
264 $worksheet->setCell($row, $col, $value);
267 case "interests_general":
268 case "interests_help_offered":
269 case "interests_help_looking":
270 if (is_array($value) && count($value)) {
271 $value = implode(
", ", $value);
279 $worksheet->setCell($row, $col, $value);
286 reset($udf_ex_fields);
287 if (count($udf_ex_fields) > 0) {
289 foreach ($udf_ex_fields as
$f) {
290 $worksheet->setCell($row, $col, $udf->get(
"f_" .
$f[
"id"]));
308 $db_settings = array();
311 $up->skipField(
"roles");
312 $profile_fields = $up->getStandardFields();
314 $query =
"SELECT * FROM settings WHERE " .
315 $ilDB->like(
"keyword",
"text",
'%usr_settings_export_%');
318 if ($row[
"value"] ==
"1") {
319 if (preg_match(
"/usr_settings_export_(.*)/", $row[
"keyword"], $setting)) {
320 $db_settings[] = $setting[1];
324 $export_settings = array();
325 foreach ($profile_fields as
$key => $value) {
326 if (in_array(
$key, $db_settings)) {
327 if (strcmp(
$key,
"password") == 0) {
331 $export_settings[] =
$key;
335 $export_settings[] =
"usr_id";
336 $export_settings[] =
"login";
337 $export_settings[] =
"last_login";
338 $export_settings[] =
"last_update";
339 $export_settings[] =
"create_date";
340 $export_settings[] =
"time_limit_owner";
341 $export_settings[] =
"time_limit_unlimited";
342 $export_settings[] =
"time_limit_from";
343 $export_settings[] =
"time_limit_until";
344 $export_settings[] =
"time_limit_message";
345 $export_settings[] =
"active";
346 $export_settings[] =
"approve_date";
347 $export_settings[] =
"agree_date";
348 $export_settings[] =
"client_ip";
349 $export_settings[] =
"auth_mode";
350 $export_settings[] =
"ext_account";
351 $export_settings[] =
"feedhash";
352 return $export_settings;
359 string $a_mode = self::FILE_TYPE_EXCEL,
360 ?array $user_data_filter =
null,
361 bool $use_temp_dir =
false
372 $expDir = $this->getExportDirectory();
374 $this->createExportDirectory();
375 $fullname = $expDir .
"/" . $this->getExportFilename($a_mode);
383 $query =
"SELECT * FROM usr_pref WHERE keyword = " .
$ilDB->quote(
'language',
'text');
385 $languages = array();
387 $languages[$row[
'usr_id']] = $row[
'value'];
392 $set =
$ilDB->query(
"SELECT * FROM usr_data_multi");
393 while ($row =
$ilDB->fetchAssoc($set)) {
394 if (!is_array($user_data_filter) ||
395 in_array($row[
"usr_id"], $user_data_filter)) {
396 $multi[$row[
"usr_id"]][$row[
"field_id"]][] = $row[
"value"];
401 $query =
"SELECT usr_data.* FROM usr_data " .
402 " ORDER BY usr_data.lastname, usr_data.firstname";
404 while ($row =
$ilDB->fetchAssoc($result)) {
405 if (isset($languages[$row[
'usr_id']])) {
406 $row[
'language'] = $languages[$row[
'usr_id']];
408 $row[
'language'] =
$lng->getDefaultLanguage();
411 if (isset($multi[$row[
"usr_id"]])) {
412 $row = array_merge($row, $multi[$row[
"usr_id"]]);
415 if (is_array($user_data_filter)) {
416 if (in_array($row[
"usr_id"], $user_data_filter)) {
426 case self::FILE_TYPE_EXCEL:
429 case self::FILE_TYPE_CSV:
432 case self::FILE_TYPE_XML:
445 if (!is_dir($this->getExportDirectory())) {
448 if (!is_writable($usrf_data_dir)) {
449 $this->
ilias->raiseError(
"Userfolder data directory (" . $usrf_data_dir
450 .
") not writeable.", $this->
ilias->error_obj->MESSAGE);
454 $export_dir = $usrf_data_dir .
"/export";
456 if (!is_dir($export_dir)) {
457 $this->
ilias->raiseError(
"Creation of Userfolder Export Directory failed.", $this->
ilias->error_obj->MESSAGE);
470 $up->skipField(
"username");
471 $up->skipField(
"roles");
472 $up->skipGroup(
"preferences");
473 $fds = $up->getStandardFields();
474 $profile_fields = [];
475 foreach ($fds as $k =>
$f) {
476 $profile_fields[] = $k;
479 return $profile_fields;
494 if (self::_lookupNewAccountMail($a_lang)) {
496 'subject' => array(
'text',$a_subject),
497 'body' => array(
'clob',$a_body),
498 'sal_g' => array(
'text',$a_sal_g),
499 'sal_f' => array(
'text',$a_sal_f),
500 'sal_m' => array(
'text',$a_sal_m)
505 array(
'lang' => array(
'text',$a_lang),
'type' => array(
'text',
'nacc'))
509 'subject' => array(
'text',$a_subject),
510 'body' => array(
'clob',$a_body),
511 'sal_g' => array(
'text',$a_sal_g),
512 'sal_f' => array(
'text',$a_sal_f),
513 'sal_m' => array(
'text',$a_sal_m),
514 'lang' => array(
'text',$a_lang),
515 'type' => array(
'text',
'nacc')
517 $ilDB->insert(
'mail_template', $values);
536 $path = $fs->getAbsolutePath() .
"/";
542 array(
'att_file' => array(
'text', $a_name)),
543 array(
'lang' => array(
'text',$a_lang),
'type' => array(
'text',
'nacc'))
558 $path = $fs->getAbsolutePath() .
"/";
560 if (file_exists(
$path . $a_lang)) {
561 unlink(
$path . $a_lang);
566 array(
'att_file' => array(
'text',
'')),
567 array(
'lang' => array(
'text',$a_lang),
'type' => array(
'text',
'nacc'))
581 $set =
$ilDB->query(
"SELECT * FROM mail_template " .
582 " WHERE type='nacc' AND lang = " .
$ilDB->quote($a_lang,
'text'));
604 $query =
"UPDATE usr_data SET time_limit_owner = " .
$ilDB->quote($a_new_id,
"integer") .
" " .
605 "WHERE time_limit_owner = " .
$ilDB->quote($a_old_id,
"integer") .
" ";
static & processCSVRow(array &$row, bool $quoteAll=false, string $separator=";", bool $outUTF8=false, bool $compatibleWithMSExcel=true)
Convertes an array for CSV usage.
@classDescription Date and time handling
addSheet(string $a_name, bool $a_activate=true)
Add sheet.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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 getDataDir()
get data directory (outside webspace)
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
createExportDirectory()
creates data directory for export files
static _writeNewAccountMail(string $a_lang, string $a_subject, string $a_sal_g, string $a_sal_f, string $a_sal_m, string $a_body)
__construct(int $a_id, bool $a_call_by_reference=true)
getUserDefinedExportFields()
Get all exportable user defined fields.
static _updateAccountMailAttachment(string $a_lang, string $a_tmp_name, string $a_name)
Update account mail attachment.
createCSVExport(array $settings, array $data, string $filename)
const ORG_OP_EDIT_USER_ACCOUNTS
createXMLExport(array $settings, array $data, string $filename)
static getProfileFields()
Get profile fields.
static _updateUserFolderAssignment(int $a_old_id, int $a_new_id)
Update user folder assignment Typically called after deleting a category with local user accounts.
createExcelExport(array $settings, array $data, string $filename)
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)
static getExportSettings()
static _deleteAccountMailAttachment(string $a_lang)
Delete account mail attachment.
getExportFilename(string $a_mode=self::FILE_TYPE_EXCEL)
getExportFiles()
Get a list of the already exported files in the export directory.
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
header include for all ilias files.