ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilUserDataSet Class Reference

Exercise data set class. More...

+ Inheritance diagram for ilUserDataSet:
+ Collaboration diagram for ilUserDataSet:

Public Member Functions

 getSupportedVersions ()
 Get supported versions.
 getXmlNamespace ($a_entity, $a_schema_version)
 Get xml namespace.
 getXmlRecord ($a_entity, $a_version, $a_set)
 Get xml record.
 afterXmlRecordWriting ($a_entity, $a_version, $a_set)
 After xml record writing hook record.
 readData ($a_entity, $a_version, $a_ids, $a_field="")
 Read data.
 importRecord ($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
 Import record.
- Public Member Functions inherited from ilDataSet
 __construct ()
 Constructor.
 init ($a_entity, $a_schema_version)
 Init.
 readData ($a_entity, $a_version, $a_ids)
 Read data from DB.
 setExportDirectories ($a_relative, $a_absolute)
 Set export directories.
 setImportDirectory ($a_val)
 Set import directory.
 getImportDirectory ()
 Get import directory.
 setDSPrefix ($a_val)
 Set XML dataset namespace prefix.
 getDSPrefix ()
 Get XML dataset namespace prefix.
 getDSPrefixString ()
 getDirectDataFromQuery ($a_query, $a_convert_to_leading_upper=true)
 Get data from query.This is a standard procedure, all db field names are directly mapped to abstract fields.
 convertToLeadingUpper ($a_str)
 Make xyz_abc a XyzAbc string.
 getJsonRepresentation ()
 Get json representation.
 getXmlRepresentation ($a_entity, $a_schema_version, $a_ids, $a_field="", $a_omit_header=false, $a_omit_types=false)
 Get xml representation <dataset install_id="123" install_url="..."> <types entity="table_name" version="4.0.1"> <ftype name="field_1" type="text"> <ftype name="field_2" type="date"> <ftype name="field_3" type="integer"> </types> <types ...> ...
 addRecordsXml ($a_writer, $a_prefixes, $a_entity, $a_schema_version, $a_ids, $a_field="")
 Add records xml.
 getNamespaces (&$namespaces, $a_entity, $a_schema_version)
 Get xml namespaces.
 getJsonRecord ($a_set)
 Get json record for version.
 getXmlTypes ($a_entity, $a_version)
 Get xml types.
 getJsonTypes ($a_entity, $a_version)
 Get json types.
 getXMLEntityName ($a_entity, $a_version)
 Get entity name for xml (may be overwritten)
 getXMLEntityTag ($a_entity, $a_schema_version)
 Get entity tag.
 getJsonEntityName ($a_entity, $a_version)
 Get entity name for json (may be overwritten)
 setImport ($a_val)
 Set import object.
 getImport ()
 Get import object.

Protected Member Functions

 getTypes ($a_entity, $a_version)
 Get field types for entity.
 getDependencies ($a_entity, $a_version, $a_rec, $a_ids)
 Determine the dependent sets of data.
- Protected Member Functions inherited from ilDataSet
 createObjectExportId ($a_type, $a_id)
 Build ilias export id.
 parseObjectExportId ($a_id, $a_fallback_id=NULL)
 Parse export id.

Protected Attributes

 $temp_picture_dirs = array()

Additional Inherited Members

- Data Fields inherited from ilDataSet
 $dircnt
const EXPORT_NO_INST_ID = 1
const EXPORT_ID_ILIAS_LOCAL = 2
const EXPORT_ID_ILIAS_LOCAL_INVALID = 3
const EXPORT_ID_ILIAS_REMOTE = 4
const EXPORT_ID_ILIAS_REMOTE_INVALID = 5
const EXPORT_ID = 6
const EXPORT_ID_INVALID = 7

Detailed Description

Exercise data set class.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 13 of file class.ilUserDataSet.php.

Member Function Documentation

ilUserDataSet::afterXmlRecordWriting (   $a_entity,
  $a_version,
  $a_set 
)

After xml record writing hook record.

Parameters
@return

Reimplemented from ilDataSet.

Definition at line 142 of file class.ilUserDataSet.php.

References ilUtil\delDir().

{
if ($a_entity == "usr_profile")
{
// cleanup temp dirs for pictures
$tmp_dir = $this->temp_picture_dirs[$a_set["Id"]];
if ($tmp_dir != "" && is_dir($tmp_dir))
{
ilUtil::delDir($tmp_dir);
}
}
}

+ Here is the call graph for this function:

ilUserDataSet::getDependencies (   $a_entity,
  $a_version,
  $a_rec,
  $a_ids 
)
protected

Determine the dependent sets of data.

Definition at line 243 of file class.ilUserDataSet.php.

{
return false;
switch ($a_entity)
{
case "personal_data":
return array (
"usr_profile" => array("ids" => $a_rec["Id"]),
"usr_setting" => array("ids" => $a_rec["Id"])
);
}
return false;
}
ilUserDataSet::getSupportedVersions ( )

Get supported versions.

Parameters
@return

Reimplemented from ilDataSet.

Definition at line 23 of file class.ilUserDataSet.php.

{
return array("4.3.0");
}
ilUserDataSet::getTypes (   $a_entity,
  $a_version 
)
protected

Get field types for entity.

Parameters
@return

Reimplemented from ilDataSet.

Definition at line 45 of file class.ilUserDataSet.php.

{
// user profile type
if ($a_entity == "usr_profile")
{
switch ($a_version)
{
case "4.3.0":
return array(
"Id" => "integer",
"Username" => "text",
"Firstname" => "text",
"Lastname" => "text",
"Title" => "text",
"Birthday" => "text",
"Gender" => "text",
"Institution" => "text",
"Department" => "text",
"Street" => "text",
"Zipcode" => "text",
"City" => "text",
"Country" => "text",
"SelCountry" => "text",
"PhoneOffice" => "text",
"PhoneHome" => "text",
"PhoneMobile" => "text",
"Fax" => "text",
"Email" => "text",
"Hobby" => "text",
"ReferralComment" => "text",
"Matriculation" => "text",
"Delicious" => "text",
"Latitude" => "text",
"Longitude" => "text",
"Picture" => "directory"
);
}
}
if ($a_entity == "usr_setting")
{
switch ($a_version)
{
case "4.3.0":
return array(
"UserId" => "integer",
"Keyword" => "text",
"Value" => "text"
);
}
}
if ($a_entity == "personal_data")
{
switch ($a_version)
{
case "4.3.0":
return array(
"Id" => "integer"
);
}
}
}
ilUserDataSet::getXmlNamespace (   $a_entity,
  $a_schema_version 
)

Get xml namespace.

Parameters
@return

Reimplemented from ilDataSet.

Definition at line 34 of file class.ilUserDataSet.php.

{
return "http://www.ilias.de/xml/Services/User/".$a_entity;
}
ilUserDataSet::getXmlRecord (   $a_entity,
  $a_version,
  $a_set 
)

Get xml record.

Parameters
@return

Reimplemented from ilDataSet.

Definition at line 117 of file class.ilUserDataSet.php.

References $ilLog, ilObjUser\copyProfilePicturesToDirectory(), ilUtil\ilTempnam(), and ilUtil\makeDir().

{
global $ilLog;
if ($a_entity == "usr_profile")
{
$tmp_dir = ilUtil::ilTempnam();
ilUtil::makeDir($tmp_dir);
include_once("./Services/User/classes/class.ilObjUser.php");
$this->temp_picture_dirs[$a_set["Id"]] = $tmp_dir;
$a_set["Picture"] = $tmp_dir;
}
return $a_set;
}

+ Here is the call graph for this function:

ilUserDataSet::importRecord (   $a_entity,
  $a_types,
  $a_rec,
  $a_mapping,
  $a_schema_version 
)

Import record.

Parameters
@return

Definition at line 264 of file class.ilUserDataSet.php.

References $ilSetting, $ilUser, $usr_id, ilObject\_lookupType(), ilObjUser\_uploadPersonalPicture(), ilDataSet\convertToLeadingUpper(), ilDataSet\getImportDirectory(), and ilUserProfile\userSettingVisible().

{
//echo $a_entity;
//var_dump($a_rec);
switch ($a_entity)
{
case "personal_data":
// only users themselves import their profiles!
// thus we can map the import id of the dataset to the current user
$a_mapping->addMapping("Services/User", "usr", $a_rec["Id"], $ilUser->getId());
break;
case "usr_profile":
$usr_id = $a_mapping->getMapping("Services/User", "usr", $a_rec["Id"]);
if ($usr_id > 0 && ilObject::_lookupType($usr_id) == "usr")
{
if (!isset($this->users[$usr_id]))
{
$this->users[$usr_id] = new ilObjUser($usr_id);
}
$user = $this->users[$usr_id];
include_once("./Services/User/classes/class.ilUserProfile.php");
$prof = new ilUserProfile();
$prof->skipField("username");
$prof->skipField("password");
$prof->skipField("roles");
$prof->skipGroup("settings");
$fields = $prof->getStandardFields();
foreach ($fields as $k => $f)
{
$up_k = $this->convertToLeadingUpper($k);
// only change fields, when it is possible in profile
!$ilSetting->get("usr_settings_disable_".$k) &&
$f["method"] != "" && isset($a_rec[$up_k]))
{
$set_method = "set".substr($f["method"], 3);
$user->{$set_method}($a_rec[$up_k]);
// echo "<br>-setting-".$set_method."-".$a_rec[$up_k]."-";
}
}
$user->update();
// personal picture
$pic_dir = $this->getImportDirectory()."/".str_replace("..", "", $a_rec["Picture"]);
if ($pic_dir != "" && is_dir($pic_dir))
{
$upload_file = $pic_dir."/upload_".$a_rec["Id"]."pic";
if (is_file($upload_file))
{
ilObjUser::_uploadPersonalPicture($upload_file, $user->getId());
}
}
}
break;
case "usr_setting":
$usr_id = $a_mapping->getMapping("Services/User", "usr", $a_rec["UserId"]);
if ($usr_id > 0 && ilObject::_lookupType($usr_id) == "usr")
{
if (!isset($this->users[$usr_id]))
{
$this->users[$usr_id] = new ilObjUser($usr_id);
}
$user = $this->users[$usr_id];
$user->writePref($a_rec["Keyword"], $a_rec["Value"]);
}
break;
}
}

