ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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

 $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 31 of file class.ilRecommendedContentManager.php.

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 }
Manages favourites, currently the interface for other components, needs discussion.
$DIC
Definition: xapitoken.php:46

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

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 87 of file class.ilRecommendedContentManager.php.

88 {
89 $this->repo->addObjectRecommendation($user_id, $ref_id);
90 }

◆ addRoleRecommendation()

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

Add role recommendation.

Parameters
int$role_id
int$ref_id

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

57 {
58 $this->repo->addRoleRecommendation($role_id, $ref_id);
59 }

◆ declineObjectRecommendation()

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

Decline object recommendation.

Parameters
int$user_id
int$ref_id

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

163 {
164 $this->repo->declineObjectRecommendation($user_id, $ref_id);
165 }

◆ getOpenRecommendationsOfUser()

ilRecommendedContentManager::getOpenRecommendationsOfUser ( int  $user_id)

Get open recommendations for user.

Parameters
int$user_sid
Returns
int[] ref ids

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

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 }
$i
Definition: metadata.php:24

References $i, $rbacreview, and $repo.

◆ getRecommendationsOfRole()

ilRecommendedContentManager::getRecommendationsOfRole ( int  $role_id)

Add role recommendation.

Parameters
int$role_id
Returns
int[]

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

76 : array
77 {
78 return $this->repo->getRecommendationsOfRoles([$role_id]);
79 }

◆ removeObjectRecommendation()

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

Remove object recommendation.

Parameters
int$user_id
int$ref_id

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

98 {
99 $this->repo->removeObjectRecommendation($user_id, $ref_id);
100 }

◆ 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 107 of file class.ilRecommendedContentManager.php.

108 {
109 $this->repo->removeRecommendationsOfRefId($ref_id);
110 }

◆ removeRecommendationsOfRole()

ilRecommendedContentManager::removeRecommendationsOfRole ( int  $role_id)

Remove all recommendations of a role.

Parameters
int$role_id

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

128 {
129 $this->repo->removeRecommendationsOfRole($role_id);
130 }

◆ removeRecommendationsOfUser()

ilRecommendedContentManager::removeRecommendationsOfUser ( int  $user_id)

Remove all recommendations of a user.

Parameters
int$user_id

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

118 {
119 $this->repo->removeRecommendationsOfUser($user_id);
120 }

◆ removeRoleRecommendation()

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

Remove role recommendation.

Parameters
int$role_id
int$ref_id

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

67 {
68 $this->repo->removeRoleRecommendation($role_id, $ref_id);
69 }

Field Documentation

◆ $fav_manager

ilRecommendedContentManager::$fav_manager
protected

Definition at line 26 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: