ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilLPCollectionOfRepositoryObjects Class Reference

LP collection of repository objects. More...

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

Public Member Functions

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

Static Public Member Functions

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

Protected Member Functions

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

Static Protected Attributes

static $possible_items = array()
 

Additional Inherited Members

- Protected Attributes inherited from ilLPCollection
 $obj_id
 
 $mode
 
 $items
 

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
Version
Id
class.ilLPCollections.php 40326 2013-03-05 11:39:24Z jluetzen

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

Member Function Documentation

◆ activateEntries()

ilLPCollectionOfRepositoryObjects::activateEntries ( array  $a_item_ids)

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

References $DIC, $ilDB, $query, and getGroupingIds().

Referenced by createNewGrouping().

301  {
302  global $DIC;
303 
304  $ilDB = $DIC['ilDB'];
305 
306  parent::activateEntries($a_item_ids);
307 
308  $grouping_ids = $this->getGroupingIds($a_item_ids);
309  if ($grouping_ids) {
310  $query = "UPDATE ut_lp_collections" .
311  " SET active = " . $ilDB->quote(1, "integer") .
312  " WHERE " . $ilDB->in("grouping_id", $grouping_ids, false, "integer") .
313  " AND obj_id = " . $ilDB->quote($this->obj_id, "integer");
314  $ilDB->manipulate($query);
315  }
316  }
global $DIC
Definition: saml.php:7
$query
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addEntry()

ilLPCollectionOfRepositoryObjects::addEntry (   $a_item_id)
protected

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

References $DIC, $ilDB, $query, deleteEntry(), and ilLPCollection\isAssignedEntry().

Referenced by cloneCollection().

205  {
206  global $DIC;
207 
208  $ilDB = $DIC['ilDB'];
209 
210  // only active entries are assigned!
211  if (!$this->isAssignedEntry($a_item_id)) {
212  // #13278 - because of grouping inactive items may exist
213  $this->deleteEntry($a_item_id);
214 
215  $query = "INSERT INTO ut_lp_collections" .
216  " (obj_id, lpmode, item_id, grouping_id, num_obligatory, active)" .
217  " VALUES (" . $ilDB->quote($this->obj_id, "integer") .
218  ", " . $ilDB->quote($this->mode, "integer") .
219  ", " . $ilDB->quote($a_item_id, "integer") .
220  ", " . $ilDB->quote(0, "integer") .
221  ", " . $ilDB->quote(0, "integer") .
222  ", " . $ilDB->quote(1, "integer") .
223  ")";
224  $ilDB->manipulate($query);
225  $this->items[] = $a_item_id;
226  }
227  return true;
228  }
global $DIC
Definition: saml.php:7
$query
isAssignedEntry($a_item_id)
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cloneCollection()

ilLPCollectionOfRepositoryObjects::cloneCollection (   $a_target_id,
  $a_copy_id 
)

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

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

132  {
133  parent::cloneCollection($a_target_id, $a_copy_id);
134 
135  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
136  $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
137  $mappings = $cwo->getMappings();
138 
139  $target_obj_id = ilObject::_lookupObjId($a_target_id);
140  $target_collection = new static($target_obj_id, $this->mode);
141 
142  // clone (active) groupings
143  foreach ($this->getGroupedItemsForLPStatus() as $grouping_id => $group) {
144  $target_item_ids = array();
145  foreach ($group["items"] as $item) {
146  if (!isset($mappings[$item]) or !$mappings[$item]) {
147  continue;
148  }
149 
150  $target_item_ids[] = $mappings[$item];
151  }
152 
153  // grouping - if not only single item left after copy?
154  if ($grouping_id && sizeof($target_item_ids) > 1) {
155  // should not be larger than group
156  $num_obligatory = min(sizeof($target_item_ids), $group["num_obligatory"]);
157 
158  $target_collection->createNewGrouping($target_item_ids, $num_obligatory);
159  } else {
160  // #15487 - single items
161  foreach ($target_item_ids as $item_id) {
162  $this->addEntry($item_id);
163  }
164  }
165  }
166  }
static _getInstance($a_copy_id)
Get instance of copy wizard options.
static _lookupObjId($a_id)
+ Here is the call graph for this function:

◆ createNewGrouping()

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

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

