ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
ilObjUserFolder Class Reference
+ Inheritance diagram for ilObjUserFolder:
+ Collaboration diagram for ilObjUserFolder:

Public Member Functions

 ilObjUserFolder ($a_id, $a_call_by_reference=true)
 Constructor public. More...
 
 delete ()
 delete userfolder and all related data DISABLED public More...
 
 getExportFilename ($a_mode="userfolder_export_excel_x86")
 
 getExportDirectory ()
 Get the location of the export directory for the user accounts. More...
 
 getExportFiles ()
 Get a list of the already exported files in the export directory. More...
 
 escapeXML ($value)
 
 createXMLExport (&$settings, &$data, $filename)
 
 getUserDefinedExportFields ()
 Get all exportable user defined fields. More...
 
 createCSVExport (&$settings, &$data, $filename)
 
 createExcelExport (&$settings, &$data, $filename, $a_mode)
 
 buildExportFile ($a_mode="userfolder_export_excel_x86", $user_data_filter=FALSE)
 build xml export file More...
 
 createExportDirectory ()
 creates data directory for export files (data_dir/usrf_data/export, depending on data directory that is set in ILIAS setup/ini) More...
 
 _writeNewAccountMail ($a_lang, $a_subject, $a_sal_g, $a_sal_f, $a_sal_m, $a_body)
 
 _updateAccountMailAttachment ($a_lang, $a_tmp_name, $a_name)
 
 _deleteAccountMailAttachment ($a_lang)
 
 _lookupNewAccountMail ($a_lang)
 
- Public Member Functions inherited from ilObject
 ilObject ($a_id=0, $a_reference=true)
 Constructor public. More...
 
 withReferences ()
 determines wehter objects are referenced or not (got ref ids or not) More...
 
 read ($a_force_db=false)
 read object data from db into object More...
 
 getId ()
 get object id public More...
 
 setId ($a_id)
 set object id public More...
 
 setRefId ($a_id)
 set reference id public More...
 
 getRefId ()
 get reference id public More...
 
 getType ()
 get object type public More...
 
 setType ($a_type)
 set object type public More...
 
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions More...
 
 getTitle ()
 get object title public More...
 
 getUntranslatedTitle ()
 get untranslated object title public More...
 
 setTitle ($a_title)
 set object title More...
 
 getDescription ()
 get object description More...
 
 setDescription ($a_desc)
 set object description More...
 
 getLongDescription ()
 get object long description (stored in object_description) More...
 
 getImportId ()
 get import id More...
 
 setImportId ($a_import_id)
 set import id More...
 
 getOwner ()
 get object owner More...
 
 getOwnerName ()
 
 _lookupOwnerName ($a_owner_id)
 lookup owner name for owner id More...
 
 setOwner ($a_owner)
 set object owner More...
 
 getCreateDate ()
 get create date public More...
 
 getLastUpdateDate ()
 get last update date public More...
 
 getDiskUsage ()
 Gets the disk usage of the object in bytes. More...
 
 setObjDataRecord ($a_record)
 set object_data record (note: this method should only be called from the ilObjectFactory class) More...
 
 create ()
 create More...
 
 update ()
 update object in db More...
 
 MDUpdateListener ($a_element)
 Meta data update listener. More...
 
 createMetaData ()
 create meta data entry More...
 
 updateMetaData ()
 update meta data entry More...
 
 deleteMetaData ()
 delete meta data entry More...
 
 updateOwner ()
 update owner of object in db More...
 
 _getIdForImportId ($a_import_id)
 get current object id for import id (static) More...
 
 _lookupOwner ($a_id)
 lookup object owner More...
 
 _lookupLastUpdate ($a_id, $a_as_string=false)
 lookup last update More...
 
 _getLastUpdateOfObjects ($a_objs)
 Get last update for a set of media objects. More...
 
 _setDeletedDate ($a_ref_id)
 only called in ilTree::saveSubTree More...
 
 _resetDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
 _lookupDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
 _writeTitle ($a_obj_id, $a_title)
 write title to db (static) More...
 
 _writeDescription ($a_obj_id, $a_desc)
 write description to db (static) More...
 
 _writeImportId ($a_obj_id, $a_import_id)
 write import id to db (static) More...
 
 _isInTrash ($a_ref_id)
 checks wether object is in trash More...
 
 _hasUntrashedReference ($a_obj_id)
 checks wether an object has at least one reference that is not in trash More...
 
 _getObjectsDataForType ($a_type, $a_omit_trash=false)
 get all objects of a certain type More...
 
 putInTree ($a_parent_ref)
 maybe this method should be in tree object!? More...
 
 setPermissions ($a_parent_ref)
 set permissions of object More...
 
 createReference ()
 creates reference for object More...
 
 countReferences ()
 count references of object More...
 
 delete ()
 delete object or referenced object (in the case of a referenced object, object data is only deleted if last reference is deleted) This function removes an object entirely from system!! More...
 
 initDefaultRoles ()
 init default roles settings Purpose of this function is to create a local role folder and local roles, that are needed depending on the object type If you want to setup default local roles you MUST overwrite this method in derived object classes (see ilObjForum for an example) public More...
 
 createRoleFolder ()
 creates a local role folder More...
 
 applyDidacticTemplate ($a_tpl_id)
 Apply template. More...
 
 notify ($a_event, $a_ref_id, $a_parent_non_rbac_id, $a_node_id, $a_params=0)
 notifys an object about an event occured Based on the event passed, each object may decide how it reacts. More...
 
 setRegisterMode ($a_bool)
 
 isUserRegistered ($a_user_id=0)
 
 requireRegistration ()
 
 getXMLZip ()
 
 getHTMLDirectory ()
 
 cloneObject ($a_target_id, $a_copy_id=0, $a_omit_tree=false)
 Clone object permissions, put in tree ... More...
 
 appendCopyInfo ($a_target_id, $a_copy_id)
 Prepend Copy info if object with same name exists in that container. More...
 
 cloneDependencies ($a_target_id, $a_copy_id)
 Clone object dependencies. More...
 
 cloneMetaData ($target_obj)
 Copy meta data. More...
 
 _lookupCreationDate ($a_id)
 Lookup creation date. More...
 

Static Public Member Functions

static getExportSettings ()
 getExport Settings More...
 
static & getProfileFields ()
 Get profile fields (DEPRECATED, use ilUserProfile() instead) More...
 
static _updateUserFolderAssignment ($a_old_id, $a_new_id)
 Update user folder assignment Typically called after deleting a category with local user accounts. More...
 
- Static Public Member Functions inherited from ilObject
static _lookupObjIdByImportId ($a_import_id)
 
static _getAllReferences ($a_id)
 get all reference ids of object More...
 
static _lookupTitle ($a_id)
 lookup object title More...
 
static _getIdsForTitle ($title, $type='', $partialmatch=false)
 
static _lookupDescription ($a_id)
 lookup object description More...
 
static _lookupObjId ($a_id)
 
static setDeletedDates ($a_ref_ids)
 Set deleted date type $ilDB. More...
 
static _lookupType ($a_id, $a_reference=false)
 lookup object type More...
 
static _lookupObjectId ($a_ref_id)
 lookup object id More...
 
static _exists ($a_id, $a_reference=false, $a_type=null)
 checks if an object exists in object_data More...
 
static _getObjectsByType ($a_obj_type="", $a_owner="")
 Get objects by type. More...
 
static _prepareCloneSelection ($a_ref_ids, $new_type, $show_path=true)
 Prepare copy wizard object selection. More...
 
static _getIcon ($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
 Get icon for repository item. More...
 
static collectDeletionDependencies (&$deps, $a_ref_id, $a_obj_id, $a_type, $a_depth=0)
 Collect deletion dependencies. More...
 
static getDeletionDependencies ($a_obj_id)
 Get deletion dependencies. More...
 
static getLongDescriptions (array $a_obj_ids)
 Get long description data. More...
 
static getAllOwnedRepositoryObjects ($a_user_id)
 Get all ids of objects user owns. More...
 
static hasAutoRating ($a_type, $a_ref_id)
 Check if auto rating is active for parent group/course. More...
 

Additional Inherited Members

- Data Fields inherited from ilObject
const TITLE_LENGTH = 255
 max length of object title More...
 
const DESC_LENGTH = 128
 
 $ilias
 
 $lng
 
 $id
 
 $ref_id
 
 $type
 
 $title
 
 $untranslatedTitle
 
 $desc
 
 $long_desc
 
 $owner
 
 $create_date
 
 $last_update
 
 $import_id
 
 $register = false
 
 $referenced
 
 $objectList
 
 $max_title
 
 $max_desc
 
 $add_dots
 
 $obj_data_record
 object_data record More...
 

Detailed Description

Definition at line 18 of file class.ilObjUserFolder.php.

Member Function Documentation

◆ _deleteAccountMailAttachment()

ilObjUserFolder::_deleteAccountMailAttachment (   $a_lang)

Definition at line 860 of file class.ilObjUserFolder.php.

References $path, and ilObject\getId().

861  {
862  global $ilDB;
863 
864  include_once "Services/User/classes/class.ilFSStorageUserFolder.php";
865  $fs = new ilFSStorageUserFolder($this->getId());
866  $path = $fs->getAbsolutePath()."/";
867 
868  @unlink($path.$a_lang);
869 
870  $ilDB->update('mail_template',
871  array('att_file' => array('text', '')),
872  array('lang' => array('text',$a_lang), 'type' => array('text','nacc')));
873  }
getId()
get object id public
$path
Definition: index.php:22
+ Here is the call graph for this function:

◆ _lookupNewAccountMail()

ilObjUserFolder::_lookupNewAccountMail (   $a_lang)

Definition at line 875 of file class.ilObjUserFolder.php.

References DB_FETCHMODE_ASSOC.

Referenced by ilAccountRegistrationGUI\__distributeMails(), ilStartUpGUI\confirmRegistration(), ilObjUserFolderGUI\importUserRoleAssignmentObject(), ilAuthContainerSOAP\loginObserver(), ilAccountMail\readAccountMail(), and ilUserImportParser\readAccountMailFromCache().

876  {
877  global $ilDB;
878 
879  $set = $ilDB->query("SELECT * FROM mail_template ".
880  " WHERE type='nacc' AND lang = ".$ilDB->quote($a_lang,'text'));
881 
882  if ($rec = $set->fetchRow(DB_FETCHMODE_ASSOC))
883  {
884  return $rec;
885  }
886  return array();
887  }
const DB_FETCHMODE_ASSOC
Definition: class.ilDB.php:10
+ Here is the caller graph for this function:

◆ _updateAccountMailAttachment()

ilObjUserFolder::_updateAccountMailAttachment (   $a_lang,
  $a_tmp_name,
  $a_name 
)

Definition at line 844 of file class.ilObjUserFolder.php.

References $path, and ilObject\getId().

845  {
846  global $ilDB;
847 
848  include_once "Services/User/classes/class.ilFSStorageUserFolder.php";
849  $fs = new ilFSStorageUserFolder($this->getId());
850  $fs->create();
851  $path = $fs->getAbsolutePath()."/";
852 
853  move_uploaded_file($a_tmp_name, $path.$a_lang);
854 
855  $ilDB->update('mail_template',
856  array('att_file' => array('text', $a_name)),
857  array('lang' => array('text',$a_lang), 'type' => array('text','nacc')));
858  }
getId()
get object id public
$path
Definition: index.php:22
+ Here is the call graph for this function:

◆ _updateUserFolderAssignment()

static ilObjUserFolder::_updateUserFolderAssignment (   $a_old_id,
  $a_new_id 
)
static

Update user folder assignment Typically called after deleting a category with local user accounts.

These users will be assigned to the global user folder.

public

Parameters
intold_id
intnew id

Definition at line 900 of file class.ilObjUserFolder.php.

References $query.

Referenced by ilObjCategory\delete(), and ilObjOrgUnit\delete().

901  {
902  global $ilDB;
903 
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);
907 
908  return true;
909  }
+ Here is the caller graph for this function:

