ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilLPCollectionOfRepositoryObjects Class Reference

LP collection of repository objects. More...

+ Inheritance diagram for ilLPCollectionOfRepositoryObjects:
+ Collaboration diagram for ilLPCollectionOfRepositoryObjects:

Public Member Functions

 __construct (int $a_obj_id, int $a_mode)
 
 getPossibleItems (int $a_ref_id, bool $a_full_data=false)
 
 cloneCollection (int $a_target_id, int $a_copy_id)
 
 deactivateEntries (array $a_item_ids)
 
 activateEntries (array $a_item_ids)
 
 createNewGrouping (array $a_item_ids, int $a_num_obligatory=1)
 
 releaseGrouping (array $a_item_ids)
 
 saveObligatoryMaterials (array $a_obl)
 
 getTableGUIData (int $a_parent_ref_id)
 
 getGroupedItemsForLPStatus ()
 
- Public Member Functions inherited from ilLPCollection
 __construct (int $a_obj_id, int $a_mode)
 
 hasSelectableItems ()
 
 cloneCollection (int $a_target_id, int $a_copy_id)
 
 getItems ()
 
 delete ()
 
 isAssignedEntry (int $a_item_id)
 
 deactivateEntries (array $a_item_ids)
 
 activateEntries (array $a_item_ids)
 

Static Public Member Functions

static hasGroupedItems (int $a_obj_id)
 
- Static Public Member Functions inherited from ilLPCollection
static getInstanceByMode (int $a_obj_id, int $a_mode)
 
static getCollectionModes ()
 

Protected Member Functions

 validateEntry (int $a_item_id)
 
 read (int $a_obj_id)
 
 addEntry (int $a_item_id)
 
 deleteEntry (int $a_item_id)
 
 getNonGroupedItems (array $a_item_ids)
 
 getGroupingIds (array $a_item_ids)
 
 parseTableGUIItem (int $a_id, array $a_item)
 
 getTableGUItemGroup (int $item_id)
 
- Protected Member Functions inherited from ilLPCollection
 read (int $a_obj_id)
 
 validateEntry (int $a_item_id)
 
 addEntry (int $a_item_id)
 
 deleteEntry (int $a_item_id)
 

Protected Attributes

ilTree $tree
 
ilObjectDefinition $objDefinition
 
- Protected Attributes inherited from ilLPCollection
int $obj_id
 
int $mode
 
array $items = []
 
ilDBInterface $db
 
ilLogger $logger
 

Static Protected Attributes

static array $possible_items = array()
 

Detailed Description

LP collection of repository objects.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 12 of file class.ilLPCollectionOfRepositoryObjects.php.

Constructor & Destructor Documentation

◆ __construct()

ilLPCollectionOfRepositoryObjects::__construct ( int  $a_obj_id,
int  $a_mode 
)

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

References $DIC, and ILIAS\GlobalScreen\Provider\__construct().

20  {
21  global $DIC;
22 
23  $this->tree = $DIC->repositoryTree();
24  $this->objDefinition = $DIC['objDefinition'];
25 
26  parent::__construct($a_obj_id, $a_mode);
27  }
global $DIC
Definition: shib_login.php:25
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ activateEntries()

ilLPCollectionOfRepositoryObjects::activateEntries ( array  $a_item_ids)

Definition at line 310 of file class.ilLPCollectionOfRepositoryObjects.php.

References getGroupingIds(), and getNonGroupedItems().

Referenced by createNewGrouping().

310  : void
311  {
312  // 44683: only activate non-grouped items via parent
313  $non_grouped_ids = $this->getNonGroupedItems($a_item_ids);
314  parent::activateEntries($non_grouped_ids);
315 
316  $grouping_ids = $this->getGroupingIds($a_item_ids);
317  if ($grouping_ids) {
318  $query = "UPDATE ut_lp_collections" .
319  " SET active = " . $this->db->quote(1, "integer") .
320  " WHERE " . $this->db->in(
321  "grouping_id",
322  $grouping_ids,
323  false,
324  "integer"
325  ) .
326  " AND obj_id = " . $this->db->quote($this->obj_id, "integer");
327  $this->db->manipulate($query);
328  }
329  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addEntry()

ilLPCollectionOfRepositoryObjects::addEntry ( int  $a_item_id)
protected

Definition at line 215 of file class.ilLPCollectionOfRepositoryObjects.php.

References deleteEntry(), and ilLPCollection\isAssignedEntry().

Referenced by cloneCollection().

215  : bool
216  {
217  // only active entries are assigned!
218  if (!$this->isAssignedEntry($a_item_id)) {
219  // #13278 - because of grouping inactive items may exist
220  $this->deleteEntry($a_item_id);
221 
222  $query = "INSERT INTO ut_lp_collections" .
223  " (obj_id, lpmode, item_id, grouping_id, num_obligatory, active)" .
224  " VALUES (" . $this->db->quote($this->obj_id, "integer") .
225  ", " . $this->db->quote($this->mode, "integer") .
226  ", " . $this->db->quote($a_item_id, "integer") .
227  ", " . $this->db->quote(0, "integer") .
228  ", " . $this->db->quote(0, "integer") .
229  ", " . $this->db->quote(1, "integer") .
230  ")";
231  $this->db->manipulate($query);
232  $this->items[] = $a_item_id;
233  }
234  return true;
235  }
isAssignedEntry(int $a_item_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cloneCollection()

ilLPCollectionOfRepositoryObjects::cloneCollection ( int  $a_target_id,
int  $a_copy_id 
)

Definition at line 143 of file class.ilLPCollectionOfRepositoryObjects.php.

References ilLPCollection\$mode, ilCopyWizardOptions\_getInstance(), ilObject\_lookupObjId(), addEntry(), and getGroupedItemsForLPStatus().

143  : void
144  {
145  parent::cloneCollection($a_target_id, $a_copy_id);
146 
147  $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
148  $mappings = $cwo->getMappings();
149 
150  $target_obj_id = ilObject::_lookupObjId($a_target_id);
151  $target_collection = new static($target_obj_id, $this->mode);
152 
153  // clone (active) groupings
154  foreach ($this->getGroupedItemsForLPStatus(
155  ) as $grouping_id => $group) {
156  $target_item_ids = array();
157  foreach ($group["items"] as $item) {
158  if (!isset($mappings[$item]) or !$mappings[$item]) {
159  continue;
160  }
161 
162  $target_item_ids[] = $mappings[$item];
163  }
164 
165  // grouping - if not only single item left after copy?
166  if ($grouping_id && sizeof($target_item_ids) > 1) {
167  // should not be larger than group
168  $num_obligatory = min(
169  sizeof($target_item_ids),
170  $group["num_obligatory"]
171  );
172 
173  $target_collection->createNewGrouping(
174  $target_item_ids,
175  $num_obligatory
176  );
177  } else {
178  // #15487 - single items
179  foreach ($target_item_ids as $item_id) {
180  $this->addEntry($item_id);
181  }
182  }
183  }
184  }
static _lookupObjId(int $ref_id)
static _getInstance(int $a_copy_id)
+ Here is the call graph for this function:

◆ createNewGrouping()

ilLPCollectionOfRepositoryObjects::createNewGrouping ( array  $a_item_ids,
int  $a_num_obligatory = 1 
)

Definition at line 331 of file class.ilLPCollectionOfRepositoryObjects.php.

References $res, activateEntries(), ilDBConstants\FETCHMODE_OBJECT, getGroupingIds(), and releaseGrouping().

334  : void {
335  $this->activateEntries($a_item_ids);
336 
337  $all_item_ids = array();
338  $grouping_ids = $this->getGroupingIds($a_item_ids);
339  $query = "SELECT item_id FROM ut_lp_collections" .
340  " WHERE obj_id = " . $this->db->quote($this->obj_id, "integer") .
341  " AND " . $this->db->in(
342  "grouping_id",
343  $grouping_ids,
344  false,
345  "integer"
346  );
347  $res = $this->db->query($query);
348  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
349  $all_item_ids[] = $row->item_id;
350  }
351 
352  $all_item_ids = array_unique(array_merge($all_item_ids, $a_item_ids));
353 
354  $this->releaseGrouping($a_item_ids);
355 
356  // Create new grouping
357  $query = "SELECT MAX(grouping_id) grp FROM ut_lp_collections" .
358  " WHERE obj_id = " . $this->db->quote($this->obj_id, "integer") .
359  " GROUP BY obj_id";
360  $res = $this->db->query($query);
361  $row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
362  $grp_id = $row->grp;
363  ++$grp_id;
364 
365  $query = "UPDATE ut_lp_collections SET" .
366  " grouping_id = " . $this->db->quote($grp_id, "integer") .
367  ", num_obligatory = " . $this->db->quote(
368  $a_num_obligatory,
369  "integer"
370  ) .
371  ", active = " . $this->db->quote(1, "integer") .
372  " WHERE obj_id = " . $this->db->quote($this->obj_id, "integer") .
373  " AND " . $this->db->in("item_id", $all_item_ids, false, "integer");
374  $this->db->manipulate($query);
375  }
$res
Definition: ltiservices.php:69
+ Here is the call graph for this function:

◆ deactivateEntries()

ilLPCollectionOfRepositoryObjects::deactivateEntries ( array  $a_item_ids)

Definition at line 291 of file class.ilLPCollectionOfRepositoryObjects.php.

References getGroupingIds().

291  : void
292  {
293  parent::deactivateEntries($a_item_ids);
294 
295  $grouping_ids = $this->getGroupingIds($a_item_ids);
296  if ($grouping_ids) {
297  $query = "UPDATE ut_lp_collections" .
298  " SET active = " . $this->db->quote(0, "integer") .
299  " WHERE " . $this->db->in(
300  "grouping_id",
301  $grouping_ids,
302  false,
303  "integer"
304  ) .
305  " AND obj_id = " . $this->db->quote($this->obj_id, "integer");
306  $this->db->manipulate($query);
307  }
308  }
+ Here is the call graph for this function:

◆ deleteEntry()

ilLPCollectionOfRepositoryObjects::deleteEntry ( int  $a_item_id)
protected

Definition at line 237 of file class.ilLPCollectionOfRepositoryObjects.php.

Referenced by addEntry(), and read().

237  : bool
238  {
239  $query = "DELETE FROM ut_lp_collections " .
240  " WHERE obj_id = " . $this->db->quote($this->obj_id, "integer") .
241  " AND item_id = " . $this->db->quote($a_item_id, "integer") .
242  " AND grouping_id = " . $this->db->quote(0, "integer");
243  $this->db->manipulate($query);
244  return true;
245  }
+ Here is the caller graph for this function:

◆ getGroupedItemsForLPStatus()

ilLPCollectionOfRepositoryObjects::getGroupedItemsForLPStatus ( )

Definition at line 512 of file class.ilLPCollectionOfRepositoryObjects.php.

References ilLPCollection\$items, $res, ilDBConstants\FETCHMODE_OBJECT, ilLPCollection\getItems(), and ILIAS\Repository\int().

Referenced by cloneCollection().

512  : array
513  {
514  $items = $this->getItems();
515  $query = " SELECT * FROM ut_lp_collections" .
516  " WHERE obj_id = " . $this->db->quote($this->obj_id, "integer") .
517  " AND active = " . $this->db->quote(1, "integer");
518  $res = $this->db->query($query);
519 
520  $grouped = array();
521  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
522  if (in_array($row->item_id, $items)) {
523  $grouped[$row->grouping_id]['items'][] = (int) $row->item_id;
524  $grouped[$row->grouping_id]['num_obligatory'] = (int) $row->num_obligatory;
525  }
526  }
527  return $grouped;
528  }
$res
Definition: ltiservices.php:69
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getGroupingIds()

