ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilCertificateUserForObjectPreloader.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
8 {
12  private static $certificates = array();
13 
18 
23 
29  {
30  $this->userCertificateRepository = $userCertificateRepository;
31  $this->activeValidator = $activeValidator;
32  }
33 
38  public function preLoadDownloadableCertificates(int $objectId)
39  {
40  if (true === $this->activeValidator->validate()) {
41  $objectIdsWithUserCertificate = $this->userCertificateRepository->fetchUserIdsWithCertificateForObject($objectId);
42  self::$certificates[$objectId] = $objectIdsWithUserCertificate;
43  }
44  }
45 
51  public function isPreloaded(int $objId, int $userId)
52  {
53  if (false === array_key_exists($objId, self::$certificates)) {
54  return false;
55  }
56 
57  if (true === in_array($userId, self::$certificates[$objId])) {
58  return true;
59  }
60 
61  return false;
62  }
63 }
$certificates
Definition: metarefresh.php:39
__construct(ilUserCertificateRepository $userCertificateRepository, ilCertificateActiveValidator $activeValidator)