+ Here is the call graph for this function:

ilUserDataSet::readData (   $a_entity,
  $a_version,
  $a_ids,
  $a_field = "" 
)

Read data.

Parameters
@return

Definition at line 161 of file class.ilUserDataSet.php.

References ilDataSet\getDirectDataFromQuery().

{
global $ilDB;
if (!is_array($a_ids))
{
$a_ids = array($a_ids);
}
if ($a_entity == "personal_data")
{
switch ($a_version)
{
case "4.3.0":
$this->data = array();
foreach ($a_ids as $id)
{
$this->data[] = array("Id" => $id);
}
break;
}
}
if ($a_entity == "usr_profile")
{
switch ($a_version)
{
case "4.3.0":
$this->getDirectDataFromQuery("SELECT usr_id id, login username, firstname, lastname, ".
" title, birthday, gender, institution, department, street, city, zipcode, country, sel_country, ".
" phone_office, phone_home, phone_mobile, fax, email, hobby, referral_comment, matriculation, ".
" delicious, latitude, longitude".
" FROM usr_data u ".
"WHERE ".
$ilDB->in("u.usr_id", $a_ids, false, "integer"));
break;
}
}
if ($a_entity == "usr_setting")
{
switch ($a_version)
{
case "4.3.0":
// for all user ids get data from usr_pref and mail options, create records user_id/name/value
$prefs = array("date_format", "day_end", "day_start", "hide_own_online_status", "hits_per_page", "language",
"public_birthday", "puplic_city", "public_country", "public_delicious", "public_department", "public_email",
"public_fax", "public_gender", "public_hobby", "public_im_aim", "public_im_icq", "public_im_jabber",
"public_im_msn", "public_im_skype", "public_im_voip", "public_im_yahoo", "public_institution", "public_location",
"public_matriculation", "public_phone_home", "public_phone_mobile", "public_phone_office", "public_profile",
"public_sel_country", "public_street", "public_title", "public_upload", "public_zipcode",
"screen_reader_optimization", "show_users_online",
"store_last_visited", "time_format", "user_tz", "weekstart");
$this->data = array();
$set = $ilDB->query("SELECT * FROM usr_pref ".
" WHERE ".$ilDB->in("keyword", $prefs, false, "text").
" AND ".$ilDB->in("usr_id", $a_ids, false, "integer"));
while ($rec = $ilDB->fetchAssoc($set))
{
$this->data[] = array("UserId" => $rec["usr_id"], "Keyword" => $rec["keyword"], "Value" => $rec["value"]);
}
/*
require_once 'Services/Mail/classes/class.ilMailOptions.php';
$mailOptions = new ilMailOptions($ilUser->getId());
/*$this->getDirectDataFromQuery("SELECT usr_id id, login username, firstname, lastname, ".
" title, birthday, gender, institution, department, street, city, zipcode, country, sel_country, ".
" phone_office, phone_home, phone_mobile, fax, email, hobby, referral_comment, matriculation, ".
" delicious, latitude, longitude".
" FROM usr_data u ".
"WHERE ".
$ilDB->in("u.usr_id", $a_ids, false, "integer"));*/
break;
}
}
}

+ Here is the call graph for this function:

Field Documentation

ilUserDataSet::$temp_picture_dirs = array()
protected

Definition at line 15 of file class.ilUserDataSet.php.


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