14 require_once
"./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 foreach (
$data as $index => $rowdata)
557 foreach ($settings as $fieldname)
559 $value = $rowdata[$fieldname];
565 case "time_limit_from":
566 case "time_limit_until":
567 $date = strftime(
"%Y-%m-%d %H:%M:%S", $value);
568 if (preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $date, $matches))
570 $worksheet->write(
$row, $col,
ilUtil::excelTime($matches[1],$matches[2],$matches[3],$matches[4],$matches[5],$matches[6]), $format_datetime);
578 if (preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $value, $matches))
580 $worksheet->write(
$row, $col,
ilUtil::excelTime($matches[1],$matches[2],$matches[3],$matches[4],$matches[5],$matches[6]), $format_datetime);
591 reset($udf_ex_fields);
592 if (count($udf_ex_fields) > 0)
594 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
596 foreach ($udf_ex_fields as $f)
615 $db_settings = array();
617 include_once(
"./Services/User/classes/class.ilUserProfile.php");
619 $up->skipField(
"roles");
620 $profile_fields =
$up->getStandardFields();
625 $query =
"SELECT * FROM settings WHERE ".
626 $ilDB->like(
"keyword",
"text",
'%usr_settings_export_%');
627 $result = $ilDB->query(
$query);
630 if (
$row[
"value"] ==
"1")
632 if (preg_match(
"/usr_settings_export_(.*)/",
$row[
"keyword"], $setting))
634 array_push($db_settings, $setting[1]);
638 $export_settings = array();
639 foreach ($profile_fields as $key => $value)
641 if (in_array($key, $db_settings))
643 if (strcmp($key,
"password") == 0)
645 array_push($export_settings,
"passwd");
649 array_push($export_settings, $key);
653 array_push($export_settings,
"login");
654 array_push($export_settings,
"last_login");
655 array_push($export_settings,
"last_update");
656 array_push($export_settings,
"create_date");
657 array_push($export_settings,
"i2passwd");
658 array_push($export_settings,
"time_limit_owner");
659 array_push($export_settings,
"time_limit_unlimited");
660 array_push($export_settings,
"time_limit_from");
661 array_push($export_settings,
"time_limit_until");
662 array_push($export_settings,
"time_limit_message");
663 array_push($export_settings,
"active");
664 array_push($export_settings,
"approve_date");
665 array_push($export_settings,
"agree_date");
666 array_push($export_settings,
"ilinc_id");
667 array_push($export_settings,
"ilinc_login");
668 array_push($export_settings,
"ilinc_passwd");
669 array_push($export_settings,
"client_ip");
670 array_push($export_settings,
"auth_mode");
671 array_push($export_settings,
"ext_account");
672 array_push($export_settings,
"feedhash");
674 return $export_settings;
680 function buildExportFile($a_mode =
"userfolder_export_excel_x86", $user_data_filter = FALSE)
703 $query =
"SELECT * FROM usr_pref WHERE keyword = ".$ilDB->quote(
'language',
'text');
705 $languages = array();
708 $languages[
$row[
'usr_id']] = $row[
'value'];
713 $query =
"SELECT usr_data.* FROM usr_data ".
714 " ORDER BY usr_data.lastname, usr_data.firstname";
715 $result = $ilDB->query(
$query);
716 while (
$row = $ilDB->fetchAssoc($result))
718 if(isset($languages[
$row[
'usr_id']]))
720 $row[
'language'] = $languages[$row[
'usr_id']];
724 $row[
'language'] = $lng->getDefaultLanguage();
727 if (is_array($user_data_filter))
729 if (in_array($row[
"usr_id"], $user_data_filter)) array_push(
$data, $row);
733 array_push(
$data, $row);
741 case "userfolder_export_excel_x86":
744 case "userfolder_export_csv":
747 case "userfolder_export_xml":
768 if(!is_writable($usrf_data_dir))
770 $this->ilias->raiseError(
"Userfolder data directory (".$usrf_data_dir
771 .
") not writeable.",$this->ilias->error_obj->MESSAGE);
775 $export_dir = $usrf_data_dir.
"/export";
777 if(!@is_dir($export_dir))
779 $this->ilias->raiseError(
"Creation of Userfolder Export Directory failed.",$this->ilias->error_obj->MESSAGE);
792 include_once(
"./Services/User/classes/class.ilUserProfile.php");
794 $up->skipField(
"username");
795 $up->skipField(
"roles");
796 $up->skipGroup(
"preferences");
797 $fds =
$up->getStandardFields();
798 foreach ($fds as $k =>
$f)
800 $profile_fields[] = $k;
803 return $profile_fields;
810 if(self::_lookupNewAccountMail($a_lang))
813 'subject' => array(
'text',$a_subject),
814 'body' => array(
'clob',$a_body),
815 'sal_g' => array(
'text',$a_sal_g),
816 'sal_f' => array(
'text',$a_sal_f),
817 'sal_m' => array(
'text',$a_sal_m)
819 $ilDB->update(
'mail_template',
821 array(
'lang' => array(
'text',$a_lang),
'type' => array(
'text',
'nacc'))
827 'subject' => array(
'text',$a_subject),
828 'body' => array(
'clob',$a_body),
829 'sal_g' => array(
'text',$a_sal_g),
830 'sal_f' => array(
'text',$a_sal_f),
831 'sal_m' => array(
'text',$a_sal_m),
832 'lang' => array(
'text',$a_lang),
833 'type' => array(
'text',
'nacc')
835 $ilDB->insert(
'mail_template',$values);
843 $set = $ilDB->query(
"SELECT * FROM mail_template ".
844 " WHERE type='nacc' AND lang = ".$ilDB->quote($a_lang,
'text'));
868 $query =
"UPDATE usr_data SET time_limit_owner = ".$ilDB->quote($a_new_id,
"integer").
" ".
869 "WHERE time_limit_owner = ".$ilDB->quote($a_old_id,
"integer").
" ";
870 $ilDB->manipulate(
$query);