$query = "\tSELECT a.*, b.`course_name`, b.`course_code`, b.`organisation_id`\n\t\t\t\tFROM `events` AS a\n\t\t\t\tLEFT JOIN `courses` AS b\n\t\t\t\tON b.`course_id` = a.`course_id`\n\t\t\t\tWHERE a.`event_id` = " . $db->qstr($event_id);
    $event_info = $db->GetRow($query);
    if ($event_info) {
        $LASTUPDATED = $event_info["updated_date"];
        if ($event_info["release_date"] && $event_info["release_date"] > time()) {
            $ERROR++;
            $ERRORSTR[] = "The event you are trying to view is not yet available. Please try again after " . date("r", $event_info["release_date"]);
            echo display_error();
        } elseif ($event_info["release_until"] && $event_info["release_until"] < time()) {
            $ERROR++;
            $ERRORSTR[] = "The event you are trying to view is no longer available; it expired " . date("r", $event_info["release_until"]);
            echo display_error($errorstr);
        } else {
            if ($ENTRADA_ACL->amIAllowed(new EventResource($event_id, $event_info["course_id"], $event_info["organisation_id"]), "read")) {
                add_statistic("events", "view", "event_id", $event_id);
                $event_resources = events_fetch_event_resources($event_id, "all");
                $event_files = is_array($event_resources["files"]) ? count($event_resources["files"]) : 0;
                $event_links = is_array($event_resources["links"]) ? count($event_resources["links"]) : 0;
                $event_quizzes = is_array($event_resources["quizzes"]) ? count($event_resources["quizzes"]) : 0;
                $event_discussions = is_array($event_resources["discussions"]) ? count($event_resources["discussions"]) : 0;
                ?>
				<div id="eventToolTip">
					<div class="colLeft">
						<table style="width: 100%" cellspacing="1" cellpadding="1" border="0">
						<tr>
							<td colspan="2" style="padding-bottom: 5px"><a href="<?php 
                echo ENTRADA_URL;
                ?>
/courses?id=<?php 
                echo $event_info["course_id"];
                ?>
 if ($ENTRADA_ACL->amIAllowed(new EventResource($EVENT_ID, $event_info['course_id'], $event_info['organisation_id']), 'read')) {
     add_statistic($MODULE, "view", "event_id", $EVENT_ID);
     $event_contacts = events_fetch_event_contacts($EVENT_ID);
     $event_audience = $event->getEventAudience();
     $associated_cohorts = array("all");
     $associated_cohorts_string = "";
     $query = "SELECT * FROM `event_audience` WHERE `event_id` = " . $db->qstr($EVENT_ID) . " AND `audience_type` = 'cohort'";
     $cohorts = $db->GetAll($query);
     if ($cohorts) {
         foreach ($cohorts as $cohort) {
             $associated_cohorts[] = $cohort["audience_value"];
             $associated_cohorts_string .= $associated_cohorts_string ? ", " . $db->qstr($cohort["audience_value"]) : $db->qstr($cohort["audience_value"]);
         }
         $event_audience_type = "cohort";
     }
     $event_resources = events_fetch_event_resources($EVENT_ID, "all");
     $event_files = $event_resources["files"];
     $event_links = $event_resources["links"];
     $event_quizzes = $event_resources["quizzes"];
     $event_discussions = $event_resources["discussions"];
     $event_types = $event_resources["types"];
     $event_lti = $event_resources['lti'];
     // Meta information for this page.
     $PAGE_META["title"] = $event_info["event_title"] . " - " . APPLICATION_NAME;
     $PAGE_META["description"] = trim(str_replace(array("\t", "\n", "\r"), " ", html_encode(strip_tags($event_info["event_goals"]))));
     $PAGE_META["keywords"] = "";
     $BREADCRUMB[] = array("url" => ENTRADA_RELATIVE . "/events?" . replace_query(array("id" => $event_info["event_id"])), "title" => $event_info["event_title"]);
     $include_details = true;
     $include_audience = true;
     $include_objectives = false;
     $include_resources = true;