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 ilMDLocation extends ilMDBase
00034 {
00035 function ilMDLocation($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 setLocation($a_location)
00044 {
00045 $this->location = $a_location;
00046 }
00047 function getLocation()
00048 {
00049 return $this->location;
00050 }
00051 function setLocationType($a_location_type)
00052 {
00053 $this->location_type = $a_location_type;
00054 }
00055 function getLocationType()
00056 {
00057 return $this->location_type;
00058 }
00059
00060 function save()
00061 {
00062 if($this->db->autoExecute('il_meta_location',
00063 $this->__getFields(),
00064 DB_AUTOQUERY_INSERT))
00065 {
00066 $this->setMetaId($this->db->getLastInsertId());
00067
00068 return $this->getMetaId();
00069 }
00070 return false;
00071 }
00072
00073 function update()
00074 {
00075 if($this->getMetaId())
00076 {
00077 if($this->db->autoExecute('il_meta_location',
00078 $this->__getFields(),
00079 DB_AUTOQUERY_UPDATE,
00080 "meta_location_id = '".$this->getMetaId()."'"))
00081 {
00082 return true;
00083 }
00084 }
00085 return false;
00086 }
00087
00088 function delete()
00089 {
00090 if($this->getMetaId())
00091 {
00092 $query = "DELETE FROM il_meta_location ".
00093 "WHERE meta_location_id = '".$this->getMetaId()."'";
00094
00095 $this->db->query($query);
00096
00097 return true;
00098 }
00099 return false;
00100 }
00101
00102
00103 function __getFields()
00104 {
00105 return array('rbac_id' => $this->getRBACId(),
00106 'obj_id' => $this->getObjId(),
00107 'obj_type' => ilUtil::prepareDBString($this->getObjType()),
00108 'parent_type' => $this->getParentType(),
00109 'parent_id' => $this->getParentId(),
00110 'location' => $this->getLocation(),
00111 'location_type' => $this->getLocationType());
00112 }
00113
00114 function read()
00115 {
00116 include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
00117
00118 if($this->getMetaId())
00119 {
00120 $query = "SELECT * FROM il_meta_location ".
00121 "WHERE meta_location_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->setLocation($row->location);
00132 $this->setLocationType($row->location_type);
00133 }
00134 }
00135 return true;
00136 }
00137
00138
00139
00140
00141
00142
00143 function toXML(&$writer)
00144 {
00145 $writer->xmlElement('Location',array('Type' => $this->getLocationType()
00146 ? $this->getLocationType()
00147 : 'LocalFile'),
00148 $this->getLocation());
00149 }
00150
00151
00152
00153 function _getIds($a_rbac_id,$a_obj_id,$a_parent_id,$a_parent_type)
00154 {
00155 global $ilDB;
00156
00157 $query = "SELECT meta_location_id FROM il_meta_location ".
00158 "WHERE rbac_id = '".$a_rbac_id."' ".
00159 "AND obj_id = '".$a_obj_id."' ".
00160 "AND parent_id = '".$a_parent_id."' ".
00161 "AND parent_type = '".$a_parent_type."' ";
00162
00163 $res = $ilDB->query($query);
00164 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00165 {
00166 $ids[] = $row->meta_location_id;
00167 }
00168 return $ids ? $ids : array();
00169 }
00170 }
00171 ?>