ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules 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. 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="", array $a_records=null, $a_delete_before=true)
 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 $ilDB, 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
global $ilDB
+ Here is the call graph for this function:

◆ __destruct()

ilAdvancedMDRecord::__destruct ( )

Destructor.

public

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

References getRecordId().

696  {
697  unset(self::$instances[$this->getRecordId()]);
698  }
+ 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 $ilDB, $query, $res, and ilAdvancedMDFieldDefinition\getInstancesByRecordId().

Referenced by delete().

322  {
323  global $ilDB;
324 
325  // Delete fields
326  foreach(ilAdvancedMDFieldDefinition::getInstancesByRecordId($a_record_id) as $field)
327  {
328  $field->delete();
329  }
330 
331  $query = "DELETE FROM adv_md_record ".
332  "WHERE record_id = ".$ilDB->quote($a_record_id ,'integer')." ";
333  $res = $ilDB->manipulate($query);
334 
335  $query = "DELETE FROM adv_md_record_objs ".
336  "WHERE record_id = ".$ilDB->quote($a_record_id ,'integer')." ";
337  $res = $ilDB->manipulate($query);
338  }
static getInstancesByRecordId($a_record_id, $a_only_searchable=false)
Get definitions by record id.
global $ilDB
+ 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 $ilDB, $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
global $ilDB
+ 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 $ilDB, $query, $records, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilSoapInstallationInfoXMLWriter\__buildClient(), ilGlossaryExporter\getActiveAdvMDRecords(), ilWikiExporter\getActiveAdvMDRecords(), ilOrgUnitType\getAvailableAdvancedMDRecords(), ilSoapAdministration\getNIC(), ilAdvancedMDRecordGUI\parseEditor(), ilAdvancedMDRecordGUI\parseFilter(), ilAdvancedMDRecordGUI\parseRecordSelection(), ilAdvancedMDRecordGUI\parseSearch(), 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:17
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
global $ilDB
+ 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 $ilDB, $query, $records, $res, $row, and DB_FETCHMODE_OBJECT.

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:17
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
global $ilDB

◆ _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 $ilDB, $query, $records, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilAdvancedMDSettingsGUI\initFormSubstitutions(), and ilAdvancedMDSettingsGUI\setSubTabs().

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:17
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
global $ilDB
+ 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(), ilAdvancedMDSettingsGUI\exportRecords(), 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 $ilDB, $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:17
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
static _getInstanceByRecordId($a_record_id)
Get instance by record id.
global $ilDB
+ 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 $ilDB, $query, $records, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilPCAMDPageList\findPages(), ilGlossaryAdvMetaDataAdapter\getAllFields(), ilWikiAdvMetaDataBlockGUI\getRecords(), ilAdvancedMDRecordGUI\parseEditor(), ilAdvancedMDRecordGUI\parseFilter(), ilAdvancedMDRecordGUI\parseSearch(), ilAdvancedMDRecordGUI\parseTableCells(), ilAdvancedMDRecordGUI\parseTableHead(), and ilAdvancedMDValues\queryForRecords().

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:17
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
global $ilDB
+ 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 $ilDB, $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
global $ilDB
+ 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 $ilDB, $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilAdvancedMDSettingsGUI\initFormSubstitutions(), ilAdvancedMDRecordGUI\parseInfoPage(), ilObjOrgUnitGUI\parseInfoScreen(), 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
global $ilDB
+ 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 575 of file class.ilAdvancedMDRecord.php.

576  {
577  $this->obj_types[] = array("obj_type"=>$a_obj_type, "sub_type"=>$a_sub_type);
578  }

◆ delete()

ilAdvancedMDRecord::delete ( )

Delete.

public

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

References _delete(), and getRecordId().

348  {
350  }
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 684 of file class.ilAdvancedMDRecord.php.

References getRecordId().

Referenced by save(), and toXML().

685  {
686  return 'il_'.IL_INST_ID.'_adv_md_record_'.$this->getRecordId();
687  }
+ 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 586 of file class.ilAdvancedMDRecord.php.

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

587  {
588  return $this->obj_types ? $this->obj_types : array();
589  }
+ Here is the caller graph for this function:

◆ getDescription()

ilAdvancedMDRecord::getDescription ( )

get description

public

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

References $description.

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

529  {
530  return $this->description;
531  }
+ Here is the caller graph for this function:

◆ getImportId()

ilAdvancedMDRecord::getImportId ( )

get import id

public

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

References $import_id.

Referenced by save().

552  {
553  return $this->import_id;
554  }
+ 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 745 of file class.ilAdvancedMDRecord.php.

References $ilDB, and $r.

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

746  {
747  global $ilDB;
748 
749  if ($a_sub_type == "")
750  {
751  $a_sub_type = "-";
752  }
753 
754  $recs = array();
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")
758  );
759  while ($rec = $ilDB->fetchAssoc($set))
760  {
761  $recs[] = $rec["rec_id"];
762  }
763  return $recs;
764  }
global $ilDB
$r
+ Here is the caller graph for this function:

◆ getRecordId()

ilAdvancedMDRecord::getRecordId ( )

Get record id.

public

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

References $record_id.

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

460  {
461  return $this->record_id;
462  }
+ Here is the caller graph for this function:

◆ getTitle()

