14 require_once
"./Services/Object/classes/class.ilObject.php";
16 define(
'USER_FOLDER_ID', 7);
26 public function __construct($a_id, $a_call_by_reference =
true)
29 parent::__construct($a_id, $a_call_by_reference);
39 public function delete()
45 if (!parent::delete()) {
60 $inst_id = IL_INST_ID;
65 case "userfolder_export_excel_x86":
66 $filename = $date .
"__" . $inst_id .
"__xls_usrf";
68 case "userfolder_export_csv":
69 $filename = $date .
"__" . $inst_id .
"__csv_usrf.csv";
71 case "userfolder_export_xml":
72 $filename = $date .
"__" . $inst_id .
"__xml_usrf.xml";
106 if (!@is_dir($dir) or
107 !is_writeable($dir)) {
118 while ($entry = $dir->read()) {
119 if ($entry !=
"." and
121 preg_match(
"/^[0-9]{10}_{2}[0-9]+_{2}([a-z0-9]{3})_usrf\.[a-z]{1,4}\$/", $entry, $matches)) {
122 $filearray[
"filename"] = $entry;
124 array_push(
$file, $filearray);
140 $value = str_replace(
"&",
"&", $value);
141 $value = str_replace(
"<",
"<", $value);
142 $value = str_replace(
">",
">", $value);
148 include_once
'./Services/User/classes/class.ilUserDefinedData.php';
149 include_once
'./Services/User/classes/class.ilObjUser.php';
157 if (is_array(
$data)) {
158 include_once
'./Services/User/classes/class.ilUserXMLWriter.php';
161 $xmlWriter->setObjects(
$data);
162 $xmlWriter->setSettings($settings);
163 $xmlWriter->setAttachRoles(
true);
165 if ($xmlWriter->start()) {
166 fwrite(
$file, $xmlWriter->getXML());
177 include_once
'./Services/User/classes/class.ilUserDefinedFields.php';
180 $udf_ex_fields =
array();
181 foreach ($udf_obj->getDefinitions() as $definition) {
182 if ($definition[
"export"] !=
false) {
183 $udf_ex_fields[] =
array(
"name" => $definition[
"field_name"],
184 "id" => $definition[
"field_id"]);
188 return $udf_ex_fields;
195 $headerrow =
array();
197 foreach ($settings as $value) {
198 array_push($headerrow, $this->lng->txt($value));
200 foreach ($udf_ex_fields as $f) {
201 array_push($headerrow, $f[
"name"]);
207 fwrite(
$file, join($separator, $formattedrow) .
"\n");
210 foreach ($settings as
$header) {
212 if (is_array($row[$header])) {
213 $row[
$header] = implode(
", ", $row[$header]);
216 array_push($csvrow, $row[$header]);
220 reset($udf_ex_fields);
221 if (count($udf_ex_fields) > 0) {
222 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
224 foreach ($udf_ex_fields as $f) {
225 array_push($csvrow, $udf->get(
"f_" . $f[
"id"]));
230 fwrite(
$file, join($separator, $formattedrow) .
"\n");
237 include_once
"./Services/Excel/classes/class.ilExcel.php";
239 $worksheet->addSheet($this->lng->txt(
"users"));
247 foreach ($settings as $value) {
248 if ($value ==
'ext_account') {
249 $value =
'user_ext_account';
254 foreach ($udf_ex_fields as $f) {
260 $this->lng->loadLanguageModule(
"meta");
266 foreach ($settings as $fieldname) {
267 $value = $rowdata[$fieldname];
268 switch ($fieldname) {
270 $worksheet->setCell(
$row, $col, $this->lng->txt(
"meta_l_" . $value));
272 case "time_limit_from":
273 case "time_limit_until":
290 case "interests_general":
291 case "interests_help_offered":
292 case "interests_help_looking":
293 if (is_array($value) &&
sizeof($value)) {
294 $value = implode(
", ", $value);
309 reset($udf_ex_fields);
310 if (count($udf_ex_fields) > 0) {
311 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
313 foreach ($udf_ex_fields as $f) {
332 $db_settings =
array();
334 include_once(
"./Services/User/classes/class.ilUserProfile.php");
336 $up->skipField(
"roles");
337 $profile_fields = $up->getStandardFields();
342 $query =
"SELECT * FROM settings WHERE " .
343 $ilDB->like(
"keyword",
"text",
'%usr_settings_export_%');
346 if (
$row[
"value"] ==
"1") {
347 if (preg_match(
"/usr_settings_export_(.*)/",
$row[
"keyword"], $setting)) {
348 array_push($db_settings, $setting[1]);
352 $export_settings =
array();
353 foreach ($profile_fields as
$key => $value) {
354 if (in_array(
$key, $db_settings)) {
355 if (strcmp(
$key,
"password") == 0) {
359 array_push($export_settings,
$key);
363 array_push($export_settings,
"usr_id");
364 array_push($export_settings,
"login");
365 array_push($export_settings,
"last_login");
366 array_push($export_settings,
"last_update");
367 array_push($export_settings,
"create_date");
368 array_push($export_settings,
"time_limit_owner");
369 array_push($export_settings,
"time_limit_unlimited");
370 array_push($export_settings,
"time_limit_from");
371 array_push($export_settings,
"time_limit_until");
372 array_push($export_settings,
"time_limit_message");
373 array_push($export_settings,
"active");
374 array_push($export_settings,
"approve_date");
375 array_push($export_settings,
"agree_date");
376 array_push($export_settings,
"client_ip");
377 array_push($export_settings,
"auth_mode");
378 array_push($export_settings,
"ext_account");
379 array_push($export_settings,
"feedhash");
380 return $export_settings;
386 public function buildExportFile($a_mode =
"userfolder_export_excel_x86", $user_data_filter =
false)
409 $query =
"SELECT * FROM usr_pref WHERE keyword = " . $ilDB->quote(
'language',
'text');
411 $languages =
array();
413 $languages[
$row[
'usr_id']] = $row[
'value'];
418 $set = $ilDB->query(
"SELECT * FROM usr_data_multi");
419 while (
$row = $ilDB->fetchAssoc($set)) {
420 if (!is_array($user_data_filter) ||
421 in_array(
$row[
"usr_id"], $user_data_filter)) {
422 $multi[
$row[
"usr_id"]][
$row[
"field_id"]][] = $row[
"value"];
427 $query =
"SELECT usr_data.* FROM usr_data " .
428 " ORDER BY usr_data.lastname, usr_data.firstname";
431 if (isset($languages[
$row[
'usr_id']])) {
432 $row[
'language'] = $languages[$row[
'usr_id']];
434 $row[
'language'] = $lng->getDefaultLanguage();
437 if (isset($multi[$row[
"usr_id"]])) {
438 $row = array_merge($row, $multi[$row[
"usr_id"]]);
441 if (is_array($user_data_filter)) {
442 if (in_array($row[
"usr_id"], $user_data_filter)) {
443 array_push(
$data, $row);
446 array_push(
$data, $row);
453 case "userfolder_export_excel_x86":
456 case "userfolder_export_csv":
459 case "userfolder_export_xml":
479 if (!is_writable($usrf_data_dir)) {
480 $this->
ilias->raiseError(
"Userfolder data directory (" . $usrf_data_dir
481 .
") not writeable.", $this->
ilias->error_obj->MESSAGE);
485 $export_dir = $usrf_data_dir .
"/export";
487 if (!@is_dir($export_dir)) {
488 $this->
ilias->raiseError(
"Creation of Userfolder Export Directory failed.", $this->
ilias->error_obj->MESSAGE);
501 include_once(
"./Services/User/classes/class.ilUserProfile.php");
503 $up->skipField(
"username");
504 $up->skipField(
"roles");
505 $up->skipGroup(
"preferences");
506 $fds = $up->getStandardFields();
507 foreach ($fds as $k => $f) {
508 $profile_fields[] = $k;
511 return $profile_fields;
518 if (self::_lookupNewAccountMail($a_lang)) {
520 'subject' =>
array(
'text',$a_subject),
521 'body' =>
array(
'clob',$a_body),
522 'sal_g' =>
array(
'text',$a_sal_g),
523 'sal_f' =>
array(
'text',$a_sal_f),
524 'sal_m' =>
array(
'text',$a_sal_m)
533 'subject' =>
array(
'text',$a_subject),
534 'body' =>
array(
'clob',$a_body),
535 'sal_g' =>
array(
'text',$a_sal_g),
536 'sal_f' =>
array(
'text',$a_sal_f),
537 'sal_m' =>
array(
'text',$a_sal_m),
538 'lang' =>
array(
'text',$a_lang),
539 'type' =>
array(
'text',
'nacc')
541 $ilDB->insert(
'mail_template', $values);
556 include_once
"Services/User/classes/class.ilFSStorageUserFolder.php";
559 $path = $fs->getAbsolutePath() .
"/";
561 ilUtil::moveUploadedFile($a_tmp_name, $a_lang,
$path . $a_lang);
578 include_once
"Services/User/classes/class.ilFSStorageUserFolder.php";
580 $path = $fs->getAbsolutePath() .
"/";
582 if (file_exists(
$path . $a_lang)) {
583 unlink(
$path . $a_lang);
597 $set = $ilDB->query(
"SELECT * FROM mail_template " .
598 " WHERE type='nacc' AND lang = " . $ilDB->quote($a_lang,
'text'));
621 $query =
"UPDATE usr_data SET time_limit_owner = " . $ilDB->quote($a_new_id,
"integer") .
" " .
622 "WHERE time_limit_owner = " . $ilDB->quote($a_old_id,
"integer") .
" ";
623 $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.
buildExportFile($a_mode="userfolder_export_excel_x86", $user_data_filter=false)
build xml export file
getExportFiles()
Get a list of the already exported files in the export directory.
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 & processCSVRow(&$row, $quoteAll=false, $separator=";", $outUTF8=false, $compatibleWithMSExcel=true)
Convertes an array for CSV usage.
foreach($_POST as $key=> $value) $res
static _lookupNewAccountMail($a_lang)
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.
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)