ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 ()
 getItems ()
 delete ()
 isAssignedEntry ($a_item_id)

Static Public Member Functions

static hasGroupedItems ($a_obj_id)

Protected Member Functions

 validateEntry ($a_item_ref_id, $a_item_type=null)
 read ()
 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
 validateEntry ($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

ilLPCollectionOfRepositoryObjects::activateEntries ( array  $a_item_ids)

Reimplemented from ilLPCollection.

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

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

Referenced by createNewGrouping().

{
global $ilDB;
$grouping_ids = $this->getGroupingIds($a_item_ids);
if($grouping_ids)
{
$query = "UPDATE ut_lp_collections".
" SET active = ".$ilDB->quote(1, "integer").
" WHERE ".$ilDB->in("grouping_id", $grouping_ids, false, "integer").
" AND obj_id = ".$ilDB->quote($this->obj_id, "integer");
$ilDB->manipulate($query);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilLPCollectionOfRepositoryObjects::addEntry (   $a_item_id)
protected

Reimplemented from ilLPCollection.

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

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

Referenced by cloneCollection().

{
global $ilDB;
// only active entries are assigned!
if(!$this->isAssignedEntry($a_item_id))
{
// #13278 - because of grouping inactive items may exist
$this->deleteEntry($a_item_id);
$query = "INSERT INTO ut_lp_collections".
" (obj_id, lpmode, item_id, grouping_id, num_obligatory, active)".
" VALUES (".$ilDB->quote($this->obj_id , "integer").
", ".$ilDB->quote($this->mode, "integer").
", ".$ilDB->quote($a_item_id , "integer").
", ".$ilDB->quote(0, "integer").
", ".$ilDB->quote(0, "integer").
", ".$ilDB->quote(1, "integer").
")";
$ilDB->manipulate($query);
$this->items[] = $a_item_id;
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilLPCollectionOfRepositoryObjects::cloneCollection (   $a_target_id,
  $a_copy_id 
)

Reimplemented from ilLPCollection.

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

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

{
parent::cloneCollection($a_target_id, $a_copy_id);
include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
$mappings = $cwo->getMappings();
$target_obj_id = ilObject::_lookupObjId($a_target_id);
$target_collection = new static($target_obj_id, $this->mode);
// clone (active) groupings
foreach($this->getGroupedItemsForLPStatus() as $grouping_id => $group)
{
$target_item_ids = array();
foreach($group["items"] as $item)
{
if(!isset($mappings[$item]) or !$mappings[$item])
{
continue;
}
$target_item_ids[] = $mappings[$item];
}
// grouping - if not only single item left after copy?
if($grouping_id && sizeof($target_item_ids) > 1)
{
// should not be larger than group
$num_obligatory = min(sizeof($target_item_ids), $group["num_obligatory"]);
$target_collection->createNewGrouping($target_item_ids, $num_obligatory);
}
else
{
// #15487 - single items
foreach($target_item_ids as $item_id)
{
$this->addEntry($item_id);
}
}
}
}

+ Here is the call graph for this function:

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

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

References $ilDB, $query, $res, $row, activateEntries(), DB_FETCHMODE_OBJECT, getGroupingIds(), and releaseGrouping().

{
global $ilDB;
$this->activateEntries($a_item_ids);
$all_item_ids = array();
$grouping_ids = $this->getGroupingIds($a_item_ids);
$query = "SELECT item_id FROM ut_lp_collections".
" WHERE obj_id = ".$ilDB->quote($this->obj_id, "integer").
" AND ".$ilDB->in("grouping_id", $grouping_ids, false, "integer");
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$all_item_ids[] = $row->item_id;
}
$all_item_ids = array_unique(array_merge($all_item_ids, $a_item_ids));
$this->releaseGrouping($a_item_ids);
// Create new grouping
$query = "SELECT MAX(grouping_id) grp FROM ut_lp_collections".
" WHERE obj_id = ".$ilDB->quote($this->obj_id, "integer").
" GROUP BY obj_id";
$res = $ilDB->query($query);
$grp_id = $row->grp;
++$grp_id;
$query = "UPDATE ut_lp_collections SET".
" grouping_id = ".$ilDB->quote($grp_id, "integer").
", num_obligatory = ".$ilDB->quote($a_num_obligatory, "integer").
", active = ".$ilDB->quote(1, "integer").
" WHERE obj_id = ".$ilDB->quote($this->obj_id, "integer").
" AND ".$ilDB->in("item_id", $all_item_ids, false, "integer");
$ilDB->manipulate($query);
return;
}

+ Here is the call graph for this function:

ilLPCollectionOfRepositoryObjects::deactivateEntries ( array  $a_item_ids)

Reimplemented from ilLPCollection.

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

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

{
global $ilDB;
$grouping_ids = $this->getGroupingIds($a_item_ids);
if($grouping_ids)
{
$query = "UPDATE ut_lp_collections".
" SET active = ".$ilDB->quote(0, "integer").
" WHERE ".$ilDB->in("grouping_id", $grouping_ids, false, "integer").
" AND obj_id = ".$ilDB->quote($this->obj_id, "integer");
$ilDB->manipulate($query);
}
}

+ Here is the call graph for this function:

ilLPCollectionOfRepositoryObjects::deleteEntry (   $a_item_id)
protected

Reimplemented from ilLPCollection.

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

References $ilDB, and $query.

Referenced by addEntry(), and read().

{
global $ilDB;
$query = "DELETE FROM ut_lp_collections ".
" WHERE obj_id = ".$ilDB->quote($this->obj_id, "integer").
" AND item_id = ".$ilDB->quote($a_item_id, "integer").
" AND grouping_id = ".$ilDB->quote(0, "integer");
$ilDB->manipulate($query);
return true;
}

+ Here is the caller graph for this function:

ilLPCollectionOfRepositoryObjects::getGroupedItemsForLPStatus ( )

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

References $ilDB, ilLPCollection\$items, $query, $res, $row, DB_FETCHMODE_OBJECT, and ilLPCollection\getItems().

Referenced by cloneCollection().

{
global $ilDB;
$items = $this->getItems();
$query = " SELECT * FROM ut_lp_collections".
" WHERE obj_id = ".$ilDB->quote($this->obj_id, "integer").
" AND active = ".$ilDB->quote(1, "integer");
$res = $ilDB->query($query);
$grouped = array();
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
if(in_array($row->item_id, $items))
{
$grouped[$row->grouping_id]['items'][] = $row->item_id;
$grouped[$row->grouping_id]['num_obligatory'] = $row->num_obligatory;
}
}
return $grouped;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilLPCollectionOfRepositoryObjects::getGroupingIds ( array  $a_item_ids)
protected

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

References $ilDB, $query, $res, $row, and DB_FETCHMODE_OBJECT.

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

{
global $ilDB;
$grouping_ids = array();
$query = "SELECT grouping_id FROM ut_lp_collections".
" WHERE obj_id = ".$ilDB->quote($this->obj_id, "integer").
" AND ".$ilDB->in("item_id", $a_item_ids, false, "integer").
" AND grouping_id > ".$ilDB->quote(0, "integer");
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$grouping_ids[] = $row->grouping_id;
}
return $grouping_ids;
}

+ Here is the caller graph for this function:

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

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

References ilLPCollection\isAssignedEntry(), ilRepositoryObjectPluginSlot\isTypePluginWithLP(), and validateEntry().

Referenced by getTableGUIData(), and read().

{
global $tree, $objDefinition;
$cache_idx = $a_ref_id."__".$a_full_data;
if(!isset(self::$possible_items[$cache_idx]))
{
$all_possible = array();
if(!$tree->isDeleted($a_ref_id))
{
include_once 'Services/Repository/classes/class.ilRepositoryObjectPluginSlot.php';
if(!$a_full_data)
{
$data = $tree->getRbacSubTreeInfo($a_ref_id);
}
else
{
$node = $tree->getNodeData($a_ref_id);
$data = $tree->getSubTree($node);
}
foreach($data as $node)
{
if(!$a_full_data)
{
$item_ref_id = $node['child'];
}
else
{
$item_ref_id = $node['ref_id'];
}
// avoid recursion
if($item_ref_id == $a_ref_id ||
!$this->validateEntry($item_ref_id, $node['type']))
{
continue;
}
switch($node['type'])
{
case 'sess':
case 'exc':
case 'fold':
case 'grp':
case 'sahs':
case 'lm':
case 'tst':
case 'htlm':
if(!$a_full_data)
{
$all_possible[] = $item_ref_id;
}
else
{
$all_possible[$item_ref_id] = array(
'ref_id' => $item_ref_id,
'obj_id' => $node['obj_id'],
'title' => $node['title'],
'description' => $node['description'],
'type' => $node['type']
);
}
break;
// repository plugin object?
case $objDefinition->isPluginTypeName($node['type']):
$only_active = false;
if(!$this->isAssignedEntry($item_ref_id))
{
$only_active = true;
}
if(ilRepositoryObjectPluginSlot::isTypePluginWithLP($node['type'], $only_active))
{
if(!$a_full_data)
{
$all_possible[] = $item_ref_id;
}
else
{
$all_possible[$item_ref_id] = array(
'ref_id' => $item_ref_id,
'obj_id' => $node['obj_id'],
'title' => $node['title'],
'description' => $node['description'],
'type' => $node['type']
);
}
}
break;
}
}
}
self::$possible_items[$cache_idx] = $all_possible;
}
return self::$possible_items[$cache_idx];
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilLPCollectionOfRepositoryObjects::getTableGUIData (   $a_parent_ref_id)

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

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

{
$items = $this->getPossibleItems($a_parent_ref_id, true);
$data = array();
$done = array();
foreach($items as $item_id => $item)
{
if(in_array($item_id, $done))
{
continue;
}
$table_item = $this->parseTableGUIItem($item_id, $item);
// grouping
$table_item['grouped'] = array();
$grouped_items = $this->getTableGUItemGroup($item_id);
if(count((array)$grouped_items['items']) > 1)
{
foreach($grouped_items['items'] as $grouped_item_id)
{
if($grouped_item_id == $item_id ||
!is_array($items[$grouped_item_id])) // #15498
{
continue;
}
$table_item['grouped'][] = $this->parseTableGUIItem($grouped_item_id, $items[$grouped_item_id]);
$table_item['num_obligatory'] = $grouped_items['num_obligatory'];
$table_item['grouping_id'] = $grouped_items['grouping_id'];
$done[] = $grouped_item_id;
}
}
$data[] = $table_item;
}
return $data;
}

+ Here is the call graph for this function:

ilLPCollectionOfRepositoryObjects::getTableGUItemGroup (   $item_id)
protected

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

References $ilDB, ilLPCollection\$items, $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by getTableGUIData().

{
global $ilDB;
$items = array();
$query = "SELECT grouping_id FROM ut_lp_collections".
" WHERE obj_id = ".$ilDB->quote($this->obj_id, "integer").
" AND item_id = ".$ilDB->quote($item_id, "integer");
$res = $ilDB->query($query);
$grouping_id = $row->grouping_id;
if($grouping_id > 0)
{
$query = "SELECT item_id, num_obligatory FROM ut_lp_collections".
" WHERE obj_id = ".$ilDB->quote($this->obj_id, "integer").
" AND grouping_id = ".$ilDB->quote($grouping_id, "integer");
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$items['items'][] = $row->item_id;
$items['num_obligatory'] = $row->num_obligatory;
$items['grouping_id'] = $grouping_id;
}
}
return $items;
}

+ Here is the caller graph for this function:

static ilLPCollectionOfRepositoryObjects::hasGroupedItems (   $a_obj_id)
static

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

References $ilDB, $query, and $res.

Referenced by ilLPCollectionSettingsTableGUI\parse().

{
global $ilDB;
$query = "SELECT item_id FROM ut_lp_collections".
" WHERE obj_id = ".$ilDB->quote($a_obj_id, "integer").
" AND grouping_id > ".$ilDB->quote(0, "integer");
$res = $ilDB->query($query);
return $res->numRows() ? true : false;
}

+ Here is the caller graph for this function:

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

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

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

Referenced by getTableGUIData().

{
$table_item = $a_item;
$table_item['id'] = $a_id;
$table_item['status'] = $this->isAssignedEntry($a_id);
$olp = ilObjectLP::getInstance($a_item['obj_id']);
$table_item['mode_id'] = $olp->getCurrentMode();
$table_item['mode'] = $olp->getModeText($table_item['mode_id']);
$table_item['anonymized'] = $olp->isAnonymized();
return $table_item;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilLPCollectionOfRepositoryObjects::read ( )
protected

Reimplemented from ilLPCollection.

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

References $ilDB, ilLPCollection\$items, $ref_id, $res, $row, ilObject\_getAllReferences(), DB_FETCHMODE_OBJECT, deleteEntry(), getPossibleItems(), and validateEntry().

{
global $ilDB;
$items = array();
$ref_ids = ilObject::_getAllReferences($this->obj_id);
$ref_id = end($ref_ids);
$possible = $this->getPossibleItems($ref_id);
$res = $ilDB->query("SELECT utc.item_id, obd.type".
" FROM ut_lp_collections utc".
" JOIN object_reference obr ON item_id = ref_id".
" JOIN object_data obd ON obr.obj_id = obd.obj_id".
" WHERE utc.obj_id = ".$ilDB->quote($this->obj_id, "integer").
" AND active = ".$ilDB->quote(1, "integer").
" ORDER BY title");
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
if(in_array($row->item_id, $possible) &&
$this->validateEntry($row->item_id, $row->type))
{
$items[] = $row->item_id;
}
else
{
$this->deleteEntry($row->item_id);
}
}
$this->items = $items;
}

+ Here is the call graph for this function:

ilLPCollectionOfRepositoryObjects::releaseGrouping ( array  $a_item_ids)

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

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

Referenced by createNewGrouping().

{
global $ilDB;
$grouping_ids = $this->getGroupingIds($a_item_ids);
$query = "UPDATE ut_lp_collections".
" SET grouping_id = ".$ilDB->quote(0, "integer").
", num_obligatory = ".$ilDB->quote(0, "integer").
" WHERE obj_id = ".$ilDB->quote($this->obj_id, "integer").
" AND " . $ilDB->in("grouping_id", $grouping_ids, false, "integer");
$ilDB->manipulate($query);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilLPCollectionOfRepositoryObjects::saveObligatoryMaterials ( array  $a_obl)

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

References $ilDB, $query, $res, $row, and DB_FETCHMODE_OBJECT.

{
global $ilDB;
foreach($a_obl as $grouping_id => $num)
{
$query = "SELECT count(obj_id) num FROM ut_lp_collections".
" WHERE obj_id = ".$ilDB->quote($this->obj_id, "integer").
" AND grouping_id = ".$ilDB->quote($grouping_id,'integer').
" GROUP BY obj_id";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
if($num <= 0 || $num >= $row->num)
{
throw new UnexpectedValueException();
}
}
}
foreach($a_obl as $grouping_id => $num)
{
$query = "UPDATE ut_lp_collections".
" SET num_obligatory = ".$ilDB->quote($num, "integer").
" WHERE obj_id = ".$ilDB->quote($this->obj_id, "integer").
" AND grouping_id = ".$ilDB->quote($grouping_id, "integer");
$ilDB->manipulate($query);
}
}
ilLPCollectionOfRepositoryObjects::validateEntry (   $a_item_ref_id,
  $a_item_type = null 
)
protected

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

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

Referenced by getPossibleItems(), and read().

{
if(!$a_item_type)
{
$a_item_type = ilObject::_lookupType($a_item_ref_id, true);
}
// this is hardcoded so we do not need to call all ObjectLP types
if($a_item_type == 'tst')
{
// Check anonymized
$item_obj_id = ilObject::_lookupObjId($a_item_ref_id);
$olp = ilObjectLP::getInstance($item_obj_id);
if($olp->isAnonymized())
{
return false;
}
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

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: