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 ilMDAnnotation extends ilMDBase
00034 {
00035 function ilMDAnnotation($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 setEntity($a_entity)
00044 {
00045 $this->entity = $a_entity;
00046 }
00047 function getEntity()
00048 {
00049 return $this->entity;
00050 }
00051 function setDate($a_date)
00052 {
00053 $this->date = $a_date;
00054 }
00055 function getDate()
00056 {
00057 return $this->date;
00058 }
00059 function setDescription($a_desc)
00060 {
00061 $this->description = $a_desc;
00062 }
00063 function getDescription()
00064 {
00065 return $this->description;
00066 }
00067 function setDescriptionLanguage($lng_obj)
00068 {
00069 if(is_object($lng_obj))
00070 {
00071 $this->description_language =& $lng_obj;
00072 }
00073 }
00074 function &getDescriptionLanguage()
00075 {
00076 return $this->description_language;
00077 }
00078 function getDescriptionLanguageCode()
00079 {
00080 if(is_object($this->description_language))
00081 {
00082 return $this->description_language->getLanguageCode();
00083 }
00084 return false;
00085 }
00086
00087 function save()
00088 {
00089 if($this->db->autoExecute('il_meta_annotation',
00090 $this->__getFields(),
00091 DB_AUTOQUERY_INSERT))
00092 {
00093 $this->setMetaId($this->db->getLastInsertId());
00094
00095 return $this->getMetaId();
00096 }
00097 return false;
00098 }
00099
00100 function update()
00101 {
00102 if($this->getMetaId())
00103 {
00104 if($this->db->autoExecute('il_meta_annotation',
00105 $this->__getFields(),
00106 DB_AUTOQUERY_UPDATE,
00107 "meta_annotation_id = '".$this->getMetaId()."'"))
00108 {
00109 return true;
00110 }
00111 }
00112 return false;
00113 }
00114
00115 function delete()
00116 {
00117 if($this->getMetaId())
00118 {
00119 $query = "DELETE FROM il_meta_annotation ".
00120 "WHERE meta_annotation_id = '".$this->getMetaId()."'";
00121
00122 $this->db->query($query);
00123
00124 return true;
00125 }
00126 return false;
00127 }
00128
00129
00130 function __getFields()
00131 {
00132 return array('rbac_id' => $this->getRBACId(),
00133 'obj_id' => $this->getObjId(),
00134 'obj_type' => $this->getObjType(),
00135 'entity' => $this->getEntity(),
00136 'date' => $this->getDate(),
00137 'description' => $this->getDescription(),
00138 'description_language' => $this->getDescriptionLanguageCode());
00139 }
00140
00141 function read()
00142 {
00143 include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
00144
00145 if($this->getMetaId())
00146 {
00147 $query = "SELECT * FROM il_meta_annotation ".
00148 "WHERE meta_annotation_id = '".$this->getMetaId()."'";
00149
00150 $res = $this->db->query($query);
00151 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00152 {
00153 $this->setRBACId($row->rbac_id);
00154 $this->setObjId($row->obj_id);
00155 $this->setObjType($row->obj_type);
00156 $this->setEntity($row->entity);
00157 $this->setDate($row->date);
00158 $this->setDescription($row->description);
00159 $this->description_language =& new ilMDLanguageItem($row->description_language);
00160 }
00161 }
00162 return true;
00163 }
00164
00165
00166
00167
00168
00169
00170 function toXML(&$writer)
00171 {
00172 $writer->xmlStartTag('Annotation');
00173 $writer->xmlElement('Entity',null,$this->getEntity());
00174 $writer->xmlElement('Date',null,$this->getDate());
00175 $writer->xmlElement('Description',array('Language' => $this->getDescriptionLanguageCode()
00176 ? $this->getDescriptionLanguageCode()
00177 : 'en'),
00178 $this->getDescription());
00179 $writer->xmlEndTag('Annotation');
00180 }
00181
00182
00183
00184
00185 function _getIds($a_rbac_id,$a_obj_id)
00186 {
00187 global $ilDB;
00188
00189 $query = "SELECT meta_annotation_id FROM il_meta_annotation ".
00190 "WHERE rbac_id = '".$a_rbac_id."' ".
00191 "AND obj_id = '".$a_obj_id."'";
00192
00193
00194 $res = $ilDB->query($query);
00195 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00196 {
00197 $ids[] = $row->meta_annotation_id;
00198 }
00199 return $ids ? $ids : array();
00200 }
00201 }
00202 ?>