ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilPDSelectedItemsBlockMembershipsProvider Class Reference

Class ilPDSelectedItemsBlockMembershipsProvider. More...

+ Inheritance diagram for ilPDSelectedItemsBlockMembershipsProvider:
+ Collaboration diagram for ilPDSelectedItemsBlockMembershipsProvider:

Public Member Functions

 __construct (ilObjUser $actor)
 ilPDSelectedItemsBlockSelectedItemsProvider constructor. More...
 
 getItems ($object_type_white_list=array())
 
Parameters
array$object_type_white_listAn optional array of object_types used for filter purposes
Returns
array An array of repository items, each given as a structured array
More...
 

Protected Member Functions

 getObjectsByMembership ($types=array())
 Gets all objects the current user is member of. More...
 

Protected Attributes

 $actor
 
 $tree
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilPDSelectedItemsBlockMembershipsProvider::__construct ( ilObjUser  $actor)

ilPDSelectedItemsBlockSelectedItemsProvider constructor.

Parameters
ilObjUser$actor

Definition at line 26 of file class.ilPDSelectedItemsBlockMembershipsProvider.php.

References $actor, and $DIC.

27  {
28  global $DIC;
29 
30  $this->actor = $actor;
31  $this->tree = $DIC->repositoryTree();
32  }
global $DIC
Definition: saml.php:7

Member Function Documentation

◆ getItems()

ilPDSelectedItemsBlockMembershipsProvider::getItems (   $object_type_white_list = array())

Parameters
array$object_type_white_listAn optional array of object_types used for filter purposes
Returns
array An array of repository items, each given as a structured array

Implements ilPDSelectedItemsBlockProvider.

Definition at line 96 of file class.ilPDSelectedItemsBlockMembershipsProvider.php.

References getObjectsByMembership().

97  {
98  return $this->getObjectsByMembership($object_type_white_list);
99  }
getObjectsByMembership($types=array())
Gets all objects the current user is member of.
+ Here is the call graph for this function:

◆ getObjectsByMembership()

ilPDSelectedItemsBlockMembershipsProvider::getObjectsByMembership (   $types = array())
protected

Gets all objects the current user is member of.

Parameters
array$types
Returns
array array of objects

Definition at line 39 of file class.ilPDSelectedItemsBlockMembershipsProvider.php.

References $key, $type, ilObject\_getAllReferences(), ilParticipants\_getMembershipByType(), array, and ilObjectFactory\getInstanceByRefId().

Referenced by getItems().

40  {
41  $items = array();
42 
43  if (is_array($types) && count($types)) {
44  foreach ($types as $type) {
45  switch ($type) {
46  case 'grp':
47  $items = array_merge(ilParticipants::_getMembershipByType($this->actor->getId(), 'grp'), $items);
48  break;
49  case 'crs':
50  $items = array_merge(ilParticipants::_getMembershipByType($this->actor->getId(), 'crs'), $items);
51  break;
52  default:
53  break;
54  }
55  }
56  } else {
57  $crs_mbs = ilParticipants::_getMembershipByType($this->actor->getId(), 'crs');
58  $grp_mbs = ilParticipants::_getMembershipByType($this->actor->getId(), 'grp');
59  $items = array_merge($crs_mbs, $grp_mbs);
60  }
61 
62  $references = array();
63 
64  foreach ($items as $key => $obj_id) {
65  $item_references = ilObject::_getAllReferences($obj_id);
66  foreach ($item_references as $ref_id) {
67  if ($this->tree->isInTree($ref_id)) {
68  $object = ilObjectFactory::getInstanceByRefId($ref_id);
69 
70  $parent_ref_id = $this->tree->getParentId($ref_id);
71  $par_left = $this->tree->getLeftValue($parent_ref_id);
72  $par_left = sprintf("%010d", $par_left);
73 
74  $references[$par_left . $object->getTitle() . $ref_id] = array(
75  'ref_id' => $ref_id,
76  'obj_id' => $obj_id,
77  'type' => $object->getType(),
78  'title' => $object->getTitle(),
79  'description' => $object->getDescription(),
80  'parent_ref' => $parent_ref_id,
81  'start' => $object->getType() == 'grp' ? $object->getStart() : $object->getCourseStart(),
82  'end' => $object->getType() == 'grp' ? $object->getEnd() : $object->getCourseEnd()
83  );
84  }
85  }
86  }
87 
88  ksort($references);
89 
90  return $references;
91  }
$type
static _getMembershipByType($a_usr_id, $a_type, $a_only_member_role=false)
get membership by type Get course or group membership
static _getAllReferences($a_id)
get all reference ids of object
Create styles array
The data for the language used.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $actor

ilPDSelectedItemsBlockMembershipsProvider::$actor
protected

Definition at line 15 of file class.ilPDSelectedItemsBlockMembershipsProvider.php.

Referenced by __construct().

◆ $tree

ilPDSelectedItemsBlockMembershipsProvider::$tree
protected

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