public static function LPStatus::isCertificateExpired in Opigno Learning path 8
Same name and namespace in other branches
- 3.x src/Entity/LPStatus.php \Drupal\opigno_learning_path\Entity\LPStatus::isCertificateExpired()
Returns flag if training certificate expired for the user.
Parameters
\Drupal\group\Entity\Group $group: Group object.
int $uid: User ID.
Return value
bool True if training certificate expired for the user, false otherwise.
3 calls to LPStatus::isCertificateExpired()
- Progress::getProgressBuildAchievementsPage in src/Progress.php 
- Get get progress for achievements page.
- Progress::getProgressBuildGroupPage in src/Progress.php 
- Get get progress for group page.
- StepsBlock::build in src/Plugin/ Block/ StepsBlock.php 
- Builds and returns the renderable array for this block plugin.
File
- src/Entity/ LPStatus.php, line 405 
Class
- LPStatus
- Defines the User Learning Path attempt status entity.
Namespace
Drupal\opigno_learning_path\EntityCode
public static function isCertificateExpired(Group $group, $uid) {
  if (self::isCertificateExpireSet($group)) {
    $db_connection = \Drupal::service('database');
    try {
      // Try to get user training expired timestamp.
      $result = $db_connection
        ->select('user_lp_status_expire', 'lps')
        ->fields('lps', [
        'expire',
      ])
        ->condition('gid', $group
        ->id())
        ->condition('uid', $uid)
        ->execute()
        ->fetchField();
    } catch (\Exception $e) {
      \Drupal::logger('opigno_learning_path')
        ->error($e
        ->getMessage());
      \Drupal::messenger()
        ->addMessage($e
        ->getMessage(), 'error');
    }
    if (!empty($result) && $result < time()) {
      // Certification expired.
      return TRUE;
    }
  }
  return FALSE;
}