ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilRecommendedContentManager.php
Go to the documentation of this file.
1<?php
2
26{
31
32 public function __construct(
36 ) {
37 global $DIC;
38
39 $this->repo = (is_null($repo))
41 : $repo;
42
43 $this->rbacreview = (is_null($rbacreview))
44 ? $DIC->rbac()->review()
46
47 $this->fav_manager = (is_null($fav_manager))
50
51 $this->access = $DIC->access();
52 }
53
54 public function addRoleRecommendation(int $role_id, int $ref_id): void
55 {
56 $this->repo->addRoleRecommendation($role_id, $ref_id);
57 }
58
59 public function removeRoleRecommendation(int $role_id, int $ref_id): void
60 {
61 $this->repo->removeRoleRecommendation($role_id, $ref_id);
62 }
63
67 public function getRecommendationsOfRole(int $role_id): array
68 {
69 return $this->repo->getRecommendationsOfRoles([$role_id]);
70 }
71
72
73 public function addObjectRecommendation(int $user_id, int $ref_id): void
74 {
75 $this->repo->addObjectRecommendation($user_id, $ref_id);
76 }
77
78 public function removeObjectRecommendation(int $user_id, int $ref_id): void
79 {
80 $this->repo->removeObjectRecommendation($user_id, $ref_id);
81 }
82
83 // Remove all recommendations of a ref id (role and user/object related)
84 public function removeRecommendationsOfRefId(int $ref_id): void
85 {
86 $this->repo->removeRecommendationsOfRefId($ref_id);
87 }
88
89 public function removeRecommendationsOfUser(int $user_id): void
90 {
91 $this->repo->removeRecommendationsOfUser($user_id);
92 }
93
94 public function removeRecommendationsOfRole(int $role_id): void
95 {
96 $this->repo->removeRecommendationsOfRole($role_id);
97 }
98
102 public function getOpenRecommendationsOfUser(int $user_id): array
103 {
104 $review = $this->rbacreview;
107
108 $role_ids = $review->assignedRoles($user_id);
109
110 $recommendations = $repo->getOpenRecommendationsOfUser($user_id, $role_ids);
111
112 // filter out favourites
113 $favourites = $this->fav_manager->getFavouritesOfUser($user_id);
114 $favourites_ref_ids = array_column($favourites, "ref_id");
115
116 return array_filter($recommendations, static function ($i) use ($favourites_ref_ids, $access): bool {
117 return !in_array($i, $favourites_ref_ids) && $access->checkAccess('visible', '', $i);
118 });
119 }
120
121 public function declineObjectRecommendation(int $user_id, int $ref_id): void
122 {
123 $this->repo->declineObjectRecommendation($user_id, $ref_id);
124 }
125}
Manages favourites, currently the interface for other components, needs discussion.
class ilRbacReview Contains Review functions of core Rbac.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getOpenRecommendationsOfUser(int $user_id, array $role_ids)
Open recommendations of user (by role or object, without declined ones)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(?ilRecommendedContentDBRepository $repo=null, ?ilRbacReview $rbacreview=null, ?ilFavouritesManager $fav_manager=null)
ilRecommendedContentDBRepository $repo
removeObjectRecommendation(int $user_id, int $ref_id)
declineObjectRecommendation(int $user_id, int $ref_id)
addObjectRecommendation(int $user_id, int $ref_id)
addRoleRecommendation(int $role_id, int $ref_id)
removeRoleRecommendation(int $role_id, int $ref_id)
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
checkAccess(string $a_permission, string $a_cmd, int $a_ref_id, string $a_type="", ?int $a_obj_id=null, ?int $a_tree_id=null)
check access for an object (provide $a_type and $a_obj_id if available for better performance)
$ref_id
Definition: ltiauth.php:66
global $DIC
Definition: shib_login.php:26