ILIAS  release_7 Revision v7.30-3-g800a261c036
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 $access;
17
21 protected $repo;
22
26 protected $rbacreview;
27
31 protected $fav_manager;
32
36 public function __construct(
40 ) {
41 global $DIC;
42
43 $this->repo = (is_null($repo))
45 : $repo;
46
47 $this->rbacreview = (is_null($rbacreview))
48 ? $DIC->rbac()->review()
50
51 $this->fav_manager = (is_null($fav_manager))
54
55 $this->access = $DIC->access();
56 }
57
63 public function addRoleRecommendation(int $role_id, int $ref_id)
64 {
65 $this->repo->addRoleRecommendation($role_id, $ref_id);
66 }
67
73 public function removeRoleRecommendation(int $role_id, int $ref_id)
74 {
75 $this->repo->removeRoleRecommendation($role_id, $ref_id);
76 }
77
83 public function getRecommendationsOfRole(int $role_id) : array
84 {
85 return $this->repo->getRecommendationsOfRoles([$role_id]);
86 }
87
88
94 public function addObjectRecommendation(int $user_id, int $ref_id)
95 {
96 $this->repo->addObjectRecommendation($user_id, $ref_id);
97 }
98
104 public function removeObjectRecommendation(int $user_id, int $ref_id)
105 {
106 $this->repo->removeObjectRecommendation($user_id, $ref_id);
107 }
108
114 public function removeRecommendationsOfRefId(int $ref_id)
115 {
116 $this->repo->removeRecommendationsOfRefId($ref_id);
117 }
118
124 public function removeRecommendationsOfUser(int $user_id)
125 {
126 $this->repo->removeRecommendationsOfUser($user_id);
127 }
128
134 public function removeRecommendationsOfRole(int $role_id)
135 {
136 $this->repo->removeRecommendationsOfRole($role_id);
137 }
138
145 public function getOpenRecommendationsOfUser(int $user_id)
146 {
147 $review = $this->rbacreview;
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 }
163
170 public function declineObjectRecommendation(int $user_id, int $ref_id)
171 {
172 $this->repo->declineObjectRecommendation($user_id, $ref_id);
173 }
174}
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.
global $DIC
Definition: goto.php:24
$i
Definition: metadata.php:24