You are here

function course_certificate_access_certificate in Course 7

Same name and namespace in other branches
  1. 6 modules/course_certificate/course_certificate.module \course_certificate_access_certificate()
  2. 7.2 modules/course_certificate/course_certificate.module \course_certificate_access_certificate()

Implements hook_access_certificate().

If something entered a complete record into the reports table, return TRUE.

File

modules/course_certificate/course_certificate.module, line 36

Code

function course_certificate_access_certificate($node, $user) {
  if (course_node_is_course($node)) {
    $course = course_get_course($node);
    $has_certificate = course_certificate_course_has_certificate($course);
    return $has_certificate && (bool) db_query("SELECT 1 FROM {course_report} WHERE nid = :nid AND uid = :uid AND complete = :complete", array(
      ':nid' => $node->nid,
      ':uid' => $user->uid,
      ':complete' => 1,
    ))
      ->fetchField();
  }
}