Esempio n. 1
0
 * @version 3.0
 * @copyright Copyright 2006 Queen's University, MEdTech Unit
 *
 * $Id: calendars.php 1103 2010-04-05 15:20:37Z simpson $
*/
@set_time_limit(0);
@set_include_path(implode(PATH_SEPARATOR, array(dirname(__FILE__) . "/../core", dirname(__FILE__) . "/../core/includes", dirname(__FILE__) . "/../core/library", get_include_path())));
/**
 * Include the Entrada init code.
 */
require_once "init.inc.php";
require_once "Entrada/icalendar/class.ical.inc.php";
$tmp_org_id = $_GET["org"];
$PROCESSED["org_id"] = clean_input($tmp_org_id, "int");
if ($PROCESSED["org_id"]) {
    $cohorts = groups_get_active_cohorts($PROCESSED["org_id"]);
    foreach ($cohorts as $cohort) {
        $query = "\n\t\t\t\t\tSELECT a.*, c.`proxy_id`, CONCAT_WS(' ', d.`firstname`, d.`lastname`) AS `fullname`, d.`email`\n\t\t\t\t\tFROM `events` AS a\n\t\t\t\t\tLEFT JOIN `event_audience` AS b\n\t\t\t\t\tON b.`event_id` = a.`event_id`\n\t\t\t\t\tLEFT JOIN `event_contacts` AS c\n\t\t\t\t\tON c.`event_id` = a.`event_id`\n\t\t\t\t\tLEFT JOIN `" . AUTH_DATABASE . "`.`user_data` AS d\n\t\t\t\t\tON d.`id` = c.`proxy_id`\n\t\t\t\t\tWHERE b.`audience_type` = 'cohort'\n\t\t\t\t\tAND b.`audience_value` = " . $db->qstr($cohort["group_id"]) . "\n\t\t\t\t\tAND (c.`contact_order` IS NULL OR c.`contact_order` = '0')\n\t\t\t\t\tORDER BY a.`event_start` ASC";
        $results = $db->GetAll($query);
        if ($results) {
            $ical = new iCal("-//" . html_encode($_SERVER["HTTP_HOST"]) . "//iCal" . ($cohort["group_name"] ? html_encode($cohort["group_name"]) : "") . " Learning Events Calendar MIMEDIR//EN", 1, ENTRADA_ABSOLUTE . "/calendars/", $cohort ? clean_input($cohort["group_name"], "numeric") : "all_cohorts");
            // (ProgrammID, Method (1 = Publish | 0 = Request), Download Directory)
            foreach ($results as $result) {
                $ical->addEvent(array($result["fullname"] != "" ? $result["fullname"] : "", $result["email"] ? $result["email"] : ""), (int) $result["event_start"], (int) $result["event_finish"], $result["event_location"], 1, array("Phase " . $result["event_phase"], html_encode($cohort["group_name"])), strip_tags($result["event_message"]), strip_tags($result["event_title"]), 1, array(), 5, 0, 0, 0, array(), 1, "", 0, 1, str_replace("http://", "https://", ENTRADA_URL) . "/events?id=" . (int) $result["event_id"], "en", md5((int) $result["event_id"]));
            }
            $ical->writeFile();
        }
    }
} else {
    echo "When running the calender generation cron job an invalid org_id was provided, or no org_id was provided.";
}