function prereqs_theme_advise_course_row

7.x prereqs.module prereqs_theme_advise_course_row(&$theme)
6.x prereqs.module prereqs_theme_advise_course_row(&$theme)

Implements hook_theme_advise_course_row. Lets us re-write how our course rows are drawn, if desired.

File

modules/prereqs/prereqs.module, line 657
This is the module file for the prereqs module.

Code

function prereqs_theme_advise_course_row(&$theme) {


  $display_status = $theme ["course"]["display_status"];
  // We only need to bother to check
  if ($display_status == "eligible") {

    fp_add_js(fp_get_module_path("prereqs") . "/js/prereqs.js");
    fp_add_css(fp_get_module_path("prereqs") . "/css/prereqs.css");

    $course = $theme ["course"]["course"];
    $student = $theme ["student"];

    $warnings = prereqs_get_prereq_warnings_for_course($course, $student);
    if (count($warnings) == 0) {
      return; // no prereqs to worry about!
    }

    // Otherwise, yes, there are prereq warnings!
    // Combine the warning messages.....

    $warning_msg = "";
    foreach ($warnings as $details) {
      $warning_msg .= $details ["plain_text"] . "\\n \\n";
    }

    $confirm = variable_get("prereqs_confirm_msg", "Are you sure you wish to advise the student to enroll in this course anyway?");

    $confirm_warning_msg = $warning_msg . "\\n\\n" . $confirm;

    $function = "toggleSelection";
    $group_select_function = "";

    // Only allow user with correct permissions actually perform advising (override lock)  If they do NOT have the permission,
    // we display a message saying they can't advise that course.
    if (!user_has_permission('override_course_locks')) {
      $confirm_warning_msg = $warning_msg . "<br><br>" . t("You do have have sufficient permissions to override this lock.");
      $function = "prereqs_no_toggleSelection";
      $group_select_function = "prereqs_no_group_toggleSelection";
    }


    $theme ["op"]["display_status"] = "locked";
    $theme ["course"]["display_status"] = "locked";
    $theme ["op"]["extra_css"] = str_replace("eligible", "locked", $theme ["op"]["extra_css"]);


    if ($theme ["op"]["onclick"]["function"] == "toggleSelection") {
      // All we need to do is add text to argument 2.      
      $theme ["op"]["onclick"]["function"] = $function;
      $theme ["op"]["onclick"]["arguments"][1] = "locked";
      $theme ["op"]["onclick"]["arguments"][2] = $confirm_warning_msg;
    }


    if (@$theme ["from_group_select"] == TRUE) {
      // Meaning, this is from a group select course row!  Let's change some things.

      $theme ["icon"]["filename"] = "n.gif";
      $theme ["icon"]["location"] = fp_get_module_path("prereqs") . "/css/images";
      $theme ["icon"]["title"] = str_replace("\\n", " ", $warning_msg);


      if ($group_select_function) {
        $theme ["op"]["onclick"]["function"] = $group_select_function;
      }
      $theme ["op"]["onclick"]["arguments"][0] = $confirm_warning_msg;
    }



  } // if display status == "eligible"


}