ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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.

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:26

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

+ 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.

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 }
getChildsByType(int $a_node_id, string $a_type)
get child nodes of given node by object type
$res
Definition: ltiservices.php:69

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

Referenced by ilRepositoryExplorer\isVisible().

+ 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.

92 : void
93 {
94 if (!in_array($a_item_ref_id, $this->items)) {
95 $this->items[] = $a_item_ref_id;
96 }
97 }

◆ cloneItems()

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

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

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 }
static _getInstance(int $a_copy_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
write(string $message, $level=ilLogLevel::INFO, array $context=[])
write log message

◆ delete()

ilItemGroupItems::delete ( )

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

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 }

References getItemGroupId().

+ Here is the call graph for this function:

◆ getAssignableItems()

ilItemGroupItems::getAssignableItems ( )

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

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 sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
ilObjectDefinition $obj_def
static _isFileHidden(string $a_file_name)
Returns true, if a file with the specified name, is usually hidden from the user.

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

Referenced by getValidItems().

+ 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.

64 : int
65 {
67 }

References $item_group_id.

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

+ Here is the caller graph for this function:

◆ getItemGroupRefId()

ilItemGroupItems::getItemGroupRefId ( )

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

74 : int
75 {
77 }

References $item_group_ref_id.

Referenced by __construct(), and getAssignableItems().

+ Here is the caller graph for this function:

◆ getItems()

ilItemGroupItems::getItems ( )

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

87 : array
88 {
89 return $this->items;
90 }

References $items.

Referenced by getValidItems().

+ Here is the caller graph for this function:

◆ getValidItems()

ilItemGroupItems::getValidItems ( )

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

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 }

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

+ Here is the call graph for this function:

◆ read()

ilItemGroupItems::read ( )

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

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 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setItemGroupId()

ilItemGroupItems::setItemGroupId ( int  $a_val)

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

59 : void
60 {
61 $this->item_group_id = $a_val;
62 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setItemGroupRefId()

ilItemGroupItems::setItemGroupRefId ( int  $a_val)

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

69 : void
70 {
71 $this->item_group_ref_id = $a_val;
72 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setItems()

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

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

82 : void
83 {
84 $this->items = $a_val;
85 }

◆ update()

ilItemGroupItems::update ( )

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

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 }

References getItemGroupId().

+ Here is the call 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 getItems(), and getValidItems().

◆ $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.

◆ $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: