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_%');
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";
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);
801 $profile_fields = array(
828 "instant_messengers",
829 "hide_own_online_status",
833 return $profile_fields;
840 if(self::_lookupNewAccountMail($a_lang))
843 'subject' => array(
'text',$a_subject),
844 'body' => array(
'clob',$a_body),
845 'sal_g' => array(
'text',$a_sal_g),
846 'sal_f' => array(
'text',$a_sal_f),
847 'sal_m' => array(
'text',$a_sal_m)
849 $ilDB->update(
'mail_template',
851 array(
'lang' => array(
'text',$a_lang),
'type' => array(
'text',
'nacc'))
857 'subject' => array(
'text',$a_subject),
858 'body' => array(
'clob',$a_body),
859 'sal_g' => array(
'text',$a_sal_g),
860 'sal_f' => array(
'text',$a_sal_f),
861 'sal_m' => array(
'text',$a_sal_m),
862 'lang' => array(
'text',$a_lang),
863 'type' => array(
'text',
'nacc')
865 $ilDB->insert(
'mail_template',$values);
873 $set = $ilDB->query(
"SELECT * FROM mail_template ".
874 " WHERE type='nacc' AND lang = ".$ilDB->quote($a_lang,
'text'));
898 $query =
"UPDATE usr_data SET time_limit_owner = ".$ilDB->quote($a_new_id,
"integer").
" ".
899 "WHERE time_limit_owner = ".$ilDB->quote($a_old_id,
"integer").
" ";
900 $ilDB->manipulate(
$query);