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 ilMDFormat extends ilMDBase
00035 {
00036 function ilMDFormat($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 setFormat($a_format)
00045 {
00046 $this->format = $a_format;
00047 }
00048 function getFormat()
00049 {
00050 return $this->format;
00051 }
00052
00053 function save()
00054 {
00055 if($this->db->autoExecute('il_meta_format',
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_format',
00071 $this->__getFields(),
00072 DB_AUTOQUERY_UPDATE,
00073 "meta_format_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_format ".
00086 "WHERE meta_format_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 'format' => $this->getFormat());
00102 }
00103
00104 function read()
00105 {
00106 include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
00107
00108 if($this->getMetaId())
00109 {
00110 $query = "SELECT * FROM il_meta_format ".
00111 "WHERE meta_format_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->setFormat($row->format);
00120 }
00121 }
00122 return true;
00123 }
00124
00125
00126
00127
00128
00129
00130 function toXML(&$writer)
00131 {
00132 if($this->getFormat())
00133 {
00134 $writer->xmlElement('Format',null,$this->getFormat());
00135 }
00136 }
00137
00138
00139
00140 function _getIds($a_rbac_id,$a_obj_id)
00141 {
00142 global $ilDB;
00143
00144 $query = "SELECT meta_format_id FROM il_meta_format ".
00145 "WHERE rbac_id = '".$a_rbac_id."' ".
00146 "AND obj_id = '".$a_obj_id."'";
00147
00148 $res = $ilDB->query($query);
00149 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00150 {
00151 $ids[] = $row->meta_format_id;
00152 }
00153 return $ids ? $ids : array();
00154 }
00155 }
00156 ?>