ilLPCollectionOfRepositoryObjects::getGroupingIds ( array  $a_item_ids)
protected

Definition at line 275 of file class.ilLPCollectionOfRepositoryObjects.php.

References $res, and ilDBConstants\T_INTEGER.

Referenced by activateEntries(), createNewGrouping(), deactivateEntries(), and releaseGrouping().

275  : array
276  {
277  $grouping_ids = [];
278 
279  $query = "SELECT grouping_id FROM ut_lp_collections" .
280  " WHERE obj_id = " . $this->db->quote($this->obj_id, ilDBConstants::T_INTEGER) .
281  " AND " . $this->db->in("item_id", $a_item_ids, false, ilDBConstants::T_INTEGER) .
282  " AND grouping_id > " . $this->db->quote(0, ilDBConstants::T_INTEGER);
283  $res = $this->db->query($query);
284  while ($row = $res->fetchObject()) {
285  $grouping_ids[] = $row->grouping_id;
286  }
287 
288  return $grouping_ids;
289  }
$res
Definition: ltiservices.php:69
+ Here is the caller graph for this function:

◆ getNonGroupedItems()

ilLPCollectionOfRepositoryObjects::getNonGroupedItems ( array  $a_item_ids)
protected

Definition at line 259 of file class.ilLPCollectionOfRepositoryObjects.php.

References $res, and ilDBConstants\T_INTEGER.

Referenced by activateEntries().

259  : array
260  {
261  $grouped_item_ids = [];
262 
263  $query = "SELECT item_id FROM ut_lp_collections" .
264  " WHERE obj_id = " . $this->db->quote($this->obj_id, ilDBConstants::T_INTEGER) .
265  " AND " . $this->db->in("item_id", $a_item_ids, false, ilDBConstants::T_INTEGER) .
266  " AND grouping_id > " . $this->db->quote(0, ilDBConstants::T_INTEGER);
267  $res = $this->db->query($query);
268  while ($row = $res->fetchObject()) {
269  $grouped_item_ids[] = $row->item_id;
270  }
271 
272  return array_diff($a_item_ids, $grouped_item_ids);
273  }
$res
Definition: ltiservices.php:69
+ Here is the caller graph for this function:

◆ getPossibleItems()

ilLPCollectionOfRepositoryObjects::getPossibleItems ( int  $a_ref_id,
bool  $a_full_data = false 
)

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

References $data, $DIC, ILIAS\Repository\int(), ilLPCollection\isAssignedEntry(), ilRepositoryObjectPluginSlot\isTypePluginWithLP(), and validateEntry().

Referenced by getTableGUIData(), and read().

32  : array {
33  global $DIC;
34 
35  $cache_idx = $a_ref_id . "__" . $a_full_data;
36  if (!isset(self::$possible_items[$cache_idx])) {
37  $all_possible = array();
38 
39  if (!$this->tree->isDeleted($a_ref_id)) {
40  if (!$a_full_data) {
41  $data = $this->tree->getRbacSubtreeInfo($a_ref_id);
42  } else {
43  $node = $this->tree->getNodeData($a_ref_id);
44  $data = $this->tree->getSubTree($node);
45  }
46  foreach ($data as $node) {
47  if (!$a_full_data) {
48  $item_ref_id = (int) $node['child'];
49  } else {
50  $item_ref_id = (int) $node['ref_id'];
51  }
52 
53  // avoid recursion
54  if ($item_ref_id == $a_ref_id || !$this->validateEntry(
55  $item_ref_id
56  )) {
57  continue;
58  }
59 
60  switch ($node['type']) {
61  case 'sess':
62  case 'exc':
63  case 'fold':
64  case 'grp':
65  case 'sahs':
66  case 'lm':
67  case 'tst':
68  case 'file':
69  case 'mcst':
70  case 'htlm':
71  case 'svy':
72  case "prg":
73  case 'iass':
74  case 'copa':
75  case 'frm':
76  case 'cmix':
77  case 'lti':
78  case 'lso':
79  case 'crsr':
80  if (!$a_full_data) {
81  $all_possible[] = $item_ref_id;
82  } else {
83  $all_possible[$item_ref_id] = array(
84  'ref_id' => (int) $item_ref_id,
85  'obj_id' => (int) $node['obj_id'],
86  'title' => (string) $node['title'],
87  'description' => (string) $node['description'],
88  'type' => (string) $node['type']
89  );
90  }
91  break;
92 
93  // repository plugin object?
94  case $this->objDefinition->isPluginTypeName(
95  $node['type']
96  ):
97  $only_active = false;
98  if (!$this->isAssignedEntry($item_ref_id)) {
99  $only_active = true;
100  }
102  $node['type'],
103  $only_active
104  )) {
105  if (!$a_full_data) {
106  $all_possible[] = $item_ref_id;
107  } else {
108  $all_possible[$item_ref_id] = array(
109  'ref_id' => (int) $item_ref_id,
110  'obj_id' => (int) $node['obj_id'],
111  'title' => (string) $node['title'],
112  'description' => (string) $node['description'],
113  'type' => (string) $node['type']
114  );
115  }
116  }
117  break;
118  }
119  }
120  }
121 
122  self::$possible_items[$cache_idx] = $all_possible;
123  }
124 
125  return self::$possible_items[$cache_idx];
126  }
isAssignedEntry(int $a_item_id)
global $DIC
Definition: shib_login.php:25
static isTypePluginWithLP(string $a_type, bool $a_active_status=true)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTableGUIData()

