14 require_once
"./Services/Object/classes/class.ilObject.php";
16 define(
'USER_FOLDER_ID',7);
29 parent::__construct($a_id,$a_call_by_reference);
45 if (!parent::delete())
61 $inst_id = IL_INST_ID;
67 case "userfolder_export_excel_x86":
68 $filename = $date.
"__".$inst_id.
"__xls_usrf";
70 case "userfolder_export_csv":
71 $filename = $date.
"__".$inst_id.
"__csv_usrf.csv";
73 case "userfolder_export_xml":
74 $filename = $date.
"__".$inst_id.
"__xml_usrf.xml";
108 if (!@is_dir($dir)
or 121 while ($entry = $dir->read())
123 if ($entry !=
"." and 125 preg_match(
"/^[0-9]{10}_{2}[0-9]+_{2}([a-z0-9]{3})_usrf\.[a-z]{1,4}\$/", $entry, $matches))
127 $filearray[
"filename"] = $entry;
129 array_push(
$file, $filearray);
145 $value = str_replace(
"&",
"&", $value);
146 $value = str_replace(
"<",
"<", $value);
147 $value = str_replace(
">",
">", $value);
153 include_once
'./Services/User/classes/class.ilUserDefinedData.php';
154 include_once
'./Services/User/classes/class.ilObjUser.php';
164 include_once
'./Services/User/classes/class.ilUserXMLWriter.php';
167 $xmlWriter->setObjects(
$data);
168 $xmlWriter->setSettings($settings);
169 $xmlWriter->setAttachRoles (
true);
171 if($xmlWriter->start())
173 fwrite(
$file, $xmlWriter->getXML());
184 include_once
'./Services/User/classes/class.ilUserDefinedFields.php';
187 $udf_ex_fields =
array();
188 foreach($udf_obj->getDefinitions() as $definition)
190 if ($definition[
"export"] != FALSE)
192 $udf_ex_fields[] =
array(
"name" => $definition[
"field_name"],
193 "id" => $definition[
"field_id"]);
197 return $udf_ex_fields;
204 $headerrow =
array();
206 foreach ($settings as $value)
208 array_push($headerrow, $this->lng->txt($value));
210 foreach ($udf_ex_fields as $f)
212 array_push($headerrow, $f[
"name"]);
218 fwrite(
$file, join ($separator, $formattedrow) .
"\n");
225 if(is_array($row[$header]))
227 $row[
$header] = implode(
", ", $row[$header]);
230 array_push($csvrow, $row[$header]);
234 reset($udf_ex_fields);
235 if (count($udf_ex_fields) > 0)
237 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
239 foreach ($udf_ex_fields as $f)
241 array_push($csvrow, $udf->get(
"f_".$f[
"id"]));
246 fwrite(
$file, join ($separator, $formattedrow) .
"\n");
253 include_once
"./Services/Excel/classes/class.ilExcel.php";
255 $worksheet->addSheet($this->lng->txt(
"users"));
263 foreach ($settings as $value)
265 if($value ==
'ext_account')
267 $value =
'user_ext_account';
272 foreach ($udf_ex_fields as $f)
279 $this->lng->loadLanguageModule(
"meta");
280 foreach (
$data as $index => $rowdata)
286 foreach ($settings as $fieldname)
288 $value = $rowdata[$fieldname];
292 $worksheet->setCell(
$row, $col, $this->lng->txt(
"meta_l_".$value));
294 case "time_limit_from":
295 case "time_limit_until":
312 case "interests_general":
313 case "interests_help_offered":
314 case "interests_help_looking":
315 if(is_array($value) &&
sizeof($value))
317 $value = implode(
", ", $value);
333 reset($udf_ex_fields);
334 if (count($udf_ex_fields) > 0)
336 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
338 foreach ($udf_ex_fields as $f)
358 $db_settings =
array();
360 include_once(
"./Services/User/classes/class.ilUserProfile.php");
362 $up->skipField(
"roles");
363 $profile_fields = $up->getStandardFields();
368 $query =
"SELECT * FROM settings WHERE ".
369 $ilDB->like(
"keyword",
"text",
'%usr_settings_export_%');
373 if (
$row[
"value"] ==
"1")
375 if (preg_match(
"/usr_settings_export_(.*)/",
$row[
"keyword"], $setting))
377 array_push($db_settings, $setting[1]);
381 $export_settings =
array();
382 foreach ($profile_fields as $key => $value)
384 if (in_array($key, $db_settings))
386 if (strcmp($key,
"password") == 0)
393 array_push($export_settings, $key);
397 array_push($export_settings,
"usr_id");
398 array_push($export_settings,
"login");
399 array_push($export_settings,
"last_login");
400 array_push($export_settings,
"last_update");
401 array_push($export_settings,
"create_date");
402 array_push($export_settings,
"time_limit_owner");
403 array_push($export_settings,
"time_limit_unlimited");
404 array_push($export_settings,
"time_limit_from");
405 array_push($export_settings,
"time_limit_until");
406 array_push($export_settings,
"time_limit_message");
407 array_push($export_settings,
"active");
408 array_push($export_settings,
"approve_date");
409 array_push($export_settings,
"agree_date");
410 array_push($export_settings,
"client_ip");
411 array_push($export_settings,
"auth_mode");
412 array_push($export_settings,
"ext_account");
413 array_push($export_settings,
"feedhash");
414 return $export_settings;
420 function buildExportFile($a_mode =
"userfolder_export_excel_x86", $user_data_filter = FALSE)
443 $query =
"SELECT * FROM usr_pref WHERE keyword = ".$ilDB->quote(
'language',
'text');
453 $set = $ilDB->query(
"SELECT * FROM usr_data_multi");
454 while(
$row = $ilDB->fetchAssoc($set))
456 if(!is_array($user_data_filter) ||
457 in_array(
$row[
"usr_id"], $user_data_filter))
459 $multi[
$row[
"usr_id"]][
$row[
"field_id"]][] = $row[
"value"];
464 $query =
"SELECT usr_data.* FROM usr_data ".
465 " ORDER BY usr_data.lastname, usr_data.firstname";
471 $row[
'language'] =
$languages[$row[
'usr_id']];
475 $row[
'language'] = $lng->getDefaultLanguage();
478 if(isset($multi[$row[
"usr_id"]]))
480 $row = array_merge($row, $multi[$row[
"usr_id"]]);
483 if (is_array($user_data_filter))
485 if (in_array($row[
"usr_id"], $user_data_filter)) array_push(
$data, $row);
489 array_push(
$data, $row);
497 case "userfolder_export_excel_x86":
500 case "userfolder_export_csv":
503 case "userfolder_export_xml":
524 if(!is_writable($usrf_data_dir))
526 $this->
ilias->raiseError(
"Userfolder data directory (".$usrf_data_dir
527 .
") not writeable.",$this->
ilias->error_obj->MESSAGE);
531 $export_dir = $usrf_data_dir.
"/export";
533 if(!@is_dir($export_dir))
535 $this->
ilias->raiseError(
"Creation of Userfolder Export Directory failed.",$this->
ilias->error_obj->MESSAGE);
548 include_once(
"./Services/User/classes/class.ilUserProfile.php");
550 $up->skipField(
"username");
551 $up->skipField(
"roles");
552 $up->skipGroup(
"preferences");
553 $fds = $up->getStandardFields();
554 foreach ($fds as $k => $f)
556 $profile_fields[] = $k;
559 return $profile_fields;
566 if(self::_lookupNewAccountMail($a_lang))
569 'subject' =>
array(
'text',$a_subject),
570 'body' =>
array(
'clob',$a_body),
571 'sal_g' =>
array(
'text',$a_sal_g),
572 'sal_f' =>
array(
'text',$a_sal_f),
573 'sal_m' =>
array(
'text',$a_sal_m)
575 $ilDB->update(
'mail_template',
583 'subject' =>
array(
'text',$a_subject),
584 'body' =>
array(
'clob',$a_body),
585 'sal_g' =>
array(
'text',$a_sal_g),
586 'sal_f' =>
array(
'text',$a_sal_f),
587 'sal_m' =>
array(
'text',$a_sal_m),
588 'lang' =>
array(
'text',$a_lang),
589 'type' =>
array(
'text',
'nacc')
591 $ilDB->insert(
'mail_template',$values);
606 include_once
"Services/User/classes/class.ilFSStorageUserFolder.php";
609 $path = $fs->getAbsolutePath().
"/";
613 $ilDB->update(
'mail_template',
615 array(
'lang' =>
array(
'text',$a_lang),
'type' =>
array(
'text',
'nacc')));
626 include_once
"Services/User/classes/class.ilFSStorageUserFolder.php";
628 $path = $fs->getAbsolutePath().
"/";
630 unlink(
$path.$a_lang);
632 $ilDB->update(
'mail_template',
634 array(
'lang' =>
array(
'text',$a_lang),
'type' =>
array(
'text',
'nacc')));
641 $set = $ilDB->query(
"SELECT * FROM mail_template ".
642 " WHERE type='nacc' AND lang = ".$ilDB->quote($a_lang,
'text'));
666 $query =
"UPDATE usr_data SET time_limit_owner = ".$ilDB->quote($a_new_id,
"integer").
" ".
667 "WHERE time_limit_owner = ".$ilDB->quote($a_old_id,
"integer").
" ";
668 $ilDB->manipulate(
$query);
static _updateUserFolderAssignment($a_old_id, $a_new_id)
Update user folder assignment Typically called after deleting a category with local user accounts...
getExportFilename($a_mode="userfolder_export_excel_x86")
static _getInstance()
Get instance.
getExportFiles()
Get a list of the already exported files in the export directory.
Class ilObject Basic functions for all objects.
getExportDirectory()
Get the location of the export directory for the user accounts.
static _writeNewAccountMail($a_lang, $a_subject, $a_sal_g, $a_sal_f, $a_sal_m, $a_body)
createXMLExport(&$settings, &$data, $filename)
createExportDirectory()
creates data directory for export files (data_dir/usrf_data/export, depending on data directory that ...
static _deleteAccountMailAttachment($a_lang)
Delete account mail attachment.
static getExportSettings()
getExport Settings
static _lookupNewAccountMail($a_lang)
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
buildExportFile($a_mode="userfolder_export_excel_x86", $user_data_filter=FALSE)
build xml export file
redirection script todo: (a better solution should control the processing via a xml file) ...
static _updateAccountMailAttachment($a_lang, $a_tmp_name, $a_name)
Update account mail attachment.
static & processCSVRow(&$row, $quoteAll=FALSE, $separator=";", $outUTF8=FALSE, $compatibleWithMSExcel=TRUE)
Convertes an array for CSV usage.
Create styles array
The data for the language used.
__construct($a_id, $a_call_by_reference=true)
Constructor public.
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static & getProfileFields()
Get profile fields (DEPRECATED, use ilUserProfile() instead)
static getDataDir()
get data directory (outside webspace)
getUserDefinedExportFields()
Get all exportable user defined fields.
const USER_FOLDER_ID
Class ilObjUserFolder.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
createExcelExport(&$settings, &$data, $filename)
createCSVExport(&$settings, &$data, $filename)