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"]);
489 foreach ($data as
$row)
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)
542 if($value ==
'ext_account')
544 $value =
'user_ext_account';
549 foreach ($udf_ex_fields as $f)
555 $this->lng->loadLanguageModule(
"meta");
556 foreach ($data as $index => $rowdata)
562 foreach ($settings as $fieldname)
564 $value = $rowdata[$fieldname];
570 case "time_limit_from":
571 case "time_limit_until":
572 $date = strftime(
"%Y-%m-%d %H:%M:%S", $value);
573 if (preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $date, $matches))
575 $worksheet->write(
$row, $col,
ilUtil::excelTime($matches[1],$matches[2],$matches[3],$matches[4],$matches[5],$matches[6]), $format_datetime);
583 if (preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $value, $matches))
585 $worksheet->write(
$row, $col,
ilUtil::excelTime($matches[1],$matches[2],$matches[3],$matches[4],$matches[5],$matches[6]), $format_datetime);
596 reset($udf_ex_fields);
597 if (count($udf_ex_fields) > 0)
599 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
601 foreach ($udf_ex_fields as $f)
620 $db_settings = array();
622 include_once(
"./Services/User/classes/class.ilUserProfile.php");
624 $up->skipField(
"roles");
625 $profile_fields = $up->getStandardFields();
630 $query =
"SELECT * FROM settings WHERE ".
631 $ilDB->like(
"keyword",
"text",
'%usr_settings_export_%');
635 if (
$row[
"value"] ==
"1")
637 if (preg_match(
"/usr_settings_export_(.*)/",
$row[
"keyword"], $setting))
639 array_push($db_settings, $setting[1]);
643 $export_settings = array();
644 foreach ($profile_fields as $key => $value)
646 if (in_array($key, $db_settings))
648 if (strcmp($key,
"password") == 0)
650 array_push($export_settings,
"passwd");
654 array_push($export_settings, $key);
658 array_push($export_settings,
"login");
659 array_push($export_settings,
"last_login");
660 array_push($export_settings,
"last_update");
661 array_push($export_settings,
"create_date");
662 array_push($export_settings,
"i2passwd");
663 array_push($export_settings,
"time_limit_owner");
664 array_push($export_settings,
"time_limit_unlimited");
665 array_push($export_settings,
"time_limit_from");
666 array_push($export_settings,
"time_limit_until");
667 array_push($export_settings,
"time_limit_message");
668 array_push($export_settings,
"active");
669 array_push($export_settings,
"approve_date");
670 array_push($export_settings,
"agree_date");
671 array_push($export_settings,
"ilinc_id");
672 array_push($export_settings,
"ilinc_login");
673 array_push($export_settings,
"ilinc_passwd");
674 array_push($export_settings,
"client_ip");
675 array_push($export_settings,
"auth_mode");
676 array_push($export_settings,
"ext_account");
677 array_push($export_settings,
"feedhash");
679 return $export_settings;
685 function buildExportFile($a_mode =
"userfolder_export_excel_x86", $user_data_filter = FALSE)
708 $query =
"SELECT * FROM usr_pref WHERE keyword = ".$ilDB->quote(
'language',
'text');
710 $languages = array();
713 $languages[
$row[
'usr_id']] = $row[
'value'];
718 $query =
"SELECT usr_data.* FROM usr_data ".
719 " ORDER BY usr_data.lastname, usr_data.firstname";
723 if(isset($languages[
$row[
'usr_id']]))
725 $row[
'language'] = $languages[$row[
'usr_id']];
729 $row[
'language'] = $lng->getDefaultLanguage();
732 if (is_array($user_data_filter))
734 if (in_array($row[
"usr_id"], $user_data_filter)) array_push($data, $row);
738 array_push($data, $row);
746 case "userfolder_export_excel_x86":
749 case "userfolder_export_csv":
752 case "userfolder_export_xml":
773 if(!is_writable($usrf_data_dir))
775 $this->ilias->raiseError(
"Userfolder data directory (".$usrf_data_dir
776 .
") not writeable.",$this->ilias->error_obj->MESSAGE);
780 $export_dir = $usrf_data_dir.
"/export";
782 if(!@is_dir($export_dir))
784 $this->ilias->raiseError(
"Creation of Userfolder Export Directory failed.",$this->ilias->error_obj->MESSAGE);
797 include_once(
"./Services/User/classes/class.ilUserProfile.php");
799 $up->skipField(
"username");
800 $up->skipField(
"roles");
801 $up->skipGroup(
"preferences");
802 $fds = $up->getStandardFields();
803 foreach ($fds as $k => $f)
805 $profile_fields[] = $k;
808 return $profile_fields;
815 if(self::_lookupNewAccountMail($a_lang))
818 'subject' => array(
'text',$a_subject),
819 'body' => array(
'clob',$a_body),
820 'sal_g' => array(
'text',$a_sal_g),
821 'sal_f' => array(
'text',$a_sal_f),
822 'sal_m' => array(
'text',$a_sal_m)
824 $ilDB->update(
'mail_template',
826 array(
'lang' => array(
'text',$a_lang),
'type' => array(
'text',
'nacc'))
832 'subject' => array(
'text',$a_subject),
833 'body' => array(
'clob',$a_body),
834 'sal_g' => array(
'text',$a_sal_g),
835 'sal_f' => array(
'text',$a_sal_f),
836 'sal_m' => array(
'text',$a_sal_m),
837 'lang' => array(
'text',$a_lang),
838 'type' => array(
'text',
'nacc')
840 $ilDB->insert(
'mail_template',$values);
848 include_once
"Services/User/classes/class.ilFSStorageUserFolder.php";
851 $path = $fs->getAbsolutePath().
"/";
853 move_uploaded_file($a_tmp_name,
$path.$a_lang);
855 $ilDB->update(
'mail_template',
856 array(
'att_file' => array(
'text', $a_name)),
857 array(
'lang' => array(
'text',$a_lang),
'type' => array(
'text',
'nacc')));
864 include_once
"Services/User/classes/class.ilFSStorageUserFolder.php";
866 $path = $fs->getAbsolutePath().
"/";
868 @unlink(
$path.$a_lang);
870 $ilDB->update(
'mail_template',
871 array(
'att_file' => array(
'text',
'')),
872 array(
'lang' => array(
'text',$a_lang),
'type' => array(
'text',
'nacc')));
879 $set = $ilDB->query(
"SELECT * FROM mail_template ".
880 " WHERE type='nacc' AND lang = ".$ilDB->quote($a_lang,
'text'));
904 $query =
"UPDATE usr_data SET time_limit_owner = ".$ilDB->quote($a_new_id,
"integer").
" ".
905 "WHERE time_limit_owner = ".$ilDB->quote($a_old_id,
"integer").
" ";
906 $ilDB->manipulate(
$query);