ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilEventItems Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilEventItems:

Public Member Functions

 __construct (int $a_event_id)
 
 getEventId ()
 
 setEventId (int $a_event_id)
 
 getItems ()
 
 setItems (array $a_items)
 
 addItem (int $a_item_ref_id)
 
 delete ()
 
 removeItems (array $a_items)
 
 update ()
 
 _isAssigned (int $a_item_id)
 
 cloneItems (int $a_source_id, int $a_copy_id)
 

Static Public Member Functions

static _delete (int $a_event_id)
 
static _getItemsOfContainer (int $a_ref_id)
 
static _getItemsOfEvent (int $a_event_id)
 
static getEventsForItemOrderedByStartingTime (int $item_ref_id)
 

Protected Member Functions

 __read ()
 

Protected Attributes

ilDBInterface $db
 
ilTree $tree
 
int $event_id = 0
 
array $items = []
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning class ilEventItems

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
Id
class.ilEventItems.php 15697 2008-01-08 20:04:33Z hschottm

Definition at line 29 of file class.ilEventItems.php.

Constructor & Destructor Documentation

◆ __construct()

ilEventItems::__construct ( int  $a_event_id)

Definition at line 37 of file class.ilEventItems.php.

References $DIC, and __read().

38  {
39  global $DIC;
40 
41  $this->db = $DIC->database();
42  $this->tree = $DIC->repositoryTree();
43 
44  $this->event_id = $a_event_id;
45  $this->__read();
46  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ __read()

ilEventItems::__read ( )
protected

Definition at line 225 of file class.ilEventItems.php.

References $db, $DIC, $ilDB, $query, $res, $tree, ilDBConstants\FETCHMODE_OBJECT, getEventId(), ILIAS\Repository\int(), ilTree\isDeleted(), and ilTree\isInTree().

Referenced by __construct().

225  : bool
226  {
227  global $DIC;
228 
229  $ilDB = $this->db;
230  $tree = $this->tree;
231 
232  $query = "SELECT * FROM event_items " .
233  "WHERE event_id = " . $ilDB->quote($this->getEventId(), 'integer') . " ";
234 
235  $res = $this->db->query($query);
236  $this->items = [];
237  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
238  if ($tree->isDeleted((int) $row->item_id)) {
239  continue;
240  }
241  if (!$tree->isInTree((int) $row->item_id)) {
242  $query = "DELETE FROM event_items " .
243  "WHERE item_id = " . $ilDB->quote($row->item_id, 'integer');
244  $ilDB->manipulate($query);
245  continue;
246  }
247 
248  $this->items[] = (int) $row->item_id;
249  }
250  return true;
251  }
$res
Definition: ltiservices.php:69
ilDBInterface $db
isInTree(?int $a_node_id)
get all information of a node.
isDeleted(int $a_node_id)
This is a wrapper for isSaved() with a more useful name.
global $DIC
Definition: feed.php:28
$query
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _delete()

static ilEventItems::_delete ( int  $a_event_id)
static

Definition at line 81 of file class.ilEventItems.php.

References $DIC, $ilDB, $query, and $res.

Referenced by ilObjSession\delete().

