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
00032 include_once 'class.ilMDBase.php';
00033
00034 class ilMDEntity extends ilMDBase
00035 {
00036 function ilMDEntity($a_rbac_id = 0,$a_obj_id = 0,$a_obj_type = '')
00037 {
00038 parent::ilMDBase($a_rbac_id,
00039 $a_obj_id,
00040 $a_obj_type);
00041 }
00042
00043
00044 function setEntity($a_entity)
00045 {
00046 $this->entity = $a_entity;
00047 }
00048 function getEntity()
00049 {
00050 return $this->entity;
00051 }
00052
00053 function save()
00054 {
00055 if($this->db->autoExecute('il_meta_entity',
00056 $this->__getFields(),
00057 DB_AUTOQUERY_INSERT))
00058 {
00059 $this->setMetaId($this->db->getLastInsertId());
00060
00061 return $this->getMetaId();
00062 }
00063 return false;
00064 }
00065
00066 function update()
00067 {
00068 if($this->getMetaId())
00069 {
00070 if($this->db->autoExecute('il_meta_entity',
00071 $this->__getFields(),
00072 DB_AUTOQUERY_UPDATE,
00073 "meta_entity_id = '".$this->getMetaId()."'"))
00074 {
00075 return true;
00076 }
00077 }
00078 return false;
00079 }
00080
00081 function delete()
00082 {
00083 if($this->getMetaId())
00084 {
00085 $query = "DELETE FROM il_meta_entity ".
00086 "WHERE meta_entity_id = '".$this->getMetaId()."'";
00087
00088 $this->db->query($query);
00089
00090 return true;
00091 }
00092 return false;
00093 }
00094
00095
00096 function __getFields()
00097 {
00098 return array('rbac_id' => $this->getRBACId(),
00099 'obj_id' => $this->getObjId(),
00100 'obj_type' => $this->getObjType(),
00101 'parent_type' => $this->getParentType(),
00102 'parent_id' => $this->getParentId(),
00103 'entity' => $this->getEntity());
00104 }
00105
00106 function read()
00107 {
00108 if($this->getMetaId())
00109 {
00110 $query = "SELECT * FROM il_meta_entity ".
00111 "WHERE meta_entity_id = '".$this->getMetaId()."'";
00112
00113 $res = $this->db->query($query);
00114 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00115 {
00116 $this->setRBACId($row->rbac_id);
00117 $this->setObjId($row->obj_id);
00118 $this->setObjType($row->obj_type);
00119 $this->setParentId($row->parent_id);
00120 $this->setParentType($row->parent_type);
00121 $this->setEntity($row->entity);
00122 }
00123 }
00124 return true;
00125 }
00126
00127
00128
00129
00130
00131
00132 function toXML(&$writer)
00133 {
00134 $writer->xmlElement('Entity',null,$this->getEntity());
00135 }
00136
00137
00138
00139 function _getIds($a_rbac_id,$a_obj_id,$a_parent_id,$a_parent_type)
00140 {
00141 global $ilDB;
00142
00143 $query = "SELECT meta_entity_id FROM il_meta_entity ".
00144 "WHERE rbac_id = '".$a_rbac_id."' ".
00145 "AND obj_id = '".$a_obj_id."' ".
00146 "AND parent_id = '".$a_parent_id."' ".
00147 "AND parent_type = '".$a_parent_type."' ".
00148 "ORDER BY meta_entity_id ";
00149
00150 $res = $ilDB->query($query);
00151 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00152 {
00153 $ids[] = $row->meta_entity_id;
00154 }
00155 return $ids ? $ids : array();
00156 }
00157 }
00158 ?>