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
00036 class ilEventItems
00037 {
00038 var $ilErr;
00039 var $ilDB;
00040 var $tree;
00041 var $lng;
00042
00043 var $event_id = null;
00044 var $items = array();
00045
00046
00047 function ilEventItems($a_event_id)
00048 {
00049 global $ilErr,$ilDB,$lng,$tree;
00050
00051 $this->ilErr =& $ilErr;
00052 $this->db =& $ilDB;
00053 $this->lng =& $lng;
00054
00055 $this->event_id = $a_event_id;
00056 $this->__read();
00057 }
00058
00059 function getEventId()
00060 {
00061 return $this->event_id;
00062 }
00063 function setEventId($a_event_id)
00064 {
00065 $this->event_id = $a_event_id;
00066 }
00067 function getItems()
00068 {
00069 return $this->items ? $this->items : array();
00070 }
00071 function setItems($a_items)
00072 {
00073 $this->items = array();
00074 foreach($a_items as $item_id)
00075 {
00076 $this->items[] = (int) $item_id;
00077 }
00078 }
00079 function delete()
00080 {
00081 return ilEventItems::_delete($this->getEventId());
00082 }
00083 function _delete($a_event_id)
00084 {
00085 global $ilDB;
00086
00087 $query = "DELETE FROM event_items ".
00088 "WHERE event_id = '".$a_event_id."'";
00089 $ilDB->query($query);
00090 return true;
00091 }
00092 function update()
00093 {
00094 $this->delete();
00095
00096 foreach($this->items as $item)
00097 {
00098 $query = "INSERT INTO event_items ".
00099 "SET event_id = '".$this->getEventId()."', ".
00100 "item_id = '".$item."'";
00101 $this->db->query($query);
00102 }
00103 return true;
00104 }
00105
00106 function _getItemsOfContainer($a_obj_id)
00107 {
00108 global $ilDB;
00109
00110 $query = "SELECT * FROM event AS e ".
00111 "JOIN event_items AS ei ON e.event_id = ei.event_id ".
00112 "WHERE obj_id = '".$a_obj_id."'";
00113
00114 $res = $ilDB->query($query);
00115 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00116 {
00117 $items[] = $row->item_id;
00118 }
00119 return $items ? $items : array();
00120 }
00121
00122 function _isAssigned($a_item_id)
00123 {
00124 global $ilDB;
00125
00126 $query = "SELECT * FROM event_items ".
00127 "WHERE item_id = '".$a_item_id."'";
00128 $res = $ilDB->query($query);
00129
00130 return $res->numRows() ? true : false;
00131 }
00132
00133
00134
00135 function __read()
00136 {
00137 $query = "SELECT * FROM event_items ".
00138 "WHERE event_id = '".$this->getEventId()."'";
00139
00140 $res = $this->db->query($query);
00141 $this->items = array();
00142 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00143 {
00144 $this->items[] = (int) $row->item_id;
00145 }
00146 return true;
00147 }
00148
00149 }
00150 ?>