14require_once 
"./Services/Object/classes/class.ilObject.php";
 
   16define(
'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());
 
  184                include_once 
'./Services/User/classes/class.ilUserDefinedFields.php';
 
  187                $udf_ex_fields = array();
 
  188                foreach($udf_obj->getDefinitions() as $definition)
 
  190                        if ($definition[
"export"] != FALSE)
 
  192                                $udf_ex_fields[] = array(
"name" => $definition[
"field_name"],
 
  193                                        "id" => $definition[
"field_id"]);
 
  197                return $udf_ex_fields;
 
  204                $headerrow = array();
 
  206                foreach ($settings as $value)   
 
  208                        array_push($headerrow, $this->lng->txt($value));
 
  210                foreach ($udf_ex_fields as $f)  
 
  212                        array_push($headerrow, $f[
"name"]);
 
  222                        foreach ($settings as $header)  
 
  225                                if(is_array(
$row[$header]))
 
  227                                        $row[$header] = implode(
", ", 
$row[$header]);
 
  230                                array_push($csvrow, 
$row[$header]);
 
  234                        reset($udf_ex_fields);
 
  235                        if (count($udf_ex_fields) > 0)
 
  237                                include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
 
  239                                foreach ($udf_ex_fields as $f)  
 
  241                                        array_push($csvrow, $udf->get(
"f_".$f[
"id"]));
 
  253                include_once 
"./Services/Excel/classes/class.ilExcelUtils.php";
 
  254                include_once 
"./Services/Excel/classes/class.ilExcelWriterAdapter.php";
 
  256                $workbook = $adapter->getWorkbook();
 
  258                $format_bold =& $workbook->addFormat();
 
  259                $format_bold->setBold();
 
  260                $format_percent =& $workbook->addFormat();
 
  261                $format_percent->setNumFormat(
"0.00%");
 
  262                $format_datetime =& $workbook->addFormat();
 
  263                $format_datetime->setNumFormat(
"DD/MM/YYYY hh:mm:ss");
 
  264                $format_title =& $workbook->addFormat();
 
  265                $format_title->setBold();
 
  266                $format_title->setColor(
'black');
 
  267                $format_title->setPattern(1);
 
  268                $format_title->setFgColor(
'silver');
 
  269                $worksheet =& $workbook->addWorksheet();
 
  276                foreach ($settings as $value)   
 
  278                        if($value == 
'ext_account')
 
  280                                $value = 
'user_ext_account';
 
  285                foreach ($udf_ex_fields as $f)  
 
  291                $this->lng->loadLanguageModule(
"meta");
 
  292                foreach (
$data as $index => $rowdata)
 
  298                        foreach ($settings as $fieldname)
 
  300                                $value = $rowdata[$fieldname];
 
  306                                        case "time_limit_from":
 
  307                                        case "time_limit_until":
 
  308                                                $date = strftime(
"%Y-%m-%d %H:%M:%S", $value);
 
  309                                                if (preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $date, $matches))
 
  311                                                        $worksheet->write(
$row, $col, 
ilUtil::excelTime($matches[1],$matches[2],$matches[3],$matches[4],$matches[5],$matches[6]), $format_datetime);
 
  319                                                if (preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $value, $matches))
 
  321                                                        $worksheet->write(
$row, $col, 
ilUtil::excelTime($matches[1],$matches[2],$matches[3],$matches[4],$matches[5],$matches[6]), $format_datetime);
 
  325                                        case "interests_general":
 
  326                                        case "interests_help_offered":
 
  327                                        case "interests_help_looking":
 
  328                                                if(is_array($value) && 
sizeof($value))
 
  330                                                        $value = implode(
", ", $value);
 
  346                        reset($udf_ex_fields);
 
  347                        if (count($udf_ex_fields) > 0)
 
  349                                include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
 
  351                                foreach ($udf_ex_fields as $f)  
 
  370                $db_settings = array();
 
  372                include_once(
"./Services/User/classes/class.ilUserProfile.php");
 
  374                $up->skipField(
"roles");
 
  375                $profile_fields = $up->getStandardFields();
 
  380                $query = 