81  : bool
82  {
83  global $DIC;
84 
85  $ilDB = $DIC->database();
86 
87  $query = "DELETE FROM event_items " .
88  "WHERE event_id = " . $ilDB->quote($a_event_id, 'integer') . " ";
89  $res = $ilDB->manipulate($query);
90  return true;
91  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
$query
+ Here is the caller graph for this function:

◆ _getItemsOfContainer()

static ilEventItems::_getItemsOfContainer ( int  $a_ref_id)
static

Definition at line 122 of file class.ilEventItems.php.

References $DIC, $ilDB, $items, $query, $res, ilDBConstants\FETCHMODE_OBJECT, and ilTree\getChildsByType().

Referenced by ilObjectActivation\getTimingsItems(), ilContainerContentGUI\initRenderer(), ilRepositoryExplorerGUI\isNodeVisible(), ilRepositoryExplorer\isVisible(), and ilContainerGUI\redrawListItemObject().

122  : array
123  {
124  global $DIC;
125 
126  $ilDB = $DIC->database();
127  $tree = $DIC->repositoryTree();
128 
129  $session_nodes = $tree->getChildsByType($a_ref_id, 'sess');
130  $session_ids = [];
131  foreach ($session_nodes as $node) {
132  $session_ids[] = $node['obj_id'];
133  }
134  $query = "SELECT item_id FROM event_items " .
135  "WHERE " . $ilDB->in('event_id', $session_ids, false, 'integer');
136 
137 
138  $res = $ilDB->query($query);
139  $items = [];
140  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
141  $items[] = $row->item_id;
142  }
143  return $items;
144  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
getChildsByType(int $a_node_id, string $a_type)
get child nodes of given node by object type
$query
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getItemsOfEvent()

static ilEventItems::_getItemsOfEvent ( int  $a_event_id)
static

Definition at line 146 of file class.ilEventItems.php.

References $DIC, $ilDB, $items, $query, $res, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by cloneItems().

146  : array
147  {
148  global $DIC;
149 
150  $ilDB = $DIC->database();
151 
152  $query = "SELECT * FROM event_items " .
153  "WHERE event_id = " . $ilDB->quote($a_event_id, 'integer');
154  $res = $ilDB->query($query);
155  $items = [];
156  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
157  $items[] = $row->item_id;
158  }
159  return $items;
160  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
$query
+ Here is the caller graph for this function:

◆ _isAssigned()

ilEventItems::_isAssigned ( int  $a_item_id)

Definition at line 162 of file class.ilEventItems.php.

References $DIC, $ilDB, $query, and $res.

162  : bool
163  {
164  global $DIC;
165 
166  $ilDB = $DIC->database();
167 
168  $query = "SELECT * FROM event_items " .
169  "WHERE item_id = " . $ilDB->quote($a_item_id, 'integer') . " ";
170  $res = $ilDB->query($query);
171 
172  return $res->numRows() ? true : false;
173  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
$query

◆ addItem()

ilEventItems::addItem ( int  $a_item_ref_id)

Definition at line 71 of file class.ilEventItems.php.

Referenced by ilObjSessionGUI\afterSaveCallback(), and ilSessionDataSet\importRecord().

71  : void
72  {
73  $this->items[] = $a_item_ref_id;
74  }
+ Here is the caller graph for this function:

◆ cloneItems()

ilEventItems::cloneItems ( int  $a_source_id,
int  $a_copy_id 
)

Definition at line 198 of file class.ilEventItems.php.

References $DIC, ilCopyWizardOptions\_getInstance(), _getItemsOfEvent(), setItems(), and update().

198  : bool
199  {
200  global $DIC;
201 
202  $ilObjDataCache = $DIC['ilObjDataCache'];
203  $ilLog = $DIC->logger()->sess();
204 
205  $ilLog->debug('Begin cloning session materials ...');
206 
207  $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
208  $mappings = $cwo->getMappings();
209 
210  $new_items = [];
211  foreach (ilEventItems::_getItemsOfEvent($a_source_id) as $item_id) {
212  if (isset($mappings[$item_id]) && $mappings[$item_id]) {
213  $ilLog->debug('Clone session material nr. ' . $item_id);
214  $new_items[] = $mappings[$item_id];
215  } else {
216  $ilLog->debug('No mapping found for session material nr. ' . $item_id);
217  }
218  }
219  $this->setItems($new_items);
220  $this->update();
221  $ilLog->debug('Finished cloning session materials ...');
222  return true;
223  }
setItems(array $a_items)
global $DIC
Definition: feed.php:28
static _getItemsOfEvent(int $a_event_id)
static _getInstance(int $a_copy_id)
+ Here is the call graph for this function:

◆ delete()

ilEventItems::delete ( )

Definition at line 76 of file class.ilEventItems.php.

References getEventId().

76  : bool
77  {
78  return self::_delete($this->getEventId());
79  }
+ Here is the call graph for this function:

◆ getEventId()

ilEventItems::getEventId ( )

Definition at line 48 of file class.ilEventItems.php.

References $event_id.

Referenced by __read(), delete(), and update().

48  : int
49  {
50  return $this->event_id;
51  }
+ Here is the caller graph for this function:

◆ getEventsForItemOrderedByStartingTime()

static ilEventItems::getEventsForItemOrderedByStartingTime ( int  $item_ref_id)
static
Parameters
int$item_ref_id
Returns
int[]

Definition at line 179 of file class.ilEventItems.php.

References $DIC, $query, $res, ilDBConstants\FETCHMODE_OBJECT, IL_CAL_DATETIME, ilDBInterface\query(), and ilDBInterface\quote().

Referenced by ilSessionClassificationPathGUI\findSessionContainerForItem().

179  : array
180  {
181  global $DIC;
182 
183  $db = $DIC->database();
184  $query = 'SELECT e.event_id,e_start FROM event_items e ' .
185  'JOIN event_appointment ea ON e.event_id = ea.event_id ' .
186  'WHERE item_id = ' . $db->quote($item_ref_id, 'integer') . ' ' .
187  'ORDER BY (e_start)';
188  $res = $db->query($query);
189 
190  $events = [];
191  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
192  $dt = new ilDateTime($row->e_start, IL_CAL_DATETIME);
193  $events[$row->event_id] = $dt->getUnixTime();
194  }
195  return $events;
196  }
$res
Definition: ltiservices.php:69
const IL_CAL_DATETIME
ilDBInterface $db
quote($value, string $type)
global $DIC
Definition: feed.php:28
query(string $query)
Run a (read-only) Query on the database.
$query
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getItems()

ilEventItems::getItems ( )

Definition at line 58 of file class.ilEventItems.php.

References $items.

Referenced by ilObjSessionGUI\createRecurringSessions(), ilObjSessionGUI\handleFileUpload(), and ilObjSessionGUI\saveMaterialsObject().

58  : array
59  {
60  return $this->items;
61  }
+ Here is the caller graph for this function:

◆ removeItems()

ilEventItems::removeItems ( array  $a_items)

Definition at line 93 of file class.ilEventItems.php.

References $query, and $res.

Referenced by ilObjSessionGUI\removeMaterialsObject().

93  : bool
94  {
95  $query = "DELETE FROM event_items WHERE " . $this->db->in('item_id', $a_items, false, 'integer') .
96  " AND event_id = " . $this->db->quote($this->event_id, 'integer');
97 
98  $res = $this->db->manipulate($query);
99 
100  return true;
101  }
$res
Definition: ltiservices.php:69
$query
+ Here is the caller graph for this function:

◆ setEventId()

ilEventItems::setEventId ( int  $a_event_id)

Definition at line 53 of file class.ilEventItems.php.

Referenced by EventItemsTest\testSetEventId().

53  : void
54  {
55  $this->event_id = $a_event_id;
56  }
+ Here is the caller graph for this function:

◆ setItems()

ilEventItems::setItems ( array  $a_items)

Definition at line 63 of file class.ilEventItems.php.

References ILIAS\Repository\int().

Referenced by cloneItems(), ilObjSessionGUI\createRecurringSessions(), and ilObjSessionGUI\handleFileUpload().

63  : void
64  {
65  $this->items = [];
66  foreach ($a_items as $item_id) {
67  $this->items[] = (int) $item_id;
68  }
69  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update()

ilEventItems::update ( )

Definition at line 103 of file class.ilEventItems.php.

References $DIC, $ilDB, $query, $res, and getEventId().

Referenced by ilObjSessionGUI\afterSaveCallback(), and cloneItems().

103  : bool
104  {
105  global $DIC;
106 
107  $ilDB = $DIC->database();
108 
109  $this->delete();
110 
111  foreach ($this->items as $item) {
112  $query = "INSERT INTO event_items (event_id,item_id) " .
113  "VALUES( " .
114  $ilDB->quote($this->getEventId(), 'integer') . ", " .
115  $ilDB->quote($item, 'integer') . " " .
116  ")";
117  $res = $ilDB->manipulate($query);
118  }
119  return true;
120  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
$query
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilDBInterface ilEventItems::$db
protected

Definition at line 31 of file class.ilEventItems.php.

Referenced by __read().

◆ $event_id

int ilEventItems::$event_id = 0
protected

Definition at line 33 of file class.ilEventItems.php.

Referenced by getEventId().

◆ $items

array ilEventItems::$items = []
protected

Definition at line 34 of file class.ilEventItems.php.

Referenced by _getItemsOfContainer(), _getItemsOfEvent(), and getItems().

◆ $tree

ilTree ilEventItems::$tree
protected

Definition at line 32 of file class.ilEventItems.php.

Referenced by __read().


The documentation for this class was generated from the following file: