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);
331 $query =
"DELETE FROM adv_md_record ".
332 "WHERE record_id = ".$ilDB->quote($a_record_id ,
'integer').
" ";
335 $query =
"DELETE FROM adv_md_record_objs ".
336 "WHERE record_id = ".$ilDB->quote($a_record_id ,
'integer').
" ";
347 public function delete()
363 $next_id = $ilDB->nextId(
'adv_md_record');
365 $query =
"INSERT INTO adv_md_record (record_id,import_id,active,title,description) ".
367 $ilDB->quote($next_id,
'integer').
", ".
368 $this->db->quote($this->
getImportId(),
'text').
", ".
369 $this->db->quote($this->
isActive() ,
'integer').
", ".
370 $this->db->quote($this->
getTitle() ,
'text').
", ".
374 $this->record_id = $next_id;
379 $query =
"UPDATE adv_md_record ".
381 "WHERE record_id = ".$this->db->quote($this->record_id ,
'integer').
" ";
389 $query =
"INSERT INTO adv_md_record_objs (record_id,obj_type,sub_type) ".
391 $this->db->quote($this->
getRecordId() ,
'integer').
", ".
392 $this->db->quote($type[
"obj_type"] ,
'text').
", ".
393 $this->db->quote($type[
"sub_type"] ,
'text').
" ".
409 $query =
"UPDATE adv_md_record ".
410 "SET active = ".$this->db->quote($this->
isActive() ,
'integer').
", ".
411 "title = ".$this->db->quote($this->
getTitle() ,
'text').
", ".
412 "description = ".$this->db->quote($this->
getDescription() ,
'text').
" ".
413 "WHERE record_id = ".$this->db->quote($this->
getRecordId() ,
'integer').
" ";
417 $query =
"DELETE FROM adv_md_record_objs ".
418 "WHERE record_id = ".$this->db->quote($this->
getRecordId() ,
'integer').
" ";
424 $query =
"INSERT INTO adv_md_record_objs (record_id,obj_type, sub_type) ".
426 $this->db->quote($this->
getRecordId() ,
'integer').
", ".
427 $this->db->quote($type[
"obj_type"] ,
'text').
", ".
428 $this->db->quote($type[
"sub_type"] ,
'text').
" ".
447 $ilErr->setMessage(
'fill_out_all_required_fields');
473 $this->active = $a_active;
496 $this->title = $a_title;
519 $this->description = $a_description;
542 $this->import_id = $a_id_string;
565 $this->obj_types = $a_obj_types;
577 $this->obj_types[] = array(
"obj_type"=>$a_obj_type,
"sub_type"=>$a_sub_type);
588 return $this->obj_types ? $this->obj_types : array();
601 if ($t[
"obj_type"] == $a_obj_type &&
602 $t[
"sub_type"] == $a_sub_type)
629 if ($obj_type[
"sub_type"] ==
"")
631 $writer->
xmlElement(
'ObjectType',null,$obj_type[
"obj_type"]);
635 $writer->
xmlElement(
'ObjectType',null,$obj_type[
"obj_type"].
":".$obj_type[
"sub_type"]);
639 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
642 $definition->toXML($writer);
658 $query =
"SELECT * FROM adv_md_record ".
659 "WHERE record_id = ".$this->db->quote($this->
getRecordId() ,
'integer').
" ";
668 $query =
"SELECT * FROM adv_md_record_objs ".
669 "WHERE record_id = ".$this->db->quote($this->
getRecordId() ,
'integer').
" ";
673 $this->obj_types[] = array(
"obj_type" =>
$row->obj_type,
674 "sub_type" =>
$row->sub_type);
686 return 'il_'.IL_INST_ID.
'_adv_md_record_'.$this->
getRecordId();
706 static function saveObjRecSelection($a_obj_id, $a_sub_type =
"", array $a_records = null, $a_delete_before =
true)
710 if ($a_sub_type ==
"")
715 if((
bool)$a_delete_before)
717 $ilDB->manipulate(
"DELETE FROM adv_md_obj_rec_select WHERE ".
718 " obj_id = ".$ilDB->quote($a_obj_id,
"integer").
719 " AND sub_type = ".$ilDB->quote($a_sub_type,
"text"));
722 if (is_array($a_records))
724 foreach ($a_records as
$r)
728 $ilDB->manipulate(
"INSERT INTO adv_md_obj_rec_select ".
729 "(obj_id, rec_id, sub_type) VALUES (".
730 $ilDB->quote($a_obj_id,
"integer").
",".
731 $ilDB->quote($r,
"integer").
",".
732 $ilDB->quote($a_sub_type,
"text").
749 if ($a_sub_type ==
"")
755 $set = $ilDB->query(
$r =
"SELECT * FROM adv_md_obj_rec_select ".
756 " WHERE obj_id = ".$ilDB->quote($a_obj_id,
"integer").
757 " AND sub_type = ".$ilDB->quote($a_sub_type,
"text")
759 while ($rec = $ilDB->fetchAssoc($set))
761 $recs[] = $rec[
"rec_id"];
appendAssignedObjectType($a_obj_type, $a_sub_type)
append assigned object types
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.
static saveObjRecSelection($a_obj_id, $a_sub_type="", array $a_records=null, $a_delete_before=true)
Save repository object record selection.
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.
static getInstancesByRecordId($a_record_id, $a_only_searchable=false)
Get definitions 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 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