"SELECT * FROM settings WHERE ".
 
  381                        $ilDB->like(
"keyword", 
"text", 
'%usr_settings_export_%');
 
  385                        if (
$row[
"value"] == 
"1")
 
  387                                if (preg_match(
"/usr_settings_export_(.*)/", 
$row[
"keyword"], $setting))
 
  389                                        array_push($db_settings, $setting[1]);
 
  393                $export_settings = array();
 
  394                foreach ($profile_fields as $key => $value)
 
  396                        if (in_array($key, $db_settings))
 
  398                                if (strcmp($key, 
"password") == 0)
 
  405                                        array_push($export_settings, $key);
 
  409                array_push($export_settings, 
"usr_id");
 
  410                array_push($export_settings, 
"login");
 
  411                array_push($export_settings, 
"last_login");
 
  412                array_push($export_settings, 
"last_update");
 
  413                array_push($export_settings, 
"create_date");
 
  414                array_push($export_settings, 
"time_limit_owner");
 
  415                array_push($export_settings, 
"time_limit_unlimited");
 
  416                array_push($export_settings, 
"time_limit_from");
 
  417                array_push($export_settings, 
"time_limit_until");
 
  418                array_push($export_settings, 
"time_limit_message");
 
  419                array_push($export_settings, 
"active");
 
  420                array_push($export_settings, 
"approve_date");
 
  421                array_push($export_settings, 
"agree_date");
 
  422                array_push($export_settings, 
"client_ip");
 
  423                array_push($export_settings, 
"auth_mode");
 
  424                array_push($export_settings, 
"ext_account");
 
  425                array_push($export_settings, 
"feedhash");
 
  427                return $export_settings;
 
  433        function buildExportFile($a_mode = 
"userfolder_export_excel_x86", $user_data_filter = FALSE)
 
  456                $query = 
"SELECT * FROM usr_pref WHERE keyword = ".$ilDB->quote(
'language',
'text');
 
  458                $languages = array();
 
  461                        $languages[
$row[
'usr_id']] = 
$row[
'value'];
 
  466                $set = 
$ilDB->query(
"SELECT * FROM usr_data_multi");
 
  469                        if(!is_array($user_data_filter) ||
 
  470                                in_array(
$row[
"usr_id"], $user_data_filter))
 
  472                                $multi[
$row[
"usr_id"]][
$row[
"field_id"]][] = 
$row[
"value"];
 
  477                $query = 
"SELECT usr_data.* FROM usr_data  ".
 
  478                        " ORDER BY usr_data.lastname, usr_data.firstname";
 
  482                        if(isset($languages[
$row[
'usr_id']]))
 
  484                                $row[
'language'] = $languages[
$row[
'usr_id']];
 
  488                                $row[
'language'] = 
$lng->getDefaultLanguage();
 
  491                        if(isset($multi[
$row[
"usr_id"]]))
 
  496                        if (is_array($user_data_filter))
 
  498                                if (in_array(
$row[
"usr_id"], $user_data_filter)) array_push(
$data, 
$row);
 
  510                        case "userfolder_export_excel_x86":
 
  513                        case "userfolder_export_csv":
 
  516                        case "userfolder_export_xml":
 
  537                        if(!is_writable($usrf_data_dir))
 
  539                                $this->
ilias->raiseError(
"Userfolder data directory (".$usrf_data_dir
 
  540                                        .
") not writeable.",$this->
ilias->error_obj->MESSAGE);
 
  544                        $export_dir = $usrf_data_dir.
"/export";
 
  546                        if(!@is_dir($export_dir))
 
  548                                $this->
