ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
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
 
ilAccessHandler $access
 

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

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

References $DIC, ilObject\_lookupObjId(), ILIAS\Repository\access(), 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 218 of file class.ilItemGroupItems.php.

218 : array
219 {
220 global $DIC;
221
222 $ilDB = $DIC->database();
223 $tree = $DIC->repositoryTree();
224
225 $itgr_ids = [];
226 $itgr_nodes = $tree->getChildsByType($a_ref_id, 'itgr');
227 foreach ($itgr_nodes as $node) {
228 $itgr_ids[] = $node['obj_id'];
229 }
230 $query = "SELECT item_ref_id FROM item_group_item " .
231 "WHERE " . $ilDB->in('item_group_id', $itgr_ids, false, 'integer');
232
233
234 $res = $ilDB->query($query);
235 $items = [];
236 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
237 $items[] = $row->item_ref_id;
238 }
239 return $items;
240 }
const FETCHMODE_OBJECT
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 94 of file class.ilItemGroupItems.php.

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

◆ cloneItems()

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

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

194 : void {
195 $ilLog = $this->log;
196
197 $ilLog->write(__METHOD__ . ': Begin cloning item group materials ... -' . $a_source_id . '-');
198
199 $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
200 $mappings = $cwo->getMappings();
201
202 $new_items = array();
203 // check: is this a ref id!?
204 $source_ig = new ilItemGroupItems($a_source_id);
205 foreach ($source_ig->getItems() as $item_ref_id) {
206 if (isset($mappings[$item_ref_id]) and $mappings[$item_ref_id]) {
207 $ilLog->write(__METHOD__ . ': Clone item group item nr. ' . $item_ref_id);
208 $new_items[] = $mappings[$item_ref_id];
209 } else {
210 $ilLog->write(__METHOD__ . ': No mapping found for item group item nr. ' . $item_ref_id);
211 }
212 }
213 $this->setItems($new_items);
214 $this->update();
215 $ilLog->write(__METHOD__ . ': Finished cloning item group items ...');
216 }
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 101 of file class.ilItemGroupItems.php.

101 : void
102 {
103 $query = "DELETE FROM item_group_item " .
104 "WHERE item_group_id = " . $this->db->quote($this->getItemGroupId(), 'integer');
105 $this->db->manipulate($query);
106 }

References getItemGroupId().

+ Here is the call graph for this function:

◆ getAssignableItems()

ilItemGroupItems::getAssignableItems ( )

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

134 : array
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 ($this->obj_def->isInactivePlugin((string) $node['type'])) {
163 continue;
164 }
165
166 if (!$this->access->checkAccess('visible', '', $node['ref_id'])) {
167 continue;
168 }
169
170 $materials[] = $node;
171 }
172
173 $materials = ilArrayUtil::sortArray($materials, "title", "asc");
174
175 return $materials;
176 }
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
static _isFileHidden(string $a_file_name)
Returns true, if a file with the specified name, is usually hidden from the user.

References ilObjFileAccess\_isFileHidden(), ILIAS\Repository\access(), 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 66 of file class.ilItemGroupItems.php.

66 : int
67 {
69 }

References $item_group_id.

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

+ Here is the caller graph for this function:

◆ getItemGroupRefId()

ilItemGroupItems::getItemGroupRefId ( )

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

76 : int
77 {
79 }

References $item_group_ref_id.

Referenced by __construct(), and getAssignableItems().

+ Here is the caller graph for this function:

◆ getItems()

ilItemGroupItems::getItems ( )

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

89 : array
90 {
91 return $this->items;
92 }

References $items.

Referenced by getValidItems().

+ Here is the caller graph for this function:

◆ getValidItems()

ilItemGroupItems::getValidItems ( )

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

178 : array
179 {
180 $items = $this->getItems();
181 $ass_items = $this->getAssignableItems();
182 $valid_items = array();
183 foreach ($ass_items as $aitem) {
184 if (in_array($aitem["ref_id"], $items)) {
185 $valid_items[] = $aitem["ref_id"];
186 }
187 }
188 return $valid_items;
189 }

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

+ Here is the call graph for this function:

◆ read()

ilItemGroupItems::read ( )

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

122 : void
123 {
124 $this->items = array();
125 $set = $this->db->query(
126 "SELECT * FROM item_group_item " .
127 " WHERE item_group_id = " . $this->db->quote($this->getItemGroupId(), "integer")
128 );
129 while ($rec = $this->db->fetchAssoc($set)) {
130 $this->items[] = $rec["item_ref_id"];
131 }
132 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setItemGroupId()

ilItemGroupItems::setItemGroupId ( int  $a_val)

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

61 : void
62 {
63 $this->item_group_id = $a_val;
64 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setItemGroupRefId()

ilItemGroupItems::setItemGroupRefId ( int  $a_val)

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

71 : void
72 {
73 $this->item_group_ref_id = $a_val;
74 }

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

84 : void
85 {
86 $this->items = $a_val;
87 }

◆ update()

ilItemGroupItems::update ( )

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

108 : void
109 {
110 $this->delete();
111
112 foreach ($this->items as $item) {
113 $query = "INSERT INTO item_group_item (item_group_id,item_ref_id) " .
114 "VALUES( " .
115 $this->db->quote($this->getItemGroupId(), 'integer') . ", " .
116 $this->db->quote($item, 'integer') . " " .
117 ")";
118 $this->db->manipulate($query);
119 }
120 }

References getItemGroupId().

+ Here is the call graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilItemGroupItems::$access
protected

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

◆ $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 34 of file class.ilItemGroupItems.php.

Referenced by getItemGroupId().

◆ $item_group_ref_id

int ilItemGroupItems::$item_group_ref_id = 0

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

Referenced by getItemGroupRefId().

◆ $items

array ilItemGroupItems::$items = array()

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

Referenced by getItems(), and getValidItems().

◆ $lng

ilLanguage ilItemGroupItems::$lng

Definition at line 33 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.

◆ $tree

ilTree ilItemGroupItems::$tree

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


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