ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilRecommendedContentManager Class Reference

Recommended content manager (business logic) More...

+ Collaboration diagram for ilRecommendedContentManager:

Public Member Functions

 __construct (ilRecommendedContentDBRepository $repo=null, ilRbacReview $rbacreview=null, ilFavouritesManager $fav_manager=null)
 Constructor. More...
 
 addRoleRecommendation (int $role_id, int $ref_id)
 Add role recommendation. More...
 
 removeRoleRecommendation (int $role_id, int $ref_id)
 Remove role recommendation. More...
 
 getRecommendationsOfRole (int $role_id)
 Add role recommendation. More...
 
 addObjectRecommendation (int $user_id, int $ref_id)
 Add object recommendation. More...
 
 removeObjectRecommendation (int $user_id, int $ref_id)
 Remove object recommendation. More...
 
 removeRecommendationsOfRefId (int $ref_id)
 Remove all recommendations of a ref id (role and user/object related) More...
 
 removeRecommendationsOfUser (int $user_id)
 Remove all recommendations of a user. More...
 
 removeRecommendationsOfRole (int $role_id)
 Remove all recommendations of a role. More...
 
 getOpenRecommendationsOfUser (int $user_id)
 Get open recommendations for user. More...
 
 declineObjectRecommendation (int $user_id, int $ref_id)
 Decline object recommendation. More...
 

Protected Attributes

 $access
 
 $repo
 
 $rbacreview
 
 $fav_manager
 

Detailed Description

Recommended content manager (business logic)

Author
killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 11 of file class.ilRecommendedContentManager.php.

Constructor & Destructor Documentation

◆ __construct()

ilRecommendedContentManager::__construct ( ilRecommendedContentDBRepository  $repo = null,
ilRbacReview  $rbacreview = null,
ilFavouritesManager  $fav_manager = null 
)

Constructor.

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

References $DIC, $fav_manager, $rbacreview, and $repo.

40  {
41  global $DIC;
42 
43  $this->repo = (is_null($repo))
45  : $repo;
46 
47  $this->rbacreview = (is_null($rbacreview))
48  ? $DIC->rbac()->review()
49  : $rbacreview;
50 
51  $this->fav_manager = (is_null($fav_manager))
52  ? new ilFavouritesManager()
53  : $fav_manager;
54 
55  $this->access = $DIC->access();
56  }
Manages favourites, currently the interface for other components, needs discussion.
global $DIC
Definition: goto.php:24

Member Function Documentation

◆ addObjectRecommendation()

ilRecommendedContentManager::addObjectRecommendation ( int  $user_id,
int  $ref_id 
)

Add object recommendation.

Parameters
int$role_id
int$ref_id

Definition at line 94 of file class.ilRecommendedContentManager.php.

95  {
96  $this->repo->addObjectRecommendation($user_id, $ref_id);
97  }

◆ addRoleRecommendation()

ilRecommendedContentManager::addRoleRecommendation ( int  $role_id,
int  $ref_id 
)

Add role recommendation.

Parameters
int$role_id
int$ref_id

Definition at line 63 of file class.ilRecommendedContentManager.php.

64  {
65  $this->repo->addRoleRecommendation($role_id, $ref_id);
66  }

◆ declineObjectRecommendation()

ilRecommendedContentManager::declineObjectRecommendation ( int  $user_id,
int  $ref_id 
)

Decline object recommendation.

Parameters
int$user_id
int$ref_id

Definition at line 170 of file class.ilRecommendedContentManager.php.

171  {
172  $this->repo->declineObjectRecommendation($user_id, $ref_id);
173  }

◆ getOpenRecommendationsOfUser()

ilRecommendedContentManager::getOpenRecommendationsOfUser ( int  $user_id)

Get open recommendations for user.

Parameters
int$user_sid
Returns
int[] ref ids

Definition at line 145 of file class.ilRecommendedContentManager.php.

References $access, $i, $rbacreview, and $repo.

146  {
147  $review = $this->rbacreview;
148  $repo = $this->repo;
150 
151  $role_ids = $review->assignedRoles($user_id);
152 
153  $recommendations = $repo->getOpenRecommendationsOfUser($user_id, $role_ids);
154 
155  // filter out favourites
156  $favourites = $this->fav_manager->getFavouritesOfUser($user_id);
157  $favourites_ref_ids = array_column($favourites, "ref_id");
158 
159  return array_filter($recommendations, function ($i) use ($favourites_ref_ids, $access) {
160  return !in_array($i, $favourites_ref_ids) && $access->checkAccess('visible', '', $i);
161  });
162  }
$i
Definition: metadata.php:24

◆ getRecommendationsOfRole()

ilRecommendedContentManager::getRecommendationsOfRole ( int  $role_id)

Add role recommendation.

Parameters
int$role_id
Returns
int[]

Definition at line 83 of file class.ilRecommendedContentManager.php.

83  : array
84  {
85  return $this->repo->getRecommendationsOfRoles([$role_id]);
86  }

◆ removeObjectRecommendation()

ilRecommendedContentManager::removeObjectRecommendation ( int  $user_id,
int  $ref_id 
)

Remove object recommendation.

Parameters
int$user_id
int$ref_id

Definition at line 104 of file class.ilRecommendedContentManager.php.

105  {
106  $this->repo->removeObjectRecommendation($user_id, $ref_id);
107  }

◆ removeRecommendationsOfRefId()

ilRecommendedContentManager::removeRecommendationsOfRefId ( int  $ref_id)

Remove all recommendations of a ref id (role and user/object related)

Parameters
int$ref_id

Definition at line 114 of file class.ilRecommendedContentManager.php.

115  {
116  $this->repo->removeRecommendationsOfRefId($ref_id);
117  }

◆ removeRecommendationsOfRole()

ilRecommendedContentManager::removeRecommendationsOfRole ( int  $role_id)

Remove all recommendations of a role.

Parameters
int$role_id

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

135  {
136  $this->repo->removeRecommendationsOfRole($role_id);
137  }

◆ removeRecommendationsOfUser()

ilRecommendedContentManager::removeRecommendationsOfUser ( int  $user_id)

Remove all recommendations of a user.

Parameters
int$user_id

Definition at line 124 of file class.ilRecommendedContentManager.php.

125  {
126  $this->repo->removeRecommendationsOfUser($user_id);
127  }

◆ removeRoleRecommendation()

ilRecommendedContentManager::removeRoleRecommendation ( int  $role_id,
int  $ref_id 
)

Remove role recommendation.

Parameters
int$role_id
int$ref_id

Definition at line 73 of file class.ilRecommendedContentManager.php.

74  {
75  $this->repo->removeRoleRecommendation($role_id, $ref_id);
76  }

Field Documentation

◆ $access

ilRecommendedContentManager::$access
protected

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

Referenced by getOpenRecommendationsOfUser().

◆ $fav_manager

ilRecommendedContentManager::$fav_manager
protected

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

Referenced by __construct().

◆ $rbacreview

ilRecommendedContentManager::$rbacreview
protected

◆ $repo

ilRecommendedContentManager::$repo
protected

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