ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilItemGroupItems Class Reference

Item group items. More...

+ Collaboration diagram for ilItemGroupItems:

Public Member Functions

 __construct ($a_item_group_ref_id=0)
 Constructor. More...
 
 setItemGroupId ($a_val)
 Set item group id. More...
 
 getItemGroupId ()
 Get item group id. More...
 
 setItemGroupRefId ($a_val)
 Set item group ref id. More...
 
 getItemGroupRefId ()
 Get item group ref id. More...
 
 setItems ($a_val)
 Set items. More...
 
 getItems ()
 Get items. More...
 
 addItem ($a_item_ref_id)
 Add one item. More...
 
 delete ()
 Delete items of item group. More...
 
 update ()
 Update item group items. More...
 
 read ()
 Read item group items. More...
 
 getAssignableItems ()
 Get assignable items. More...
 
 getValidItems ()
 Get valid items. More...
 
 cloneItems ($a_source_id, $a_copy_id)
 Clone items. More...
 

Static Public Member Functions

static _getItemsOfContainer ($a_ref_id)
 

Data Fields

 $ilDB
 
 $tree
 
 $lng
 
 $item_group_id = 0
 
 $item_group_ref_id = 0
 
 $items = array()
 

Protected Attributes

 $db
 
 $obj_def
 
 $obj_data_cache
 
 $log
 

Detailed Description

Item group items.

This class is used to store the materials (items) that are assigned to an item group. Main table used is item_group_item

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 15 of file class.ilItemGroupItems.php.

Constructor & Destructor Documentation

◆ __construct()

ilItemGroupItems::__construct (   $a_item_group_ref_id = 0)

Constructor.

Parameters
int$a_item_group_ref_idref id of item group

Definition at line 50 of file class.ilItemGroupItems.php.

References $DIC, $ilDB, $lng, $tree, ilObject\_lookupObjId(), getItemGroupId(), getItemGroupRefId(), read(), setItemGroupId(), and setItemGroupRefId().

51  {
52  global $DIC;
53 
54  $this->obj_data_cache = $DIC["ilObjDataCache"];
55  $this->log = $DIC["ilLog"];
56  $ilDB = $DIC->database();
57  $lng = $DIC->language();
58  $tree = $DIC->repositoryTree();
59  $objDefinition = $DIC["objDefinition"];
60 
61  $this->db = $ilDB;
62  $this->lng = $lng;
63  $this->tree = $tree;
64  $this->obj_def = $objDefinition;
65 
66  $this->setItemGroupRefId((int) $a_item_group_ref_id);
67  if ($this->getItemGroupRefId() > 0) {
68  $this->setItemGroupId((int) ilObject::_lookupObjId($a_item_group_ref_id));
69  }
70 
71  if ($this->getItemGroupId() > 0) {
72  $this->read();
73  }
74  }
global $DIC
Definition: saml.php:7
getItemGroupId()
Get item group id.
static _lookupObjId($a_id)
setItemGroupRefId($a_val)
Set item group ref id.
setItemGroupId($a_val)
Set item group id.
getItemGroupRefId()
Get item group ref id.
read()
Read item group items.
+ Here is the call graph for this function:

Member Function Documentation

◆ _getItemsOfContainer()

static ilItemGroupItems::_getItemsOfContainer (   $a_ref_id)
static

Definition at line 295 of file class.ilItemGroupItems.php.

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

Referenced by ilRepositoryExplorer\isVisible().

296  {
297  global $DIC;
298 
299  $ilDB = $DIC->database();
300  $tree = $DIC->repositoryTree();
301 
302  $itgr_nodes = $tree->getChildsByType($a_ref_id, 'itgr');
303  foreach ($itgr_nodes as $node) {
304  $itgr_ids[] = $node['obj_id'];
305  }
306  $query = "SELECT item_ref_id FROM item_group_item " .
307  "WHERE " . $ilDB->in('item_group_id', $itgr_ids, false, 'integer');
308 
309 
310  $res = $ilDB->query($query);
311  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
312  $items[] = $row->item_ref_id;
313  }
314  return $items ? $items : array();
315  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ addItem()

ilItemGroupItems::addItem (   $a_item_ref_id)

Add one item.

Parameters
int$a_item_ref_iditem ref id

Definition at line 141 of file class.ilItemGroupItems.php.

Referenced by ilObjItemGroupGUI\afterSaveCallback().

142  {
143  if (!in_array($a_item_ref_id, $this->items)) {
144  $this->items[] = (int) $a_item_ref_id;
145  }
146  }
+ Here is the caller graph for this function:

◆ cloneItems()

ilItemGroupItems::cloneItems (   $a_source_id,
  $a_copy_id 
)

Clone items.

public

Parameters
intsource event id
intcopy id

Definition at line 267 of file class.ilItemGroupItems.php.

References $ilLog, $log, $obj_data_cache, ilCopyWizardOptions\_getInstance(), array, setItems(), and update().

268  {
269  $ilObjDataCache = $this->obj_data_cache;
270  $ilLog = $this->log;
271 
272  $ilLog->write(__METHOD__ . ': Begin cloning item group materials ... -' . $a_source_id . '-');
273 
274  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
275  $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
276  $mappings = $cwo->getMappings();
277 
278  $new_items = array();
279  // check: is this a ref id!?
280  $source_ig = new ilItemGroupItems($a_source_id);
281  foreach ($source_ig->getItems() as $item_ref_id) {
282  if (isset($mappings[$item_ref_id]) and $mappings[$item_ref_id]) {
283  $ilLog->write(__METHOD__ . ': Clone item group item nr. ' . $item_ref_id);
284  $new_items[] = $mappings[$item_ref_id];
285  } else {
286  $ilLog->write(__METHOD__ . ': No mapping found for item group item nr. ' . $item_ref_id);
287  }
288  }
289  $this->setItems($new_items);
290  $this->update();
291  $ilLog->write(__METHOD__ . ': Finished cloning item group items ...');
292  return true;
293  }
static _getInstance($a_copy_id)
Get instance of copy wizard options.
setItems($a_val)
Set items.
Item group items.
Create styles array
The data for the language used.
update()
Update item group items.
+ Here is the call graph for this function:

◆ delete()

ilItemGroupItems::delete ( )

Delete items of item group.

Definition at line 151 of file class.ilItemGroupItems.php.

References $query, and getItemGroupId().

152  {
153  $query = "DELETE FROM item_group_item " .
154  "WHERE item_group_id = " . $this->db->quote($this->getItemGroupId(), 'integer');
155  $this->db->manipulate($query);
156  }
getItemGroupId()
Get item group id.
$query
+ Here is the call graph for this function:

◆ getAssignableItems()

ilItemGroupItems::getAssignableItems ( )

Get assignable items.

Parameters

Definition at line 196 of file class.ilItemGroupItems.php.

References $obj_def, ilObjFileAccess\_isFileHidden(), array, getItemGroupRefId(), and ilUtil\sortArray().

Referenced by getValidItems().

197  {
198  $objDefinition = $this->obj_def;
199 
200  if ($this->getItemGroupRefId() <= 0) {
201  return array();
202  }
203 
204  $parent_node = $this->tree->getNodeData(
205  $this->tree->getParentId($this->getItemGroupRefId())
206  );
207 
208  $materials = array();
209  $nodes = $this->tree->getChilds($parent_node["child"]);
210 
211  include_once("./Modules/File/classes/class.ilObjFileAccess.php");
212  foreach ($nodes as $node) {
213  // filter side blocks and session, item groups and role folder
214  if ($node['child'] == $parent_node["child"] ||
215  $this->obj_def->isSideBlock($node['type']) ||
216  in_array($node['type'], array('sess', 'itgr', 'rolf', 'adm'))) {
217  continue;
218  }
219 
220  // filter hidden files
221  // see http://www.ilias.de/mantis/view.php?id=10269
222  if ($node['type'] == "file" &&
223  ilObjFileAccess::_isFileHidden($node['title'])) {
224  continue;
225  }
226 
227  if ($objDefinition->isInactivePlugin($node['type'])) {
228  continue;
229  }
230 
231  $materials[] = $node;
232  }
233 
234  $materials = ilUtil::sortArray($materials, "title", "asc");
235 
236  return $materials;
237  }
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static _isFileHidden($a_file_name)
Returns true, if a file with the specified name, is usually hidden from the user. ...
Create styles array
The data for the language used.
getItemGroupRefId()
Get item group ref id.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getItemGroupId()

ilItemGroupItems::getItemGroupId ( )

Get item group id.

Returns
int item group id

Definition at line 91 of file class.ilItemGroupItems.php.

References $item_group_id.

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

92  {
93  return $this->item_group_id;
94  }
+ Here is the caller graph for this function:

◆ getItemGroupRefId()

ilItemGroupItems::getItemGroupRefId ( )

Get item group ref id.

Returns
int item group ref id

Definition at line 111 of file class.ilItemGroupItems.php.

References $item_group_ref_id.

Referenced by __construct(), and getAssignableItems().

112  {
114  }
+ Here is the caller graph for this function:

◆ getItems()

ilItemGroupItems::getItems ( )

Get items.

Returns
array items (array of ref ids)

Definition at line 131 of file class.ilItemGroupItems.php.

References $items.

Referenced by ilItemGroupItemsTableGUI\__construct(), and getValidItems().

132  {
133  return $this->items;
134  }
+ Here is the caller graph for this function:

◆ getValidItems()

ilItemGroupItems::getValidItems ( )

Get valid items.

Parameters

Definition at line 246 of file class.ilItemGroupItems.php.

References $items, array, getAssignableItems(), and getItems().

247  {
248  $items = $this->getItems();
249  $ass_items = $this->getAssignableItems();
250  $valid_items = array();
251  foreach ($ass_items as $aitem) {
252  if (in_array($aitem["ref_id"], $items)) {
253  $valid_items[] = $aitem["ref_id"];
254  }
255  }
256  return $valid_items;
257  }
getAssignableItems()
Get assignable items.
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ read()

ilItemGroupItems::read ( )

Read item group items.

Definition at line 178 of file class.ilItemGroupItems.php.

References array.

Referenced by __construct().

179  {
180  $this->items = array();
181  $set = $this->db->query(
182  "SELECT * FROM item_group_item " .
183  " WHERE item_group_id = " . $this->db->quote($this->getItemGroupId(), "integer")
184  );
185  while ($rec = $this->db->fetchAssoc($set)) {
186  $this->items[] = $rec["item_ref_id"];
187  }
188  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ setItemGroupId()

ilItemGroupItems::setItemGroupId (   $a_val)

Set item group id.

Parameters
int$a_valitem group id

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

Referenced by __construct().

82  {
83  $this->item_group_id = $a_val;
84  }
+ Here is the caller graph for this function:

◆ setItemGroupRefId()

ilItemGroupItems::setItemGroupRefId (   $a_val)

Set item group ref id.

Parameters
int$a_valitem group ref id

Definition at line 101 of file class.ilItemGroupItems.php.

Referenced by __construct().

102  {
103  $this->item_group_ref_id = $a_val;
104  }
+ Here is the caller graph for this function:

◆ setItems()

ilItemGroupItems::setItems (   $a_val)

Set items.

Parameters
array$a_valitems (array of ref ids)

Definition at line 121 of file class.ilItemGroupItems.php.

Referenced by cloneItems().

122  {
123  $this->items = $a_val;
124  }
+ Here is the caller graph for this function:

◆ update()

ilItemGroupItems::update ( )

Update item group items.

Definition at line 161 of file class.ilItemGroupItems.php.

References $query, and getItemGroupId().

Referenced by cloneItems().

162  {
163  $this->delete();
164 
165  foreach ($this->items as $item) {
166  $query = "INSERT INTO item_group_item (item_group_id,item_ref_id) " .
167  "VALUES( " .
168  $this->db->quote($this->getItemGroupId(), 'integer') . ", " .
169  $this->db->quote($item, 'integer') . " " .
170  ")";
171  $this->db->manipulate($query);
172  }
173  }
getItemGroupId()
Get item group id.
$query
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilItemGroupItems::$db
protected

Definition at line 20 of file class.ilItemGroupItems.php.

◆ $ilDB

ilItemGroupItems::$ilDB

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

Referenced by __construct(), and _getItemsOfContainer().

◆ $item_group_id

ilItemGroupItems::$item_group_id = 0

Definition at line 41 of file class.ilItemGroupItems.php.

Referenced by getItemGroupId().

◆ $item_group_ref_id

ilItemGroupItems::$item_group_ref_id = 0

Definition at line 42 of file class.ilItemGroupItems.php.

Referenced by getItemGroupRefId().

◆ $items

ilItemGroupItems::$items = array()

Definition at line 43 of file class.ilItemGroupItems.php.

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

◆ $lng

ilItemGroupItems::$lng

Definition at line 39 of file class.ilItemGroupItems.php.

Referenced by __construct().

◆ $log

ilItemGroupItems::$log
protected

Definition at line 35 of file class.ilItemGroupItems.php.

Referenced by cloneItems().

◆ $obj_data_cache

ilItemGroupItems::$obj_data_cache
protected

Definition at line 30 of file class.ilItemGroupItems.php.

Referenced by cloneItems().

◆ $obj_def

ilItemGroupItems::$obj_def
protected

Definition at line 25 of file class.ilItemGroupItems.php.

Referenced by getAssignableItems().

◆ $tree

ilItemGroupItems::$tree

Definition at line 38 of file class.ilItemGroupItems.php.

Referenced by __construct(), and _getItemsOfContainer().


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