ilias->raiseError(
"Creation of Userfolder Export Directory failed.",$this->
ilias->error_obj->MESSAGE);
 
  561                include_once(
"./Services/User/classes/class.ilUserProfile.php");
 
  563                $up->skipField(
"username");
 
  564                $up->skipField(
"roles");
 
  565                $up->skipGroup(
"preferences");
 
  566                $fds = $up->getStandardFields();
 
  567                foreach ($fds as $k => $f)
 
  569                        $profile_fields[] = $k;
 
  572                return $profile_fields;
 
  579                if(self::_lookupNewAccountMail($a_lang))
 
  582                                'subject'               => array(
'text',$a_subject),
 
  583                                'body'                  => array(
'clob',$a_body),
 
  584                                'sal_g'                 => array(
'text',$a_sal_g),
 
  585                                'sal_f'                 => array(
'text',$a_sal_f),
 
  586                                'sal_m'                 => array(
'text',$a_sal_m)
 
  588                        $ilDB->update(
'mail_template',
 
  590                                array(
'lang' => array(
'text',$a_lang), 
'type' => array(
'text',
'nacc'))
 
  596                                'subject'               => array(
'text',$a_subject),
 
  597                                'body'                  => array(
'clob',$a_body),
 
  598                                'sal_g'                 => array(
'text',$a_sal_g),
 
  599                                'sal_f'                 => array(
'text',$a_sal_f),
 
  600                                'sal_m'                 => array(
'text',$a_sal_m),
 
  601                                'lang'                  => array(
'text',$a_lang),
 
  602                                'type'                  => array(
'text',
'nacc')
 
  604                        $ilDB->insert(
'mail_template',$values);
 
  612                include_once 
"Services/User/classes/class.ilFSStorageUserFolder.php";
 
  615                $path = $fs->getAbsolutePath().
"/";
 
  617                move_uploaded_file($a_tmp_name, 
$path.$a_lang);         
 
  619                $ilDB->update(
'mail_template',
 
  620                                array(
'att_file' => array(
'text', $a_name)),
 
  621                                array(
'lang' => array(
'text',$a_lang), 
'type' => array(
'text',
'nacc')));
 
  628                include_once 
"Services/User/classes/class.ilFSStorageUserFolder.php";
 
  630                $path = $fs->getAbsolutePath().
"/";
 
  632                @unlink(
$path.$a_lang);
 
  634                $ilDB->update(
'mail_template',
 
  635                                array(
'att_file' => array(
'text', 
'')),
 
  636                                array(
'lang' => array(
'text',$a_lang), 
'type' => array(
'text',
'nacc')));
 
  643                $set = 
$ilDB->query(
"SELECT * FROM mail_template ".
 
  644                        " WHERE type='nacc' AND lang = ".
$ilDB->quote($a_lang,
'text'));
 
  668                $query = 
"UPDATE usr_data SET time_limit_owner = ".$ilDB->quote($a_new_id, 
"integer").
" ".
 
  669                        "WHERE time_limit_owner = ".$ilDB->quote($a_old_id, 
"integer").
" ";
 
_convert_text($a_text, $a_target="has been removed")
Class ilExcelWriterAdapter.
createExportDirectory()
creates data directory for export files (data_dir/usrf_data/export, depending on data directory that ...
_lookupNewAccountMail($a_lang)
_deleteAccountMailAttachment($a_lang)
_updateAccountMailAttachment($a_lang, $a_tmp_name, $a_name)
getUserDefinedExportFields()
Get all exportable user defined fields.
_writeNewAccountMail($a_lang, $a_subject, $a_sal_g, $a_sal_f, $a_sal_m, $a_body)
getExportFilename($a_mode="userfolder_export_excel_x86")
ilObjUserFolder($a_id, $a_call_by_reference=true)
Constructor @access public.
createExcelExport(&$settings, &$data, $filename, $a_mode)
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)
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.
ilObject($a_id=0, $a_reference=true)
Constructor @access public.
getId()
get object id @access public
static _getInstance()
Get instance.
static getDataDir()
get data directory (outside webspace)
static excelTime($year="", $month="", $day="", $hour="", $minute="", $second="")
Calculates a Microsoft Excel date/time value.
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)