You are here

function signup_certificate_access_certificate in Certificate 4.x

Same name and namespace in other branches
  1. 8.3 modules/signup_certificate/signup_certificate.module \signup_certificate_access_certificate()
  2. 6.2 modules/signup_certificate/signup_certificate.module \signup_certificate_access_certificate()
  3. 6 modules/signup_certificate/signup_certificate.module \signup_certificate_access_certificate()
  4. 7.3 modules/signup_certificate/signup_certificate.module \signup_certificate_access_certificate()
  5. 7.2 modules/signup_certificate/signup_certificate.module \signup_certificate_access_certificate()
  6. 3.x modules/signup_certificate/signup_certificate.module \signup_certificate_access_certificate()

Implements hook_access_certificate().

File

modules/signup_certificate/signup_certificate.module, line 6

Code

function signup_certificate_access_certificate($node, $user) {
  if (in_array($node->type, signup_content_types())) {
    $sql = "SELECT 1 FROM {signup_log} WHERE nid = :nid AND uid = :uid AND attended = 1";

    // TODO: Drupal Rector Notice: Please delete the following comment after you've made any necessary changes.
    // You will need to use `\Drupal\core\Database\Database::getConnection()` if you do not yet have access to the container here.
    $attended = \Drupal::database()
      ->query($sql, array(
      ':nid' => $node->nid,
      ':uid' => $user->uid,
    ))
      ->fetchField();
    return (bool) $attended;
  }
}