ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilAdvancedMDRecord Class Reference
+ Collaboration diagram for ilAdvancedMDRecord:

Public Member Functions

 __construct ($a_record_id=0)
 Singleton constructor To create an array of new records (without saving them) call the constructor directly.
 delete ()
 Delete.
 save ()
 save
 update ()
 update
 validate ()
 Validate settings Write error message to ilErr.
 getRecordId ()
 Get record id.
 setActive ($a_active)
 Set active.
 isActive ()
 Check if record is active.
 setTitle ($a_title)
 Set title.
 getTitle ()
 get title
 setDescription ($a_description)
 set description
 getDescription ()
 get description
 setImportId ($a_id_string)
 set import id
 getImportId ()
 get import id
 setAssignedObjectTypes ($a_obj_types)
 Set assigned object types.
 appendAssignedObjectType ($a_obj_type)
 append assigned object types
 getAssignedObjectTypes ()
 Get assigned object types.
 toXML (ilXmlWriter $writer)
 To Xml.
 __destruct ()
 Destructor.

Static Public Member Functions

static _getInstanceByRecordId ($a_record_id)
 Get instance by record id.
static _getActiveSearchableRecords ()
 Get active searchable records.
static _lookupTitle ($a_record_id)
 Lookup title.
static _lookupRecordIdByImportId ($a_ilias_id)
 Lookup record Id by import id.
static _getAssignableObjectTypes ()
 Get assignable object type.
static _getActivatedObjTypes ()
 get activated obj types
static _getRecords ()
 Get records.
static _getAllRecordsByObjectType ()
 Get records by obj_type.
static _getActivatedRecordsByObjectType ($a_obj_type)
 Get activated records by object type.
static _delete ($a_record_id)
 Delete record and all related data.

Protected Member Functions

 generateImportId ()
 generate unique record id

Protected Attributes

 $record_id
 $import_id
 $active
 $title
 $description
 $obj_types = array()
 $db = null

Private Member Functions

 read ()
 read record and assiged object types

Static Private Attributes

static $instances = array()

Detailed Description

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

Constructor & Destructor Documentation

ilAdvancedMDRecord::__construct (   $a_record_id = 0)

Singleton constructor To create an array of new records (without saving them) call the constructor directly.

Otherwise call getInstance...

public

Parameters
intrecord id

Definition at line 55 of file class.ilAdvancedMDRecord.php.

References getRecordId(), and read().

{
global $ilDB;
$this->record_id = $a_record_id;
$this->db = $ilDB;
if($this->getRecordId())
{
$this->read();
}
}

+ Here is the call graph for this function:

ilAdvancedMDRecord::__destruct ( )

Destructor.

public

Definition at line 595 of file class.ilAdvancedMDRecord.php.

References getRecordId().

{
unset(self::$instances[$this->getRecordId()]);
}

+ Here is the call graph for this function:

Member Function Documentation

static ilAdvancedMDRecord::_delete (   $a_record_id)
static

Delete record and all related data.

public

Parameters
intrecord id

Definition at line 271 of file class.ilAdvancedMDRecord.php.

References ilAdvancedMDFieldDefinition\_deleteByRecordId().

Referenced by delete().

{
global $ilDB;
// Delete fields
$query = "DELETE FROM adv_md_record ".
"WHERE record_id = ".$ilDB->quote($a_record_id)." ";
$ilDB->query($query);
$query = "DELETE FROM adv_md_record_objs ".
"WHERE record_id = ".$ilDB->quote($a_record_id)." ";
$ilDB->query($query);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilAdvancedMDRecord::_getActivatedObjTypes ( )
static

get activated obj types

public

Parameters
stringobj types

Definition at line 175 of file class.ilAdvancedMDRecord.php.

References $obj_types, $res, and DB_FETCHMODE_OBJECT.

Referenced by ilAdvancedSearchGUI\__setSearchOptions(), ilObjCategoryGUI\getSubTabs(), ilAdvancedSearchGUI\initAdvancedMetaDataForm(), and ilAdvancedMDSettingsGUI\updateSubstitutions().

{
global $ilDB;
$query = "SELECT DISTINCT(obj_type) FROM adv_md_record_objs AS amo ".
"JOIN adv_md_record AS amr ON amo.record_id = amr.record_id ".
"WHERE active = 1 ";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$obj_types[] = $row->obj_type;
}
return $obj_types ? $obj_types : array();
}

+ Here is the caller graph for this function:

static ilAdvancedMDRecord::_getActivatedRecordsByObjectType (   $a_obj_type)
static

Get activated records by object type.

public

Parameters
stringobj_type

Definition at line 242 of file class.ilAdvancedMDRecord.php.

References $res, _getInstanceByRecordId(), and DB_FETCHMODE_OBJECT.

Referenced by ilSoapInstallationInfoXMLWriter\__buildClient(), ilSoapAdministration\getNIC(), ilAdvancedMDRecordGUI\parseEditor(), and ilAdvancedMDRecordGUI\parseInfoPage().

{
global $ilDB;
$records = array();
$query = "SELECT amro.record_id AS record_id FROM adv_md_record_objs AS amro ".
"JOIN adv_md_record AS amr ON amr.record_id = amro.record_id ".
"WHERE active = 1 ".
"AND obj_type = ".$ilDB->quote($a_obj_type)." ";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$records[] = self::_getInstanceByRecordId($row->record_id);
}
return $records;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilAdvancedMDRecord::_getActiveSearchableRecords ( )
static

Get active searchable records.

public

Definition at line 92 of file class.ilAdvancedMDRecord.php.

References $res, _getInstanceByRecordId(), and DB_FETCHMODE_OBJECT.

Referenced by ilAdvancedMDRecordGUI\parseSearch().

{
global $ilDB;
$query = "SELECT DISTINCT(amr.record_id) FROM adv_md_record AS amr ".
"JOIN adv_md_field_definition USING (record_id) ".
"WHERE searchable = 1 AND active = 1";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$records[] = self::_getInstanceByRecordId($row->record_id);
}
return $records ? $records : array();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilAdvancedMDRecord::_getAllRecordsByObjectType ( )
static

Get records by obj_type.

public

Parameters

Definition at line 219 of file class.ilAdvancedMDRecord.php.

References $res, _getInstanceByRecordId(), and DB_FETCHMODE_OBJECT.

Referenced by ilAdvancedMDSettingsGUI\initFormSubstitutions().

{
global $ilDB;
$records = array();
$query = "SELECT * FROM adv_md_record_objs ";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$records[$row->obj_type][] = self::_getInstanceByRecordId($row->record_id);
}
return $records;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilAdvancedMDRecord::_getAssignableObjectTypes ( )
static

Get assignable object type.

public

Definition at line 162 of file class.ilAdvancedMDRecord.php.

Referenced by ilSoapInstallationInfoXMLWriter\__buildClient(), ilAdvancedMDRecordTableGUI\fillRow(), ilSoapAdministration\getNIC(), and ilAdvancedMDSettingsGUI\initForm().

{
return array('cat','crs','rcrs');
}

+ Here is the caller graph for this function:

static ilAdvancedMDRecord::_getInstanceByRecordId (   $a_record_id)
static

Get instance by record id.

public

Parameters
intrecord id

Definition at line 76 of file class.ilAdvancedMDRecord.php.

Referenced by _getActivatedRecordsByObjectType(), _getActiveSearchableRecords(), _getAllRecordsByObjectType(), _getRecords(), ilAdvancedMDSettingsGUI\confirmDeleteRecords(), ilAdvancedMDSettingsGUI\deleteRecords(), ilAdvancedMDRecordParser\initRecordObject(), and ilAdvancedMDSettingsGUI\initRecordObject().

{
if(isset(self::$instances[$a_record_id]))
{
return self::$instances[$a_record_id];
}
return self::$instances[$a_record_id] = new ilAdvancedMDRecord($a_record_id);
}

+ Here is the caller graph for this function:

static ilAdvancedMDRecord::_getRecords ( )
static

Get records.

public

Parameters
arrayarray of record objects

Definition at line 198 of file class.ilAdvancedMDRecord.php.

References $res, _getInstanceByRecordId(), and DB_FETCHMODE_OBJECT.

Referenced by ilAdvancedMDSettingsGUI\getRecordObjects().

{
global $ilDB;
$query = "SELECT record_id FROM adv_md_record ";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$records[] = ilAdvancedMDRecord::_getInstanceByRecordId($row->record_id);
}
return $records ? $records : array();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilAdvancedMDRecord::_lookupRecordIdByImportId (   $a_ilias_id)
static

Lookup record Id by import id.

public

Parameters
stringilias id

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

References $res, and DB_FETCHMODE_OBJECT.

Referenced by ilAdvancedMDRecordParser\extractRecordId().

{
global $ilDB;
$query = "SELECT record_id FROM adv_md_record ".
"WHERE import_id = ".$ilDB->quote($a_ilias_id)." ";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
return $row->record_id;
}
return 0;
}

+ Here is the caller graph for this function:

static ilAdvancedMDRecord::_lookupTitle (   $a_record_id)
static

Lookup title.

public

Parameters
intrecord_id

Definition at line 115 of file class.ilAdvancedMDRecord.php.

References $res, and DB_FETCHMODE_OBJECT.

Referenced by ilAdvancedMDSettingsGUI\initFormSubstitutions(), and ilECSSettingsGUI\prepareFieldSelection().

{
static $title_cache = array();
if(isset($title_cache[$a_record_id]))
{
return $title_cache[$a_record_id];
}
global $ilDB;
$query = "SELECT title FROm adv_md_record ".
"WHERE record_id = ".$ilDB->quote($a_record_id)." ";
$res = $ilDB->query($query);
$row = $res->fetchRow(DB_FETCHMODE_OBJECT);
return $title_cache[$a_record_id] = $row->title;
}

+ Here is the caller graph for this function:

ilAdvancedMDRecord::appendAssignedObjectType (   $a_obj_type)

append assigned object types

public

Parameters
stringilias object type

Definition at line 505 of file class.ilAdvancedMDRecord.php.

{
$this->obj_types[] = $a_obj_type;
}
ilAdvancedMDRecord::delete ( )

Delete.

public

Definition at line 294 of file class.ilAdvancedMDRecord.php.

References _delete(), and getRecordId().

+ Here is the call graph for this function:

ilAdvancedMDRecord::generateImportId ( )
protected

generate unique record id

protected

Returns

Definition at line 584 of file class.ilAdvancedMDRecord.php.

References getRecordId().

Referenced by save(), and toXML().

