Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Attributes

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 activate 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:
int record 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 596 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:
int record id

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

References ilAdvancedMDFieldDefinition::_deleteByRecordId().

Referenced by delete().

        {
                global $ilDB;
                
                // Delete fields
                ilAdvancedMDFieldDefinition::_deleteByRecordId($a_record_id);
                
                $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 activate obj types

public

Parameters:
string obj types

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

References $obj_types, and $res.

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:
string obj_type

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

References $res, and _getInstanceByRecordId().

Referenced by 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, and _getInstanceByRecordId().

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 220 of file class.ilAdvancedMDRecord.php.

References $res, and _getInstanceByRecordId().

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 ilAdvancedMDRecordTableGUI::fillRow(), and ilAdvancedMDSettingsGUI::initForm().

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

Here is the caller graph for this function:

static ilAdvancedMDRecord::_getInstanceByRecordId ( a_record_id  )  [static]

Get instance by record id.

public

Parameters:
int record id

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

Referenced by _getActivatedRecordsByObjectType(), _getActiveSearchableRecords(), _getAllRecordsByObjectType(), _getRecords(), ilAdvancedMDSettingsGUI::confirmDeleteRecords(), ilAdvancedMDSettingsGUI::deleteRecords(), ilAdvancedMDSettingsGUI::initRecordObject(), and ilAdvancedMDRecordParser::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:
array array of record objects

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

References $res, and _getInstanceByRecordId().

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:
string ilias id

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

References $res.

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:
int record_id

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

References $res.

Referenced by ilAdvancedMDSettingsGUI::initFormSubstitutions().

        {
                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:
string ilias object type

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

        {
                $this->obj_types[] = $a_obj_type;
        }

ilAdvancedMDRecord::delete (  ) 

Delete.

public

Definition at line 295 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 585 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 517 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 459 of file class.ilAdvancedMDRecord.php.

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

        {
                return $this->description;
        }

Here is the caller graph for this function:

ilAdvancedMDRecord::getImportId (  ) 

get import id

public

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

Referenced by save().

        {
                return $this->import_id;        
        }

Here is the caller graph for this function:

ilAdvancedMDRecord::getRecordId (  ) 

Get record id.

public

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

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

        {
                return $this->record_id;
        }

Here is the caller graph for this function:

ilAdvancedMDRecord::getTitle (  ) 

get title

public

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

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 413 of file class.ilAdvancedMDRecord.php.

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 558 of file class.ilAdvancedMDRecord.php.

References $res, 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 306 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 402 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:
array array(string) array of object types. E.g array('crs','crsl')

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

        {
                $this->obj_types = $a_obj_types;
        }

ilAdvancedMDRecord::setDescription ( a_description  ) 

set description

public

Parameters:
string description

Definition at line 448 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:
string import id

Definition at line 471 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:
string title

Definition at line 425 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:
object ilXmlWriter

Definition at line 531 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');
                foreach(ilAdvancedMDFieldDefinition::_getDefinitionsByRecordId($this->getRecordId()) as $definition)
                {
                        $definition->toXML($writer);
                }
                $writer->xmlEndTag('Record');
        }

Here is the call graph for this function:

ilAdvancedMDRecord::update (  ) 

update

public

Definition at line 341 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 372 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.

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.

ilAdvancedMDRecord::$import_id [protected]

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

ilAdvancedMDRecord::$instances = array() [static, private]

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.

ilAdvancedMDRecord::$title [protected]

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


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