References $DIC, $ilDB, $query, $res, $row, activateEntries(), ilDBConstants\FETCHMODE_OBJECT, getGroupingIds(), and releaseGrouping().

319  {
320  global $DIC;
321 
322  $ilDB = $DIC['ilDB'];
323 
324  $this->activateEntries($a_item_ids);
325 
326  $all_item_ids = array();
327 
328  $grouping_ids = $this->getGroupingIds($a_item_ids);
329 
330  $query = "SELECT item_id FROM ut_lp_collections" .
331  " WHERE obj_id = " . $ilDB->quote($this->obj_id, "integer") .
332  " AND " . $ilDB->in("grouping_id", $grouping_ids, false, "integer");
333  $res = $ilDB->query($query);
334  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
335  $all_item_ids[] = $row->item_id;
336  }
337 
338  $all_item_ids = array_unique(array_merge($all_item_ids, $a_item_ids));
339 
340  $this->releaseGrouping($a_item_ids);
341 
342  // Create new grouping
343  $query = "SELECT MAX(grouping_id) grp FROM ut_lp_collections" .
344  " WHERE obj_id = " . $ilDB->quote($this->obj_id, "integer") .
345  " GROUP BY obj_id";
346  $res = $ilDB->query($query);
348  $grp_id = $row->grp;
349  ++$grp_id;
350 
351  $query = "UPDATE ut_lp_collections SET" .
352  " grouping_id = " . $ilDB->quote($grp_id, "integer") .
353  ", num_obligatory = " . $ilDB->quote($a_num_obligatory, "integer") .
354  ", active = " . $ilDB->quote(1, "integer") .
355  " WHERE obj_id = " . $ilDB->quote($this->obj_id, "integer") .
356  " AND " . $ilDB->in("item_id", $all_item_ids, false, "integer");
357  $ilDB->manipulate($query);
358 
359  return;
360  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ Here is the call graph for this function:

◆ deactivateEntries()

ilLPCollectionOfRepositoryObjects::deactivateEntries ( array  $a_item_ids)

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

References $DIC, $ilDB, $query, and getGroupingIds().

283  {
284  global $DIC;
285 
286  $ilDB = $DIC['ilDB'];
287 
288  parent::deactivateEntries($a_item_ids);
289 
290  $grouping_ids = $this->getGroupingIds($a_item_ids);
291  if ($grouping_ids) {
292  $query = "UPDATE ut_lp_collections" .
293  " SET active = " . $ilDB->quote(0, "integer") .
294  " WHERE " . $ilDB->in("grouping_id", $grouping_ids, false, "integer") .
295  " AND obj_id = " . $ilDB->quote($this->obj_id, "integer");
296  $ilDB->manipulate($query);
297  }
298  }
global $DIC
Definition: saml.php:7
$query
global $ilDB
+ Here is the call graph for this function:

◆ deleteEntry()

ilLPCollectionOfRepositoryObjects::deleteEntry (   $a_item_id)
protected

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

References $DIC, $ilDB, and $query.

Referenced by addEntry(), and read().

231  {
232  global $DIC;
233 
234  $ilDB = $DIC['ilDB'];
235 
236  $query = "DELETE FROM ut_lp_collections " .
237  " WHERE obj_id = " . $ilDB->quote($this->obj_id, "integer") .
238  " AND item_id = " . $ilDB->quote($a_item_id, "integer") .
239  " AND grouping_id = " . $ilDB->quote(0, "integer");
240  $ilDB->manipulate($query);
241  return true;
242  }
global $DIC
Definition: saml.php:7
$query
global $ilDB
+ Here is the caller graph for this function:

◆ getGroupedItemsForLPStatus()

ilLPCollectionOfRepositoryObjects::getGroupedItemsForLPStatus ( )

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

References $DIC, $ilDB, ilLPCollection\$items, $query, $res, $row, ilDBConstants\FETCHMODE_OBJECT, and ilLPCollection\getItems().

Referenced by cloneCollection().

491  {
492  global $DIC;
493 
494  $ilDB = $DIC['ilDB'];
495 
496  $items = $this->getItems();
497 
498  $query = " SELECT * FROM ut_lp_collections" .
499  " WHERE obj_id = " . $ilDB->quote($this->obj_id, "integer") .
500  " AND active = " . $ilDB->quote(1, "integer");
501  $res = $ilDB->query($query);
502 
503  $grouped = array();
504  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
505  if (in_array($row->item_id, $items)) {
506  $grouped[$row->grouping_id]['items'][] = $row->item_id;
507  $grouped[$row->grouping_id]['num_obligatory'] = $row->num_obligatory;
508  }
509  }
510 
511  return $grouped;
512  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ 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 262 of file class.ilLPCollectionOfRepositoryObjects.php.

References $DIC, $ilDB, $query, $res, $row, and ilDBConstants\FETCHMODE_OBJECT.

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

263  {
264  global $DIC;
265 
266  $ilDB = $DIC['ilDB'];
267 
268  $grouping_ids = array();
269 
270  $query = "SELECT grouping_id FROM ut_lp_collections" .
271  " WHERE obj_id = " . $ilDB->quote($this->obj_id, "integer") .
272  " AND " . $ilDB->in("item_id", $a_item_ids, false, "integer") .
273  " AND grouping_id > " . $ilDB->quote(0, "integer");
274  $res = $ilDB->query($query);
275  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
276  $grouping_ids[] = $row->grouping_id;
277  }
278 
279  return $grouping_ids;
280  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ Here is the caller graph for this function:

◆ getPossibleItems()

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

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

References $data, $DIC, $tree, ilLPCollection\isAssignedEntry(), ilRepositoryObjectPluginSlot\isTypePluginWithLP(), and validateEntry().

Referenced by getTableGUIData(), and read().

21  {
22  global $DIC;
23 
24  $tree = $DIC['tree'];
25  $objDefinition = $DIC['objDefinition'];
26 
27  $cache_idx = $a_ref_id . "__" . $a_full_data;
28 
29  if (!isset(self::$possible_items[$cache_idx])) {
30  $all_possible = array();
31 
32  if (!$tree->isDeleted($a_ref_id)) {
33  include_once 'Services/Repository/classes/class.ilRepositoryObjectPluginSlot.php';
34 
35  if (!$a_full_data) {
36  $data = $tree->getRbacSubTreeInfo($a_ref_id);
37  } else {
38  $node = $tree->getNodeData($a_ref_id);
39  $data = $tree->getSubTree($node);
40  }
41  foreach ($data as $node) {
42  if (!$a_full_data) {
43  $item_ref_id = $node['child'];
44  } else {
45  $item_ref_id = $node['ref_id'];
46  }
47 
48  // avoid recursion
49  if ($item_ref_id == $a_ref_id ||
50  !$this->validateEntry($item_ref_id, $node['type'])) {
51  continue;
52  }
53 
54  switch ($node['type']) {
55  case 'sess':
56  case 'exc':
57  case 'fold':
58  case 'grp':
59  case 'sahs':
60  case 'lm':
61  case 'tst':
62  case 'file':
63  case 'mcst':
64  case 'htlm':
65  case 'svy':
66  case "prg":
67  case 'iass':
68  case 'copa':
69  case 'lso':
70  if (!$a_full_data) {
71  $all_possible[] = $item_ref_id;
72  } else {
73  $all_possible[$item_ref_id] = array(
74  'ref_id' => $item_ref_id,
75  'obj_id' => $node['obj_id'],
76  'title' => $node['title'],
77  'description' => $node['description'],
78  'type' => $node['type']
79  );
80  }
81  break;
82 
83  // repository plugin object?
84  case $objDefinition->isPluginTypeName($node['type']):
85  $only_active = false;
86  if (!$this->isAssignedEntry($item_ref_id)) {
87  $only_active = true;
88  }
89  if (ilRepositoryObjectPluginSlot::isTypePluginWithLP($node['type'], $only_active)) {
90  if (!$a_full_data) {
91  $all_possible[] = $item_ref_id;
92  } else {
93  $all_possible[$item_ref_id] = array(
94  'ref_id' => $item_ref_id,
95  'obj_id' => $node['obj_id'],
96  'title' => $node['title'],
97  'description' => $node['description'],
98  'type' => $node['type']
99  );
100  }
101  }
102  break;
103  }
104  }
105  }
106 
107  self::$possible_items[$cache_idx] = $all_possible;
108  }
109 
110  return self::$possible_items[$cache_idx];
111  }
static isTypePluginWithLP($a_type, $a_active_status=true)
Check whether a repository type is a plugin which has active learning progress.
global $DIC
Definition: saml.php:7
isAssignedEntry($a_item_id)
$data
Definition: bench.php:6
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTableGUIData()