{
return 'il_'.IL_INST_ID.'_adv_md_record_'.$this->getRecordId();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAdvancedMDRecord::getAssignedObjectTypes ( )

Get assigned object types.

public

Definition at line 516 of file class.ilAdvancedMDRecord.php.

Referenced by save(), toXML(), and update().

{
return $this->obj_types ? $this->obj_types : array();
}

+ Here is the caller graph for this function:

ilAdvancedMDRecord::getDescription ( )

get description

public

Definition at line 458 of file class.ilAdvancedMDRecord.php.

References $description.

Referenced by save(), toXML(), and update().

{
}

+ Here is the caller graph for this function:

ilAdvancedMDRecord::getImportId ( )

get import id

public

Definition at line 481 of file class.ilAdvancedMDRecord.php.

References $import_id.

Referenced by save().

{
}

+ Here is the caller graph for this function:

ilAdvancedMDRecord::getRecordId ( )

Get record id.

public

Definition at line 389 of file class.ilAdvancedMDRecord.php.

References $record_id.

Referenced by __construct(), __destruct(), delete(), generateImportId(), read(), save(), toXML(), and update().

{
}

+ Here is the caller graph for this function:

ilAdvancedMDRecord::getTitle ( )

get title

public

Definition at line 435 of file class.ilAdvancedMDRecord.php.

References $title.

Referenced by save(), toXML(), update(), and validate().

{
return $this->title;
}

+ Here is the caller graph for this function:

ilAdvancedMDRecord::isActive ( )

Check if record is active.

public

Definition at line 412 of file class.ilAdvancedMDRecord.php.

References $active.

Referenced by save(), toXML(), and update().

{
return (bool) $this->active;
}

+ Here is the caller graph for this function:

ilAdvancedMDRecord::read ( )
private

read record and assiged object types

private

Parameters

Definition at line 557 of file class.ilAdvancedMDRecord.php.

References $res, DB_FETCHMODE_OBJECT, getRecordId(), setActive(), setDescription(), setImportId(), and setTitle().

Referenced by __construct().

{
$query = "SELECT * FROM adv_md_record ".
"WHERE record_id = ".$this->db->quote($this->getRecordId())." ";
$res = $this->db->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->setImportId($row->import_id);
$this->setActive($row->active);
$this->setTitle($row->title);
$this->setDescription($row->description);
}
$query = "SELECT * FROM adv_md_record_objs ".
"WHERE record_id = ".$this->db->quote($this->getRecordId())." ";
$res = $this->db->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->obj_types[] = $row->obj_type;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAdvancedMDRecord::save ( )

save

public

Definition at line 305 of file class.ilAdvancedMDRecord.php.

References $res, generateImportId(), getAssignedObjectTypes(), getDescription(), getImportId(), getRecordId(), getTitle(), and isActive().

{
// Save import id if given
$query = "INSERT INTO adv_md_record ".
"SET import_id = ".$this->db->quote($this->getImportId()).", ".
"active = ".$this->db->quote($this->isActive()).", ".
"title = ".$this->db->quote($this->getTitle()).", ".
"description = ".$this->db->quote($this->getDescription())." ";
$this->db->query($query);
$this->record_id = $this->db->getLastInsertId();
if(!strlen($this->getImportId()))
{
// set import id to default value
$query = "UPDATE adv_md_record ".
"SET import_id = ".$this->db->quote($this->generateImportId())." ".
"WHERE record_id = ".$this->db->quote($this->record_id)." ";
$res = $this->db->query($query);
}
foreach($this->getAssignedObjectTypes() as $type)
{
$query = "INSERT INTO adv_md_record_objs ".
"SET record_id = ".$this->db->quote($this->getRecordId()).", ".
"obj_type = ".$this->db->quote($type)." ";
$this->db->query($query);
}
}

+ Here is the call graph for this function:

ilAdvancedMDRecord::setActive (   $a_active)

Set active.

public

Parameters

Definition at line 401 of file class.ilAdvancedMDRecord.php.

Referenced by read().

{
$this->active = $a_active;
}

+ Here is the caller graph for this function:

ilAdvancedMDRecord::setAssignedObjectTypes (   $a_obj_types)

Set assigned object types.

public

Parameters
arrayarray(string) array of object types. E.g array('crs','crsl')

Definition at line 493 of file class.ilAdvancedMDRecord.php.

{
$this->obj_types = $a_obj_types;
}
ilAdvancedMDRecord::setDescription (   $a_description)

set description

public

Parameters
stringdescription

Definition at line 447 of file class.ilAdvancedMDRecord.php.

Referenced by read().

{
$this->description = $a_description;
}

+ Here is the caller graph for this function:

ilAdvancedMDRecord::setImportId (   $a_id_string)

set import id

public

Parameters
stringimport id

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

Referenced by read().

{
$this->import_id = $a_id_string;
}

+ Here is the caller graph for this function:

ilAdvancedMDRecord::setTitle (   $a_title)

Set title.

public

Parameters
stringtitle

Definition at line 424 of file class.ilAdvancedMDRecord.php.

Referenced by read().

{
$this->title = $a_title;
}

+ Here is the caller graph for this function:

ilAdvancedMDRecord::toXML ( ilXmlWriter  $writer)

To Xml.

This method writes only the subset Record (including all fields) Use class.ilAdvancedMDRecordXMLWriter to generate a complete xml presentation.

public

Parameters
objectilXmlWriter

Definition at line 530 of file class.ilAdvancedMDRecord.php.

References ilAdvancedMDFieldDefinition\_getDefinitionsByRecordId(), generateImportId(), getAssignedObjectTypes(), getDescription(), getRecordId(), getTitle(), isActive(), ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

{
$writer->xmlStartTag('Record',array('active' => $this->isActive() ? 1 : 0,
'id' => $this->generateImportId()));
$writer->xmlElement('Title',null,$this->getTitle());
$writer->xmlElement('Description',null,$this->getDescription());
foreach($this->getAssignedObjectTypes() as $obj_type)
{
$writer->xmlElement('ObjectType',null,$obj_type);
}
include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
{
$definition->toXML($writer);
}
$writer->xmlEndTag('Record');
}

+ Here is the call graph for this function:

ilAdvancedMDRecord::update ( )

update

public

Definition at line 340 of file class.ilAdvancedMDRecord.php.

References getAssignedObjectTypes(), getDescription(), getRecordId(), getTitle(), and isActive().

{
$query = "UPDATE adv_md_record ".
"SET active = ".$this->db->quote($this->isActive()).", ".
"title = ".$this->db->quote($this->getTitle()).", ".
"description = ".$this->db->quote($this->getDescription())." ".
"WHERE record_id = ".$this->db->quote($this->getRecordId())." ";
$this->db->query($query);
// Delete assignments
$query = "DELETE FROM adv_md_record_objs ".
"WHERE record_id = ".$this->db->quote($this->getRecordId())." ";
$this->db->query($query);
// Insert assignments
foreach($this->getAssignedObjectTypes() as $type)
{
$query = "INSERT INTO adv_md_record_objs ".
"SET record_id = ".$this->db->quote($this->getRecordId()).", ".
"obj_type = ".$this->db->quote($type)." ";
$this->db->query($query);
}
}

+ Here is the call graph for this function:

ilAdvancedMDRecord::validate ( )

Validate settings Write error message to ilErr.

public

Definition at line 371 of file class.ilAdvancedMDRecord.php.

References $ilErr, $lng, and getTitle().

{
global $ilErr,$lng;
if(!strlen($this->getTitle()))
{
$ilErr->setMessage('fill_out_all_required_fields');
return false;
}
return true;
}

+ Here is the call graph for this function:

Field Documentation

ilAdvancedMDRecord::$active
protected

Definition at line 40 of file class.ilAdvancedMDRecord.php.

Referenced by isActive().

ilAdvancedMDRecord::$db = null
protected

Definition at line 44 of file class.ilAdvancedMDRecord.php.

ilAdvancedMDRecord::$description
protected

Definition at line 42 of file class.ilAdvancedMDRecord.php.

Referenced by getDescription().

ilAdvancedMDRecord::$import_id
protected

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

Referenced by getImportId().

ilAdvancedMDRecord::$instances = array()
staticprivate

Definition at line 36 of file class.ilAdvancedMDRecord.php.

ilAdvancedMDRecord::$obj_types = array()
protected

Definition at line 43 of file class.ilAdvancedMDRecord.php.

Referenced by _getActivatedObjTypes().

ilAdvancedMDRecord::$record_id
protected

Definition at line 38 of file class.ilAdvancedMDRecord.php.

Referenced by getRecordId().

ilAdvancedMDRecord::$title
protected

Definition at line 41 of file class.ilAdvancedMDRecord.php.

Referenced by getTitle().


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