Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00031 include_once 'class.ilMDBase.php';
00032
00033 class ilMDIdentifier_ extends ilMDBase
00034 {
00035 function ilMDIdentifier_($a_rbac_id = 0,$a_obj_id = 0,$a_obj_type = '')
00036 {
00037 parent::ilMDBase($a_rbac_id,
00038 $a_obj_id,
00039 $a_obj_type);
00040 }
00041
00042
00043 function setCatalog($a_catalog)
00044 {
00045 $this->catalog = $a_catalog;
00046 }
00047 function getCatalog()
00048 {
00049 return $this->catalog;
00050 }
00051 function setEntry($a_entry)
00052 {
00053 $this->entry = $a_entry;
00054 }
00055 function getEntry()
00056 {
00057 return $this->entry;
00058 }
00059
00060
00061 function save()
00062 {
00063 if($this->db->autoExecute('il_meta_identifier_',
00064 $this->__getFields(),
00065 DB_AUTOQUERY_INSERT))
00066 {
00067 $this->setMetaId($this->db->getLastInsertId());
00068
00069 return $this->getMetaId();
00070 }
00071 return false;
00072 }
00073
00074 function update()
00075 {
00076 if($this->getMetaId())
00077 {
00078 if($this->db->autoExecute('il_meta_identifier_',
00079 $this->__getFields(),
00080 DB_AUTOQUERY_UPDATE,
00081 "meta_identifier__id = '".$this->getMetaId()."'"))
00082 {
00083 return true;
00084 }
00085 }
00086 return false;
00087 }
00088
00089 function delete()
00090 {
00091 if($this->getMetaId())
00092 {
00093 $query = "DELETE FROM il_meta_identifier_ ".
00094 "WHERE meta_identifier__id = '".$this->getMetaId()."'";
00095
00096 $this->db->query($query);
00097
00098 return true;
00099 }
00100 return false;
00101 }
00102
00103
00104 function __getFields()
00105 {
00106 return array('rbac_id' => $this->getRBACId(),
00107 'obj_id' => $this->getObjId(),
00108 'obj_type' => ilUtil::prepareDBString($this->getObjType()),
00109 'parent_type' => $this->getParentType(),
00110 'parent_id' => $this->getParentId(),
00111 'catalog' => $this->getCatalog(),
00112 'entry' => $this->getEntry());
00113
00114 }
00115
00116 function read()
00117 {
00118 if($this->getMetaId())
00119 {
00120 $query = "SELECT * FROM il_meta_identifier_ ".
00121 "WHERE meta_identifier__id = '".$this->getMetaId()."'";
00122
00123 $res = $this->db->query($query);
00124 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00125 {
00126 $this->setRBACId($row->rbac_id);
00127 $this->setObjId($row->obj_id);
00128 $this->setObjType($row->obj_type);
00129 $this->setParentId($row->parent_id);
00130 $this->setParentType($row->parent_type);
00131 $this->setCatalog($row->catalog);
00132 $this->setEntry($row->entry);
00133 }
00134 }
00135 return true;
00136 }
00137
00138
00139
00140
00141
00142
00143 function toXML(&$writer)
00144 {
00145 $writer->xmlElement('Identifier_',array('Catalog' => $this->getCatalog(),
00146 'Entry' => $this->getEntry() ? $this->getEntry() : "ID1"));
00147 }
00148
00149
00150
00151 function _getIds($a_rbac_id,$a_obj_id,$a_parent_id,$a_parent_type)
00152 {
00153 global $ilDB;
00154
00155 $query = "SELECT meta_identifier__id FROM il_meta_identifier_ ".
00156 "WHERE rbac_id = '".$a_rbac_id."' ".
00157 "AND obj_id = '".$a_obj_id."' ".
00158 "AND parent_id = '".$a_parent_id."' ".
00159 "AND parent_type = '".$a_parent_type."'";
00160
00161
00162 $res = $ilDB->query($query);
00163 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00164 {
00165 $ids[] = $row->meta_identifier__id;
00166 }
00167 return $ids ? $ids : array();
00168 }
00169 }
00170 ?>