ilLPCollectionOfRepositoryObjects::getTableGUIData (   $a_parent_ref_id)

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

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

411  {
412  $items = $this->getPossibleItems($a_parent_ref_id, true);
413 
414  $data = array();
415  $done = array();
416  foreach ($items as $item_id => $item) {
417  if (in_array($item_id, $done)) {
418  continue;
419  }
420 
421  $table_item = $this->parseTableGUIItem($item_id, $item);
422 
423  // grouping
424  $table_item['grouped'] = array();
425  $grouped_items = $this->getTableGUItemGroup($item_id);
426  if (count((array) $grouped_items['items']) > 1) {
427  foreach ($grouped_items['items'] as $grouped_item_id) {
428  if ($grouped_item_id == $item_id ||
429  !is_array($items[$grouped_item_id])) { // #15498
430  continue;
431  }
432 
433  $table_item['grouped'][] = $this->parseTableGUIItem($grouped_item_id, $items[$grouped_item_id]);
434  $table_item['num_obligatory'] = $grouped_items['num_obligatory'];
435  $table_item['grouping_id'] = $grouped_items['grouping_id'];
436 
437  $done[] = $grouped_item_id;
438  }
439  }
440 
441  $data[] = $table_item;
442  }
443 
444  return $data;
445  }
$data
Definition: bench.php:6
+ Here is the call graph for this function:

◆ getTableGUItemGroup()

ilLPCollectionOfRepositoryObjects::getTableGUItemGroup (   $item_id)
protected

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

References $DIC, $ilDB, ilLPCollection\$items, $query, $res, $row, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by getTableGUIData().

462  {
463  global $DIC;
464 
465  $ilDB = $DIC['ilDB'];
466 
467  $items = array();
468 
469  $query = "SELECT grouping_id FROM ut_lp_collections" .
470  " WHERE obj_id = " . $ilDB->quote($this->obj_id, "integer") .
471  " AND item_id = " . $ilDB->quote($item_id, "integer");
472  $res = $ilDB->query($query);
474  $grouping_id = $row->grouping_id;
475  if ($grouping_id > 0) {
476  $query = "SELECT item_id, num_obligatory FROM ut_lp_collections" .
477  " WHERE obj_id = " . $ilDB->quote($this->obj_id, "integer") .
478  " AND grouping_id = " . $ilDB->quote($grouping_id, "integer");
479  $res = $ilDB->query($query);
480  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
481  $items['items'][] = $row->item_id;
482  $items['num_obligatory'] = $row->num_obligatory;
483  $items['grouping_id'] = $grouping_id;
484  }
485  }
486 
487  return $items;
488  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ Here is the caller graph for this function:

◆ hasGroupedItems()

static ilLPCollectionOfRepositoryObjects::hasGroupedItems (   $a_obj_id)
static

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

References $DIC, $ilDB, $query, and $res.

Referenced by ilLPCollectionSettingsTableGUI\parse().

250  {
251  global $DIC;
252 
253  $ilDB = $DIC['ilDB'];
254 
255  $query = "SELECT item_id FROM ut_lp_collections" .
256  " WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer") .
257  " AND grouping_id > " . $ilDB->quote(0, "integer");
258  $res = $ilDB->query($query);
259  return $res->numRows() ? true : false;
260  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the caller graph for this function:

◆ parseTableGUIItem()

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

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

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

Referenced by getTableGUIData().

