ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilItemGroupItems 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 ilItemGroupItems:

Public Member Functions

 __construct (int $a_item_group_ref_id=0)
 
 setItemGroupId (int $a_val)
 
 getItemGroupId ()
 
 setItemGroupRefId (int $a_val)
 
 getItemGroupRefId ()
 
 setItems (array $a_val)
 
 getItems ()
 
 addItem (int $a_item_ref_id)
 
 delete ()
 
 update ()
 
 read ()
 
 getAssignableItems ()
 
 getValidItems ()
 
 cloneItems (int $a_source_id, int $a_copy_id)
 

Static Public Member Functions

static _getItemsOfContainer (int $a_ref_id)
 

Data Fields

ilTree $tree
 
ilLanguage $lng
 
int $item_group_id = 0
 
int $item_group_ref_id = 0
 
array $items = array()
 

Protected Attributes

ilDBInterface $db
 
ilObjectDefinition $obj_def
 
ilObjectDataCache $obj_data_cache
 
ilLogger $log
 

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 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
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

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

Constructor & Destructor Documentation

◆ __construct()

ilItemGroupItems::__construct ( int  $a_item_group_ref_id = 0)

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

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

39  {
40  global $DIC;
41 
42  $this->obj_data_cache = $DIC["ilObjDataCache"];
43  $this->log = $DIC["ilLog"];
44  $this->db = $DIC->database();
45  $this->lng = $DIC->language();
46  $this->tree = $DIC->repositoryTree();
47  $this->obj_def = $DIC["objDefinition"];
48 
49  $this->setItemGroupRefId($a_item_group_ref_id);
50  if ($this->getItemGroupRefId() > 0) {
51  $this->setItemGroupId(ilObject::_lookupObjId($a_item_group_ref_id));
52  }
53 
54  if ($this->getItemGroupId() > 0) {
55  $this->read();
56  }
57  }
static _lookupObjId(int $ref_id)
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ _getItemsOfContainer()

static ilItemGroupItems::_getItemsOfContainer ( int  $a_ref_id)
static

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

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

Referenced by ilRepositoryExplorer\isVisible().

214  : array
215  {
216  global $DIC;
217 
218  $ilDB = $DIC->database();
219  $tree = $DIC->repositoryTree();
220 
221  $itgr_ids = [];
222  $itgr_nodes = $tree->getChildsByType($a_ref_id, 'itgr');
223  foreach ($itgr_nodes as $node) {
224  $itgr_ids[] = $node['obj_id'];
225  }
226  $query = "SELECT item_ref_id FROM item_group_item " .
227  "WHERE " . $ilDB->in('item_group_id', $itgr_ids, false, 'integer');
228 
229 
230  $res = $ilDB->query($query);
231  $items = [];
232  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
233  $items[] = $row->item_ref_id;
234  }
235  return $items;
236  }
$res
Definition: ltiservices.php:66
getChildsByType(int $a_node_id, string $a_type)
get child nodes of given node by object type
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addItem()

ilItemGroupItems::addItem ( int  $a_item_ref_id)

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

Referenced by ilObjItemGroupGUI\afterSaveCallback().

92  : void
93  {
94  if (!in_array($a_item_ref_id, $this->items)) {
95  $this->items[] = $a_item_ref_id;
96  }
97  }
+ Here is the caller graph for this function:

◆ cloneItems()

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

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

References $log, ilCopyWizardOptions\_getInstance(), setItems(), update(), and ilLogger\write().

190  : void {
191  $ilLog = $this->log;
192 
193  $ilLog->write(__METHOD__ . ': Begin cloning item group materials ... -' . $a_source_id . '-');
194 
195  $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
196  $mappings = $cwo->getMappings();
197 
198  $new_items = array();
199  // check: is this a ref id!?
200  $source_ig = new ilItemGroupItems($a_source_id);
201  foreach ($source_ig->getItems() as $item_ref_id) {
202  if (isset($mappings[$item_ref_id]) and $mappings[$item_ref_id]) {
203  $ilLog->write(__METHOD__ . ': Clone item group item nr. ' . $item_ref_id);
204  $new_items[] = $mappings[$item_ref_id];
205  } else {
206  $ilLog->write(__METHOD__ . ': No mapping found for item group item nr. ' . $item_ref_id);
207  }
208  }
209  $this->setItems($new_items);
210  $this->update();
211  $ilLog->write(__METHOD__ . ': Finished cloning item group items ...');
212  }
write(string $message, $level=ilLogLevel::INFO, array $context=[])
write log message
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getInstance(int $a_copy_id)
+ Here is the call graph for this function:

◆ delete()

ilItemGroupItems::delete ( )

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

References getItemGroupId().

99  : void
100  {
101  $query = "DELETE FROM item_group_item " .
102  "WHERE item_group_id = " . $this->db->quote($this->getItemGroupId(), 'integer');
103  $this->db->manipulate($query);
104  }
+ Here is the call graph for this function:

◆ getAssignableItems()

ilItemGroupItems::getAssignableItems ( )

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

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

Referenced by getValidItems().

132  : array
133  {
134  $objDefinition = $this->obj_def;
135 
136  if ($this->getItemGroupRefId() <= 0) {
137  return array();
138  }
139 
140  $parent_node = $this->tree->getNodeData(
141  $this->tree->getParentId($this->getItemGroupRefId())
142  );
143 
144  $materials = array();
145  $nodes = $this->tree->getChilds($parent_node["child"]);
146 
147  foreach ($nodes as $node) {
148  // filter side blocks and session, item groups and role folder
149  if ($node['child'] == $parent_node["child"] ||
150  $this->obj_def->isSideBlock($node['type']) ||
151  in_array($node['type'], array('sess', 'itgr', 'rolf', 'adm'))) {
152  continue;
153  }
154 
155  // filter hidden files
156  // see http://www.ilias.de/mantis/view.php?id=10269
157  if ($node['type'] == "file" &&
158  ilObjFileAccess::_isFileHidden((string) $node['title'])) {
159  continue;
160  }
161 
162  if ($objDefinition->isInactivePlugin((string) $node['type'])) {
163  continue;
164  }
165 
166  $materials[] = $node;
167  }
168 
169  $materials = ilArrayUtil::sortArray($materials, "title", "asc");
170 
171  return $materials;
172  }
static _isFileHidden(string $a_file_name)
Returns true, if a file with the specified name, is usually hidden from the user. ...
ilObjectDefinition $obj_def
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getItemGroupId()

ilItemGroupItems::getItemGroupId ( )

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

References $item_group_id.

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

64  : int
65  {
66  return $this->item_group_id;
67  }
+ Here is the caller graph for this function:

◆ getItemGroupRefId()

ilItemGroupItems::getItemGroupRefId ( )

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

References $item_group_ref_id.

Referenced by __construct(), and getAssignableItems().

74  : int
75  {
77  }
+ Here is the caller graph for this function:

◆ getItems()

ilItemGroupItems::getItems ( )

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

References $items.

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

87  : array
88  {
89  return $this->items;
90  }
+ Here is the caller graph for this function:

◆ getValidItems()

ilItemGroupItems::getValidItems ( )

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

References getAssignableItems(), and getItems().

174  : array
175  {
176  $items = $this->getItems();
177  $ass_items = $this->getAssignableItems();
178  $valid_items = array();
179  foreach ($ass_items as $aitem) {
180  if (in_array($aitem["ref_id"], $items)) {
181  $valid_items[] = $aitem["ref_id"];
182  }
183  }
184  return $valid_items;
185  }
+ Here is the call graph for this function:

◆ read()

ilItemGroupItems::read ( )

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

Referenced by __construct().

120  : void
121  {
122  $this->items = array();
123  $set = $this->db->query(
124  "SELECT * FROM item_group_item " .
125  " WHERE item_group_id = " . $this->db->quote($this->getItemGroupId(), "integer")
126  );
127  while ($rec = $this->db->fetchAssoc($set)) {
128  $this->items[] = $rec["item_ref_id"];
129  }
130  }
+ Here is the caller graph for this function:

◆ setItemGroupId()

ilItemGroupItems::setItemGroupId ( int  $a_val)

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

Referenced by __construct().

59  : void
60  {
61  $this->item_group_id = $a_val;
62  }
+ Here is the caller graph for this function:

◆ setItemGroupRefId()

ilItemGroupItems::setItemGroupRefId ( int  $a_val)

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

Referenced by __construct().

69  : void
70  {
71  $this->item_group_ref_id = $a_val;
72  }
+ Here is the caller graph for this function:

◆ setItems()

ilItemGroupItems::setItems ( array  $a_val)
Parameters
int[]$a_val items (array of ref ids)

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

Referenced by cloneItems().

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

◆ update()

ilItemGroupItems::update ( )

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

References getItemGroupId().

Referenced by cloneItems().

106  : void
107  {
108  $this->delete();
109 
110  foreach ($this->items as $item) {
111  $query = "INSERT INTO item_group_item (item_group_id,item_ref_id) " .
112  "VALUES( " .
113  $this->db->quote($this->getItemGroupId(), 'integer') . ", " .
114  $this->db->quote($item, 'integer') . " " .
115  ")";
116  $this->db->manipulate($query);
117  }
118  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilDBInterface ilItemGroupItems::$db
protected

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

◆ $item_group_id

int ilItemGroupItems::$item_group_id = 0

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

Referenced by getItemGroupId().

◆ $item_group_ref_id

int ilItemGroupItems::$item_group_ref_id = 0

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

Referenced by getItemGroupRefId().

◆ $items

array ilItemGroupItems::$items = array()

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

Referenced by _getItemsOfContainer(), and getItems().

◆ $lng

ilLanguage ilItemGroupItems::$lng

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

◆ $log

ilLogger ilItemGroupItems::$log
protected

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

Referenced by cloneItems().

◆ $obj_data_cache

ilObjectDataCache ilItemGroupItems::$obj_data_cache
protected

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

◆ $obj_def

ilObjectDefinition ilItemGroupItems::$obj_def
protected

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

Referenced by getAssignableItems().

◆ $tree

ilTree ilItemGroupItems::$tree

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


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