ILIAS  release_4-4 Revision
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. More...
 
 delete ()
 Delete. More...
 
 save ()
 save More...
 
 update ()
 update More...
 
 validate ()
 Validate settings Write error message to ilErr. More...
 
 getRecordId ()
 Get record id. More...
 
 setActive ($a_active)
 Set active. More...
 
 isActive ()
 Check if record is active. More...
 
 setTitle ($a_title)
 Set title. More...
 
 getTitle ()
 get title More...
 
 setDescription ($a_description)
 set description More...
 
 getDescription ()
 get description More...
 
 setImportId ($a_id_string)
 set import id More...
 
 getImportId ()
 get import id More...
 
 setAssignedObjectTypes ($a_obj_types)
 Set assigned object types. More...
 
 appendAssignedObjectType ($a_obj_type, $a_sub_type)
 append assigned object types More...
 
 getAssignedObjectTypes ()
 Get assigned object types. More...
 
 isAssignedObjectType ($a_obj_type, $a_sub_type)
 Is assigned object type? More...
 
 toXML (ilXmlWriter $writer)
 To Xml. More...
 
 __destruct ()
 Destructor. More...
 

Static Public Member Functions

static _getInstanceByRecordId ($a_record_id)
 Get instance by record id. More...
 
static _getActiveSearchableRecords ()
 Get active searchable records. More...
 
static _lookupTitle ($a_record_id)
 Lookup title. More...
 
static _lookupRecordIdByImportId ($a_ilias_id)
 Lookup record Id by import id. More...
 
static _getAssignableObjectTypes ($a_include_text=false)
 Get assignable object type. More...
 
static _getActivatedObjTypes ()
 get activated obj types More...
 
static _getRecords ()
 Get records. More...
 
static _getAllRecordsByObjectType ()
 Get records by obj_type Note: this returns only records with no sub types! public. More...
 
static _getActivatedRecordsByObjectType ($a_obj_type, $a_sub_type="")
 Get activated records by object type. More...
 
static _getSelectedRecordsByObject ($a_obj_type, $a_obj_id, $a_sub_type="")
 Get selected records by object. More...
 
static _delete ($a_record_id)
 Delete record and all related data. More...
 
static saveObjRecSelection ($a_obj_id, $a_sub_type="", $a_records)
 Save repository object record selection. More...
 
static getObjRecSelection ($a_obj_id, $a_sub_type="")
 Get repository object record selection. More...
 

Protected Member Functions

 generateImportId ()
 generate unique record id More...
 

Protected Attributes

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

Private Member Functions

 read ()
 read record and assiged object types More...
 

Static Private Attributes

static $instances = array()
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

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

References getRecordId(), and read().

37  {
38  global $ilDB;
39 
40  $this->record_id = $a_record_id;
41  $this->db = $ilDB;
42 
43  if($this->getRecordId())
44  {
45  $this->read();
46  }
47  }
read()
read record and assiged object types
+ Here is the call graph for this function:

◆ __destruct()

ilAdvancedMDRecord::__destruct ( )

Destructor.

public

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

References getRecordId().

693  {
694  unset(self::$instances[$this->getRecordId()]);
695  }
+ Here is the call graph for this function:

Member Function Documentation

◆ _delete()

static ilAdvancedMDRecord::_delete (   $a_record_id)
static

Delete record and all related data.

public

Parameters
intrecord id

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

References $query, $res, and ilAdvancedMDFieldDefinition\_deleteByRecordId().

Referenced by delete().

322  {
323  global $ilDB;
324 
325  // Delete fields
327 
328  $query = "DELETE FROM adv_md_record ".
329  "WHERE record_id = ".$ilDB->quote($a_record_id ,'integer')." ";
330  $res = $ilDB->manipulate($query);
331 
332  $query = "DELETE FROM adv_md_record_objs ".
333  "WHERE record_id = ".$ilDB->quote($a_record_id ,'integer')." ";
334  $res = $ilDB->manipulate($query);
335  }
static _deleteByRecordId($a_record_id)
Delete all fields by record_id.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getActivatedObjTypes()

static ilAdvancedMDRecord::_getActivatedObjTypes ( )
static

get activated obj types

public

Parameters
stringobj types

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

References $obj_types, $query, $res, $row, and DB_FETCHMODE_OBJECT.

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

184  {
185  global $ilDB;
186 
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 ".
189  "WHERE active = 1 ";
190  $res = $ilDB->query($query);
191  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
192  {
193  $obj_types[] = $row->obj_type;
194  }
195  return $obj_types ? $obj_types : array();
196  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the caller graph for this function:

◆ _getActivatedRecordsByObjectType()

static ilAdvancedMDRecord::_getActivatedRecordsByObjectType (   $a_obj_type,
  $a_sub_type = "" 
)
static

Get activated records by object type.

public

Parameters
stringobj_type

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

References $query, $records, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilSoapInstallationInfoXMLWriter\__buildClient(), ilGlossaryExporter\getActiveAdvMDRecords(), ilSoapAdministration\getNIC(), ilAdvancedMDRecordGUI\parseEditor(), ilAdvancedMDRecordGUI\parseFilter(), ilAdvancedMDRecordGUI\parseInfoPage(), ilAdvancedMDRecordGUI\parseRecordSelection(), ilAdvancedMDRecordGUI\parseTableCells(), and ilAdvancedMDRecordGUI\parseTableHead().

251  {
252  global $ilDB;
253 
254  $records = array();
255 
256  if ($a_sub_type == "")
257  {
258  $a_sub_type = "-";
259  }
260 
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 ".
263  "WHERE active = 1 ".
264  "AND obj_type = ".$ilDB->quote($a_obj_type ,'text')." ".
265  "AND sub_type = ".$ilDB->quote($a_sub_type ,'text');
266 
267  $res = $ilDB->query($query);
268  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
269  {
270  $records[] = self::_getInstanceByRecordId($row->record_id);
271  }
272 
273  return $records;
274  }
$records
Definition: simple_test.php:22
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the caller graph for this function:

◆ _getActiveSearchableRecords()

static ilAdvancedMDRecord::_getActiveSearchableRecords ( )
static

Get active searchable records.

public

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

References $query, $records, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilAdvancedMDRecordGUI\parseSearch().

74  {
75  global $ilDB;
76 
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 ";
80 
81  $res = $ilDB->query($query);
82  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
83  {
84  $records[] = self::_getInstanceByRecordId($row->record_id);
85  }
86  return $records ? $records : array();
87  }
$records
Definition: simple_test.php:22
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the caller graph for this function:

◆ _getAllRecordsByObjectType()

static ilAdvancedMDRecord::_getAllRecordsByObjectType ( )
static

Get records by obj_type Note: this returns only records with no sub types! public.

Parameters

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

References $query, $records, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilAdvancedMDSettingsGUI\initFormSubstitutions().

228  {
229  global $ilDB;
230 
231  $records = array();
232 
233  $query = "SELECT * FROM adv_md_record_objs WHERE sub_type=".$ilDB->quote("-", "text");
234  $res = $ilDB->query($query);
235  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
236  {
237  $records[$row->obj_type][] = self::_getInstanceByRecordId($row->record_id);
238  }
239  return $records;
240  }
$records
Definition: simple_test.php:22
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the caller graph for this function:

◆ _getAssignableObjectTypes()

static ilAdvancedMDRecord::_getAssignableObjectTypes (   $a_include_text = false)
static

Get assignable object type.

public

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

References $lng.

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

145  {
146  global $objDefinition, $lng;
147 
148  $types = array();
149  $amet_types = $objDefinition->getAdvancedMetaDataTypes();
150 
151  foreach ($amet_types as $at)
152  {
153  if ($a_include_text)
154  {
155  $text = $lng->txt("obj_".$at["obj_type"]);
156  if ($at["sub_type"] != "")
157  {
158  $lng->loadLanguageModule($at["obj_type"]);
159  $text.= ": ".$lng->txt($at["obj_type"]."_".$at["sub_type"]);
160  }
161  else
162  {
163  $at["sub_type"] = "-";
164  }
165  $at["text"] = $text;
166  }
167 
168  $types[] = $at;
169  }
170 
171  return $types;
172  return array('cat','crs','rcrs');
173  }
global $lng
Definition: privfeed.php:40
+ Here is the caller graph for this function:

◆ _getInstanceByRecordId()

static ilAdvancedMDRecord::_getInstanceByRecordId (   $a_record_id)
static

Get instance by record id.

public

Parameters
intrecord id

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

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

58  {
59  if(isset(self::$instances[$a_record_id]))
60  {
61  return self::$instances[$a_record_id];
62  }
63  return self::$instances[$a_record_id] = new ilAdvancedMDRecord($a_record_id);
64  }
+ Here is the caller graph for this function:

◆ _getRecords()

static ilAdvancedMDRecord::_getRecords ( )
static

Get records.

public

Parameters
arrayarray of record objects

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

References $query, $records, $res, $row, _getInstanceByRecordId(), and DB_FETCHMODE_OBJECT.

Referenced by ilLuceneAdvancedSearchFields\getFields(), and ilAdvancedMDSettingsGUI\getRecordObjects().

207  {
208  global $ilDB;
209 
210  $query = "SELECT record_id FROM adv_md_record ";
211  $res = $ilDB->query($query);
212  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
213  {
215  }
216  return $records ? $records : array();
217  }
$records
Definition: simple_test.php:22
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
static _getInstanceByRecordId($a_record_id)
Get instance by record id.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getSelectedRecordsByObject()

static ilAdvancedMDRecord::_getSelectedRecordsByObject (   $a_obj_type,
  $a_obj_id,
  $a_sub_type = "" 
)
static

Get selected records by object.

Parameters
string$a_obj_typeobject type
string$a_obj_idobject id
string$a_sub_typesub type

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

References $query, $records, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilGlossaryAdvMetaDataAdapter\getAllFields(), ilAdvancedMDRecordGUI\parseEditor(), ilAdvancedMDRecordGUI\parseFilter(), ilAdvancedMDRecordGUI\parseTableCells(), and ilAdvancedMDRecordGUI\parseTableHead().

284  {
285  global $ilDB;
286 
287  $records = array();
288 
289  if ($a_sub_type == "")
290  {
291  $a_sub_type = "-";
292  }
293 
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) ".
297  "WHERE active = 1 ".
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')
301  ;
302 
303  $res = $ilDB->query($query);
304  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
305  {
306  $records[] = self::_getInstanceByRecordId($row->record_id);
307  }
308 
309  return $records;
310  }
$records
Definition: simple_test.php:22
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the caller graph for this function:

