14require_once 
"./Services/Object/classes/class.ilObject.php";
 
   16define(
'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';
 
  163        if (is_array(
$data)) {
 
  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()) {
 
  172                fwrite($file, $xmlWriter->getXML());
 
  183        include_once 
'./Services/User/classes/class.ilUserDefinedFields.php';
 
  186        $udf_ex_fields = array();
 
  187        foreach ($udf_obj->getDefinitions() as $definition) {
 
  188            if ($definition[
"export"] != 
false) {
 
  189                $udf_ex_fields[] = array(
"name" => $definition[
"field_name"],
 
  190                    "id" => $definition[
"field_id"]);
 
  194        return $udf_ex_fields;
 
  201        $headerrow = array();
 
  203        foreach ($settings as $value) { 
 
  204            array_push($headerrow, $this->lng->txt($value));
 
  206        foreach ($udf_ex_fields as 
$f) {        
 
  207            array_push($headerrow, 
$f[
"name"]);
 
  213        fwrite($file, join($separator, $formattedrow) . 
"\n");
 
  216            foreach ($settings as 
$header) {    
 
  226            reset($udf_ex_fields);
 
  227            if (count($udf_ex_fields) > 0) {
 
  228                include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
 
  230                foreach ($udf_ex_fields as 
$f) {        
 
  231                    array_push($csvrow, $udf->get(
"f_" . 
$f[
"id"]));
 
  236            fwrite($file, join($separator, $formattedrow) . 
"\n");
 
  243        include_once 
"./Services/Excel/classes/class.ilExcel.php";
 
  245        $worksheet->addSheet($this->lng->txt(
"users"));
 
  253        foreach ($settings as $value) { 
 
  254            if ($value == 
'ext_account') {
 
  255                $value = 
'user_ext_account';
 
  257            $worksheet->setCell(
$row, $col, $this->lng->txt($value));
 
  260        foreach ($udf_ex_fields as 
$f) {        
 
  261            $worksheet->setCell(
$row, $col, 
$f[
"name"]);
 
  264        $worksheet->setBold(
"A1:" . $worksheet->getColumnCoord($col - 1) . 
"1");
 
  266        $this->lng->loadLanguageModule(
"meta");
 
  272            foreach ($settings as $fieldname) {
 
  273                $value = $rowdata[$fieldname];
 
  274                switch ($fieldname) {
 
  276                        $worksheet->setCell(
$row, $col, $this->lng->txt(
"meta_l_" . $value));
 
  278                    case "time_limit_from":
 
  279                    case "time_limit_until":
 
  283                        $worksheet->setCell(
$row, $col, $value);
 
  293                        $worksheet->setCell(
$row, $col, $value);
 
  296                    case "interests_general":
 
  297                    case "interests_help_offered":
 
  298                    case "interests_help_looking":
 
  299                        if (is_array($value) && 
sizeof($value)) {
 
  300                            $value = implode(
", ", $value);
 
  308                        $worksheet->setCell(
$row, $col, $value);
 
  315            reset($udf_ex_fields);
 
  316            if (count($udf_ex_fields) > 0) {
 
  317                include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
 
  319                foreach ($udf_ex_fields as 
$f) {        
 
  320                    $worksheet->setCell(
$row, $col, $udf->get(
"f_" . 
$f[
"id"]));
 
  340        $db_settings = array();
 
  342        include_once(
"./Services/User/classes/class.ilUserProfile.php");
 
  344        $up->skipField(
"roles");
 
  345        $profile_fields = $up->getStandardFields();
 
  350        $query = 
"SELECT * FROM settings WHERE " .
 
  351            $ilDB->like(
"keyword", 
"text", 
'%usr_settings_export_%');
 
  354            if (
$row[
"value"] == 
"1") {
 
  355                if (preg_match(
"/usr_settings_export_(.*)/", 
$row[
"keyword"], $setting)) {
 
  356                    array_push($db_settings, $setting[1]);
 
  360        $export_settings = array();
 
  361        foreach ($profile_fields as 
$key => $value) {
 
  362            if (in_array(
$key, $db_settings)) {
 
  363                if (strcmp(
$key, 
"password") == 0) {
 
  367                    array_push($export_settings, 
$key);
 
  371        array_push($export_settings, 
"usr_id");
 
  372        array_push($export_settings, 
"login");
 
  373        array_push($export_settings, 
"last_login");
 
  374        array_push($export_settings, 
"last_update");
 
  375        array_push($export_settings, 
"create_date");
 
  376        array_push($export_settings, 
"time_limit_owner");
 
  377        array_push($export_settings, 
"time_limit_unlimited");
 
  378        array_push($export_settings, 
"time_limit_from");
 
  379        array_push($export_settings, 
"time_limit_until");
 
  380        array_push($export_settings, 
"time_limit_message");
 
  381        array_push($export_settings, 
"active");
 
  382        array_push($export_settings, 
"approve_date");
 
  383        array_push($export_settings, 
"agree_date");
 
  384        array_push($export_settings, 
"client_ip");
 
  385        array_push($export_settings, 
"auth_mode");
 
  386        array_push($export_settings, 
"ext_account");
 
  387        array_push($export_settings, 
"feedhash");
 
  388        return $export_settings;
 
  394    public function buildExportFile($a_mode = 
"userfolder_export_excel_x86", $user_data_filter = 
false)
 
  407        $ilias = 
$DIC[
'ilias'];
 
  427        $query = 
"SELECT * FROM usr_pref WHERE keyword = " . 
$ilDB->quote(
'language', 
'text');
 
  436        $set = 
$ilDB->query(
"SELECT * FROM usr_data_multi");
 
  438            if (!is_array($user_data_filter) ||
 
  439                in_array(
$row[
"usr_id"], $user_data_filter)) {
 
  440                $multi[
$row[
"usr_id"]][
$row[
"field_id"]][] = 
$row[
"value"];
 
  445        $query = 
"SELECT usr_data.* FROM usr_data  " .
 
  446            " ORDER BY usr_data.lastname, usr_data.firstname";
 
  452                $row[
'language'] = 
$lng->getDefaultLanguage();
 
  455            if (isset($multi[
$row[
"usr_id"]])) {
 
  459            if (is_array($user_data_filter)) {
 
  460                if (in_array(
$row[
"usr_id"], $user_data_filter)) {
 
  471            case "userfolder_export_excel_x86":
 
  474            case "userfolder_export_csv":
 
  477            case "userfolder_export_xml":
 
  497            if (!is_writable($usrf_data_dir)) {
 
  498                $this->
ilias->raiseError(
"Userfolder data directory (" . $usrf_data_dir
 
  499                    . 
") not writeable.", $this->
ilias->error_obj->MESSAGE);
 
  503            $export_dir = $usrf_data_dir . 
"/export";
 
  505            if (!@is_dir($export_dir)) {
 
  506                $this->
ilias->raiseError(
"Creation of Userfolder Export Directory failed.", $this->
ilias->error_obj->MESSAGE);
 
  519        include_once(
"./Services/User/classes/class.ilUserProfile.php");
 
  521        $up->skipField(
"username");
 
  522        $up->skipField(
"roles");
 
  523        $up->skipGroup(
"preferences");
 
  524        $fds = $up->getStandardFields();
 
  525        foreach ($fds as $k => 
$f) {
 
  526            $profile_fields[] = $k;
 
  529        return $profile_fields;
 
  538        if (self::_lookupNewAccountMail($a_lang)) {
 
  540                'subject' => array(
'text',$a_subject),
 
  541                'body' => array(
'clob',$a_body),
 
  542                'sal_g' => array(
'text',$a_sal_g),
 
  543                'sal_f' => array(
'text',$a_sal_f),
 
  544                'sal_m' => array(
'text',$a_sal_m)
 
  549                array(
'lang' => array(
'text',$a_lang), 
'type' => array(
'text',
'nacc'))
 
  553                'subject' => array(
'text',$a_subject),
 
  554                'body' => array(
'clob',$a_body),
 
  555                'sal_g' => array(
'text',$a_sal_g),
 
  556                'sal_f' => array(
'text',$a_sal_f),
 
  557                'sal_m' => array(
'text',$a_sal_m),
 
  558                'lang' => array(
'text',$a_lang),
 
  559                'type' => array(
'text',
'nacc')
 
  578        include_once 
"Services/User/classes/class.ilFSStorageUserFolder.php";
 
  581        $path = $fs->getAbsolutePath() . 
"/";
 
  583        ilUtil::moveUploadedFile($a_tmp_name, $a_lang, 
$path . $a_lang);
 
  587            array(
'att_file' => array(
'text', $a_name)),
 
  588            array(
'lang' => array(
'text',$a_lang), 
'type' => array(
'text',
'nacc'))
 
  602        include_once 
"Services/User/classes/class.ilFSStorageUserFolder.php";
 
  604        $path = $fs->getAbsolutePath() . 
"/";
 
  606        if (file_exists(
$path . $a_lang)) {
 
  607            unlink(
$path . $a_lang);
 
  612            array(
'att_file' => array(
'text', 
'')),
 
  613            array(
'lang' => array(
'text',$a_lang), 
'type' => array(
'text',
'nacc'))
 
  623        $set = 
$ilDB->query(
"SELECT * FROM mail_template " .
 
  624            " WHERE type='nacc' AND lang = " . 
$ilDB->quote($a_lang, 
'text'));
 
  649        $query = 
"UPDATE usr_data SET time_limit_owner = " . 
$ilDB->quote($a_new_id, 
"integer") . 
" " .
 
  650            "WHERE time_limit_owner = " . 
$ilDB->quote($a_old_id, 
"integer") . 
" ";
 
An exception for terminatinating execution or to throw for unit testing.
const USER_FOLDER_ID
Class ilObjUserFolder.
@classDescription Date and time handling
static _deleteAccountMailAttachment($a_lang)
Delete account mail attachment.
createExportDirectory()
creates data directory for export files (data_dir/usrf_data/export, depending on data directory that ...
getUserDefinedExportFields()
Get all exportable user defined fields.
getExportFilename($a_mode="userfolder_export_excel_x86")
createExcelExport(&$settings, &$data, $filename)
__construct($a_id, $a_call_by_reference=true)
Constructor @access public.
static _updateAccountMailAttachment($a_lang, $a_tmp_name, $a_name)
Update account mail attachment.
createCSVExport(&$settings, &$data, $filename)
buildExportFile($a_mode="userfolder_export_excel_x86", $user_data_filter=false)
build xml export file
createXMLExport(&$settings, &$data, $filename)
static _updateUserFolderAssignment($a_old_id, $a_new_id)
Update user folder assignment Typically called after deleting a category with local user accounts.
static getExportSettings()
getExport Settings
static & getProfileFields()
Get profile fields (DEPRECATED, use ilUserProfile() instead)
static _writeNewAccountMail($a_lang, $a_subject, $a_sal_g, $a_sal_f, $a_sal_m, $a_body)
static _lookupNewAccountMail($a_lang)
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.
Class ilObject Basic functions for all objects.
static _getInstance()
Get instance.
static getDataDir()
get data directory (outside webspace)
static & processCSVRow(&$row, $quoteAll=false, $separator=";", $outUTF8=false, $compatibleWithMSExcel=true)
Convertes an array for CSV usage.
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
redirection script todo: (a better solution should control the processing via a xml file)
foreach($_POST as $key=> $value) $res