ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilFavouritesManager.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
27 {
29  protected bool $globally_activated;
30 
31  public function __construct(?ilFavouritesDBRepository $repo = null)
32  {
33  global $DIC;
34 
35  $this->globally_activated = ($DIC->settings()->get('rep_favourites', '0') === '1');
36  $this->repo = is_null($repo)
38  : $repo;
39  }
40 
41  // Add favourite
42  public function add(int $user_id, int $ref_id): void
43  {
44  $this->repo->add($user_id, $ref_id);
46  }
47 
48  // Remove favourite
49  public function remove(int $user_id, int $ref_id): void
50  {
51  $this->repo->remove($user_id, $ref_id);
53  }
54 
55  // Is item favourite?
56  public function ifIsFavourite(int $user_id, int $ref_id): bool
57  {
58  if (!$this->isGloballyActivated()) {
59  return false;
60  }
61  return $this->repo->ifIsFavourite($user_id, $ref_id);
62  }
63 
68  public function loadData(int $user_id, array $ref_ids): void
69  {
70  $this->repo->loadData($user_id, $ref_ids);
71  }
72 
73  public function isGloballyActivated(): bool
74  {
76  }
77 
82  public function getFavouritesOfUser(int $user_id, ?array $a_types = null): array
83  {
84  if (!$this->isGloballyActivated()) {
85  return [];
86  }
87  return $this->repo->getFavouritesOfUser($user_id, $a_types);
88  }
89 
90  // Remove favourite entries of a repository item
91  public function removeFavouritesOfRefId(int $ref_id): void
92  {
93  $this->repo->removeFavouritesOfRefId($ref_id);
94  }
95 
96  // Remove favourite entries of a user
97  public function removeFavouritesOfUser(int $user_id): void
98  {
99  $this->repo->removeFavouritesOfRefId($user_id);
100  }
101 }
add(int $user_id, int $ref_id)
ifIsFavourite(int $user_id, int $ref_id)
Manages favourites, currently the interface for other components, needs discussion.
loadData(int $user_id, array $ref_ids)
Preloads data into cache.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$ref_id
Definition: ltiauth.php:65
__construct(?ilFavouritesDBRepository $repo=null)
global $DIC
Definition: shib_login.php:22
ilFavouritesDBRepository $repo
getFavouritesOfUser(int $user_id, ?array $a_types=null)
Get favourites of user.
static deletePDItemsCache(int $a_usr_id)
Delete cache (add remove desktop item)