ilLPCollectionOfRepositoryObjects::getTableGUIData ( int  $a_parent_ref_id)

Definition at line 429 of file class.ilLPCollectionOfRepositoryObjects.php.

References $data, ilLPCollection\$items, getPossibleItems(), getTableGUItemGroup(), and parseTableGUIItem().

429  : array
430  {
431  $items = $this->getPossibleItems($a_parent_ref_id, true);
432 
433  $data = array();
434  $done = array();
435  foreach ($items as $item_id => $item) {
436  if (in_array($item_id, $done)) {
437  continue;
438  }
439 
440  $table_item = $this->parseTableGUIItem($item_id, $item);
441 
442  // grouping
443  $table_item['grouped'] = array();
444  $grouped_items = $this->getTableGUItemGroup($item_id);
445  if (count((array) ($grouped_items['items'] ?? [])) > 1) {
446  foreach ($grouped_items['items'] as $grouped_item_id) {
447  if ($grouped_item_id == $item_id ||
448  !is_array($items[$grouped_item_id] ?? false)) { // #15498
449  continue;
450  }
451 
452  $table_item['grouped'][] = $this->parseTableGUIItem(
453  $grouped_item_id,
454  $items[$grouped_item_id]
455  );
456  $table_item['num_obligatory'] = $grouped_items['num_obligatory'];
457  $table_item['grouping_id'] = $grouped_items['grouping_id'];
458 
459  $done[] = $grouped_item_id;
460  }
461  }
462  $data[] = $table_item;
463  }
464  return $data;
465  }
getPossibleItems(int $a_ref_id, bool $a_full_data=false)
+ Here is the call graph for this function:

◆ getTableGUItemGroup()

ilLPCollectionOfRepositoryObjects::getTableGUItemGroup ( int  $item_id)
protected

Definition at line 481 of file class.ilLPCollectionOfRepositoryObjects.php.

References ilLPCollection\$items, $res, ilDBConstants\FETCHMODE_OBJECT, and ILIAS\Repository\int().

Referenced by getTableGUIData().

481  : array
482  {
483  $items = array();
484  $query = "SELECT grouping_id FROM ut_lp_collections" .
485  " WHERE obj_id = " . $this->db->quote($this->obj_id, "integer") .
486  " AND item_id = " . $this->db->quote($item_id, "integer");
487  $res = $this->db->query($query);
488  $grouping_id = 0;
489  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
490  $grouping_id = (int) $row->grouping_id;
491  }
492  if ($grouping_id > 0) {
493  $query = "SELECT item_id, num_obligatory FROM ut_lp_collections" .
494  " WHERE obj_id = " . $this->db->quote(
495  $this->obj_id,
496  "integer"
497  ) .
498  " AND grouping_id = " . $this->db->quote(
499  $grouping_id,
500  "integer"
501  );
502  $res = $this->db->query($query);
503  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
504  $items['items'][] = (int) $row->item_id;
505  $items['num_obligatory'] = (int) $row->num_obligatory;
506  $items['grouping_id'] = (int) $grouping_id;
507  }
508  }
509  return $items;
510  }
$res
Definition: ltiservices.php:69
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasGroupedItems()

static ilLPCollectionOfRepositoryObjects::hasGroupedItems ( int  $a_obj_id)
static

Definition at line 247 of file class.ilLPCollectionOfRepositoryObjects.php.

References $DIC, $ilDB, and $res.

Referenced by ilLPCollectionSettingsTableGUI\parse().

247  : bool
248  {
249  global $DIC;
250 
251  $ilDB = $DIC['ilDB'];
252  $query = "SELECT item_id FROM ut_lp_collections" .
253  " WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer") .
254  " AND grouping_id > " . $ilDB->quote(0, "integer");
255  $res = $ilDB->query($query);
256  return $res->numRows() ? true : false;
257  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: shib_login.php:25
+ Here is the caller graph for this function:

◆ parseTableGUIItem()

ilLPCollectionOfRepositoryObjects::parseTableGUIItem ( int  $a_id,
array  $a_item 
)
protected

Definition at line 467 of file class.ilLPCollectionOfRepositoryObjects.php.

References ilObjectLP\getInstance(), and ilLPCollection\isAssignedEntry().

Referenced by getTableGUIData().

467  : array
468  {
469  $table_item = $a_item;
470  $table_item['id'] = $a_id;
471  $table_item['status'] = $this->isAssignedEntry($a_id);
472 
473  $olp = ilObjectLP::getInstance($a_item['obj_id']);
474  $table_item['mode_id'] = $olp->getCurrentMode();
475  $table_item['mode'] = $olp->getModeText($table_item['mode_id']);
476  $table_item['anonymized'] = $olp->isAnonymized();
477 
478  return $table_item;
479  }
isAssignedEntry(int $a_item_id)
static getInstance(int $obj_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

ilLPCollectionOfRepositoryObjects::read ( int  $a_obj_id)
protected

Definition at line 186 of file class.ilLPCollectionOfRepositoryObjects.php.

References ilLPCollection\$items, $ref_id, $res, ilObject\_getAllReferences(), deleteEntry(), ilDBConstants\FETCHMODE_OBJECT, getPossibleItems(), and validateEntry().

186  : void
187  {
188  $items = array();
189 
190  $ref_ids = ilObject::_getAllReferences($a_obj_id);
191  $ref_id = end($ref_ids);
192  $possible = $this->getPossibleItems($ref_id);
193 
194  $res = $this->db->query(
195  "SELECT utc.item_id, obd.type" .
196  " FROM ut_lp_collections utc" .
197  " JOIN object_reference obr ON item_id = ref_id" .
198  " JOIN object_data obd ON obr.obj_id = obd.obj_id" .
199  " WHERE utc.obj_id = " . $this->db->quote($a_obj_id, "integer") .
200  " AND active = " . $this->db->quote(1, "integer") .
201  " ORDER BY title"
202  );
203  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
204  if (in_array($row->item_id, $possible) &&
205  $this->validateEntry((int) $row->item_id)) {
206  $items[] = $row->item_id;
207  } else {
208  $this->deleteEntry((int) $row->item_id);
209  }
210  }
211 
212  $this->items = $items;
213  }
$res
Definition: ltiservices.php:69
static _getAllReferences(int $id)
get all reference ids for object ID
$ref_id
Definition: ltiauth.php:66
getPossibleItems(int $a_ref_id, bool $a_full_data=false)
+ Here is the call graph for this function:

◆ releaseGrouping()

ilLPCollectionOfRepositoryObjects::releaseGrouping ( array  $a_item_ids)

Definition at line 377 of file class.ilLPCollectionOfRepositoryObjects.php.

References getGroupingIds().

Referenced by createNewGrouping().

377  : void
378  {
379  $grouping_ids = $this->getGroupingIds($a_item_ids);
380 
381  $query = "UPDATE ut_lp_collections" .
382  " SET grouping_id = " . $this->db->quote(0, "integer") .
383  ", num_obligatory = " . $this->db->quote(0, "integer") .
384  " WHERE obj_id = " . $this->db->quote($this->obj_id, "integer") .
385  " AND " . $this->db->in(
386  "grouping_id",
387  $grouping_ids,
388  false,
389  "integer"
390  );
391  $this->db->manipulate($query);
392  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveObligatoryMaterials()

ilLPCollectionOfRepositoryObjects::saveObligatoryMaterials ( array  $a_obl)

Definition at line 394 of file class.ilLPCollectionOfRepositoryObjects.php.

References $res, and ilDBConstants\FETCHMODE_OBJECT.

394  : void
395  {
396  foreach ($a_obl as $grouping_id => $num) {
397  $query = "SELECT count(obj_id) num FROM ut_lp_collections" .
398  " WHERE obj_id = " . $this->db->quote(
399  $this->obj_id,
400  "integer"
401  ) .
402  " AND grouping_id = " . $this->db->quote(
403  $grouping_id,
404  'integer'
405  ) .
406  " GROUP BY obj_id";
407  $res = $this->db->query($query);
408  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
409  if ($num <= 0 || $num >= $row->num) {
410  throw new UnexpectedValueException();
411  }
412  }
413  }
414  foreach ($a_obl as $grouping_id => $num) {
415  $query = "UPDATE ut_lp_collections" .
416  " SET num_obligatory = " . $this->db->quote($num, "integer") .
417  " WHERE obj_id = " . $this->db->quote(
418  $this->obj_id,
419  "integer"
420  ) .
421  " AND grouping_id = " . $this->db->quote(
422  $grouping_id,
423  "integer"
424  );
425  $this->db->manipulate($query);
426  }
427  }
$res
Definition: ltiservices.php:69

◆ validateEntry()

ilLPCollectionOfRepositoryObjects::validateEntry ( int  $a_item_id)
protected

Definition at line 128 of file class.ilLPCollectionOfRepositoryObjects.php.

References ilObject\_lookupObjId(), ilObject\_lookupType(), and ilObjectLP\getInstance().

Referenced by getPossibleItems(), and read().

128  : bool
129  {
130  $a_item_type = ilObject::_lookupType($a_item_id, true);
131  // this is hardcoded so we do not need to call all ObjectLP types
132  if ($a_item_type == 'tst') {
133  // Check anonymized
134  $item_obj_id = ilObject::_lookupObjId($a_item_id);
135  $olp = ilObjectLP::getInstance($item_obj_id);
136  if ($olp->isAnonymized()) {
137  return false;
138  }
139  }
140  return true;
141  }
static _lookupObjId(int $ref_id)
static _lookupType(int $id, bool $reference=false)
static getInstance(int $obj_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $objDefinition

ilObjectDefinition ilLPCollectionOfRepositoryObjects::$objDefinition
protected

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

◆ $possible_items

array ilLPCollectionOfRepositoryObjects::$possible_items = array()
staticprotected

Definition at line 14 of file class.ilLPCollectionOfRepositoryObjects.php.

◆ $tree

ilTree ilLPCollectionOfRepositoryObjects::$tree
protected

Definition at line 16 of file class.ilLPCollectionOfRepositoryObjects.php.


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