ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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()
45
46 $this->fav_manager = (is_null($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;
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}
An exception for terminatinating execution or to throw for unit testing.
Manages favourites, currently the interface for other components, needs discussion.
class ilRbacReview Contains Review functions of core Rbac.
Recommended content manager (business logic)
__construct(ilRecommendedContentDBRepository $repo=null, ilRbacReview $rbacreview=null, ilFavouritesManager $fav_manager=null)
Constructor.
removeRecommendationsOfRefId(int $ref_id)
Remove all recommendations of a ref id (role and user/object related)
getOpenRecommendationsOfUser(int $user_id)
Get open recommendations for user.
removeObjectRecommendation(int $user_id, int $ref_id)
Remove object recommendation.
removeRecommendationsOfUser(int $user_id)
Remove all recommendations of a user.
removeRecommendationsOfRole(int $role_id)
Remove all recommendations of a role.
declineObjectRecommendation(int $user_id, int $ref_id)
Decline object recommendation.
addObjectRecommendation(int $user_id, int $ref_id)
Add object recommendation.
addRoleRecommendation(int $role_id, int $ref_id)
Add role recommendation.
removeRoleRecommendation(int $role_id, int $ref_id)
Remove role recommendation.
getRecommendationsOfRole(int $role_id)
Add role recommendation.
$i
Definition: metadata.php:24
$DIC
Definition: xapitoken.php:46