ilAdvancedMDRecord::getTitle ( )

get title

public

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

References $title.

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

506  {
507  return $this->title;
508  }
+ Here is the caller graph for this function:

◆ isActive()

ilAdvancedMDRecord::isActive ( )

Check if record is active.

public

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

References $active.

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

483  {
484  return (bool) $this->active;
485  }
+ 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 597 of file class.ilAdvancedMDRecord.php.

References $t, and getAssignedObjectTypes().

598  {
599  foreach ($this->getAssignedObjectTypes() as $t)
600  {
601  if ($t["obj_type"] == $a_obj_type &&
602  $t["sub_type"] == $a_sub_type)
603  {
604  return true;
605  }
606  }
607  return false;
608  }
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 654 of file class.ilAdvancedMDRecord.php.

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

Referenced by __construct().

655  {
656  global $ilDB;
657 
658  $query = "SELECT * FROM adv_md_record ".
659  "WHERE record_id = ".$this->db->quote($this->getRecordId() ,'integer')." ";
660  $res = $this->db->query($query);
661  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
662  {
663  $this->setImportId($row->import_id);
664  $this->setActive($row->active);
665  $this->setTitle($row->title);
666  $this->setDescription($row->description);
667  }
668  $query = "SELECT * FROM adv_md_record_objs ".
669  "WHERE record_id = ".$this->db->quote($this->getRecordId() ,'integer')." ";
670  $res = $this->db->query($query);
671  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
672  {
673  $this->obj_types[] = array("obj_type" => $row->obj_type,
674  "sub_type" => $row->sub_type);
675  }
676  }
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.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilAdvancedMDRecord::save ( )

save

public

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

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

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

◆ saveObjRecSelection()

static ilAdvancedMDRecord::saveObjRecSelection (   $a_obj_id,
  $a_sub_type = "",
array  $a_records = null,
  $a_delete_before = true 
)
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 706 of file class.ilAdvancedMDRecord.php.

References $ilDB, and $r.

Referenced by ilOrgUnitType\getAvailableAdvancedMDRecords(), ilAdvancedMetaDataImporter\importXmlRepresentation(), ilAdvancedMDRecordGUI\saveSelection(), and ilObjOrgUnit\update().

707  {
708  global $ilDB;
709 
710  if ($a_sub_type == "")
711  {
712  $a_sub_type = "-";
713  }
714 
715  if((bool)$a_delete_before)
716  {
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"));
720  }
721 
722  if (is_array($a_records))
723  {
724  foreach ($a_records as $r)
725  {
726  if ($r > 0)
727  {
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").
733  ")");
734  }
735  }
736  }
737  }
global $ilDB
$r
+ Here is the caller graph for this function:

◆ setActive()

ilAdvancedMDRecord::setActive (   $a_active)

Set active.

public

Parameters

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

Referenced by read().

472  {
473  $this->active = $a_active;
474  }
+ 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 563 of file class.ilAdvancedMDRecord.php.

564  {
565  $this->obj_types = $a_obj_types;
566  }

◆ setDescription()

ilAdvancedMDRecord::setDescription (   $a_description)

set description

public

Parameters
stringdescription

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

Referenced by read().

518  {
519  $this->description = $a_description;
520  }
+ Here is the caller graph for this function:

◆ setImportId()

ilAdvancedMDRecord::setImportId (   $a_id_string)

set import id

public

Parameters
stringimport id

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

Referenced by read().

541  {
542  $this->import_id = $a_id_string;
543  }
+ Here is the caller graph for this function:

◆ setTitle()

ilAdvancedMDRecord::setTitle (   $a_title)

Set title.

public

Parameters
stringtitle

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

Referenced by read().

495  {
496  $this->title = $a_title;
497  }
+ 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 620 of file class.ilAdvancedMDRecord.php.

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

621  {
622  $writer->xmlStartTag('Record',array('active' => $this->isActive() ? 1 : 0,
623  'id' => $this->generateImportId()));
624  $writer->xmlElement('Title',null,$this->getTitle());
625  $writer->xmlElement('Description',null,$this->getDescription());
626 
627  foreach($this->getAssignedObjectTypes() as $obj_type)
628  {
629  if ($obj_type["sub_type"] == "")
630  {
631  $writer->xmlElement('ObjectType',null,$obj_type["obj_type"]);
632  }
633  else
634  {
635  $writer->xmlElement('ObjectType',null,$obj_type["obj_type"].":".$obj_type["sub_type"]);
636  }
637  }
638 
639  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
640  foreach(ilAdvancedMDFieldDefinition::getInstancesByRecordId($this->getRecordId()) as $definition)
641  {
642  $definition->toXML($writer);
643  }
644  $writer->xmlEndTag('Record');
645  }
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.
static getInstancesByRecordId($a_record_id, $a_only_searchable=false)
Get definitions by record id.
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 405 of file class.ilAdvancedMDRecord.php.

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

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

◆ validate()

ilAdvancedMDRecord::validate ( )

Validate settings Write error message to ilErr.

public

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

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

442  {
443  global $ilErr,$lng;
444 
445  if(!strlen($this->getTitle()))
446  {
447  $ilErr->setMessage('fill_out_all_required_fields');
448  return false;
449  }
450  return true;
451  }
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: