function opigno_og_prereq_form_alter in Opigno 7
File
- modules/
og_prereq/ opigno_og_prereq.module, line 123 - Module hook implementations.
Code
function opigno_og_prereq_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == "og_ui_confirm_subscribe") {
$node = node_load($form['gid']['#value']);
if (isset($node->course_required_course_ref[LANGUAGE_NONE][0]['target_id'])) {
if (module_exists("opigno_quiz_app")) {
global $user;
$courses_not_passed = "";
$has_courses_not_passed = FALSE;
foreach ($node->course_required_course_ref[LANGUAGE_NONE] as $index => $value) {
if (!opigno_quiz_app_user_passed($value['target_id'], $user->uid)) {
$course_not_passed = node_load($value['target_id']);
$courses_not_passed .= " " . l($course_not_passed->title, 'node/' . $value['target_id']);
$has_courses_not_passed = TRUE;
}
}
if ($has_courses_not_passed) {
drupal_set_message(t('You cannot subscribe to this course. There are required courses not completed:') . $courses_not_passed, 'warning');
drupal_goto("node/" . $form['gid']['#value']);
}
}
}
}
}