◆ _lookupRecordIdByImportId()

static ilAdvancedMDRecord::_lookupRecordIdByImportId (   $a_ilias_id)
static

Lookup record Id by import id.

public

Parameters
stringilias id

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

References $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilAdvancedMDRecordParser\extractRecordId().

125  {
126  global $ilDB;
127 
128  $query = "SELECT record_id FROM adv_md_record ".
129  "WHERE import_id = ".$ilDB->quote($a_ilias_id ,'text')." ";
130  $res = $ilDB->query($query);
131  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
132  {
133  return $row->record_id;
134  }
135  return 0;
136  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the caller graph for this function:

◆ _lookupTitle()

static ilAdvancedMDRecord::_lookupTitle (   $a_record_id)
static

Lookup title.

public

Parameters
intrecord_id

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

References $query, $res, $row, and DB_FETCHMODE_OBJECT.

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

98  {
99  static $title_cache = array();
100 
101  if(isset($title_cache[$a_record_id]))
102  {
103  return $title_cache[$a_record_id];
104  }
105 
106  global $ilDB;
107 
108  $query = "SELECT title FROM adv_md_record ".
109  "WHERE record_id = ".$ilDB->quote($a_record_id ,'integer')." ";
110  $res = $ilDB->query($query);
111  $row = $res->fetchRow(DB_FETCHMODE_OBJECT);
112 
113  return $title_cache[$a_record_id] = $row->title;
114  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the caller graph for this function:

◆ appendAssignedObjectType()

ilAdvancedMDRecord::appendAssignedObjectType (   $a_obj_type,
  $a_sub_type 
)

append assigned object types

public

Parameters
stringilias object type

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

573  {
574  $this->obj_types[] = array("obj_type"=>$a_obj_type, "sub_type"=>$a_sub_type);
575  }

◆ delete()

ilAdvancedMDRecord::delete ( )

Delete.

public

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

References _delete(), and getRecordId().

345  {
347  }
static _delete($a_record_id)
Delete record and all related data.
+ Here is the call graph for this function:

◆ generateImportId()

ilAdvancedMDRecord::generateImportId ( )
protected

generate unique record id

protected

Returns

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

References getRecordId().

Referenced by save(), and toXML().

682  {
683  return 'il_'.IL_INST_ID.'_adv_md_record_'.$this->getRecordId();
684  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAssignedObjectTypes()

ilAdvancedMDRecord::getAssignedObjectTypes ( )

Get assigned object types.

public

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

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

584  {
585  return $this->obj_types ? $this->obj_types : array();
586  }
+ Here is the caller graph for this function:

◆ getDescription()

ilAdvancedMDRecord::getDescription ( )

get description

public

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

References $description.

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

526  {
527  return $this->description;
528  }
+ Here is the caller graph for this function:

◆ getImportId()

ilAdvancedMDRecord::getImportId ( )

get import id

public

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

References $import_id.

Referenced by save().

549  {
550  return $this->import_id;
551  }
+ Here is the caller graph for this function:

◆ getObjRecSelection()

static ilAdvancedMDRecord::getObjRecSelection (   $a_obj_id,
  $a_sub_type = "" 
)
static

Get repository object record selection.

Parameters
integer$a_obj_idobject id if repository object
array$a_recordsarray of record ids that are selected (in use) by the object

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

References $r.

Referenced by ilGlossaryExporter\getActiveAdvMDRecords(), and ilAdvancedMDRecordGUI\parseRecordSelection().

740  {
741  global $ilDB;
742 
743  if ($a_sub_type == "")
744  {
745  $a_sub_type = "-";
746  }
747 
748  $recs = array();
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")
752  );
753  while ($rec = $ilDB->fetchAssoc($set))
754  {
755  $recs[] = $rec["rec_id"];
756  }
757  return $recs;
758  }
$r
+ Here is the caller graph for this function:

◆ getRecordId()

ilAdvancedMDRecord::getRecordId ( )

Get record id.

public

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

References $record_id.

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

457  {
458  return $this->record_id;
459  }
+ Here is the caller graph for this function:

◆ getTitle()

ilAdvancedMDRecord::getTitle ( )

get title

public

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

References $title.

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

503  {
504  return $this->title;
505  }
+ Here is the caller graph for this function:

◆ isActive()

ilAdvancedMDRecord::isActive ( )

Check if record is active.

public

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

References $active.

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

480  {
481  return (bool) $this->active;
482  }
+ Here is the caller graph for this function:

◆ isAssignedObjectType()

ilAdvancedMDRecord::isAssignedObjectType (   $a_obj_type,
  $a_sub_type 
)

Is assigned object type?

Parameters

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

References $t, and getAssignedObjectTypes().

595  {
596  foreach ($this->getAssignedObjectTypes() as $t)
597  {
598  if ($t["obj_type"] == $a_obj_type &&
599  $t["sub_type"] == $a_sub_type)
600  {
601  return true;
602  }
603  }
604  return false;
605  }
getAssignedObjectTypes()
Get assigned object types.
+ Here is the call graph for this function:

◆ read()

ilAdvancedMDRecord::read ( )
private

read record and assiged object types

private

Parameters

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

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

Referenced by __construct().

652  {
653  global $ilDB;
654 
655  $query = "SELECT * FROM adv_md_record ".
656  "WHERE record_id = ".$this->db->quote($this->getRecordId() ,'integer')." ";
657  $res = $this->db->query($query);
658  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
659  {
660  $this->setImportId($row->import_id);
661  $this->setActive($row->active);
662  $this->setTitle($row->title);
663  $this->setDescription($row->description);
664  }
665  $query = "SELECT * FROM adv_md_record_objs ".
666  "WHERE record_id = ".$this->db->quote($this->getRecordId() ,'integer')." ";
667  $res = $this->db->query($query);
668  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
669  {
670  $this->obj_types[] = array("obj_type" => $row->obj_type,
671  "sub_type" => $row->sub_type);
672  }
673  }
setActive($a_active)
Set active.
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
setDescription($a_description)
set description
setImportId($a_id_string)
set import id
setTitle($a_title)
Set title.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilAdvancedMDRecord::save ( )

save

public

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

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

356  {
357  global $ilDB;
358 
359  // Save import id if given
360  $next_id = $ilDB->nextId('adv_md_record');
361 
362  $query = "INSERT INTO adv_md_record (record_id,import_id,active,title,description) ".
363  "VALUES(".
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').", ".
368  $this->db->quote($this->getDescription() ,'text')." ".
369  ")";
370  $res = $ilDB->manipulate($query);
371  $this->record_id = $next_id;
372 
373  if(!strlen($this->getImportId()))
374  {
375  // set import id to default value
376  $query = "UPDATE adv_md_record ".
377  "SET import_id = ".$this->db->quote($this->generateImportId() ,'text')." ".
378  "WHERE record_id = ".$this->db->quote($this->record_id ,'integer')." ";
379  $res = $ilDB->manipulate($query);
380  }
381 
382  foreach($this->getAssignedObjectTypes() as $type)
383  {
384  global $ilDB;
385 
386  $query = "INSERT INTO adv_md_record_objs (record_id,obj_type,sub_type) ".
387  "VALUES( ".
388  $this->db->quote($this->getRecordId() ,'integer').", ".
389  $this->db->quote($type["obj_type"] ,'text').", ".
390  $this->db->quote($type["sub_type"] ,'text')." ".
391  ")";
392  $res = $ilDB->manipulate($query);
393  }
394  }
getDescription()
get description
isActive()
Check if record is active.
getAssignedObjectTypes()
Get assigned object types.
generateImportId()
generate unique record id
+ Here is the call graph for this function:

◆ saveObjRecSelection()

static ilAdvancedMDRecord::saveObjRecSelection (   $a_obj_id,
  $a_sub_type = "",
  $a_records 
)
static

Save repository object record selection.

Parameters
integer$a_obj_idobject id if repository object
array$a_recordsarray of record ids that are selected (in use) by the object

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

References $r.

Referenced by ilAdvancedMetaDataImporter\importXmlRepresentation(), and ilAdvancedMDRecordGUI\saveSelection().

704  {
705  global $ilDB;
706 
707  if ($a_sub_type == "")
708  {
709  $a_sub_type = "-";
710  }
711 
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"));
715 
716  if (is_array($a_records))
717  {
718  foreach ($a_records as $r)
719  {
720  if ($r > 0)
721  {
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").
727  ")");
728  }
729  }
730  }
731  }
$r
+ Here is the caller graph for this function:

◆ setActive()

ilAdvancedMDRecord::setActive (   $a_active)

Set active.

public

Parameters

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

Referenced by read().

469  {
470  $this->active = $a_active;
471  }
+ Here is the caller graph for this function:

◆ setAssignedObjectTypes()

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

561  {
562  $this->obj_types = $a_obj_types;
563  }

◆ setDescription()

ilAdvancedMDRecord::setDescription (   $a_description)

set description

public

Parameters
stringdescription

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

Referenced by read().

515  {
516  $this->description = $a_description;
517  }
+ Here is the caller graph for this function:

◆ setImportId()

ilAdvancedMDRecord::setImportId (   $a_id_string)

set import id

public

Parameters
stringimport id

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

Referenced by read().

538  {
539  $this->import_id = $a_id_string;
540  }
+ Here is the caller graph for this function:

◆ setTitle()

ilAdvancedMDRecord::setTitle (   $a_title)

Set title.

public

Parameters
stringtitle

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

Referenced by read().

492  {
493  $this->title = $a_title;
494  }
+ Here is the caller graph for this function:

◆ toXML()

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

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

618  {
619  $writer->xmlStartTag('Record',array('active' => $this->isActive() ? 1 : 0,
620  'id' => $this->generateImportId()));
621  $writer->xmlElement('Title',null,$this->getTitle());
622  $writer->xmlElement('Description',null,$this->getDescription());
623 
624  foreach($this->getAssignedObjectTypes() as $obj_type)
625  {
626  if ($obj_type["sub_type"] == "")
627  {
628  $writer->xmlElement('ObjectType',null,$obj_type["obj_type"]);
629  }
630  else
631  {
632  $writer->xmlElement('ObjectType',null,$obj_type["obj_type"].":".$obj_type["sub_type"]);
633  }
634  }
635 
636  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
638  {
639  $definition->toXML($writer);
640  }
641  $writer->xmlEndTag('Record');
642  }
static _getDefinitionsByRecordId($a_record_id)
get definitions
getDescription()
get description
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)
xmlEndTag($tag)
Writes an endtag.
isActive()
Check if record is active.
getAssignedObjectTypes()
Get assigned object types.
generateImportId()
generate unique record id
+ Here is the call graph for this function:

◆ update()

ilAdvancedMDRecord::update ( )

update

public

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

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

403  {
404  global $ilDB;
405 
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')." ";
411  $res = $ilDB->manipulate($query);
412 
413  // Delete assignments
414  $query = "DELETE FROM adv_md_record_objs ".
415  "WHERE record_id = ".$this->db->quote($this->getRecordId() ,'integer')." ";
416  $res = $ilDB->manipulate($query);
417 
418  // Insert assignments
419  foreach($this->getAssignedObjectTypes() as $type)
420  {
421  $query = "INSERT INTO adv_md_record_objs (record_id,obj_type, sub_type) ".
422  "VALUES ( ".
423  $this->db->quote($this->getRecordId() ,'integer').", ".
424  $this->db->quote($type["obj_type"] ,'text').", ".
425  $this->db->quote($type["sub_type"] ,'text')." ".
426  ")";
427  $res = $ilDB->manipulate($query);
428  }
429  }
getDescription()
get description
isActive()
Check if record is active.
getAssignedObjectTypes()
Get assigned object types.
+ Here is the call graph for this function:

◆ validate()

ilAdvancedMDRecord::validate ( )

Validate settings Write error message to ilErr.

public

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

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

439  {
440  global $ilErr,$lng;
441 
442  if(!strlen($this->getTitle()))
443  {
444  $ilErr->setMessage('fill_out_all_required_fields');
445  return false;
446  }
447  return true;
448  }
global $lng
Definition: privfeed.php:40
+ Here is the call graph for this function:

Field Documentation

◆ $active

ilAdvancedMDRecord::$active
protected

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

Referenced by isActive().

◆ $db

ilAdvancedMDRecord::$db = null
protected

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

◆ $description

ilAdvancedMDRecord::$description
protected

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

Referenced by getDescription().

◆ $import_id

ilAdvancedMDRecord::$import_id
protected

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

Referenced by getImportId().

◆ $instances

ilAdvancedMDRecord::$instances = array()
staticprivate

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

◆ $obj_types

ilAdvancedMDRecord::$obj_types = array()
protected

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

Referenced by _getActivatedObjTypes().

◆ $record_id

ilAdvancedMDRecord::$record_id
protected

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

Referenced by getRecordId().

◆ $title

ilAdvancedMDRecord::$title
protected

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

Referenced by getTitle().


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