448  {
449  $table_item = $a_item;
450  $table_item['id'] = $a_id;
451  $table_item['status'] = $this->isAssignedEntry($a_id);
452 
453  $olp = ilObjectLP::getInstance($a_item['obj_id']);
454  $table_item['mode_id'] = $olp->getCurrentMode();
455  $table_item['mode'] = $olp->getModeText($table_item['mode_id']);
456  $table_item['anonymized'] = $olp->isAnonymized();
457 
458  return $table_item;
459  }
isAssignedEntry($a_item_id)
static getInstance($a_obj_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

ilLPCollectionOfRepositoryObjects::read (   $a_obj_id)
protected

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

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

174  {
175  global $DIC;
176 
177  $ilDB = $DIC['ilDB'];
178 
179  $items = array();
180 
181  $ref_ids = ilObject::_getAllReferences($a_obj_id);
182  $ref_id = end($ref_ids);
183  $possible = $this->getPossibleItems($ref_id);
184 
185  $res = $ilDB->query("SELECT utc.item_id, obd.type" .
186  " FROM ut_lp_collections utc" .
187  " JOIN object_reference obr ON item_id = ref_id" .
188  " JOIN object_data obd ON obr.obj_id = obd.obj_id" .
189  " WHERE utc.obj_id = " . $ilDB->quote($a_obj_id, "integer") .
190  " AND active = " . $ilDB->quote(1, "integer") .
191  " ORDER BY title");
192  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
193  if (in_array($row->item_id, $possible) &&
194  $this->validateEntry($row->item_id, $row->type)) {
195  $items[] = $row->item_id;
196  } else {
197  $this->deleteEntry($row->item_id);
198  }
199  }
200 
201  $this->items = $items;
202  }
global $DIC
Definition: saml.php:7
static _getAllReferences($a_id)
get all reference ids of object
foreach($_POST as $key=> $value) $res
$row
global $ilDB
+ Here is the call graph for this function:

◆ releaseGrouping()

ilLPCollectionOfRepositoryObjects::releaseGrouping ( array  $a_item_ids)

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

References $DIC, $ilDB, $query, and getGroupingIds().

Referenced by createNewGrouping().

363  {
364  global $DIC;
365 
366  $ilDB = $DIC['ilDB'];
367 
368  $grouping_ids = $this->getGroupingIds($a_item_ids);
369 
370  $query = "UPDATE ut_lp_collections" .
371  " SET grouping_id = " . $ilDB->quote(0, "integer") .
372  ", num_obligatory = " . $ilDB->quote(0, "integer") .
373  " WHERE obj_id = " . $ilDB->quote($this->obj_id, "integer") .
374  " AND " . $ilDB->in("grouping_id", $grouping_ids, false, "integer");
375  $ilDB->manipulate($query);
376  }
global $DIC
Definition: saml.php:7
$query
global $ilDB
+ 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 378 of file class.ilLPCollectionOfRepositoryObjects.php.

References $DIC, $ilDB, $query, $res, $row, and ilDBConstants\FETCHMODE_OBJECT.

379  {
380  global $DIC;
381 
382  $ilDB = $DIC['ilDB'];
383 
384  foreach ($a_obl as $grouping_id => $num) {
385  $query = "SELECT count(obj_id) num FROM ut_lp_collections" .
386  " WHERE obj_id = " . $ilDB->quote($this->obj_id, "integer") .
387  " AND grouping_id = " . $ilDB->quote($grouping_id, 'integer') .
388  " GROUP BY obj_id";
389  $res = $ilDB->query($query);
390  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
391  if ($num <= 0 || $num >= $row->num) {
392  throw new UnexpectedValueException();
393  }
394  }
395  }
396  foreach ($a_obl as $grouping_id => $num) {
397  $query = "UPDATE ut_lp_collections" .
398  " SET num_obligatory = " . $ilDB->quote($num, "integer") .
399  " WHERE obj_id = " . $ilDB->quote($this->obj_id, "integer") .
400  " AND grouping_id = " . $ilDB->quote($grouping_id, "integer");
401  $ilDB->manipulate($query);
402  }
403  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB

◆ validateEntry()

ilLPCollectionOfRepositoryObjects::validateEntry (   $a_item_ref_id,
  $a_item_type = null 
)
protected

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

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

Referenced by getPossibleItems(), and read().

114  {
115  if (!$a_item_type) {
116  $a_item_type = ilObject::_lookupType($a_item_ref_id, true);
117  }
118 
119  // this is hardcoded so we do not need to call all ObjectLP types
120  if ($a_item_type == 'tst') {
121  // Check anonymized
122  $item_obj_id = ilObject::_lookupObjId($a_item_ref_id);
123  $olp = ilObjectLP::getInstance($item_obj_id);
124  if ($olp->isAnonymized()) {
125  return false;
126  }
127  }
128  return true;
129  }
static _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
static getInstance($a_obj_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $possible_items

ilLPCollectionOfRepositoryObjects::$possible_items = array()
staticprotected

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


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