40 $this->record_id = $a_record_id;
59 if(isset(self::$instances[$a_record_id]))
61 return self::$instances[$a_record_id];
77 $query =
"SELECT DISTINCT(amr.record_id) FROM adv_md_record amr ".
78 "JOIN adv_mdf_definition amfd ON amr.record_id = amfd.record_id ".
79 "WHERE searchable = 1 AND active = 1 ";
84 $records[] = self::_getInstanceByRecordId(
$row->record_id);
99 static $title_cache = array();
101 if(isset($title_cache[$a_record_id]))
103 return $title_cache[$a_record_id];
108 $query =
"SELECT title FROM adv_md_record ".
109 "WHERE record_id = ".$ilDB->quote($a_record_id ,
'integer').
" ";
113 return $title_cache[$a_record_id] =
$row->title;
128 $query =
"SELECT record_id FROM adv_md_record ".
129 "WHERE import_id = ".$ilDB->quote($a_ilias_id ,
'text').
" ";
133 return $row->record_id;
146 global $objDefinition,
$lng;
149 $amet_types = $objDefinition->getAdvancedMetaDataTypes();
151 foreach ($amet_types as $at)
155 $text = $lng->txt(
"obj_".$at[
"obj_type"]);
156 if ($at[
"sub_type"] !=
"")
158 $lng->loadLanguageModule($at[
"obj_type"]);
159 $text.=
": ".$lng->txt($at[
"obj_type"].
"_".$at[
"sub_type"]);
163 $at[
"sub_type"] =
"-";
172 return array(
'cat',
'crs',
'rcrs');
187 $query =
"SELECT DISTINCT(obj_type) FROM adv_md_record_objs amo ".
188 "JOIN adv_md_record amr ON amo.record_id = amr.record_id ".
210 $query =
"SELECT record_id FROM adv_md_record ";
233 $query =
"SELECT * FROM adv_md_record_objs WHERE sub_type=".$ilDB->quote(
"-",
"text");
256 if ($a_sub_type ==
"")
261 $query =
"SELECT amro.record_id record_id FROM adv_md_record_objs amro ".
262 "JOIN adv_md_record amr ON amr.record_id = amro.record_id ".
264 "AND obj_type = ".$ilDB->quote($a_obj_type ,
'text').
" ".
265 "AND sub_type = ".$ilDB->quote($a_sub_type ,
'text');
270 $records[] = self::_getInstanceByRecordId(
$row->record_id);
289 if ($a_sub_type ==
"")
294 $query =
"SELECT amro.record_id record_id FROM adv_md_record_objs amro ".
295 "JOIN adv_md_record amr ON (amr.record_id = amro.record_id) ".
296 "JOIN adv_md_obj_rec_select os ON (amr.record_id = os.rec_id AND amro.sub_type = os.sub_type) ".
298 "AND amro.obj_type = ".$ilDB->quote($a_obj_type ,
'text').
" ".
299 "AND amro.sub_type = ".$ilDB->quote($a_sub_type ,
'text').
" ".
300 "AND os.obj_id = ".$ilDB->quote($a_obj_id ,
'integer')
306 $records[] = self::_getInstanceByRecordId(
$row->record_id);
328 $query =
"DELETE FROM adv_md_record ".
329 "WHERE record_id = ".$ilDB->quote($a_record_id ,
'integer').
" ";
332 $query =
"DELETE FROM adv_md_record_objs ".
333 "WHERE record_id = ".$ilDB->quote($a_record_id ,
'integer').
" ";
344 public function delete()
360 $next_id = $ilDB->nextId(
'adv_md_record');
362 $query =
"INSERT INTO adv_md_record (record_id,import_id,active,title,description) ".
364 $ilDB->quote($next_id,
'integer').
", ".
365 $this->db->quote($this->
getImportId(),
'text').
", ".
366 $this->db->quote($this->
isActive() ,
'integer').
", ".
367 $this->db->quote($this->
getTitle() ,
'text').
", ".
371 $this->record_id = $next_id;
376 $query =
"UPDATE adv_md_record ".
378 "WHERE record_id = ".$this->db->quote($this->record_id ,
'integer').
" ";
386 $query =
"INSERT INTO adv_md_record_objs (record_id,obj_type,sub_type) ".
388 $this->db->quote($this->
getRecordId() ,
'integer').
", ".
389 $this->db->quote($type[
"obj_type"] ,
'text').
", ".
390 $this->db->quote($type[
"sub_type"] ,
'text').
" ".
406 $query =
"UPDATE adv_md_record ".
407 "SET active = ".$this->db->quote($this->
isActive() ,
'integer').
", ".
408 "title = ".$this->db->quote($this->
getTitle() ,
'text').
", ".
409 "description = ".$this->db->quote($this->
getDescription() ,
'text').
" ".
410 "WHERE record_id = ".$this->db->quote($this->
getRecordId() ,
'integer').
" ";
414 $query =
"DELETE FROM adv_md_record_objs ".
415 "WHERE record_id = ".$this->db->quote($this->
getRecordId() ,
'integer').
" ";
421 $query =
"INSERT INTO adv_md_record_objs (record_id,obj_type, sub_type) ".
423 $this->db->quote($this->
getRecordId() ,
'integer').
", ".
424 $this->db->quote($type[
"obj_type"] ,
'text').
", ".
425 $this->db->quote($type[
"sub_type"] ,
'text').
" ".
444 $ilErr->setMessage(
'fill_out_all_required_fields');
470 $this->active = $a_active;
493 $this->title = $a_title;
516 $this->description = $a_description;
539 $this->import_id = $a_id_string;
562 $this->obj_types = $a_obj_types;
574 $this->obj_types[] = array(
"obj_type"=>$a_obj_type,
"sub_type"=>$a_sub_type);
585 return $this->obj_types ? $this->obj_types : array();
598 if ($t[
"obj_type"] == $a_obj_type &&
599 $t[
"sub_type"] == $a_sub_type)
626 if ($obj_type[
"sub_type"] ==
"")
628 $writer->
xmlElement(
'ObjectType',null,$obj_type[
"obj_type"]);
632 $writer->
xmlElement(
'ObjectType',null,$obj_type[
"obj_type"].
":".$obj_type[
"sub_type"]);
636 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
639 $definition->toXML($writer);
655 $query =
"SELECT * FROM adv_md_record ".
656 "WHERE record_id = ".$this->db->quote($this->
getRecordId() ,
'integer').
" ";
665 $query =
"SELECT * FROM adv_md_record_objs ".
666 "WHERE record_id = ".$this->db->quote($this->
getRecordId() ,
'integer').
" ";
670 $this->obj_types[] = array(
"obj_type" =>
$row->obj_type,
671 "sub_type" =>
$row->sub_type);
683 return 'il_'.IL_INST_ID.
'_adv_md_record_'.$this->
getRecordId();
707 if ($a_sub_type ==
"")
712 $ilDB->manipulate(
"DELETE FROM adv_md_obj_rec_select WHERE ".
713 " obj_id = ".$ilDB->quote($a_obj_id,
"integer").
714 " AND sub_type = ".$ilDB->quote($a_sub_type,
"text"));
716 if (is_array($a_records))
718 foreach ($a_records as
$r)
722 $ilDB->manipulate(
"INSERT INTO adv_md_obj_rec_select ".
723 "(obj_id, rec_id, sub_type) VALUES (".
724 $ilDB->quote($a_obj_id,
"integer").
",".
725 $ilDB->quote($r,
"integer").
",".
726 $ilDB->quote($a_sub_type,
"text").
743 if ($a_sub_type ==
"")
749 $set = $ilDB->query(
$r =
"SELECT * FROM adv_md_obj_rec_select ".
750 " WHERE obj_id = ".$ilDB->quote($a_obj_id,
"integer").
751 " AND sub_type = ".$ilDB->quote($a_sub_type,
"text")
753 while ($rec = $ilDB->fetchAssoc($set))
755 $recs[] = $rec[
"rec_id"];
static _getDefinitionsByRecordId($a_record_id)
get definitions
appendAssignedObjectType($a_obj_type, $a_sub_type)
append assigned object types
static _deleteByRecordId($a_record_id)
Delete all fields by record_id.
static _getRecords()
Get records.
getDescription()
get description
setActive($a_active)
Set active.
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.
xmlElement($tag, $attrs=NULL, $data=Null, $encode=TRUE, $escape=TRUE)
Writes a basic element (no children, just textual content)
static _getActiveSearchableRecords()
Get active searchable records.
static _getActivatedRecordsByObjectType($a_obj_type, $a_sub_type="")
Get activated records by object type.
xmlEndTag($tag)
Writes an endtag.
const DB_FETCHMODE_OBJECT
isActive()
Check if record is active.
setDescription($a_description)
set description
static _delete($a_record_id)
Delete record and all related data.
toXML(ilXmlWriter $writer)
To Xml.
static _getInstanceByRecordId($a_record_id)
Get instance by record id.
getRecordId()
Get record id.
__construct($a_record_id=0)
Singleton constructor To create an array of new records (without saving them) call the constructor di...
static _getSelectedRecordsByObject($a_obj_type, $a_obj_id, $a_sub_type="")
Get selected records by object.
validate()
Validate settings Write error message to ilErr.
getAssignedObjectTypes()
Get assigned object types.
static _getAllRecordsByObjectType()
Get records by obj_type Note: this returns only records with no sub types! public.
setImportId($a_id_string)
set import id
static _lookupTitle($a_record_id)
Lookup title.
setTitle($a_title)
Set title.
read()
read record and assiged object types
static _getAssignableObjectTypes($a_include_text=false)
Get assignable object type.
setAssignedObjectTypes($a_obj_types)
Set assigned object types.
getImportId()
get import id
static _getActivatedObjTypes()
get activated obj types
isAssignedObjectType($a_obj_type, $a_sub_type)
Is assigned object type?
static saveObjRecSelection($a_obj_id, $a_sub_type="", $a_records)
Save repository object record selection.
static getObjRecSelection($a_obj_id, $a_sub_type="")
Get repository object record selection.
static _lookupRecordIdByImportId($a_ilias_id)
Lookup record Id by import id.
generateImportId()
generate unique record id