You are here

function course_course_credit_map in Course 7

Same name and namespace in other branches
  1. 8.3 course.module \course_course_credit_map()
  2. 8.2 course.module \course_course_credit_map()
  3. 7.2 course.module \course_course_credit_map()
  4. 3.x course.module \course_course_credit_map()

Implements hook_course_credit_map().

Figure out if the user's enrollment fields make them eligible for credit.

File

./course.module, line 2973
course.module Core functionality for Courses.

Code

function course_course_credit_map($node, $account, $mappings) {
  if ($enrollment = course_enrollment_load($node, $account)) {
    $entity = entity_load_single('course_enrollment', $enrollment->eid);
    if (!empty($mappings['course_enrollment'])) {
      foreach ((array) $mappings['course_enrollment'] as $field => $values) {
        if (!empty($entity->{$field})) {
          foreach ($entity->{$field}[LANGUAGE_NONE] as $item) {
            if (in_array($item['value'], $values)) {
              return TRUE;
            }
          }
        }
      }
    }
  }
}