• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

classes/class.ilObjUserFolder.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 
00035 require_once "class.ilObject.php";
00036 
00037 class ilObjUserFolder extends ilObject
00038 {
00045         function ilObjUserFolder($a_id,$a_call_by_reference = true)
00046         {
00047                 $this->type = "usrf";
00048                 $this->ilObject($a_id,$a_call_by_reference);
00049         }
00050 
00057         function ilClone($a_parent_ref)
00058         {               
00059                 // DISABLED
00060                 return false;
00061 
00062                 global $rbacadmin;
00063 
00064                 // always call parent ilClone function first!!
00065                 $new_ref_id = parent::ilClone($a_parent_ref);
00066                 
00067                 // put here userfolder specific stuff
00068 
00069                 // ... and finally always return new reference ID!!
00070                 return $new_ref_id;
00071         }
00072 
00079         function delete()
00080         {               
00081                 // DISABLED
00082                 return false;
00083 
00084                 // always call parent delete function first!!
00085                 if (!parent::delete())
00086                 {
00087                         return false;
00088                 }
00089                 // put here userfolder specific stuff
00090                 
00091                 // always call parent delete function at the end!!
00092                 return true;
00093         }
00094         
00095 
00096         function getExportFilename($a_mode = "userfolder_export_excel_x86")
00097         {
00098                 $filename = "";
00099                 //$settings = $this->ilias->getAllSettings();
00100                 //$this->inst_id = $settings["inst_id"];
00101                 $inst_id = IL_INST_ID;
00102 
00103                 $date = time();
00104 
00105                 switch($a_mode)
00106                 {
00107                         case "userfolder_export_excel_x86":                             
00108                                 $filename = $date."__".$inst_id."__x86_usrf.xls";
00109                                 break;
00110                         case "userfolder_export_excel_ppc":                             
00111                                 $filename = $date."__".$inst_id."__ppc_usrf.xls";
00112                                 break;
00113                         case "userfolder_export_csv":                           
00114                                 $filename = $date."__".$inst_id."__csv_usrf.csv";
00115                                 break;
00116                         case "userfolder_export_xml":
00117                                 $filename = $date."__".$inst_id."__xml_usrf.xml";
00118                                 break;
00119                 }
00120                 return $filename;
00121         }
00122         
00123         
00131         function getExportDirectory()
00132         {
00133                 $export_dir = ilUtil::getDataDir()."/usrf_data/export";
00134 
00135                 return $export_dir;
00136         }
00137 
00146         function getExportFiles()
00147         {
00148                 $dir = $this->getExportDirectory();
00149                 
00150                 // quit if export dir not available
00151                 if (!@is_dir($dir) or
00152                         !is_writeable($dir))
00153                 {
00154                         return array();
00155                 }
00156 
00157                 // open directory
00158                 $dir = dir($dir);
00159 
00160                 // initialize array
00161                 $file = array();
00162 
00163                 // get files and save the in the array
00164                 while ($entry = $dir->read())
00165                 {
00166                         if ($entry != "." and
00167                                 $entry != ".." and
00168                                 preg_match("/^[0-9]{10}_{2}[0-9]+_{2}([a-z0-9]{3})_usrf\.[a-z]{1,3}\$/", $entry, $matches))
00169                         {
00170                                 $filearray["filename"] = $entry;
00171                                 $filearray["filesize"] = filesize($this->getExportDirectory()."/".$entry);
00172                                 array_push($file, $filearray);
00173                         }
00174                 }
00175 
00176                 // close import directory
00177                 $dir->close();
00178 
00179                 // sort files
00180                 sort ($file);
00181                 reset ($file);
00182 
00183                 return $file;
00184         }
00185         
00186         function escapeXML($value)
00187         {
00188                 $value = str_replace("&", "&amp;", $value);
00189                 $value = str_replace("<", "&lt;", $value);
00190                 $value = str_replace(">", "&gt;", $value);
00191                 return $value;
00192         }
00193 
00194         function createXMLExport(&$settings, &$data, $filename)
00195         {
00196                 global $rbacreview;
00197                 global $ilDB;
00198                 global $log;
00199                 
00200                 $file = fopen($filename, "w");
00201                 fwrite($file, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
00202                 fwrite($file, "<!DOCTYPE Users SYSTEM \"ilias_user_0_2.dtd\">\n");
00203                 fwrite($file, "<Users>\n");
00204                 foreach ($data as $row) 
00205                 {
00206                         //$log->write(date("[y-m-d H:i:s] ")."User data export: processing user " . $row["login"]);
00207                         foreach ($row as $key => $value)
00208                         {
00209                                 $row[$key] = $this->escapeXML($value);
00210                         }
00211                         $userline = "";
00212                         // TODO: Define combobox for "Action" ???
00213                         if (strlen($row["language"]) == 0) $row["language"] = "en";
00214                         $userline .= "<User Id=\"".$row["usr_id"]."\" Language=\"".$row["language"]."\" Action=\"Insert\">\n";
00215                         if (array_search("login", $settings) !== FALSE)
00216                         {
00217                                 $userline .= "<Login>".$row["login"]."</Login>\n";
00218                         }
00219                         // Alternative way to get the roles of a user?
00220                         $query = sprintf("SELECT object_data.title, rbac_fa.* FROM object_data, rbac_ua, rbac_fa WHERE rbac_ua.usr_id = %s AND rbac_ua.rol_id = rbac_fa.rol_id AND object_data.obj_id = rbac_fa.rol_id",
00221                                 $ilDB->quote($row["usr_id"])
00222                         );
00223                         $rbacresult = $ilDB->query($query);
00224                         while ($rbacrow = $rbacresult->fetchRow(DB_FETCHMODE_ASSOC))
00225                         {
00226                                 $type = "";
00227                                 if ($rbacrow["assign"] == "y")
00228                                 {
00229                                         if ($rbacrow["parent"] == ROLE_FOLDER_ID)
00230                                         {
00231                                                 $type = "Global";
00232                                         }
00233                                         else
00234                                         {
00235                                                 $type = "Local";
00236                                         }
00237                                         if (strlen($type))
00238                                         {
00239                                                 $userline .= "<Role Id=\"".$rbacrow["rol_id"]."\" Type=\"".$type."\">".$rbacrow["title"]."</Role>\n";
00240                                         }
00241                                 }
00242                         }
00243                         //$log->write(date("[y-m-d H:i:s] ")."User data export: get all roles");
00244                         /* the export of roles is to expensive. on a system with 6000 users the following
00245                            section needs 37 seconds
00246                                  
00247                         $roles = $rbacreview->getRolesByFilter(1, $row["usr_id"]);
00248                         $ass_roles = $rbacreview->assignedRoles($row["usr_id"]);
00249                         foreach ($roles as $role)
00250                         {
00251                                 if (array_search($role["obj_id"], $ass_roles) !== FALSE)
00252                                 {
00253                                         $type = "";
00254                                         switch ($role["role_type"])
00255                                         {
00256                                                 case "global":
00257                                                         $type = "Global";
00258                                                         break;
00259                                                 case "local":
00260                                                         $type = "Local";
00261                                                         break;
00262                                         }
00263                                         if (strlen($type))
00264                                         {
00265                                                 $userline .= "<Role Id=\"".$role["obj_id"]."\" Type=\"".$type."\">".$role["title"]."</Role>\n";
00266                                         }
00267                                 }
00268                         }
00269                         */
00270                         //$log->write(date("[y-m-d H:i:s] ")."User data export: got all roles");
00271                         $i2passwd = FALSE;
00272                         if (array_search("i2passwd", $settings) !== FALSE)
00273                         {
00274                                 if (strlen($row["i2passwd"])) $i2passwd = TRUE;
00275                                 if ($i2passwd) $userline .= "<Password Type=\"ILIAS2\">".$row["i2passwd"]."</Password>\n";
00276                         }
00277                         if ((!$i2passwd) && (array_search("passwd", $settings) !== FALSE))
00278                         {
00279                                 if (strlen($row["passwd"])) $userline .= "<Password Type=\"ILIAS3\">".$row["passwd"]."</Password>\n";
00280                         }
00281                         if (array_search("firstname", $settings) !== FALSE)
00282                         {
00283                                 if (strlen($row["firstname"])) $userline .= "<Firstname>".$row["firstname"]."</Firstname>\n";
00284                         }
00285                         if (array_search("lastname", $settings) !== FALSE)
00286                         {
00287                                 if (strlen($row["lastname"])) $userline .= "<Lastname>".$row["lastname"]."</Lastname>\n";
00288                         }
00289                         if (array_search("title", $settings) !== FALSE)
00290                         {
00291                                 if (strlen($row["title"])) $userline .= "<Title>".$row["title"]."</Title>\n";
00292                         }
00293                         if (array_search("upload", $settings) !== FALSE)
00294                         {
00295                                 // personal picture
00296                                 $q = sprintf("SELECT value FROM usr_pref WHERE usr_id=%s AND keyword='profile_image'", $ilDB->quote($row["usr_id"] . ""));
00297                                 $r = $ilDB->query($q);
00298                                 if ($r->numRows() == 1)
00299                                 {
00300                                         $personal_picture_data = $r->fetchRow(DB_FETCHMODE_ASSOC);
00301                                         $personal_picture = $personal_picture_data["value"];
00302                                         $webspace_dir = ilUtil::getWebspaceDir();
00303                                         $image_file = $webspace_dir."/usr_images/".$personal_picture;
00304                                         if (@is_file($image_file))
00305                                         {
00306                                                 $fh = fopen($image_file, "rb");
00307                                                 if ($fh)
00308                                                 {
00309                                                         $image_data = fread($fh, filesize($image_file));
00310                                                         fclose($fh);
00311                                                         $base64 = base64_encode($image_data);
00312                                                         $imagetype = "image/jpeg";
00313                                                         if (preg_match("/.*\.(png|gif)$/", $personal_picture, $matches))
00314                                                         {
00315                                                                 $imagetype = "image/".$matches[1];
00316                                                         }
00317                                                         $userline .= "<PersonalPicture imagetype=\"$imagetype\" encoding=\"Base64\">$base64</PersonalPicture>\n";
00318                                                 }
00319                                         }                                       
00320                                 }
00321                         }
00322                         if (array_search("gender", $settings) !== FALSE)
00323                         {
00324                                 if (strlen($row["gender"])) $userline .= "<Gender>".$row["gender"]."</Gender>\n";
00325                         }
00326                         if (array_search("email", $settings) !== FALSE)
00327                         {
00328                                 if (strlen($row["email"])) $userline .= "<Email>".$row["email"]."</Email>\n";
00329                         }
00330                         if (array_search("institution", $settings) !== FALSE)
00331                         {
00332                                 if (strlen($row["institution"])) $userline .= "<Institution>".$row["institution"]."</Institution>\n";
00333                         }
00334                         if (array_search("street", $settings) !== FALSE)
00335                         {
00336                                 if (strlen($row["street"])) $userline .= "<Street>".$row["street"]."</Street>\n";
00337                         }
00338                         if (array_search("city", $settings) !== FALSE)
00339                         {
00340                                 if (strlen($row["city"])) $userline .= "<City>".$row["city"]."</City>\n";
00341                         }
00342                         if (array_search("zipcode", $settings) !== FALSE)
00343                         {
00344                                 if (strlen($row["zipcode"])) $userline .= "<PostalCode>".$row["zipcode"]."</PostalCode>\n";
00345                         }
00346                         if (array_search("country", $settings) !== FALSE)
00347                         {
00348                                 if (strlen($row["country"])) $userline .= "<Country>".$row["country"]."</Country>\n";
00349                         }
00350                         if (array_search("phone_office", $settings) !== FALSE)
00351                         {
00352                                 if (strlen($row["phone_office"])) $userline .= "<PhoneOffice>".$row["phone_office"]."</PhoneOffice>\n";
00353                         }
00354                         if (array_search("phone_home", $settings) !== FALSE)
00355                         {
00356                                 if (strlen($row["phone_home"])) $userline .= "<PhoneHome>".$row["phone_home"]."</PhoneHome>\n";
00357                         }
00358                         if (array_search("phone_mobile", $settings) !== FALSE)
00359                         {
00360                                 if (strlen($row["phone_mobile"])) $userline .= "<PhoneMobile>".$row["phone_mobile"]."</PhoneMobile>\n";
00361                         }
00362                         if (array_search("fax", $settings) !== FALSE)
00363                         {
00364                                 if (strlen($row["fax"])) $userline .= "<Fax>".$row["fax"]."</Fax>\n";
00365                         }
00366                         if (strlen($row["hobby"])) if (array_search("hobby", $settings) !== FALSE)
00367                         {
00368                                 $userline .= "<Hobby>".$row["hobby"]."</Hobby>\n";
00369                         }
00370                         if (array_search("department", $settings) !== FALSE)
00371                         {
00372                                 if (strlen($row["department"])) $userline .= "<Department>".$row["department"]."</Department>\n";
00373                         }
00374                         if (array_search("referral_comment", $settings) !== FALSE)
00375                         {
00376                                 if (strlen($row["referral_comment"])) $userline .= "<Comment>".$row["referral_comment"]."</Comment>\n";
00377                         }
00378                         if (array_search("matriculation", $settings) !== FALSE)
00379                         {
00380                                 if (strlen($row["matriculation"])) $userline .= "<Matriculation>".$row["matriculation"]."</Matriculation>\n";
00381                         }
00382                         if (array_search("active", $settings) !== FALSE)
00383                         {
00384                                 if ($row["active"])
00385                                 {
00386                                         $userline .= "<Active>true</Active>\n";
00387                                 }
00388                                 else
00389                                 {
00390                                         $userline .= "<Active>false</Active>\n";
00391                                 }
00392                         }
00393                         if (array_search("client_ip", $settings) !== FALSE)
00394                         {
00395                                 if (strlen($row["client_ip"])) $userline .= "<ClientIP>".$row["client_ip"]."</ClientIP>\n";
00396                         }
00397                         if (array_search("time_limit_owner", $settings) !== FALSE)
00398                         {
00399                                 if (strlen($row["time_limit_owner"])) $userline .= "<TimeLimitOwner>".$row["time_limit_owner"]."</TimeLimitOwner>\n";
00400                         }
00401                         if (array_search("time_limit_unlimited", $settings) !== FALSE)
00402                         {
00403                                 if (strlen($row["time_limit_unlimited"])) $userline .= "<TimeLimitUnlimited>".$row["time_limit_unlimited"]."</TimeLimitUnlimited>\n";
00404                         }
00405                         if (array_search("time_limit_from", $settings) !== FALSE)
00406                         {
00407                                 if (strlen($row["time_limit_from"])) $userline .= "<TimeLimitFrom>".$row["time_limit_from"]."</TimeLimitFrom>\n";
00408                         }
00409                         if (array_search("time_limit_until", $settings) !== FALSE)
00410                         {
00411                                 if (strlen($row["time_limit_until"])) $userline .= "<TimeLimitUntil>".$row["time_limit_until"]."</TimeLimitUntil>\n";
00412                         }
00413                         if (array_search("time_limit_message", $settings) !== FALSE)
00414                         {
00415                                 if (strlen($row["time_limit_message"])) $userline .= "<TimeLimitMessage>".$row["time_limit_message"]."</TimeLimitMessage>\n";
00416                         }
00417                         if (array_search("approve_date", $settings) !== FALSE)
00418                         {
00419                                 if (strlen($row["approve_date"])) $userline .= "<ApproveDate>".$row["approve_date"]."</ApproveDate>\n";
00420                         }
00421                         if (array_search("agree_date", $settings) !== FALSE)
00422                         {
00423                                 if (strlen($row["agree_date"])) $userline .= "<AgreeDate>".$row["agree_date"]."</AgreeDate>\n";
00424                         }
00425                         if (array_search("ilinc_id", $settings) !== FALSE)
00426                         {
00427                                 if (strlen($row["ilinc_id"])) $userline .= "<iLincID>".$row["ilinc_id"]."</iLincID>\n";
00428                         }
00429                         if (array_search("ilinc_user", $settings) !== FALSE)
00430                         {
00431                                 if (strlen($row["ilinc_user"])) $userline .= "<iLincUser>".$row["ilinc_user"]."</iLincUser>\n";
00432                         }
00433                         if (array_search("ilinc_passwd", $settings) !== FALSE)
00434                         {
00435                                 if (strlen($row["ilinc_passwd"])) $userline .= "<iLincPasswd>".$row["ilinc_passwd"]."</iLincPasswd>\n";
00436                         }
00437                         if (array_search("auth_mode", $settings) !== FALSE)
00438                         {
00439                                 if (strlen($row["auth_mode"])) $userline .= "<AuthMode type=\"".$row["auth_mode"]."\"></AuthMode>\n";
00440                         }
00441                         $userline .= "</User>\n";
00442                         fwrite($file, $userline);
00443                 }
00444                 fwrite($file, "</Users>\n");
00445                 fclose($file);
00446         }
00447         
00448         function createCSVExport(&$settings, &$data, $filename)
00449         {
00450                 $headerrow = array();
00451                 foreach ($settings as $value)
00452                 {
00453                         array_push($headerrow, $this->lng->txt($value));
00454                 }
00455                 $separator = ";";
00456                 $file = fopen($filename, "w");
00457                 $formattedrow =& ilUtil::processCSVRow($headerrow, TRUE, $separator);
00458                 fwrite($file, join ($separator, $formattedrow) ."\n");
00459                 foreach ($data as $row) 
00460                 {
00461                         $csvrow = array();
00462                         foreach ($settings as $header)
00463                         {
00464                                 array_push($csvrow, $row[$header]);
00465                         }
00466                         $formattedrow =& ilUtil::processCSVRow($csvrow, TRUE, $separator);
00467                         fwrite($file, join ($separator, $formattedrow) ."\n");
00468                 }
00469                 fclose($file);
00470         }
00471         
00472         function createExcelExport(&$settings, &$data, $filename, $a_mode)
00473         {
00474                 include_once ("./classes/class.ilExcelUtils.php");
00475                 $result = @include_once 'Spreadsheet/Excel/Writer.php';
00476                 if (!$result)
00477                 {
00478                         include_once './classes/Spreadsheet/Excel/Writer.php';
00479                 }
00480                 // Creating a workbook
00481                 $workbook = new Spreadsheet_Excel_Writer($filename);
00482 
00483                 // sending HTTP headers
00484 //              $workbook->send($filename);
00485 
00486                 // Creating a worksheet
00487                 $format_bold =& $workbook->addFormat();
00488                 $format_bold->setBold();
00489                 $format_percent =& $workbook->addFormat();
00490                 $format_percent->setNumFormat("0.00%");
00491                 $format_datetime =& $workbook->addFormat();
00492                 $format_datetime->setNumFormat("DD/MM/YYYY hh:mm:ss");
00493                 $format_title =& $workbook->addFormat();
00494                 $format_title->setBold();
00495                 $format_title->setColor('black');
00496                 $format_title->setPattern(1);
00497                 $format_title->setFgColor('silver');
00498                 $worksheet =& $workbook->addWorksheet();
00499                 $row = 0;
00500                 $col = 0;
00501                 
00502                 foreach ($settings as $value)
00503                 {
00504                         $worksheet->write($row, $col, ilExcelUtils::_convert_text($this->lng->txt($value), $a_mode), $format_title);
00505                         $col++;
00506                 }
00507 
00508 
00509                 foreach ($data as $index => $rowdata) 
00510                 {
00511                         $row++;
00512                         $col = 0;
00513                         foreach ($settings as $fieldname)
00514                         {
00515 //                      foreach ($rowdata as $rowindex => $value)
00516 //                      {
00517                                 $value = $rowdata[$fieldname];
00518                                 switch ($fieldname)
00519                                 {
00520                                         case "language":
00521                                                 $worksheet->write($row, $col, ilExcelUtils::_convert_text($this->lng->txt("lang_".$value), $a_mode));
00522                                                 break;
00523                                         case "time_limit_from":
00524                                         case "time_limit_until":
00525                                                 $date = strftime("%Y-%m-%d %H:%M:%S", $value);
00526                                                 if (preg_match("/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $date, $matches))
00527                                                 {
00528                                                         $worksheet->write($row, $col, ilUtil::excelTime($matches[1],$matches[2],$matches[3],$matches[4],$matches[5],$matches[6]), $format_datetime);
00529                                                 }
00530                                                 break;
00531                                         case "last_login":
00532                                         case "last_update":
00533                                         case "create_date":
00534                                         case "approve_date":
00535                                         case "agree_date":
00536                                                 if (preg_match("/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $value, $matches))
00537                                                 {
00538                                                         $worksheet->write($row, $col, ilUtil::excelTime($matches[1],$matches[2],$matches[3],$matches[4],$matches[5],$matches[6]), $format_datetime);
00539                                                 }
00540                                                 break;
00541                                         default:
00542                                                 $worksheet->write($row, $col, ilExcelUtils::_convert_text($value, $a_mode));
00543                                                 break;
00544                                 }
00545                                 $col++;
00546                         }
00547                 }
00548                 $workbook->close();
00549         }
00550         
00551         function getExportSettings()
00552         {
00553                 global $ilDB;
00554                 
00555                 $db_settings = array();
00556                 $profile_fields =& $this->getProfileFields();
00557                 $query = "SELECT * FROM `settings` WHERE keyword LIKE '%usr_settings_export_%' AND value = '1'";
00558                 $result = $ilDB->query($query);
00559                 while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
00560                 {
00561                         if (preg_match("/usr_settings_export_(.*)/", $row["keyword"], $setting))
00562                         {
00563                                 array_push($db_settings, $setting[1]);
00564                         }
00565                 }
00566                 $export_settings = array();
00567                 foreach ($profile_fields as $key => $value)
00568                 {
00569                         if (in_array($value, $db_settings))
00570                         {
00571                                 if (strcmp($value, "password") == 0)
00572                                 {
00573                                         array_push($export_settings, "passwd");
00574                                 }
00575                                 else
00576                                 {
00577                                         array_push($export_settings, $value);
00578                                 }
00579                         }
00580                 }
00581                 array_push($export_settings, "login");
00582                 array_push($export_settings, "last_login");
00583                 array_push($export_settings, "last_update");
00584                 array_push($export_settings, "create_date");
00585                 array_push($export_settings, "i2passwd");
00586                 array_push($export_settings, "time_limit_owner");
00587                 array_push($export_settings, "time_limit_unlimited");
00588                 array_push($export_settings, "time_limit_from");
00589                 array_push($export_settings, "time_limit_until");
00590                 array_push($export_settings, "time_limit_message");
00591                 array_push($export_settings, "active");
00592                 array_push($export_settings, "approve_date");
00593                 array_push($export_settings, "agree_date");
00594                 array_push($export_settings, "ilinc_id");
00595                 array_push($export_settings, "ilinc_user");
00596                 array_push($export_settings, "ilinc_passwd");
00597                 array_push($export_settings, "client_ip");
00598                 array_push($export_settings, "auth_mode");
00599                 return $export_settings;
00600         }
00601         
00605         function buildExportFile($a_mode = "userfolder_export_excel_x86")
00606         {
00607                 global $ilBench;
00608                 global $log;
00609                 global $ilDB;
00610                 global $ilias;
00611                 
00612                 //get Log File
00613                 $expDir = $this->getExportDirectory();
00614                 //$expLog = &$log;
00615                 //$expLog->delete();
00616                 //$expLog->setLogFormat("");
00617                 //$expLog->write(date("[y-m-d H:i:s] ")."Start export of user data");
00618 
00619                 // create export directory if needed
00620                 $this->createExportDirectory();
00621                 
00622                 //get data
00623                 //$expLog->write(date("[y-m-d H:i:s] ")."User data export: build an array of all user data entries");
00624                 $settings =& $this->getExportSettings();
00625                 $data = array();
00626                 $query = "SELECT usr_data.*, usr_pref.value AS language FROM usr_data, usr_pref WHERE usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = 'language' ORDER BY usr_data.lastname, usr_data.firstname";
00627                 $result = $ilDB->query($query);
00628                 while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
00629                 {
00630 //                      $datarow = array();
00631                         array_push($data, $row);
00632 //                      array_push($data, $datarow);
00633                 }
00634                 //$expLog->write(date("[y-m-d H:i:s] ")."User data export: build an array of all user data entries");
00635 
00636                 $fullname = $expDir."/".$this->getExportFilename($a_mode);
00637                 switch ($a_mode)
00638                 {
00639                         case "userfolder_export_excel_x86":
00640                                 $this->createExcelExport($settings, $data, $fullname, "latin1");
00641                                 break;
00642                         case "userfolder_export_excel_ppc":
00643                                 $this->createExcelExport($settings, $data, $fullname, "macos");
00644                                 break;
00645                         case "userfolder_export_csv":
00646                                 $this->createCSVExport($settings, $data, $fullname);
00647                                 break;
00648                         case "userfolder_export_xml":
00649                                 $this->createXMLExport($settings, $data, $fullname);
00650                                 break;
00651                 }
00652                 //$expLog->write(date("[y-m-d H:i:s] ")."Finished export of user data");
00653         
00654                 return $fullname;       
00655         }
00656         
00657 
00663         function createExportDirectory()
00664         {
00665                 if (!@is_dir($this->getExportDirectory()))
00666                 {
00667                         $usrf_data_dir = ilUtil::getDataDir()."/usrf_data";
00668                         ilUtil::makeDir($usrf_data_dir);
00669                         if(!is_writable($usrf_data_dir))
00670                         {
00671                                 $this->ilias->raiseError("Userfolder data directory (".$usrf_data_dir
00672                                         .") not writeable.",$this->ilias->error_obj->MESSAGE);
00673                         }
00674                         
00675                         // create Export subdirectory (data_dir/lm_data/lm_<id>/Export)
00676                         $export_dir = $usrf_data_dir."/export";
00677                         ilUtil::makeDir($export_dir);
00678                         if(!@is_dir($export_dir))
00679                         {
00680                                 $this->ilias->raiseError("Creation of Userfolder Export Directory failed.",$this->ilias->error_obj->MESSAGE);
00681                         }
00682                 }
00683         }
00684         
00685         function &getProfileFields()
00686         {
00687                 $profile_fields = array(
00688                         "gender",
00689                         "firstname",
00690                         "lastname",
00691                         "title",
00692                         "upload",
00693                         "password",
00694                         "institution",
00695                         "department",
00696                         "street",
00697                         "zipcode",
00698                         "city",
00699                         "country",
00700                         "phone_office",
00701                         "phone_home",
00702                         "phone_mobile",
00703                         "fax",
00704                         "email",
00705                         "hobby",
00706                         "referral_comment",
00707                         "matriculation",
00708                         "language",
00709                         "skin_style",
00710                         "hits_per_page",
00711                         "show_users_online"
00712                 );
00713                 return $profile_fields;
00714         }
00715         
00716 } // END class.ilObjUserFolder
00717 ?>

Generated on Fri Dec 13 2013 10:18:28 for ILIAS Release_3_5_x_branch .rev 46805 by  doxygen 1.7.1