ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjUserFolder.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 
34 require_once "./classes/class.ilObject.php";
35 
36 define('USER_FOLDER_ID',7);
37 
39 {
46  function ilObjUserFolder($a_id,$a_call_by_reference = true)
47  {
48  $this->type = "usrf";
49  $this->ilObject($a_id,$a_call_by_reference);
50  }
51 
52 
59  function delete()
60  {
61  // DISABLED
62  return false;
63 
64  // always call parent delete function first!!
65  if (!parent::delete())
66  {
67  return false;
68  }
69  // put here userfolder specific stuff
70 
71  // always call parent delete function at the end!!
72  return true;
73  }
74 
75 
76  function getExportFilename($a_mode = "userfolder_export_excel_x86")
77  {
78  $filename = "";
79  //$settings = $this->ilias->getAllSettings();
80  //$this->inst_id = $settings["inst_id"];
81  $inst_id = IL_INST_ID;
82 
83  $date = time();
84 
85  switch($a_mode)
86  {
87  case "userfolder_export_excel_x86":
88  $filename = $date."__".$inst_id."__xls_usrf.xls";
89  break;
90  case "userfolder_export_csv":
91  $filename = $date."__".$inst_id."__csv_usrf.csv";
92  break;
93  case "userfolder_export_xml":
94  $filename = $date."__".$inst_id."__xml_usrf.xml";
95  break;
96  }
97  return $filename;
98  }
99 
100 
109  {
110  $export_dir = ilUtil::getDataDir()."/usrf_data/export";
111 
112  return $export_dir;
113  }
114 
123  function getExportFiles()
124  {
125  $dir = $this->getExportDirectory();
126 
127  // quit if export dir not available
128  if (!@is_dir($dir) or
129  !is_writeable($dir))
130  {
131  return array();
132  }
133 
134  // open directory
135  $dir = dir($dir);
136 
137  // initialize array
138  $file = array();
139 
140  // get files and save the in the array
141  while ($entry = $dir->read())
142  {
143  if ($entry != "." and
144  $entry != ".." and
145  preg_match("/^[0-9]{10}_{2}[0-9]+_{2}([a-z0-9]{3})_usrf\.[a-z]{1,3}\$/", $entry, $matches))
146  {
147  $filearray["filename"] = $entry;
148  $filearray["filesize"] = filesize($this->getExportDirectory()."/".$entry);
149  array_push($file, $filearray);
150  }
151  }
152 
153  // close import directory
154  $dir->close();
155 
156  // sort files
157  sort ($file);
158  reset ($file);
159 
160  return $file;
161  }
162 
163  function escapeXML($value)
164  {
165  $value = str_replace("&", "&amp;", $value);
166  $value = str_replace("<", "&lt;", $value);
167  $value = str_replace(">", "&gt;", $value);
168  return $value;
169  }
170 
171  function createXMLExport(&$settings, &$data, $filename)
172  {
173  include_once './Services/User/classes/class.ilUserDefinedData.php';
174  include_once './Services/User/classes/class.ilObjUser.php';
175 
176  global $rbacreview;
177  global $ilDB;
178  global $log;
179 
180  $file = fopen($filename, "w");
181 
182  if (is_array($data))
183  {
184  include_once './Services/User/classes/class.ilUserXMLWriter.php';
185 
186  $xmlWriter = new ilUserXMLWriter();
187  $xmlWriter->setObjects($data);
188  $xmlWriter->setSettings($settings);
189  $xmlWriter->setAttachRoles (true);
190 
191  if($xmlWriter->start())
192  {
193  fwrite($file, $xmlWriter->getXML());
194  }
195  }
196 
197 /*
198  fwrite($file, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
199  fwrite($file, "<!DOCTYPE Users SYSTEM \"".ILIAS_HTTP_PATH."/xml/ilias_user_3_8.dtd\">\n");
200  fwrite($file, "<Users>");
201  foreach ($data as $row)
202  {
203  //$log->write(date("[y-m-d H:i:s] ")."User data export: processing user " . $row["login"]);
204  foreach ($row as $key => $value)
205  {
206  $row[$key] = $this->escapeXML($value);
207  }
208  $userline = "";
209  // TODO: Define combobox for "Action" ???
210  if (strlen($row["language"]) == 0) $row["language"] = "en";
211  $userline .= "<User Id=\"il_".IL_INST_ID."_usr_".$row["usr_id"]."\" Language=\"".$row["language"]."\" Action=\"Insert\">";
212  if (array_search("login", $settings) !== FALSE)
213  {
214  $userline .= "<Login>".$row["login"]."</Login>";
215  }
216  // Alternative way to get the roles of a user?
217  $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",
218  $ilDB->quote($row["usr_id"])
219  );
220  $rbacresult = $ilDB->query($query);
221  while ($rbacrow = $rbacresult->fetchRow(DB_FETCHMODE_ASSOC))
222  {
223  $type = "";
224  if ($rbacrow["assign"] == "y")
225  {
226  if ($rbacrow["parent"] == ROLE_FOLDER_ID)
227  {
228  $type = "Global";
229  }
230  else
231  {
232  $type = "Local";
233  }
234  if (strlen($type))
235  {
236  $userline .= "<Role Id=\"il_".IL_INST_ID."_role_".$rbacrow["rol_id"]."\" Type=\"".$type."\">".$rbacrow["title"]."</Role>";
237  }
238  }
239  }
240  //$log->write(date("[y-m-d H:i:s] ")."User data export: get all roles");
241  /* the export of roles is to expensive. on a system with 6000 users the following
242  section needs 37 seconds
243 
244  $roles = $rbacreview->getRolesByFilter(1, $row["usr_id"]);
245  $ass_roles = $rbacreview->assignedRoles($row["usr_id"]);
246  foreach ($roles as $role)
247  {
248  if (array_search($role["obj_id"], $ass_roles) !== FALSE)
249  {
250  $type = "";
251  switch ($role["role_type"])
252  {
253  case "global":
254  $type = "Global";
255  break;
256  case "local":
257  $type = "Local";
258  break;
259  }
260  if (strlen($type))
261  {
262  $userline .= "<Role Id=\"".$role["obj_id"]."\" Type=\"".$type."\">".$role["title"]."</Role>";
263  }
264  }
265  }
266  */
267 /* //$log->write(date("[y-m-d H:i:s] ")."User data export: got all roles");
268  $i2passwd = FALSE;
269  if (array_search("i2passwd", $settings) !== FALSE)
270  {
271  if (strlen($row["i2passwd"])) $i2passwd = TRUE;
272  if ($i2passwd) $userline .= "<Password Type=\"ILIAS2\">".$row["i2passwd"]."</Password>";
273  }
274  if ((!$i2passwd) && (array_search("passwd", $settings) !== FALSE))
275  {
276  if (strlen($row["passwd"])) $userline .= "<Password Type=\"ILIAS3\">".$row["passwd"]."</Password>";
277  }
278  if (array_search("firstname", $settings) !== FALSE)
279  {
280  if (strlen($row["firstname"])) $userline .= "<Firstname>".$row["firstname"]."</Firstname>";
281  }
282  if (array_search("lastname", $settings) !== FALSE)
283  {
284  if (strlen($row["lastname"])) $userline .= "<Lastname>".$row["lastname"]."</Lastname>";
285  }
286  if (array_search("title", $settings) !== FALSE)
287  {
288  if (strlen($row["title"])) $userline .= "<Title>".$row["title"]."</Title>";
289  }
290  if (array_search("upload", $settings) !== FALSE)
291  {
292  // personal picture
293  $q = sprintf("SELECT value FROM usr_pref WHERE usr_id=%s AND keyword='profile_image'", $ilDB->quote($row["usr_id"] . ""));
294  $r = $ilDB->query($q);
295  if ($r->numRows() == 1)
296  {
297  $personal_picture_data = $r->fetchRow(DB_FETCHMODE_ASSOC);
298  $personal_picture = $personal_picture_data["value"];
299  $webspace_dir = ilUtil::getWebspaceDir();
300  $image_file = $webspace_dir."/usr_images/".$personal_picture;
301  if (@is_file($image_file))
302  {
303  $fh = fopen($image_file, "rb");
304  if ($fh)
305  {
306  $image_data = fread($fh, filesize($image_file));
307  fclose($fh);
308  $base64 = base64_encode($image_data);
309  $imagetype = "image/jpeg";
310  if (preg_match("/.*\.(png|gif)$/", $personal_picture, $matches))
311  {
312  $imagetype = "image/".$matches[1];
313  }
314  $userline .= "<PersonalPicture imagetype=\"$imagetype\" encoding=\"Base64\">$base64</PersonalPicture>";
315  }
316  }
317  }
318  }
319  if (array_search("gender", $settings) !== FALSE)
320  {
321  if (strlen($row["gender"])) $userline .= "<Gender>".$row["gender"]."</Gender>";
322  }
323  if (array_search("email", $settings) !== FALSE)
324  {
325  if (strlen($row["email"])) $userline .= "<Email>".$row["email"]."</Email>";
326  }
327  if (array_search("institution", $settings) !== FALSE)
328  {
329  if (strlen($row["institution"])) $userline .= "<Institution>".$row["institution"]."</Institution>";
330  }
331  if (array_search("street", $settings) !== FALSE)
332  {
333  if (strlen($row["street"])) $userline .= "<Street>".$row["street"]."</Street>";
334  }
335  if (array_search("city", $settings) !== FALSE)
336  {
337  if (strlen($row["city"])) $userline .= "<City>".$row["city"]."</City>";
338  }
339  if (array_search("zipcode", $settings) !== FALSE)
340  {
341  if (strlen($row["zipcode"])) $userline .= "<PostalCode>".$row["zipcode"]."</PostalCode>";
342  }
343  if (array_search("country", $settings) !== FALSE)
344  {
345  if (strlen($row["country"])) $userline .= "<Country>".$row["country"]."</Country>";
346  }
347  if (array_search("phone_office", $settings) !== FALSE)
348  {
349  if (strlen($row["phone_office"])) $userline .= "<PhoneOffice>".$row["phone_office"]."</PhoneOffice>";
350  }
351  if (array_search("phone_home", $settings) !== FALSE)
352  {
353  if (strlen($row["phone_home"])) $userline .= "<PhoneHome>".$row["phone_home"]."</PhoneHome>";
354  }
355  if (array_search("phone_mobile", $settings) !== FALSE)
356  {
357  if (strlen($row["phone_mobile"])) $userline .= "<PhoneMobile>".$row["phone_mobile"]."</PhoneMobile>";
358  }
359  if (array_search("fax", $settings) !== FALSE)
360  {
361  if (strlen($row["fax"])) $userline .= "<Fax>".$row["fax"]."</Fax>";
362  }
363  if (strlen($row["hobby"])) if (array_search("hobby", $settings) !== FALSE)
364  {
365  $userline .= "<Hobby>".$row["hobby"]."</Hobby>";
366  }
367  if (array_search("department", $settings) !== FALSE)
368  {
369  if (strlen($row["department"])) $userline .= "<Department>".$row["department"]."</Department>";
370  }
371  if (array_search("referral_comment", $settings) !== FALSE)
372  {
373  if (strlen($row["referral_comment"])) $userline .= "<Comment>".$row["referral_comment"]."</Comment>";
374  }
375  if (array_search("matriculation", $settings) !== FALSE)
376  {
377  if (strlen($row["matriculation"])) $userline .= "<Matriculation>".$row["matriculation"]."</Matriculation>";
378  }
379  if (array_search("active", $settings) !== FALSE)
380  {
381  if ($row["active"])
382  {
383  $userline .= "<Active>true</Active>";
384  }
385  else
386  {
387  $userline .= "<Active>false</Active>";
388  }
389  }
390  if (array_search("client_ip", $settings) !== FALSE)
391  {
392  if (strlen($row["client_ip"])) $userline .= "<ClientIP>".$row["client_ip"]."</ClientIP>";
393  }
394  if (array_search("time_limit_owner", $settings) !== FALSE)
395  {
396  if (strlen($row["time_limit_owner"])) $userline .= "<TimeLimitOwner>".$row["time_limit_owner"]."</TimeLimitOwner>";
397  }
398  if (array_search("time_limit_unlimited", $settings) !== FALSE)
399  {
400  if (strlen($row["time_limit_unlimited"])) $userline .= "<TimeLimitUnlimited>".$row["time_limit_unlimited"]."</TimeLimitUnlimited>";
401  }
402  if (array_search("time_limit_from", $settings) !== FALSE)
403  {
404  if (strlen($row["time_limit_from"])) $userline .= "<TimeLimitFrom>".$row["time_limit_from"]."</TimeLimitFrom>";
405  }
406  if (array_search("time_limit_until", $settings) !== FALSE)
407  {
408  if (strlen($row["time_limit_until"])) $userline .= "<TimeLimitUntil>".$row["time_limit_until"]."</TimeLimitUntil>";
409  }
410  if (array_search("time_limit_message", $settings) !== FALSE)
411  {
412  if (strlen($row["time_limit_message"])) $userline .= "<TimeLimitMessage>".$row["time_limit_message"]."</TimeLimitMessage>";
413  }
414  if (array_search("approve_date", $settings) !== FALSE)
415  {
416  if (strlen($row["approve_date"])) $userline .= "<ApproveDate>".$row["approve_date"]."</ApproveDate>";
417  }
418  if (array_search("agree_date", $settings) !== FALSE)
419  {
420  if (strlen($row["agree_date"])) $userline .= "<AgreeDate>".$row["agree_date"]."</AgreeDate>";
421  }
422  if ((int) $row["ilinc_id"] !=0) {
423  if (array_search("ilinc_id", $settings) !== FALSE)
424  {
425  if (strlen($row["ilinc_id"])) $userline .= "<iLincID>".$row["ilinc_id"]."</iLincID>";
426  }
427  if (array_search("ilinc_login", $settings) !== FALSE)
428  {
429  if (strlen($row["ilinc_login"])) $userline .= "<iLincLogin>".$row["ilinc_login"]."</iLincLogin>";
430  }
431  if (array_search("ilinc_passwd", $settings) !== FALSE)
432  {
433  if (strlen($row["ilinc_passwd"])) $userline .= "<iLincPasswd>".$row["ilinc_passwd"]."</iLincPasswd>";
434  }
435  }
436  if (array_search("auth_mode", $settings) !== FALSE)
437  {
438  if (strlen($row["auth_mode"])) $userline .= "<AuthMode type=\"".$row["auth_mode"]."\"></AuthMode>";
439  }
440  if (array_search("skin_style", $settings) !== FALSE)
441  {
442  $userline .=
443  "<Look Skin=\"" . ilObjUser::_lookupPref($row["usr_id"], "skin") . "\" " .
444  "Style=\"" . ilObjUser::_lookupPref($row["usr_id"], "style") . "\"></Look>";
445  }
446 
447  if (array_search("last_update", $settings) !== FALSE)
448  {
449  if (strlen($row["last_update"])) $userline .= "<LastUpdate>".$row["last_update"]."</LastUpdate>";
450  }
451 
452  if (array_search("last_login", $settings) !== FALSE)
453  {
454  if (strlen($row["last_login"])) $userline .= "<LastLogin>".$row["last_login"]."</LastLogin>";
455  }
456 
457  // Append User defined field data
458  $udf_data = new ilUserDefinedData($row['usr_id']);
459  $userline .= $udf_data->toXML();
460 
461  $userline .= "</User>";
462  fwrite($file, $userline);
463  }
464  fwrite($file, "</Users>");
465  fclose($file);*/
466  }
467 
468  function createCSVExport(&$settings, &$data, $filename)
469  {
470  $headerrow = array();
471  foreach ($settings as $value)
472  {
473  array_push($headerrow, $this->lng->txt($value));
474  }
475  $separator = ";";
476  $file = fopen($filename, "w");
477  $formattedrow =& ilUtil::processCSVRow($headerrow, TRUE, $separator);
478  fwrite($file, join ($separator, $formattedrow) ."");
479  foreach ($data as $row)
480  {
481  $csvrow = array();
482  foreach ($settings as $header)
483  {
484  array_push($csvrow, $row[$header]);
485  }
486  $formattedrow =& ilUtil::processCSVRow($csvrow, TRUE, $separator);
487  fwrite($file, join ($separator, $formattedrow) ."\n");
488  }
489  fclose($file);
490  }
491 
492  function createExcelExport(&$settings, &$data, $filename, $a_mode)
493  {
494  include_once "./classes/class.ilExcelUtils.php";
495  include_once "./classes/class.ilExcelWriterAdapter.php";
496  $adapter = new ilExcelWriterAdapter($filename, FALSE);
497  $workbook = $adapter->getWorkbook();
498  // Creating a worksheet
499  $format_bold =& $workbook->addFormat();
500  $format_bold->setBold();
501  $format_percent =& $workbook->addFormat();
502  $format_percent->setNumFormat("0.00%");
503  $format_datetime =& $workbook->addFormat();
504  $format_datetime->setNumFormat("DD/MM/YYYY hh:mm:ss");
505  $format_title =& $workbook->addFormat();
506  $format_title->setBold();
507  $format_title->setColor('black');
508  $format_title->setPattern(1);
509  $format_title->setFgColor('silver');
510  $worksheet =& $workbook->addWorksheet();
511  $row = 0;
512  $col = 0;
513 
514  foreach ($settings as $value)
515  {
516  $worksheet->write($row, $col, ilExcelUtils::_convert_text($this->lng->txt($value), $a_mode), $format_title);
517  $col++;
518  }
519 
520 
521  foreach ($data as $index => $rowdata)
522  {
523  $row++;
524  $col = 0;
525  foreach ($settings as $fieldname)
526  {
527 // foreach ($rowdata as $rowindex => $value)
528 // {
529  $value = $rowdata[$fieldname];
530  switch ($fieldname)
531  {
532  case "language":
533  $worksheet->write($row, $col, ilExcelUtils::_convert_text($this->lng->txt("lang_".$value), $a_mode));
534  break;
535  case "time_limit_from":
536  case "time_limit_until":
537  $date = strftime("%Y-%m-%d %H:%M:%S", $value);
538  if (preg_match("/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $date, $matches))
539  {
540  $worksheet->write($row, $col, ilUtil::excelTime($matches[1],$matches[2],$matches[3],$matches[4],$matches[5],$matches[6]), $format_datetime);
541  }
542  break;
543  case "last_login":
544  case "last_update":
545  case "create_date":
546  case "approve_date":
547  case "agree_date":
548  if (preg_match("/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $value, $matches))
549  {
550  $worksheet->write($row, $col, ilUtil::excelTime($matches[1],$matches[2],$matches[3],$matches[4],$matches[5],$matches[6]), $format_datetime);
551  }
552  break;
553  default:
554  $worksheet->write($row, $col, ilExcelUtils::_convert_text($value, $a_mode));
555  break;
556  }
557  $col++;
558  }
559  }
560  $workbook->close();
561  }
562 
568  static function getExportSettings()
569  {
570  global $ilDB;
571 
572  $db_settings = array();
573  $profile_fields =& ilObjUserFolder::getProfileFields();
574  $profile_fields[] = "preferences";
575 
576  $query = "SELECT * FROM `settings` WHERE keyword LIKE '%usr_settings_export_%'";
577  $result = $ilDB->query($query);
578  $export_pref_settings_found = false;
579  while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
580  {
581  if (preg_match("/usr_settings_export_(.*)/", $row["keyword"], $setting))
582  {
583  $export_pref_settings_found = $setting[1] == "preferences";
584  if ($row["value"] == 1)
585  array_push($db_settings, $setting[1]);
586  }
587  }
588  //if export preferences not set then default behaviour
589  if (!$export_pref_settings_found)
590  array_push($db_settings, "preferences");
591 
592  $export_settings = array();
593  foreach ($profile_fields as $key => $value)
594  {
595  if (in_array($value, $db_settings))
596  {
597  if (strcmp($value, "password") == 0)
598  {
599  array_push($export_settings, "passwd");
600  }
601  else
602  {
603  array_push($export_settings, $value);
604  }
605  }
606  }
607  array_push($export_settings, "login");
608  array_push($export_settings, "last_login");
609  array_push($export_settings, "last_update");
610  array_push($export_settings, "create_date");
611  array_push($export_settings, "i2passwd");
612  array_push($export_settings, "time_limit_owner");
613  array_push($export_settings, "time_limit_unlimited");
614  array_push($export_settings, "time_limit_from");
615  array_push($export_settings, "time_limit_until");
616  array_push($export_settings, "time_limit_message");
617  array_push($export_settings, "active");
618  array_push($export_settings, "approve_date");
619  array_push($export_settings, "agree_date");
620  array_push($export_settings, "ilinc_id");
621  array_push($export_settings, "ilinc_login");
622  array_push($export_settings, "ilinc_passwd");
623  array_push($export_settings, "client_ip");
624  array_push($export_settings, "auth_mode");
625  array_push($export_settings, "ext_account");
626  array_push($export_settings, "feedhash");
627 
628  return $export_settings;
629  }
630 
634  function buildExportFile($a_mode = "userfolder_export_excel_x86", $user_data_filter = FALSE)
635  {
636  global $ilBench;
637  global $log;
638  global $ilDB;
639  global $ilias;
640 
641  //get Log File
642  $expDir = $this->getExportDirectory();
643  //$expLog = &$log;
644  //$expLog->delete();
645  //$expLog->setLogFormat("");
646  //$expLog->write(date("[y-m-d H:i:s] ")."Start export of user data");
647 
648  // create export directory if needed
649  $this->createExportDirectory();
650 
651  //get data
652  //$expLog->write(date("[y-m-d H:i:s] ")."User data export: build an array of all user data entries");
653  $settings =& $this->getExportSettings();
654  $data = array();
655  $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";
656  $result = $ilDB->query($query);
657  while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
658  {
659  if (is_array($user_data_filter))
660  {
661  if (in_array($row["usr_id"], $user_data_filter)) array_push($data, $row);
662  }
663  else
664  {
665  array_push($data, $row);
666  }
667  }
668  //$expLog->write(date("[y-m-d H:i:s] ")."User data export: build an array of all user data entries");
669 
670  $fullname = $expDir."/".$this->getExportFilename($a_mode);
671  switch ($a_mode)
672  {
673  case "userfolder_export_excel_x86":
674  $this->createExcelExport($settings, $data, $fullname, "latin1");
675  break;
676  case "userfolder_export_csv":
677  $this->createCSVExport($settings, $data, $fullname);
678  break;
679  case "userfolder_export_xml":
680  $this->createXMLExport($settings, $data, $fullname);
681  break;
682  }
683  //$expLog->write(date("[y-m-d H:i:s] ")."Finished export of user data");
684 
685  return $fullname;
686  }
687 
688 
695  {
696  if (!@is_dir($this->getExportDirectory()))
697  {
698  $usrf_data_dir = ilUtil::getDataDir()."/usrf_data";
699  ilUtil::makeDir($usrf_data_dir);
700  if(!is_writable($usrf_data_dir))
701  {
702  $this->ilias->raiseError("Userfolder data directory (".$usrf_data_dir
703  .") not writeable.",$this->ilias->error_obj->MESSAGE);
704  }
705 
706  // create Export subdirectory (data_dir/lm_data/lm_<id>/Export)
707  $export_dir = $usrf_data_dir."/export";
708  ilUtil::makeDir($export_dir);
709  if(!@is_dir($export_dir))
710  {
711  $this->ilias->raiseError("Creation of Userfolder Export Directory failed.",$this->ilias->error_obj->MESSAGE);
712  }
713  }
714  }
715 
721  static function &getProfileFields()
722  {
723  $profile_fields = array(
724  "gender",
725  "firstname",
726  "lastname",
727  "title",
728  "password",
729  "institution",
730  "department",
731  "street",
732  "zipcode",
733  "city",
734  "country",
735  "phone_office",
736  "phone_home",
737  "phone_mobile",
738  "fax",
739  "email",
740  "hobby",
741  "referral_comment",
742  "matriculation",
743  "upload",
744  "language",
745  "skin_style",
746  "hits_per_page",
747  "show_users_online",
748  "instant_messengers",
749  "hide_own_online_status"
750  );
751  return $profile_fields;
752  }
753 
754  function _writeNewAccountMail($a_lang, $a_subject, $a_sal_g, $a_sal_f, $a_sal_m, $a_body)
755  {
756  global $ilDB;
757 
758  $ilDB->query("REPLACE INTO usr_new_account_mail ".
759  "(lang, subject, body, sal_g, sal_f, sal_m) VALUES ".
760  "(".$ilDB->quote($a_lang).",".$ilDB->quote($a_subject).",".$ilDB->quote($a_body).
761  ",".$ilDB->quote($a_sal_g).",".$ilDB->quote($a_sal_f).",".$ilDB->quote($a_sal_m).")");
762  }
763 
764  function _lookupNewAccountMail($a_lang)
765  {
766  global $ilDB;
767 
768  $set = $ilDB->query("SELECT * FROM usr_new_account_mail ".
769  " WHERE lang = ".$ilDB->quote($a_lang));
770 
771  if ($rec = $set->fetchRow(DB_FETCHMODE_ASSOC))
772  {
773  return $rec;
774  }
775  return array();
776  }
777 
789  public static function _updateUserFolderAssignment($a_old_id,$a_new_id)
790  {
791  global $ilDB;
792 
793  $query = "UPDATE usr_data SET time_limit_owner = ".$ilDB->quote($a_new_id)." ".
794  "WHERE time_limit_owner = ".$ilDB->quote($a_old_id)." ";
795  $ilDB->query($query);
796 
797  return true;
798  }
799 
800 
801 } // END class.ilObjUserFolder
802 ?>