ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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()
 

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 30 of file class.ilItemGroupItems.php.

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

31  {
32  global $ilDB, $lng, $tree, $objDefinition;
33 
34  $this->db = $ilDB;
35  $this->lng = $lng;
36  $this->tree = $tree;
37  $this->obj_def = $objDefinition;
38 
39  $this->setItemGroupRefId((int) $a_item_group_ref_id);
40  if ($this->getItemGroupRefId() > 0)
41  {
42  $this->setItemGroupId((int) ilObject::_lookupObjId($a_item_group_ref_id));
43  }
44 
45  if ($this->getItemGroupId() > 0)
46  {
47  $this->read();
48  }
49  }
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 281 of file class.ilItemGroupItems.php.

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

Referenced by ilRepositoryExplorer\isVisible().

282  {
283  global $ilDB,$tree;
284 
285  $itgr_nodes = $tree->getChildsByType($a_ref_id,'itgr');
286  foreach ($itgr_nodes as $node)
287  {
288  $itgr_ids[] = $node['obj_id'];
289  }
290  $query = "SELECT item_ref_id FROM item_group_item ".
291  "WHERE ".$ilDB->in('item_group_id', $itgr_ids,false,'integer');
292 
293 
294  $res = $ilDB->query($query);
295  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
296  {
297  $items[] = $row->item_ref_id;
298  }
299  return $items ? $items : array();
300  }
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 116 of file class.ilItemGroupItems.php.

Referenced by ilObjItemGroupGUI\afterSaveCallback().

117  {
118  if (!in_array($a_item_ref_id, $this->items))
119  {
120  $this->items[] = (int) $a_item_ref_id;
121  }
122  }
+ 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 250 of file class.ilItemGroupItems.php.

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

251  {
252  global $ilObjDataCache,$ilLog;
253 
254  $ilLog->write(__METHOD__.': Begin cloning item group materials ... -'.$a_source_id.'-');
255 
256  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
257  $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
258  $mappings = $cwo->getMappings();
259 
260  $new_items = array();
261 // check: is this a ref id!?
262  $source_ig = new ilItemGroupItems($a_source_id);
263  foreach($source_ig->getItems() as $item_ref_id)
264  {
265  if(isset($mappings[$item_ref_id]) and $mappings[$item_ref_id])
266  {
267  $ilLog->write(__METHOD__.': Clone item group item nr. '.$item_ref_id);
268  $new_items[] = $mappings[$item_ref_id];
269  }
270  else
271  {
272  $ilLog->write(__METHOD__.': No mapping found for item group item nr. '.$item_ref_id);
273  }
274  }
275  $this->setItems($new_items);
276  $this->update();
277  $ilLog->write(__METHOD__.': Finished cloning item group items ...');
278  return true;
279  }
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 127 of file class.ilItemGroupItems.php.

References $query, and getItemGroupId().

128  {
129  $query = "DELETE FROM item_group_item ".
130  "WHERE item_group_id = ".$this->db->quote($this->getItemGroupId(), 'integer');
131  $this->db->manipulate($query);
132  }
getItemGroupId()
Get item group id.
+ Here is the call graph for this function:

◆ getAssignableItems()

ilItemGroupItems::getAssignableItems ( )

Get assignable items.

Parameters

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

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

Referenced by getValidItems().

