ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilRecommendedContentManager.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
12 {
16  protected $repo;
17 
21  protected $rbacreview;
22 
26  protected $fav_manager;
27 
31  public function __construct(
35  ) {
36  global $DIC;
37 
38  $this->repo = (is_null($repo))
40  : $repo;
41 
42  $this->rbacreview = (is_null($rbacreview))
43  ? $DIC->rbac()->review()
44  : $rbacreview;
45 
46  $this->fav_manager = (is_null($fav_manager))
47  ? new ilFavouritesManager()
48  : $fav_manager;
49  }
50 
56  public function addRoleRecommendation(int $role_id, int $ref_id)
57  {
58  $this->repo->addRoleRecommendation($role_id, $ref_id);
59  }
60 
66  public function removeRoleRecommendation(int $role_id, int $ref_id)
67  {
68  $this->repo->removeRoleRecommendation($role_id, $ref_id);
69  }
70 
76  public function getRecommendationsOfRole(int $role_id) : array
77  {
78  return $this->repo->getRecommendationsOfRoles([$role_id]);
79  }
80 
81 
87  public function addObjectRecommendation(int $user_id, int $ref_id)
88  {
89  $this->repo->addObjectRecommendation($user_id, $ref_id);
90  }
91 
97  public function removeObjectRecommendation(int $user_id, int $ref_id)
98  {
99  $this->repo->removeObjectRecommendation($user_id, $ref_id);
100  }
101 
107  public function removeRecommendationsOfRefId(int $ref_id)
108  {
109  $this->repo->removeRecommendationsOfRefId($ref_id);
110  }
111 
117  public function removeRecommendationsOfUser(int $user_id)
118  {
119  $this->repo->removeRecommendationsOfUser($user_id);
120  }
121 
127  public function removeRecommendationsOfRole(int $role_id)
128  {
129  $this->repo->removeRecommendationsOfRole($role_id);
130  }
131 
138  public function getOpenRecommendationsOfUser(int $user_id)
139  {
140  $review = $this->rbacreview;
141  $repo = $this->repo;
142 
143  $role_ids = $review->assignedRoles($user_id);
144 
145  $recommendations = $repo->getOpenRecommendationsOfUser($user_id, $role_ids);
146 
147  // filter out favourites
148  $favourites = $this->fav_manager->getFavouritesOfUser($user_id);
149  $favourites_ref_ids = array_column($favourites, "ref_id");
150 
151  return array_filter($recommendations, function ($i) use ($favourites_ref_ids) {
152  return !in_array($i, $favourites_ref_ids);
153  });
154  }
155 
162  public function declineObjectRecommendation(int $user_id, int $ref_id)
163  {
164  $this->repo->declineObjectRecommendation($user_id, $ref_id);
165  }
166 }
removeRoleRecommendation(int $role_id, int $ref_id)
Remove role recommendation.
removeRecommendationsOfUser(int $user_id)
Remove all recommendations of a user.
__construct(ilRecommendedContentDBRepository $repo=null, ilRbacReview $rbacreview=null, ilFavouritesManager $fav_manager=null)
Constructor.
addObjectRecommendation(int $user_id, int $ref_id)
Add object recommendation.
getRecommendationsOfRole(int $role_id)
Add role recommendation.
Manages favourites, currently the interface for other components, needs discussion.
addRoleRecommendation(int $role_id, int $ref_id)
Add role recommendation.
removeRecommendationsOfRole(int $role_id)
Remove all recommendations of a role.
removeObjectRecommendation(int $user_id, int $ref_id)
Remove object recommendation.
declineObjectRecommendation(int $user_id, int $ref_id)
Decline object recommendation.
getOpenRecommendationsOfUser(int $user_id)
Get open recommendations for user.
$DIC
Definition: xapitoken.php:46
Recommended content manager (business logic)
removeRecommendationsOfRefId(int $ref_id)
Remove all recommendations of a ref id (role and user/object related)
$i
Definition: metadata.php:24
class ilRbacReview Contains Review functions of core Rbac.