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         fwrite($file, implode($separator, $formattedrow) . 
"\n");
   167         foreach ($data as $row) {
   169             foreach ($settings as $header) {    
   171                 if (isset($row[$header]) && is_array($row[$header])) {
   172                     $row[$header] = implode(
", ", $row[$header]);
   175                 $csvrow[] = $row[$header] ?? 
'';
   179             reset($udf_ex_fields);
   180             if (count($udf_ex_fields) > 0) {
   182                 foreach ($udf_ex_fields as $f) {        
   183                     $csvrow[] = $udf->get(
"f_" . $f[
"id"]);
   188             fwrite($file, implode($separator, $formattedrow) . 
"\n");
   199         $worksheet->addSheet($this->
lng->txt(
"users"));
   207         foreach ($settings as $value) { 
   208             if ($value == 
'ext_account') {
   209                 $value = 
'user_ext_account';
   211             $worksheet->setCell($row, $col, $this->
lng->txt($value));
   214         foreach ($udf_ex_fields as 
$f) {        
   215             $worksheet->setCell($row, $col, $f[
"name"]);
   218         $worksheet->setBold(
"A1:" . $worksheet->getColumnCoord($col - 1) . 
"1");
   220         $this->
lng->loadLanguageModule(
"meta");
   221         foreach ($data as $index => $rowdata) {
   226             foreach ($settings as $fieldname) {
   227                 $value = $rowdata[$fieldname] ?? 
"";
   228                 switch ($fieldname) {
   230                         $worksheet->setCell($row, $col, $this->
lng->txt(
"meta_l_" . $value));
   232                     case "time_limit_from":
   233                     case "time_limit_until":
   237                         $worksheet->setCell($row, $col, $value);
   247                         $worksheet->setCell($row, $col, $value);
   250                     case "interests_general":
   251                     case "interests_help_offered":
   252                     case "interests_help_looking":
   253                         if (is_array($value) && count($value)) {
   254                             $value = implode(
", ", $value);
   262                         $worksheet->setCell($row, $col, $value);
   269             reset($udf_ex_fields);
   270             if (count($udf_ex_fields) > 0) {
   272                 foreach ($udf_ex_fields as $f) {        
   273                     $worksheet->setCell($row, $col, $udf->get(
"f_" . $f[
"id"]));
   279         $worksheet->writeToFile($filename);
   289         $ilDB = $DIC[
'ilDB'];
   294         $up->skipField(
"roles");
   295         $profile_fields = $up->getStandardFields();
   297         $query = 
"SELECT * FROM settings WHERE " .
   298             $ilDB->like(
"keyword", 
"text", 
'%usr_settings_export_%');
   299         $result = 
$ilDB->query($query);
   301             if ($row[
"value"] == 
"1") {
   302                 if (preg_match(
"/usr_settings_export_(.*)/", $row[
"keyword"], $setting)) {
   303                     $db_settings[] = $setting[1];
   307         $export_settings = [];
   308         foreach ($profile_fields as 
$key => $value) {
   309             if (in_array(
$key, $db_settings)) {
   310                 if (strcmp(
$key, 
"password") == 0) {
   314                     $export_settings[] = 
$key;
   318         $export_settings[] = 
"usr_id";
   319         $export_settings[] = 
"login";
   320         $export_settings[] = 
"last_login";
   321         $export_settings[] = 
"last_update";
   322         $export_settings[] = 
"create_date";
   323         $export_settings[] = 
"time_limit_owner";
   324         $export_settings[] = 
"time_limit_unlimited";
   325         $export_settings[] = 
"time_limit_from";
   326         $export_settings[] = 
"time_limit_until";
   327         $export_settings[] = 
"time_limit_message";
   328         $export_settings[] = 
"active";
   329         $export_settings[] = 
"approve_date";
   330         $export_settings[] = 
"agree_date";
   331         $export_settings[] = 
"client_ip";
   332         $export_settings[] = 
"auth_mode";
   333         $export_settings[] = 
"ext_account";
   334         $export_settings[] = 
"feedhash";
   335         return $export_settings;
   342         string $a_mode = self::FILE_TYPE_EXCEL,
   343         ?array $user_data_filter = null,
   344         bool $use_temp_dir = 
false   348         $ilDB = $DIC[
'ilDB'];
   366         $query = 
"SELECT * FROM usr_pref WHERE keyword = " . 
$ilDB->quote(
'language', 
'text');
   370             $languages[$row[
'usr_id']] = $row[
'value'];
   375         $set = 
$ilDB->query(
"SELECT * FROM usr_data_multi");
   376         while ($row = 
$ilDB->fetchAssoc($set)) {
   377             if (!is_array($user_data_filter) ||
   378                 in_array($row[
"usr_id"], $user_data_filter)) {
   379                 $multi[$row[
"usr_id"]][$row[
"field_id"]][] = $row[
"value"];
   384         $query = 
"SELECT usr_data.* FROM usr_data  " .
   385             " ORDER BY usr_data.lastname, usr_data.firstname";
   386         $result = 
$ilDB->query($query);
   387         while ($row = 
$ilDB->fetchAssoc($result)) {
   388             if (isset($languages[$row[
'usr_id']])) {
   389                 $row[
'language'] = $languages[$row[
'usr_id']];
   394             if (isset($multi[$row[
"usr_id"]])) {
   395                 $row = array_merge($row, $multi[$row[
"usr_id"]]);
   398             if (is_array($user_data_filter)) {
   399                 if (in_array($row[
"usr_id"], $user_data_filter)) {
   409             case self::FILE_TYPE_EXCEL:
   412             case self::FILE_TYPE_CSV:
   415             case self::FILE_TYPE_XML:
   431             if (!is_writable($usrf_data_dir)) {
   432                 $this->
ilias->raiseError(
"Userfolder data directory (" . $usrf_data_dir
   433                     . 
") not writeable.", $this->
ilias->error_obj->MESSAGE);
   437             $export_dir = $usrf_data_dir . 
"/export";
   439             if (!is_dir($export_dir)) {
   440                 $this->
ilias->raiseError(
"Creation of Userfolder Export Directory failed.", $this->
ilias->error_obj->MESSAGE);
   453         $up->skipField(
"username");
   454         $up->skipField(
"roles");
   455         $up->skipGroup(
"preferences");
   456         $fds = $up->getStandardFields();
   457         $profile_fields = [];
   458         foreach ($fds as $k => 
$f) {
   459             $profile_fields[] = $k;
   462         return $profile_fields;
   475         $ilDB = $DIC[
'ilDB'];
   477         if (self::_lookupNewAccountMail($a_lang)) {
   479                 'subject' => [
'text',$a_subject],
   480                 'body' => [
'clob',$a_body],
   481                 'sal_g' => [
'text',$a_sal_g],
   482                 'sal_f' => [
'text',$a_sal_f],
   483                 'sal_m' => [
'text',$a_sal_m]
   488                 [
'lang' => [
'text',$a_lang], 
'type' => [
'text',
'nacc']]
   492                 'subject' => [
'text',$a_subject],
   493                 'body' => [
'clob',$a_body],
   494                 'sal_g' => [
'text',$a_sal_g],
   495                 'sal_f' => [
'text',$a_sal_f],
   496                 'sal_m' => [
'text',$a_sal_m],
   497                 'lang' => [
'text',$a_lang],
   498                 'type' => [
'text',
'nacc']
   500             $ilDB->insert(
'mail_template', $values);
   515         $ilDB = $DIC[
'ilDB'];
   519         $path = $fs->getAbsolutePath() . 
"/";
   525             [
'att_file' => [
'text', $a_name]],
   526             [
'lang' => [
'text',$a_lang], 
'type' => [
'text',
'nacc']]
   538         $ilDB = $DIC[
'ilDB'];
   541         $path = $fs->getAbsolutePath() . 
"/";
   543         if (file_exists(
$path . $a_lang)) {
   544             unlink(
$path . $a_lang);
   549             [
'att_file' => [
'text', 
'']],
   550             [
'lang' => [
'text',$a_lang], 
'type' => [
'text',
'nacc']]
   562         $ilDB = $DIC[
'ilDB'];
   564         $set = 
$ilDB->query(
"SELECT * FROM mail_template " .
   565             " WHERE type='nacc' AND lang = " . 
$ilDB->quote($a_lang, 
'text'));
   585         $ilDB = $DIC[
'ilDB'];
   587         $query = 
"UPDATE usr_data SET time_limit_owner = " . 
$ilDB->quote($a_new_id, 
"integer") . 
" " .
   588             "WHERE time_limit_owner = " . 
$ilDB->quote($a_old_id, 
"integer") . 
" ";
   589         $ilDB->manipulate($query);
 createXMLExport(array $settings, array $data, string $filename)
 
static & processCSVRow(array &$row, bool $quoteAll=false, string $separator=';', bool $outUTF8=false, bool $compatibleWithMSExcel=true)
Convertes an array for CSV usage. 
 
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. 
 
createExportDirectory()
creates data directory for export files 
 
createExcelExport(array $settings, array $data, string $filename)
 
static getExportSettings()
 
createCSVExport(array $settings, array $data, string $filename)
 
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)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
header include for all ilias files. 
 
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. 
 
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 ...