174  {
175  global $objDefinition;
176 
177  if ($this->getItemGroupRefId() <= 0)
178  {
179  return array();
180  }
181 
182  $parent_node = $this->tree->getNodeData(
183  $this->tree->getParentId($this->getItemGroupRefId()));
184 
185  $materials = array();
186  $nodes = $this->tree->getChilds($parent_node["child"]);
187 
188  include_once("./Modules/File/classes/class.ilObjFileAccess.php");
189  foreach($nodes as $node)
190  {
191  // filter side blocks and session, item groups and role folder
192  if ($node['child'] == $parent_node["child"] ||
193  $this->obj_def->isSideBlock($node['type']) ||
194  in_array($node['type'], array('sess', 'itgr', 'rolf', 'adm')))
195  {
196  continue;
197  }
198 
199  // filter hidden files
200  // see http://www.ilias.de/mantis/view.php?id=10269
201  if ($node['type'] == "file" &&
202  ilObjFileAccess::_isFileHidden($node['title']))
203  {
204  continue;
205  }
206 
207  if ($objDefinition->isInactivePlugin($node['type']))
208  {
209  continue;
210  }
211 
212  $materials[] = $node;
213  }
214 
215  $materials = ilUtil::sortArray($materials, "title", "asc");
216 
217  return $materials;
218  }
static _isFileHidden($a_file_name)
Returns true, if a file with the specified name, is usually hidden from the user. ...
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
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 66 of file class.ilItemGroupItems.php.

References $item_group_id.

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

67  {
68  return $this->item_group_id;
69  }
+ 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 86 of file class.ilItemGroupItems.php.

References $item_group_ref_id.

Referenced by __construct(), and getAssignableItems().

87  {
89  }
+ Here is the caller graph for this function:

◆ getItems()

ilItemGroupItems::getItems ( )

Get items.

Returns
array items (array of ref ids)

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

References $items.

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

107  {
108  return $this->items;
109  }
+ Here is the caller graph for this function:

◆ getValidItems()

ilItemGroupItems::getValidItems ( )

Get valid items.

Parameters

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

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

228  {
229  $items = $this->getItems();
230  $ass_items = $this->getAssignableItems();
231  $valid_items = array();
232  foreach ($ass_items as $aitem)
233  {
234  if (in_array($aitem["ref_id"], $items))
235  {
236  $valid_items[] = $aitem["ref_id"];
237  }
238  }
239  return $valid_items;
240  }
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 155 of file class.ilItemGroupItems.php.

References array.

Referenced by __construct().

156  {
157  $this->items = array();
158  $set = $this->db->query("SELECT * FROM item_group_item ".
159  " WHERE item_group_id = ".$this->db->quote($this->getItemGroupId(), "integer")
160  );
161  while ($rec = $this->db->fetchAssoc($set))
162  {
163  $this->items[] = $rec["item_ref_id"];
164  }
165  }
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 56 of file class.ilItemGroupItems.php.

Referenced by __construct().

57  {
58  $this->item_group_id = $a_val;
59  }
+ 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 76 of file class.ilItemGroupItems.php.

Referenced by __construct().

77  {
78  $this->item_group_ref_id = $a_val;
79  }
+ 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 96 of file class.ilItemGroupItems.php.

Referenced by cloneItems().

97  {
98  $this->items = $a_val;
99  }
+ Here is the caller graph for this function:

◆ update()

ilItemGroupItems::update ( )

Update item group items.

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

References $query, and getItemGroupId().

Referenced by cloneItems().

138  {
139  $this->delete();
140 
141  foreach($this->items as $item)
142  {
143  $query = "INSERT INTO item_group_item (item_group_id,item_ref_id) ".
144  "VALUES( ".
145  $this->db->quote($this->getItemGroupId() ,'integer').", ".
146  $this->db->quote($item ,'integer')." ".
147  ")";
148  $this->db->manipulate($query);
149  }
150  }
getItemGroupId()
Get item group id.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ilDB

ilItemGroupItems::$ilDB

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

Referenced by __construct(), and _getItemsOfContainer().

◆ $item_group_id

ilItemGroupItems::$item_group_id = 0

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

Referenced by getItemGroupId().

◆ $item_group_ref_id

ilItemGroupItems::$item_group_ref_id = 0

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

Referenced by getItemGroupRefId().

◆ $items

ilItemGroupItems::$items = array()

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

Referenced by _getItemsOfContainer(), and getItems().

◆ $lng

ilItemGroupItems::$lng

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

Referenced by __construct().

◆ $tree

ilItemGroupItems::$tree

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

Referenced by __construct(), and _getItemsOfContainer().


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