ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilCertificateMigrationValidator.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 {
11 
16  {
17  $this->certificateSettings = $certificateSettings;
18  }
19 
25  public function isMigrationAvailable(\ilObjUser $user, \ilCertificateMigration $migrationHelper) : bool
26  {
27  if (!$this->areCertificatesGloballyEnabled()) {
28  return false;
29  }
30 
31  if ($this->isMigrationFinishedForUser($user)) {
32  return false;
33  }
34 
35  if ($migrationHelper->isTaskRunning() || $migrationHelper->isTaskFinished()) {
36  return false;
37  }
38 
39  $isUserCreatedAfterFeatureIntroduction = $this->isUserCreatedAfterFeatureIntroduction($user);
40 
41  return $isUserCreatedAfterFeatureIntroduction;
42  }
43 
47  protected function areCertificatesGloballyEnabled() : bool
48  {
49  $certificatesGloballyEnabled = (bool) $this->certificateSettings->get('active', false);
50 
51  return $certificatesGloballyEnabled;
52  }
53 
58  protected function isMigrationFinishedForUser(\ilObjUser $user) : bool
59  {
60  $migrationFinished = $user->getPref('cert_migr_finished') == 1;
61 
62  return $migrationFinished;
63  }
64 
70  {
71  $createdBeforeFeatureIntroduction = false;
72 
73  $userCreationDate = $user->getCreateDate();
74  if (null !== $userCreationDate) {
75  $userCreatedTimestamp = strtotime($userCreationDate);
76  $introducedTimestamp = $this->certificateSettings->get('persisting_cers_introduced_ts', 0);
77 
78  if ($userCreatedTimestamp < $introducedTimestamp) {
79  $createdBeforeFeatureIntroduction = true;
80  }
81  }
82 
83  return $createdBeforeFeatureIntroduction;
84  }
85 }
getCreateDate()
get create date public
getPref($a_keyword)
get a user preference
Class ilCertificateMigration.
isMigrationAvailable(\ilObjUser $user, \ilCertificateMigration $migrationHelper)
$user
Definition: migrateto20.php:57