14 require_once
"./Services/Object/classes/class.ilObject.php";
16 define(
'USER_FOLDER_ID',7);
29 $this->
ilObject($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.xls";
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,3}\$/", $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());
454 include_once
'./Services/User/classes/class.ilUserDefinedFields.php';
457 $udf_ex_fields = array();
458 foreach($udf_obj->getDefinitions() as $definition)
460 if ($definition[
"export"] != FALSE)
462 $udf_ex_fields[] = array(
"name" => $definition[
"field_name"],
463 "id" => $definition[
"field_id"]);
467 return $udf_ex_fields;
474 $headerrow = array();
476 foreach ($settings as $value)
478 array_push($headerrow, $this->lng->txt($value));
480 foreach ($udf_ex_fields as $f)
482 array_push($headerrow, $f[
"name"]);
492 foreach ($settings as $header)
494 array_push($csvrow, $row[$header]);
498 reset($udf_ex_fields);
499 if (count($udf_ex_fields) > 0)
501 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
503 foreach ($udf_ex_fields as $f)
505 array_push($csvrow, $udf->get(
"f_".$f[
"id"]));
517 include_once
"./Services/Excel/classes/class.ilExcelUtils.php";
518 include_once
"./Services/Excel/classes/class.ilExcelWriterAdapter.php";
520 $workbook = $adapter->getWorkbook();
522 $format_bold =& $workbook->addFormat();
523 $format_bold->setBold();
524 $format_percent =& $workbook->addFormat();
525 $format_percent->setNumFormat(
"0.00%");
526 $format_datetime =& $workbook->addFormat();
527 $format_datetime->setNumFormat(
"DD/MM/YYYY hh:mm:ss");
528 $format_title =& $workbook->addFormat();
529 $format_title->setBold();
530 $format_title->setColor(
'black');
531 $format_title->setPattern(1);
532 $format_title->setFgColor(
'silver');
533 $worksheet =& $workbook->addWorksheet();
540 foreach ($settings as $value)
545 foreach ($udf_ex_fields as $f)
551 $this->lng->loadLanguageModule(
"meta");
552 foreach (
$data as $index => $rowdata)
558 foreach ($settings as $fieldname)
560 $value = $rowdata[$fieldname];
566 case "time_limit_from":
567 case "time_limit_until":
568 $date = strftime(
"%Y-%m-%d %H:%M:%S", $value);
569 if (preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $date, $matches))
571 $worksheet->write(
$row, $col,
ilUtil::excelTime($matches[1],$matches[2],$matches[3],$matches[4],$matches[5],$matches[6]), $format_datetime);
579 if (preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $value, $matches))
581 $worksheet->write(
$row, $col,
ilUtil::excelTime($matches[1],$matches[2],$matches[3],$matches[4],$matches[5],$matches[6]), $format_datetime);
592 reset($udf_ex_fields);
593 if (count($udf_ex_fields) > 0)
595 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
597 foreach ($udf_ex_fields as $f)
616 $db_settings = array();
618 include_once(
"./Services/User/classes/class.ilUserProfile.php");
620 $up->skipField(
"roles");
621 $profile_fields = $up->getStandardFields();
626 $query =
"SELECT * FROM settings WHERE ".
627 $ilDB->like(
"keyword",
"text",
'%usr_settings_export_%');
631 if (
$row[
"value"] ==
"1")
633 if (preg_match(
"/usr_settings_export_(.*)/",
$row[
"keyword"], $setting))
635 array_push($db_settings, $setting[1]);
639 $export_settings = array();
640 foreach ($profile_fields as $key => $value)
642 if (in_array($key, $db_settings))
644 if (strcmp($key,
"password") == 0)
646 array_push($export_settings,
"passwd");
650 array_push($export_settings, $key);
654 array_push($export_settings,
"login");
655 array_push($export_settings,
"last_login");
656 array_push($export_settings,
"last_update");
657 array_push($export_settings,
"create_date");
658 array_push($export_settings,
"i2passwd");
659 array_push($export_settings,
"time_limit_owner");
660 array_push($export_settings,
"time_limit_unlimited");
661 array_push($export_settings,
"time_limit_from");
662 array_push($export_settings,
"time_limit_until");
663 array_push($export_settings,
"time_limit_message");
664 array_push($export_settings,
"active");
665 array_push($export_settings,
"approve_date");
666 array_push($export_settings,
"agree_date");
667 array_push($export_settings,
"ilinc_id");
668 array_push($export_settings,
"ilinc_login");
669 array_push($export_settings,
"ilinc_passwd");
670 array_push($export_settings,
"client_ip");
671 array_push($export_settings,
"auth_mode");
672 array_push($export_settings,
"ext_account");
673 array_push($export_settings,
"feedhash");
675 return $export_settings;
681 function buildExportFile($a_mode =
"userfolder_export_excel_x86", $user_data_filter = FALSE)
704 $query =
"SELECT * FROM usr_pref WHERE keyword = ".$ilDB->quote(
'language',
'text');
706 $languages = array();
709 $languages[
$row[
'usr_id']] = $row[
'value'];
714 $query =
"SELECT usr_data.* FROM usr_data ".
715 " ORDER BY usr_data.lastname, usr_data.firstname";
719 if(isset($languages[
$row[
'usr_id']]))
721 $row[
'language'] = $languages[$row[
'usr_id']];
725 $row[
'language'] = $lng->getDefaultLanguage();
728 if (is_array($user_data_filter))
730 if (in_array($row[
"usr_id"], $user_data_filter)) array_push(
$data, $row);
734 array_push(
$data, $row);
742 case "userfolder_export_excel_x86":
745 case "userfolder_export_csv":
748 case "userfolder_export_xml":
769 if(!is_writable($usrf_data_dir))
771 $this->ilias->raiseError(
"Userfolder data directory (".$usrf_data_dir
772 .
") not writeable.",$this->ilias->error_obj->MESSAGE);
776 $export_dir = $usrf_data_dir.
"/export";
778 if(!@is_dir($export_dir))
780 $this->ilias->raiseError(
"Creation of Userfolder Export Directory failed.",$this->ilias->error_obj->MESSAGE);
793 include_once(
"./Services/User/classes/class.ilUserProfile.php");
795 $up->skipField(
"username");
796 $up->skipField(
"roles");
797 $up->skipGroup(
"preferences");
798 $fds = $up->getStandardFields();
799 foreach ($fds as $k => $f)
801 $profile_fields[] = $k;
804 return $profile_fields;
811 if(self::_lookupNewAccountMail($a_lang))
814 'subject' => array(
'text',$a_subject),
815 'body' => array(
'clob',$a_body),
816 'sal_g' => array(
'text',$a_sal_g),
817 'sal_f' => array(
'text',$a_sal_f),
818 'sal_m' => array(
'text',$a_sal_m)
820 $ilDB->update(
'mail_template',
822 array(
'lang' => array(
'text',$a_lang),
'type' => array(
'text',
'nacc'))
828 'subject' => array(
'text',$a_subject),
829 'body' => array(
'clob',$a_body),
830 'sal_g' => array(
'text',$a_sal_g),
831 'sal_f' => array(
'text',$a_sal_f),
832 'sal_m' => array(
'text',$a_sal_m),
833 'lang' => array(
'text',$a_lang),
834 'type' => array(
'text',
'nacc')
836 $ilDB->insert(
'mail_template',$values);
844 include_once
"Services/User/classes/class.ilFSStorageUserFolder.php";
847 $path = $fs->getAbsolutePath().
"/";
849 move_uploaded_file($a_tmp_name,
$path.$a_lang);
851 $ilDB->update(
'mail_template',
852 array(
'att_file' => array(
'text', $a_name)),
853 array(
'lang' => array(
'text',$a_lang),
'type' => array(
'text',
'nacc')));
860 include_once
"Services/User/classes/class.ilFSStorageUserFolder.php";
862 $path = $fs->getAbsolutePath().
"/";
864 @unlink(
$path.$a_lang);
866 $ilDB->update(
'mail_template',
867 array(
'att_file' => array(
'text',
'')),
868 array(
'lang' => array(
'text',$a_lang),
'type' => array(
'text',
'nacc')));
875 $set = $ilDB->query(
"SELECT * FROM mail_template ".
876 " WHERE type='nacc' AND lang = ".$ilDB->quote($a_lang,
'text'));
900 $query =
"UPDATE usr_data SET time_limit_owner = ".$ilDB->quote($a_new_id,
"integer").
" ".
901 "WHERE time_limit_owner = ".$ilDB->quote($a_old_id,
"integer").
" ";
902 $ilDB->manipulate(
$query);