◆ _writeNewAccountMail()

ilObjUserFolder::_writeNewAccountMail (   $a_lang,
  $a_subject,
  $a_sal_g,
  $a_sal_f,
  $a_sal_m,
  $a_body 
)

Definition at line 811 of file class.ilObjUserFolder.php.

812  {
813  global $ilDB;
814 
815  if(self::_lookupNewAccountMail($a_lang))
816  {
817  $values = array(
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)
823  );
824  $ilDB->update('mail_template',
825  $values,
826  array('lang' => array('text',$a_lang), 'type' => array('text','nacc'))
827  );
828  }
829  else
830  {
831  $values = array(
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')
839  );
840  $ilDB->insert('mail_template',$values);
841  }
842  }

◆ buildExportFile()

ilObjUserFolder::buildExportFile (   $a_mode = "userfolder_export_excel_x86",
  $user_data_filter = FALSE 
)

build xml export file

Definition at line 685 of file class.ilObjUserFolder.php.

References $data, $ilBench, ilObject\$ilias, ilObject\$lng, $log, $query, $res, $result, $row, createCSVExport(), createExcelExport(), createExportDirectory(), createXMLExport(), DB_FETCHMODE_ASSOC, getExportDirectory(), getExportFilename(), and getExportSettings().

686  {
687  global $ilBench;
688  global $log;
689  global $ilDB;
690  global $ilias;
691  global $lng;
692 
693  //get Log File
694  $expDir = $this->getExportDirectory();
695  //$expLog = &$log;
696  //$expLog->delete();
697  //$expLog->setLogFormat("");
698  //$expLog->write(date("[y-m-d H:i:s] ")."Start export of user data");
699 
700  // create export directory if needed
701  $this->createExportDirectory();
702 
703  //get data
704  //$expLog->write(date("[y-m-d H:i:s] ")."User data export: build an array of all user data entries");
705  $settings =& $this->getExportSettings();
706 
707  // user languages
708  $query = "SELECT * FROM usr_pref WHERE keyword = ".$ilDB->quote('language','text');
709  $res = $ilDB->query($query);
710  $languages = array();
711  while($row = $res->fetchRow(DB_FETCHMODE_ASSOC))
712  {
713  $languages[$row['usr_id']] = $row['value'];
714  }
715 
716 
717  $data = array();
718  $query = "SELECT usr_data.* FROM usr_data ".
719  " ORDER BY usr_data.lastname, usr_data.firstname";
720  $result = $ilDB->query($query);
721  while ($row = $ilDB->fetchAssoc($result))
722  {
723  if(isset($languages[$row['usr_id']]))
724  {
725  $row['language'] = $languages[$row['usr_id']];
726  }
727  else
728  {
729  $row['language'] = $lng->getDefaultLanguage();
730  }
731 
732  if (is_array($user_data_filter))
733  {
734  if (in_array($row["usr_id"], $user_data_filter)) array_push($data, $row);
735  }
736  else
737  {
738  array_push($data, $row);
739  }
740  }
741  //$expLog->write(date("[y-m-d H:i:s] ")."User data export: build an array of all user data entries");
742 
743  $fullname = $expDir."/".$this->getExportFilename($a_mode);
744  switch ($a_mode)
745  {
746  case "userfolder_export_excel_x86":
747  $this->createExcelExport($settings, $data, $fullname, "latin1");
748  break;
749  case "userfolder_export_csv":
750  $this->createCSVExport($settings, $data, $fullname);
751  break;
752  case "userfolder_export_xml":
753  $this->createXMLExport($settings, $data, $fullname);
754  break;
755  }
756  //$expLog->write(date("[y-m-d H:i:s] ")."Finished export of user data");
757 
758  return $fullname;
759  }
getExportFilename($a_mode="userfolder_export_excel_x86")
$result
getExportDirectory()
Get the location of the export directory for the user accounts.
createXMLExport(&$settings, &$data, $filename)
createExportDirectory()
creates data directory for export files (data_dir/usrf_data/export, depending on data directory that ...
static getExportSettings()
getExport Settings
const DB_FETCHMODE_ASSOC
Definition: class.ilDB.php:10
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
global $ilBench
Definition: ilias.php:18
createExcelExport(&$settings, &$data, $filename, $a_mode)
createCSVExport(&$settings, &$data, $filename)
+ Here is the call graph for this function:

◆ createCSVExport()

ilObjUserFolder::createCSVExport ( $settings,
$data,
  $filename 
)

Definition at line 470 of file class.ilObjUserFolder.php.

References $data, $file, $filename, $row, $separator, getUserDefinedExportFields(), and ilUtil\processCSVRow().

Referenced by buildExportFile().

471  {
472 
473  // header
474  $headerrow = array();
475  $udf_ex_fields = $this->getUserDefinedExportFields();
476  foreach ($settings as $value) // standard fields
477  {
478  array_push($headerrow, $this->lng->txt($value));
479  }
480  foreach ($udf_ex_fields as $f) // custom fields
481  {
482  array_push($headerrow, $f["name"]);
483  }
484 
485  $separator = ";";
486  $file = fopen($filename, "w");
487  $formattedrow =& ilUtil::processCSVRow($headerrow, TRUE, $separator);
488  fwrite($file, join ($separator, $formattedrow) ."\n");
489  foreach ($data as $row)
490  {
491  $csvrow = array();
492  foreach ($settings as $header) // standard fields
493  {
494  array_push($csvrow, $row[$header]);
495  }
496 
497  // custom fields
498  reset($udf_ex_fields);
499  if (count($udf_ex_fields) > 0)
500  {
501  include_once("./Services/User/classes/class.ilUserDefinedData.php");
502  $udf = new ilUserDefinedData($row["usr_id"]);
503  foreach ($udf_ex_fields as $f) // custom fields
504  {
505  array_push($csvrow, $udf->get("f_".$f["id"]));
506  }
507  }
508 
509  $formattedrow =& ilUtil::processCSVRow($csvrow, TRUE, $separator);
510  fwrite($file, join ($separator, $formattedrow) ."\n");
511  }
512  fclose($file);
513  }
print $file
$separator
Class ilUserDefinedData.
static & processCSVRow(&$row, $quoteAll=FALSE, $separator=";", $outUTF8=FALSE, $compatibleWithMSExcel=TRUE)
Convertes an array for CSV usage.
$filename
Definition: buildRTE.php:89
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
getUserDefinedExportFields()
Get all exportable user defined fields.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createExcelExport()

ilObjUserFolder::createExcelExport ( $settings,
$data,
  $filename,
  $a_mode 
)

Definition at line 515 of file class.ilObjUserFolder.php.

References $data, $filename, $row, ilExcelUtils\_convert_text(), ilUtil\excelTime(), and getUserDefinedExportFields().

Referenced by buildExportFile().

516  {
517  include_once "./Services/Excel/classes/class.ilExcelUtils.php";
518  include_once "./Services/Excel/classes/class.ilExcelWriterAdapter.php";
519  $adapter = new ilExcelWriterAdapter($filename, FALSE);
520  $workbook = $adapter->getWorkbook();
521  // Creating a worksheet
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();
534  $row = 0;
535  $col = 0;
536 
537  $udf_ex_fields = $this->getUserDefinedExportFields();
538 
539  // title row
540  foreach ($settings as $value) // standard fields
541  {
542  if($value == 'ext_account')
543  {
544  $value = 'user_ext_account';
545  }
546  $worksheet->write($row, $col, ilExcelUtils::_convert_text($this->lng->txt($value), $a_mode), $format_title);
547  $col++;
548  }
549  foreach ($udf_ex_fields as $f) // custom fields
550  {
551  $worksheet->write($row, $col, ilExcelUtils::_convert_text($f["name"], $a_mode), $format_title);
552  $col++;
553  }
554 
555  $this->lng->loadLanguageModule("meta");
556  foreach ($data as $index => $rowdata)
557  {
558  $row++;
559  $col = 0;
560 
561  // standard fields
562  foreach ($settings as $fieldname)
563  {
564  $value = $rowdata[$fieldname];
565  switch ($fieldname)
566  {
567  case "language":
568  $worksheet->write($row, $col, ilExcelUtils::_convert_text($this->lng->txt("meta_l_".$value), $a_mode));
569  break;
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))
574  {
575  $worksheet->write($row, $col, ilUtil::excelTime($matches[1],$matches[2],$matches[3],$matches[4],$matches[5],$matches[6]), $format_datetime);
576  }
577  break;
578  case "last_login":
579  case "last_update":
580  case "create_date":
581  case "approve_date":
582  case "agree_date":
583  if (preg_match("/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $value, $matches))
584  {
585  $worksheet->write($row, $col, ilUtil::excelTime($matches[1],$matches[2],$matches[3],$matches[4],$matches[5],$matches[6]), $format_datetime);
586  }
587  break;
588  default:
589  $worksheet->write($row, $col, ilExcelUtils::_convert_text($value, $a_mode));
590  break;
591  }
592  $col++;
593  }
594 
595  // custom fields
596  reset($udf_ex_fields);
597  if (count($udf_ex_fields) > 0)
598  {
599  include_once("./Services/User/classes/class.ilUserDefinedData.php");
600  $udf = new ilUserDefinedData($rowdata["usr_id"]);
601  foreach ($udf_ex_fields as $f) // custom fields
602  {
603  $worksheet->write($row, $col, ilExcelUtils::_convert_text($udf->get("f_".$f["id"]), $a_mode));
604  $col++;
605  }
606  }
607  }
608  $workbook->close();
609  }
Class ilUserDefinedData.
_convert_text($a_text, $a_target="has been removed")
Class ilExcelWriterAdapter.
$filename
Definition: buildRTE.php:89
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
getUserDefinedExportFields()
Get all exportable user defined fields.
static excelTime($year="", $month="", $day="", $hour="", $minute="", $second="")
Calculates a Microsoft Excel date/time value.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createExportDirectory()

ilObjUserFolder::createExportDirectory ( )

creates data directory for export files (data_dir/usrf_data/export, depending on data directory that is set in ILIAS setup/ini)

Definition at line 767 of file class.ilObjUserFolder.php.

References ilUtil\getDataDir(), getExportDirectory(), and ilUtil\makeDir().

Referenced by buildExportFile().

768  {
769  if (!@is_dir($this->getExportDirectory()))
770  {
771  $usrf_data_dir = ilUtil::getDataDir()."/usrf_data";
772  ilUtil::makeDir($usrf_data_dir);
773  if(!is_writable($usrf_data_dir))
774  {
775  $this->ilias->raiseError("Userfolder data directory (".$usrf_data_dir
776  .") not writeable.",$this->ilias->error_obj->MESSAGE);
777  }
778 
779  // create Export subdirectory (data_dir/lm_data/lm_<id>/Export)
780  $export_dir = $usrf_data_dir."/export";
781  ilUtil::makeDir($export_dir);
782  if(!@is_dir($export_dir))
783  {
784  $this->ilias->raiseError("Creation of Userfolder Export Directory failed.",$this->ilias->error_obj->MESSAGE);
785  }
786  }
787  }
getExportDirectory()
Get the location of the export directory for the user accounts.
redirection script todo: (a better solution should control the processing via a xml file) ...
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static getDataDir()
get data directory (outside webspace)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createXMLExport()

ilObjUserFolder::createXMLExport ( $settings,
$data,
  $filename 
)

Definition at line 151 of file class.ilObjUserFolder.php.

References $data, $file, $filename, and $log.

Referenced by buildExportFile().

152  {
153  include_once './Services/User/classes/class.ilUserDefinedData.php';
154  include_once './Services/User/classes/class.ilObjUser.php';
155 
156  global $rbacreview;
157  global $ilDB;
158  global $log;
159 
160  $file = fopen($filename, "w");
161 
162  if (is_array($data))
163  {
164  include_once './Services/User/classes/class.ilUserXMLWriter.php';
165 
166  $xmlWriter = new ilUserXMLWriter();
167  $xmlWriter->setObjects($data);
168  $xmlWriter->setSettings($settings);
169  $xmlWriter->setAttachRoles (true);
170 
171  if($xmlWriter->start())
172  {
173  fwrite($file, $xmlWriter->getXML());
174  }
175  }
176 
177 /*
178  fwrite($file, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
179  fwrite($file, "<!DOCTYPE Users SYSTEM \"".ILIAS_HTTP_PATH."/xml/ilias_user_3_8.dtd\">\n");
180  fwrite($file, "<Users>");
181  foreach ($data as $row)
182  {
183  //$log->write(date("[y-m-d H:i:s] ")."User data export: processing user " . $row["login"]);
184  foreach ($row as $key => $value)
185  {
186  $row[$key] = $this->escapeXML($value);
187  }
188  $userline = "";
189  // TODO: Define combobox for "Action" ???
190  if (strlen($row["language"]) == 0) $row["language"] = "en";
191  $userline .= "<User Id=\"il_".IL_INST_ID."_usr_".$row["usr_id"]."\" Language=\"".$row["language"]."\" Action=\"Insert\">";
192  if (array_search("login", $settings) !== FALSE)
193  {
194  $userline .= "<Login>".$row["login"]."</Login>";
195  }
196  // Alternative way to get the roles of a user?
197  $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",
198  $ilDB->quote($row["usr_id"])
199  );
200  $rbacresult = $ilDB->query($query);
201  while ($rbacrow = $rbacresult->fetchRow(DB_FETCHMODE_ASSOC))
202  {
203  $type = "";
204  if ($rbacrow["assign"] == "y")
205  {
206  if ($rbacrow["parent"] == ROLE_FOLDER_ID)
207  {
208  $type = "Global";
209  }
210  else
211  {
212  $type = "Local";
213  }
214  if (strlen($type))
215  {
216  $userline .= "<Role Id=\"il_".IL_INST_ID."_role_".$rbacrow["rol_id"]."\" Type=\"".$type."\">".$rbacrow["title"]."</Role>";
217  }
218  }
219  }
220  //$log->write(date("[y-m-d H:i:s] ")."User data export: get all roles");
221  /* the export of roles is to expensive. on a system with 6000 users the following
222  section needs 37 seconds
223 
224  $roles = $rbacreview->getRolesByFilter(1, $row["usr_id"]);
225  $ass_roles = $rbacreview->assignedRoles($row["usr_id"]);
226  foreach ($roles as $role)
227  {
228  if (array_search($role["obj_id"], $ass_roles) !== FALSE)
229  {
230  $type = "";
231  switch ($role["role_type"])
232  {
233  case "global":
234  $type = "Global";
235  break;
236  case "local":
237  $type = "Local";
238  break;
239  }
240  if (strlen($type))
241  {
242  $userline .= "<Role Id=\"".$role["obj_id"]."\" Type=\"".$type."\">".$role["title"]."</Role>";
243  }
244  }
245  }
246  */
247 /* //$log->write(date("[y-m-d H:i:s] ")."User data export: got all roles");
248  $i2passwd = FALSE;
249  if (array_search("i2passwd", $settings) !== FALSE)
250  {
251  if (strlen($row["i2passwd"])) $i2passwd = TRUE;
252  if ($i2passwd) $userline .= "<Password Type=\"ILIAS2\">".$row["i2passwd"]."</Password>";
253  }
254  if ((!$i2passwd) && (array_search("passwd", $settings) !== FALSE))
255  {
256  if (strlen($row["passwd"])) $userline .= "<Password Type=\"ILIAS3\">".$row["passwd"]."</Password>";
257  }
258  if (array_search("firstname", $settings) !== FALSE)
259  {
260  if (strlen($row["firstname"])) $userline .= "<Firstname>".$row["firstname"]."</Firstname>";
261  }
262  if (array_search("lastname", $settings) !== FALSE)
263  {
264  if (strlen($row["lastname"])) $userline .= "<Lastname>".$row["lastname"]."</Lastname>";
265  }
266  if (array_search("title", $settings) !== FALSE)
267  {
268  if (strlen($row["title"])) $userline .= "<Title>".$row["title"]."</Title>";
269  }
270  if (array_search("upload", $settings) !== FALSE)
271  {
272  // personal picture
273  $q = sprintf("SELECT value FROM usr_pref WHERE usr_id=%s AND keyword='profile_image'", $ilDB->quote($row["usr_id"] . ""));
274  $r = $ilDB->query($q);
275  if ($r->numRows() == 1)
276  {
277  $personal_picture_data = $r->fetchRow(DB_FETCHMODE_ASSOC);
278  $personal_picture = $personal_picture_data["value"];
279  $webspace_dir = ilUtil::getWebspaceDir();
280  $image_file = $webspace_dir."/usr_images/".$personal_picture;
281  if (@is_file($image_file))
282  {
283  $fh = fopen($image_file, "rb");
284  if ($fh)
285  {
286  $image_data = fread($fh, filesize($image_file));
287  fclose($fh);
288  $base64 = base64_encode($image_data);
289  $imagetype = "image/jpeg";
290  if (preg_match("/.*\.(png|gif)$/", $personal_picture, $matches))
291  {
292  $imagetype = "image/".$matches[1];
293  }
294  $userline .= "<PersonalPicture imagetype=\"$imagetype\" encoding=\"Base64\">$base64</PersonalPicture>";
295  }
296  }
297  }
298  }
299  if (array_search("gender", $settings) !== FALSE)
300  {
301  if (strlen($row["gender"])) $userline .= "<Gender>".$row["gender"]."</Gender>";
302  }
303  if (array_search("email", $settings) !== FALSE)
304  {
305  if (strlen($row["email"])) $userline .= "<Email>".$row["email"]."</Email>";
306  }
307  if (array_search("institution", $settings) !== FALSE)
308  {
309  if (strlen($row["institution"])) $userline .= "<Institution>".$row["institution"]."</Institution>";
310  }
311  if (array_search("street", $settings) !== FALSE)
312  {
313  if (strlen($row["street"])) $userline .= "<Street>".$row["street"]."</Street>";
314  }
315  if (array_search("city", $settings) !== FALSE)
316  {
317  if (strlen($row["city"])) $userline .= "<City>".$row["city"]."</City>";
318  }
319  if (array_search("zipcode", $settings) !== FALSE)
320  {
321  if (strlen($row["zipcode"])) $userline .= "<PostalCode>".$row["zipcode"]."</PostalCode>";
322  }
323  if (array_search("country", $settings) !== FALSE)
324  {
325  if (strlen($row["country"])) $userline .= "<Country>".$row["country"]."</Country>";
326  }
327  if (array_search("phone_office", $settings) !== FALSE)
328  {
329  if (strlen($row["phone_office"])) $userline .= "<PhoneOffice>".$row["phone_office"]."</PhoneOffice>";
330  }
331  if (array_search("phone_home", $settings) !== FALSE)
332  {
333  if (strlen($row["phone_home"])) $userline .= "<PhoneHome>".$row["phone_home"]."</PhoneHome>";
334  }
335  if (array_search("phone_mobile", $settings) !== FALSE)
336  {
337  if (strlen($row["phone_mobile"])) $userline .= "<PhoneMobile>".$row["phone_mobile"]."</PhoneMobile>";
338  }
339  if (array_search("fax", $settings) !== FALSE)
340  {
341  if (strlen($row["fax"])) $userline .= "<Fax>".$row["fax"]."</Fax>";
342  }
343  if (strlen($row["hobby"])) if (array_search("hobby", $settings) !== FALSE)
344  {
345  $userline .= "<Hobby>".$row["hobby"]."</Hobby>";
346  }
347  if (array_search("department", $settings) !== FALSE)
348  {
349  if (strlen($row["department"])) $userline .= "<Department>".$row["department"]."</Department>";
350  }
351  if (array_search("referral_comment", $settings) !== FALSE)
352  {
353  if (strlen($row["referral_comment"])) $userline .= "<Comment>".$row["referral_comment"]."</Comment>";
354  }
355  if (array_search("matriculation", $settings) !== FALSE)
356  {
357  if (strlen($row["matriculation"])) $userline .= "<Matriculation>".$row["matriculation"]."</Matriculation>";
358  }
359  if (array_search("active", $settings) !== FALSE)
360  {
361  if ($row["active"])
362  {
363  $userline .= "<Active>true</Active>";
364  }
365  else
366  {
367  $userline .= "<Active>false</Active>";
368  }
369  }
370  if (array_search("client_ip", $settings) !== FALSE)
371  {
372  if (strlen($row["client_ip"])) $userline .= "<ClientIP>".$row["client_ip"]."</ClientIP>";
373  }
374  if (array_search("time_limit_owner", $settings) !== FALSE)
375  {
376  if (strlen($row["time_limit_owner"])) $userline .= "<TimeLimitOwner>".$row["time_limit_owner"]."</TimeLimitOwner>";
377  }
378  if (array_search("time_limit_unlimited", $settings) !== FALSE)
379  {
380  if (strlen($row["time_limit_unlimited"])) $userline .= "<TimeLimitUnlimited>".$row["time_limit_unlimited"]."</TimeLimitUnlimited>";
381  }
382  if (array_search("time_limit_from", $settings) !== FALSE)
383  {
384  if (strlen($row["time_limit_from"])) $userline .= "<TimeLimitFrom>".$row["time_limit_from"]."</TimeLimitFrom>";
385  }
386  if (array_search("time_limit_until", $settings) !== FALSE)
387  {
388  if (strlen($row["time_limit_until"])) $userline .= "<TimeLimitUntil>".$row["time_limit_until"]."</TimeLimitUntil>";
389  }
390  if (array_search("time_limit_message", $settings) !== FALSE)
391  {
392  if (strlen($row["time_limit_message"])) $userline .= "<TimeLimitMessage>".$row["time_limit_message"]."</TimeLimitMessage>";
393  }
394  if (array_search("approve_date", $settings) !== FALSE)
395  {
396  if (strlen($row["approve_date"])) $userline .= "<ApproveDate>".$row["approve_date"]."</ApproveDate>";
397  }
398  if (array_search("agree_date", $settings) !== FALSE)
399  {
400  if (strlen($row["agree_date"])) $userline .= "<AgreeDate>".$row["agree_date"]."</AgreeDate>";
401  }
402  if ((int) $row["ilinc_id"] !=0) {
403  if (array_search("ilinc_id", $settings) !== FALSE)
404  {
405  if (strlen($row["ilinc_id"])) $userline .= "<iLincID>".$row["ilinc_id"]."</iLincID>";
406  }
407  if (array_search("ilinc_login", $settings) !== FALSE)
408  {
409  if (strlen($row["ilinc_login"])) $userline .= "<iLincLogin>".$row["ilinc_login"]."</iLincLogin>";
410  }
411  if (array_search("ilinc_passwd", $settings) !== FALSE)
412  {
413  if (strlen($row["ilinc_passwd"])) $userline .= "<iLincPasswd>".$row["ilinc_passwd"]."</iLincPasswd>";
414  }
415  }
416  if (array_search("auth_mode", $settings) !== FALSE)
417  {
418  if (strlen($row["auth_mode"])) $userline .= "<AuthMode type=\"".$row["auth_mode"]."\"></AuthMode>";
419  }
420  if (array_search("skin_style", $settings) !== FALSE)
421  {
422  $userline .=
423  "<Look Skin=\"" . ilObjUser::_lookupPref($row["usr_id"], "skin") . "\" " .
424  "Style=\"" . ilObjUser::_lookupPref($row["usr_id"], "style") . "\"></Look>";
425  }
426 
427  if (array_search("last_update", $settings) !== FALSE)
428  {
429  if (strlen($row["last_update"])) $userline .= "<LastUpdate>".$row["last_update"]."</LastUpdate>";
430  }
431 
432  if (array_search("last_login", $settings) !== FALSE)
433  {
434  if (strlen($row["last_login"])) $userline .= "<LastLogin>".$row["last_login"]."</LastLogin>";
435  }
436 
437  // Append User defined field data
438  $udf_data = new ilUserDefinedData($row['usr_id']);
439  $userline .= $udf_data->toXML();
440 
441  $userline .= "</User>";
442  fwrite($file, $userline);
443  }
444  fwrite($file, "</Users>");
445  fclose($file);*/
446  }
print $file
XML writer class.
$filename
Definition: buildRTE.php:89
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
+ Here is the caller graph for this function:

◆ delete()

ilObjUserFolder::delete ( )

delete userfolder and all related data DISABLED public

Returns
boolean true if all object data were removed; false if only a references were removed

Definition at line 39 of file class.ilObjUserFolder.php.

40  {
41  // DISABLED
42  return false;
43 
44  // always call parent delete function first!!
45  if (!parent::delete())
46  {
47  return false;
48  }
49  // put here userfolder specific stuff
50 
51  // always call parent delete function at the end!!
52  return true;
53  }

◆ escapeXML()

ilObjUserFolder::escapeXML (   $value)

Definition at line 143 of file class.ilObjUserFolder.php.

144  {
145  $value = str_replace("&", "&amp;", $value);
146  $value = str_replace("<", "&lt;", $value);
147  $value = str_replace(">", "&gt;", $value);
148  return $value;
149  }

◆ getExportDirectory()

ilObjUserFolder::getExportDirectory ( )

Get the location of the export directory for the user accounts.

Get the location of the export directory for the user accounts

public

Definition at line 88 of file class.ilObjUserFolder.php.

References ilUtil\getDataDir().

Referenced by buildExportFile(), createExportDirectory(), and getExportFiles().

89  {
90  $export_dir = ilUtil::getDataDir()."/usrf_data/export";
91 
92  return $export_dir;
93  }
static getDataDir()
get data directory (outside webspace)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getExportFilename()

ilObjUserFolder::getExportFilename (   $a_mode = "userfolder_export_excel_x86")

Definition at line 56 of file class.ilObjUserFolder.php.

References $filename.

Referenced by buildExportFile().

57  {
58  $filename = "";
59  //$settings = $this->ilias->getAllSettings();
60  //$this->inst_id = $settings["inst_id"];
61  $inst_id = IL_INST_ID;
62 
63  $date = time();
64 
65  switch($a_mode)
66  {
67  case "userfolder_export_excel_x86":
68  $filename = $date."__".$inst_id."__xls_usrf.xls";
69  break;
70  case "userfolder_export_csv":
71  $filename = $date."__".$inst_id."__csv_usrf.csv";
72  break;
73  case "userfolder_export_xml":
74  $filename = $date."__".$inst_id."__xml_usrf.xml";
75  break;
76  }
77  return $filename;
78  }
$filename
Definition: buildRTE.php:89
+ Here is the caller graph for this function:

◆ getExportFiles()

ilObjUserFolder::getExportFiles ( )

Get a list of the already exported files in the export directory.

Get a list of the already exported files in the export directory

Returns
array A list of file names public

Definition at line 103 of file class.ilObjUserFolder.php.

References $file, and getExportDirectory().

104  {
105  $dir = $this->getExportDirectory();
106 
107  // quit if export dir not available
108  if (!@is_dir($dir) or
109  !is_writeable($dir))
110  {
111  return array();
112  }
113 
114  // open directory
115  $dir = dir($dir);
116 
117  // initialize array
118  $file = array();
119 
120  // get files and save the in the array
121  while ($entry = $dir->read())
122  {
123  if ($entry != "." and
124  $entry != ".." and
125  preg_match("/^[0-9]{10}_{2}[0-9]+_{2}([a-z0-9]{3})_usrf\.[a-z]{1,3}\$/", $entry, $matches))
126  {
127  $filearray["filename"] = $entry;
128  $filearray["filesize"] = filesize($this->getExportDirectory()."/".$entry);
129  array_push($file, $filearray);
130  }
131  }
132 
133  // close import directory
134  $dir->close();
135 
136  // sort files
137  sort ($file);
138  reset ($file);
139 
140  return $file;
141  }
print $file
getExportDirectory()
Get the location of the export directory for the user accounts.
+ Here is the call graph for this function:

◆ getExportSettings()

static ilObjUserFolder::getExportSettings ( )
static

getExport Settings

Returns
array of exportable fields

Definition at line 616 of file class.ilObjUserFolder.php.

References $query, $result, $row, and DB_FETCHMODE_ASSOC.

Referenced by ilUserXMLWriter\__handleUser(), and buildExportFile().

617  {
618  global $ilDB;
619 
620  $db_settings = array();
621 
622  include_once("./Services/User/classes/class.ilUserProfile.php");
623  $up = new ilUserProfile();
624  $up->skipField("roles");
625  $profile_fields = $up->getStandardFields();
626 
627  /*$profile_fields =& ilObjUserFolder::getProfileFields();
628  $profile_fields[] = "preferences";*/
629 
630  $query = "SELECT * FROM settings WHERE ".
631  $ilDB->like("keyword", "text", '%usr_settings_export_%');
632  $result = $ilDB->query($query);
633  while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
634  {
635  if ($row["value"] == "1")
636  {
637  if (preg_match("/usr_settings_export_(.*)/", $row["keyword"], $setting))
638  {
639  array_push($db_settings, $setting[1]);
640  }
641  }
642  }
643  $export_settings = array();
644  foreach ($profile_fields as $key => $value)
645  {
646  if (in_array($key, $db_settings))
647  {
648  if (strcmp($key, "password") == 0)
649  {
650  array_push($export_settings, "passwd");
651  }
652  else
653  {
654  array_push($export_settings, $key);
655  }
656  }
657  }
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");
678 
679  return $export_settings;
680  }
$result
Class ilUserProfile.
const DB_FETCHMODE_ASSOC
Definition: class.ilDB.php:10
+ Here is the caller graph for this function:

◆ getProfileFields()

static& ilObjUserFolder::getProfileFields ( )
static

Get profile fields (DEPRECATED, use ilUserProfile() instead)

Returns
array of fieldnames

Definition at line 795 of file class.ilObjUserFolder.php.

796  {
797  include_once("./Services/User/classes/class.ilUserProfile.php");
798  $up = new ilUserProfile();
799  $up->skipField("username");
800  $up->skipField("roles");
801  $up->skipGroup("preferences");
802  $fds = $up->getStandardFields();
803  foreach ($fds as $k => $f)
804  {
805  $profile_fields[] = $k;
806  }
807 
808  return $profile_fields;
809  }
Class ilUserProfile.

◆ getUserDefinedExportFields()

ilObjUserFolder::getUserDefinedExportFields ( )

Get all exportable user defined fields.

Definition at line 452 of file class.ilObjUserFolder.php.

References ilUserDefinedFields\_getInstance().

Referenced by createCSVExport(), and createExcelExport().

453  {
454  include_once './Services/User/classes/class.ilUserDefinedFields.php';
455  $udf_obj =& ilUserDefinedFields::_getInstance();
456 
457  $udf_ex_fields = array();
458  foreach($udf_obj->getDefinitions() as $definition)
459  {
460  if ($definition["export"] != FALSE)
461  {
462  $udf_ex_fields[] = array("name" => $definition["field_name"],
463  "id" => $definition["field_id"]);
464  }
465  }
466 
467  return $udf_ex_fields;
468  }
static _getInstance()
Get instance.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ilObjUserFolder()

ilObjUserFolder::ilObjUserFolder (   $a_id,
  $a_call_by_reference = true 
)

Constructor public.

Parameters
integerreference_id or object_id
booleantreat the id as reference_id (true) or object_id (false)

Definition at line 26 of file class.ilObjUserFolder.php.

References ilObject\ilObject().

27  {
28  $this->type = "usrf";
29  $this->ilObject($a_id,$a_call_by_reference);
30  }
ilObject($a_id=0, $a_reference=true)
Constructor public.
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: