$webclass->title = stripslashes($_POST["title"]); $webclass->description = stripslashes($_POST["description"]); $webclass->tags = stripslashes($_POST["tags"]); $webclass->class_date = $_POST["method_face_date"]; $webclass->time = $_POST["timeEntry"]; $webclass->duration = $_POST["duration"]; $webclass->max_students = $_POST["max_students"]; if (isset($_POST['publicwebclass'])) { $webclass->public_class = 1; } else { $webclass->public_class = 0; } $reference = sclipo_createWebClass($_SESSION["sclipo_id"], $USER->username, $webclass); $newClass = new SclipoWebClass(); $newClass->course = $mod->course; $newClass->teacherid = sclipo_getUserIDFromSession($_SESSION["sclipo_id"], $USER->username); $newClass->name = $_POST["title"]; $newClass->description = $_POST["description"]; $newClass->tags = $_POST["tags"]; $newClass->class_date = $_POST["method_face_date"]; $newClass->time = $_POST["timeEntry"]; $newClass->duration = $_POST["duration"]; $newClass->max_students = $_POST["max_students"]; $newClass->reference = $reference; $newClass->teacherinfo = $USER->id; $instanceid = $addinstancefunction($newClass); // Add a record to the sclipo table $mod->instance = $instanceid; list($month, $day, $year) = split('/', $_POST["method_face_date"]); list($hour, $min) = split(':', $_POST["timeEntry"]); $month = intval($month);
$context = get_context_instance(CONTEXT_COURSE, $course->id); require_capability('moodle/course:manageactivities', $context); if (!($module = get_record("modules", "id", $cm->module))) { error("This module doesn't exist"); } if (!($form = get_record($module->name, "id", $cm->instance))) { error("The required instance of this module doesn't exist"); } if (!($cw = get_record("course_sections", "id", $cm->section))) { error("This course section doesn't exist"); } if (isset($return)) { $SESSION->returnpage = "{$CFG->wwwroot}/mod/{$module->name}/view.php?id={$cm->id}"; } // Check if we are allowed to update if ($form->teacherid != sclipo_getUserIDFromSession($_SESSION["sclipo_id"], $USER->username)) { $navlinks = array(); $navlinks[] = array('name' => "Sclipo Live Web Class", 'link' => "", 'type' => 'activity'); $navlinks[] = array('name' => "Edit Web Class", 'link' => '', 'type' => 'action'); $navigation = build_navigation($navlinks); print_header_simple("Sclipo Live Web Class", '', $navigation, '', "", false); echo "<center><strong>No Permission, only the teacher who created this class can edit it!</strong></center>"; exit; } $form->coursemodule = $cm->id; $form->section = $cm->section; // The section ID $form->course = $course->id; $form->module = $module->id; $form->modulename = $module->name; $form->instance = $cm->instance;
/** * Given an ID of an instance of this module, * this function will permanently delete the instance * and any data that depends on it. * * @param int $id Id of the module instance * @return boolean Success/Failure */ function sclipowebclass_delete_instance($id) { require_once "sclipoapi.php"; global $USER; global $CFG; if (!($sclipo = get_record("sclipowebclass", "id", "{$id}"))) { return false; } $result = true; $pageURL = 'http'; if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") { $pageURL .= "s"; } $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; } if (sclipo_checkLogin($_SESSION["sclipo_id"], $USER->username) == 0) { // Need to log in $redirectpage = $pageURL; $cssfile = $CFG->wwwroot; $cssfile .= "/mod/sclipowebclass/css/"; $navlinks = array(); $navlinks[] = array('name' => "Sclipo Live Web Class", 'link' => "", 'type' => 'activity'); $navlinks[] = array('name' => "Create & Schedule Web Classes", 'link' => '', 'type' => 'action'); $navigation = build_navigation($navlinks); print_header_simple("Sclipo Live Web Class", '', $navigation, "", "", false); $icon = '<img class="icon" src="../mod/sclipowebclass/icon.gif" alt="Sclipo"/>'; print_heading_with_help("Create & Schedule Your Sclipo Web Classes", "mods", "sclipowebclass", $icon); print_simple_box_start('center', '', '', 5, 'generalbox', "sclipowebclass"); echo "<center><strong>Please log in first to Sclipo through Moodle</strong></center>"; $redirectpage = $CFG->wwwroot . "/course/view.php?id=" . $sclipo->course; $delete = 1; include "mod.html"; exit; } if (sclipo_getUserIDFromSession($_SESSION["sclipo_id"], $USER->username) != $sclipo->teacherid) { // No permission $redirectpage = $pageURL; $cssfile = $CFG->wwwroot; $cssfile .= "/mod/sclipowebclass/css/"; $navlinks = array(); $navlinks[] = array('name' => "Sclipo Live Web Class", 'link' => "", 'type' => 'activity'); $navlinks[] = array('name' => "Create & Schedule Web Classes", 'link' => '', 'type' => 'action'); $navigation = build_navigation($navlinks); print_header_simple("Sclipo", '', $navigation, "", "", false); $icon = '<img class="icon" src="../mod/sclipowebclass/icon.gif" alt="Sclipo"/>'; print_heading_with_help("Create & Schedule Your Sclipo Web Classes", "mods", "sclipowebclass", $icon); print_simple_box_start('center', '', '', 5, 'generalbox', "sclipowebclass"); echo "<center><strong>Only the teacher who created the web class can delete it</strong></center>"; exit; } // Delete web class at sclipo server sclipo_deleteWebClass($_SESSION["sclipo_id"], $USER->username, $sclipo->reference); # Delete any dependent records here # if (!delete_records("sclipowebclass", "id", "{$sclipo->id}")) { $result = false; } return $result; }