function elluminate_update_instance($elluminate) { global $CFG; global $USER; global $DB; $update_id = $elluminate->update; $meeting = $DB->get_record('elluminate', array('id' => $elluminate->instance)); $elluminate->creator = $meeting->creator; $elluminate->chairlist = $meeting->chairlist; $timenow = time(); /// The start and end times don't make sense. if ($elluminate->timestart > $elluminate->timeend) { $a = new stdClass(); $a->timestart = userdate($elluminate->timestart); $a->timeend = userdate($elluminate->timeend); redirect($CFG->wwwroot . '/course/modedit.php?update=' . $elluminate->coursemodule . '&return=1', get_string('invalidsessiontimes', 'elluminate', $a), 5); } if ($elluminate->timestart == $elluminate->timeend) { $a = new stdClass(); $a->timestart = userdate($elluminate->timestart); $a->timeend = userdate($elluminate->timeend); redirect($CFG->wwwroot . '/course/modedit.php?update=' . $elluminate->coursemodule . '&return=1', get_string('samesessiontimes', 'elluminate', $a), 5); } //If the start time has changed, check that it's not before now if ($elluminate->timestart != $meeting->timestart) { if ($elluminate->timestart < $timenow) { $a = new stdClass(); $a->timestart = userdate($elluminate->timestart); $a->timeend = userdate($elluminate->timeend); redirect($CFG->wwwroot . '/course/mod.php?id=' . $elluminate->course . '&section=' . $elluminate->section . '&sesskey=' . $USER->sesskey . '&add=elluminate', get_string('starttimebeforenow', 'elluminate', $a), 5); } } $yearinseconds = 31536000; $timedif = $elluminate->timeend - $elluminate->timestart; if ($timedif > $yearinseconds) { $a = new stdClass(); $a->timestart = userdate($elluminate->timestart); $a->timeend = userdate($elluminate->timeend); redirect($CFG->wwwroot . '/course/modedit.php?update=' . $elluminate->coursemodule . '&return=1', get_string('meetinglessthanyear', 'elluminate', $a), 5); } $year_later = $timenow + $yearinseconds; if ($elluminate->timestart > $year_later) { $a = new stdClass(); $a->timestart = userdate($elluminate->timestart); $a->timeend = userdate($elluminate->timeend); redirect($CFG->wwwroot . '/course/mod.php?id=' . $elluminate->course . '&section=' . $elluminate->section . '&sesskey=' . $USER->sesskey . '&add=elluminate', get_string('meetingstartoverayear', 'elluminate', $a), 5); } $elluminate->timemodified = time(); $elluminate->id = $elluminate->instance; if (empty($elluminate->groupparentid)) { $elluminate->groupparentid = $meeting->groupparentid; } if (empty($elluminate->customdescription)) { $elluminate->customdescription = $meeting->customdescription; } if (!empty($elluminate->edit_groupmode)) { $elluminate->groupmode = $elluminate->edit_groupmode; } if (empty($elluminate->sessiontype)) { $elluminate->sessiontype = $meeting->sessiontype; } if ($elluminate->sessiontype == 3) { $elluminate->groupingid = $elluminate->grouping_id; } /// The start and end times don't make sense. if ($elluminate->timestart > $elluminate->timeend) { /// Get the course module ID for this instance. $sql = "SELECT cm.id\n FROM {modules} m,\n {course_modules} cm\n WHERE m.name = 'elluminate'\n AND cm.module = m.id\n AND cm.instance = :instanceid"; $sql_params = array('instanceid' => $elluminate->id); if (!($cmid = get_field_sql($sql, $sql_params))) { redirect($CFG->wwwroot . '/mod/elluminate/view.php?id=' . $elluminate->id, 'The meeting start time of ' . userdate($elluminate->timestart) . ' is after the meeting end time of ' . userdate($elluminate->timeend), 5); } redirect($CFG->wwwroot . '/course/mod.php?update=' . $cmid . '&return=true&' . 'sesskey=' . $USER->sesskey, 'The meeting start time of ' . userdate($elluminate->timestart) . ' is after the meeting end time of ' . userdate($elluminate->timeend), 5); } /// If the grade value for attendance has changed, modify any existing attendance records. if ($elluminate->grade != $meeting->grade) { $attendance = $DB->get_records('elluminate_attendance', array('elluminateid' => $meeting->id)); foreach ($attendance as $attendee) { if ($attendee->grade > 0) { /// We're using a scale. if ($elluminate->grade < 0) { $grades = make_grades_menu($elluminate->grade); $attendee->grade = key($grades); /// We're using a numerical value. } else { $attendee->grade = $elluminate->grade; } $DB->update_record('elluminate_attendance', $attendee); elluminate_update_grades($elluminate, $attendee->userid); } } } if (empty($elluminate->boundarytimedisplay)) { $elluminate->boundarytimedisplay = 0; } if (empty($elluminate->maxtalkers)) { $elluminate->maxtalkers = 1; } $elluminate->seats = 0; $search = array("<", "&", "\"", "#", "%"); $replace = ''; $elluminate->sessionname = str_replace($search, $replace, $elluminate->name); if (empty($elluminate->sessionname)) { redirect($CFG->wwwroot . '/course/modedit.php?update=' . $update_id . '&return=1', get_string('meetingnameempty', 'elluminate'), 5); } if (!empty($meeting->meetingid)) { $create_result = elluminate_update_meeting($meeting->meetingid, $elluminate->timestart, $elluminate->timeend, $elluminate->sessionname, '', '', $elluminate->sessiontype, $elluminate->seats, $elluminate->boundarytime, $elluminate->maxtalkers, $elluminate->recordingmode, '', $elluminate->id); if ($create_result->DefaultAdapterMeetingResponseShort->meetingId > 0) { } else { print_error($create_result->message); } } $DB->update_record('elluminate', $elluminate); elluminate_grade_item_update($elluminate); elluminate_check_for_new_groups($elluminate); if ($elluminate->sessiontype == '2' || $elluminate->sessiontype == '3') { if ($elluminate->groupmode != 0) { elluminate_update_group_records($elluminate); } else { elluminate_update_events($meeting); } } else { elluminate_update_events($meeting); } $meeting = $DB->get_record('elluminate', array('id' => $elluminate->instance)); return true; }
} } } //In Moodle 2.2.2 the groupmodeforce option is not being enforced on objects below the //course level. So now we look to see if the force group mode is on or not. If groupmodeforce is not turned on for the //course, then we can trust the cm object to have the correct groupmode value. Otherwise, we do not trust the cm //object and instead get the value from our existing course. if ($cm->groupmode != $elluminate->groupmode) { if ($course->groupmodeforce == 0) { $elluminate->groupmode = $cm->groupmode; } else { $cm->groupmode = $elluminate->groupmode; } elluminate_check_for_group_change($cm, $elluminate); } elluminate_check_for_new_groups($elluminate); $context = get_context_instance(CONTEXT_MODULE, $cm->id); $accessallgroups = has_capability('moodle/site:accessallgroups', $context); /// Check to see if groups are being used here $groupmode = $elluminate->groupmode; if ($elluminate->sessiontype == 2 || $elluminate->sessiontype == 3) { if (empty($groupid)) { if (!$accessallgroups) { if ($elluminate->sessiontype == 2) { $availablegroups = groups_get_all_groups($cm->course, $USER->id); } else { if ($elluminate->sessiontype == 3) { $availablegroups = groups_get_all_groups($cm->course, $USER->id, $elluminate->groupingid); } else { $availablegroups = null; $currentgroupid = 0;
function definition() { global $CFG, $COURSE, $USER, $DB; $id = optional_param('update', '', PARAM_RAW); if (!empty($id)) { if (!($cm = get_coursemodule_from_id('elluminate', $id))) { print_error("Course Module ID was incorrect"); } if (!($elluminate = $DB->get_record("elluminate", array('id' => $cm->instance)))) { print_error("Course module is incorrect"); } } if (!empty($id)) { //In Moodle 2.2.2 the groupmodeforce option is not being enforced on objects below the //course level. So now we look to see if the force group mode is on or not. If groupmodeforce is not turned on for the //course, then we can trust the cm object to have the correct groupmode value. Otherwise, we do not trust the cm //object and instead get the value from our existing course. if ($cm->groupmode != $elluminate->groupmode) { if ($COURSE->groupmodeforce == 0) { $elluminate->groupmode = $cm->groupmode; } else { $cm->groupmode = $elluminate->groupmode; } elluminate_check_for_group_change($cm, $elluminate); if (!($elluminate = $DB->get_record("elluminate", array('id' => $cm->instance)))) { print_error("Course module is incorrect"); } //We're doing a redirect onto itself so that the changes are reflected on the UI //redirect($CFG->wwwroot . '/course/modedit.php?update=' . $cm->id. '&return=0'); } else { //print"<br></br>=============== we're in the esle"; //print_error(var_export($elluminate)); elluminate_check_for_new_groups($elluminate); } } //print"<br></br>=============== we're in the esle"; //print_error(var_export($elluminate)); if (!empty($elluminate)) { $participant = false; if ($elluminate->sessiontype == 1) { //Checks to see if the user is a participant in the private meeting if (elluminate_is_participant_in_meeting($elluminate, $USER->id)) { //then checks to make sure that the user role has the privilege to join a meeting $participant = true; } } else { $participant = true; } if ($participant == false) { print_error('You need to be invited to this private session in order to edit it.'); } } $elluminate_boundary_times = array(0 => '0', 15 => '15', 30 => '30', 45 => '45', 60 => '60'); $elluminate_max_talkers = array(1 => '1', 2 => '2', 3 => '3', 4 => '4', 5 => '5', 6 => '6'); //------------------------------------------------------------------------------- $mform =& $this->_form; //------------------------------------------------------------------------------- $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('text', 'name', get_string('title', 'elluminate'), array('size' => '64', 'maxlength' => '64')); $mform->setType('name', PARAM_RAW); $mform->addRule('name', null, 'required', null, 'client'); //These are in place to pull the localized string and use it in the javascript $mform->addElement('hidden', 'noGroupString', get_string('groupsnone')); $mform->addElement('hidden', 'seperateGroupString', get_string('groupsseparate')); $mform->addElement('hidden', 'visibleGroupString', get_string('groupsvisible')); $sessiontypes = array(); if ($COURSE->groupmodeforce == '0') { $sessiontypes[0] = get_string('course', 'elluminate'); $sessiontypes[1] = get_string('private', 'elluminate'); $has_groups = $DB->get_records('groups', array('courseid' => $COURSE->id), 'name ASC'); if ($has_groups != false) { $sessiontypes[2] = get_string('group', 'group'); } $has_groupings = $DB->get_records('groupings', array('courseid' => $COURSE->id), 'name ASC'); if ($has_groupings != false) { $sessiontypes[3] = get_string('grouping', 'group'); } } else { if ($COURSE->groupmode == 0) { $sessiontypes[0] = get_string('course', 'elluminate'); $sessiontypes[1] = get_string('private', 'elluminate'); $has_groupings = $DB->get_records('groupings', array('courseid' => $COURSE->id), 'name ASC'); if ($has_groupings != false) { $sessiontypes[3] = get_string('grouping', 'group'); } } else { if ($COURSE->groupmode > 0) { $has_groups = $DB->get_records('groups', array('courseid' => $COURSE->id), 'name ASC'); if ($has_groups != false) { $sessiontypes[2] = get_string('group', 'group'); } $has_groupings = $DB->get_records('groupings', array('courseid' => $COURSE->id), 'name ASC'); if ($has_groupings != false) { $sessiontypes[3] = get_string('grouping', 'group'); } } } } $mform->addElement('select', 'sessiontype', get_string('sessiontype', 'elluminate'), $sessiontypes); $mform->addElement('select', 'customname', get_string('appendgroupname', 'elluminate'), array(0 => 'None', 1 => 'Only Group Name', 2 => 'Append Group Name to Title')); $mform->addElement('text', 'sessionname', get_string('customsessionname', 'elluminate'), array('size' => '64', 'maxlength' => '64')); $mform->disabledIf('sessionname', 'customname', 'eq', 1); $mform->disabledIf('sessionname', 'customname', 'eq', 2); $mform->addElement('text', 'sessionname_state', 'Session Name State', array('size' => '64', 'maxlength' => '64')); if (!empty($id)) { $mform->addElement('hidden', 'isedit', 'true'); //This is a placeholder to do disables on. $mform->addElement('hidden', 'edit_groupmode', $elluminate->groupmode); if ($elluminate->sessiontype == '0') { $mform->setDefault('sessiontype', 0); } else { if ($elluminate->sessiontype == '1') { $mform->setDefault('sessiontype', 1); } else { if ($elluminate->sessiontype == '2') { $mform->setDefault('sessiontype', 2); } else { if ($elluminate->sessiontype == '3') { $mform->setDefault('sessiontype', 3); $mform->setDefault('grouping', $elluminate->groupid); } } } } $mform->disabledIf('sessiontype', 'isedit', 'eq', 'true'); } $mform->addElement('htmleditor', 'description', get_string('description', 'elluminate')); $mform->setType('description', PARAM_RAW); $mform->addElement('checkbox', 'customdescription', get_string('customdescription', 'elluminate')); $mform->disabledIf('customdescription', 'sessiontype', 'eq', 0); $mform->disabledIf('customdescription', 'sessiontype', 'eq', 1); $mform->addElement('date_time_selector', 'timestart', get_string('meetingbegins', 'elluminate'), array('optional' => false, 'step' => 15)); $mform->setDefault('timestart', time() + 900); $mform->addElement('date_time_selector', 'timeend', get_string('meetingends', 'elluminate'), array('optional' => false, 'step' => 15)); $mform->setDefault('timeend', time() + 4500); $recording_options = array(ELLUMINATELIVE_RECORDING_NONE => get_string('disabled', 'elluminate'), ELLUMINATELIVE_RECORDING_MANUAL => get_string('manual', 'elluminate'), ELLUMINATELIVE_RECORDING_AUTOMATIC => get_string('automatic', 'elluminate')); $mform->addElement('select', 'recordingmode', get_string('recordingmode', 'elluminate'), $recording_options); $mform->setDefault('recordingmode', ELLUMINATELIVE_RECORDING_MANUAL); $mform->addHelpButton('recordingmode', 'recordingmode', 'elluminate'); $mform->addElement('select', 'maxtalkers', get_string('maxtalkers', 'elluminate'), $elluminate_max_talkers); if (!empty($elluminate->maxtalkers)) { $mform->setDefault('maxtalkers', $elluminate->maxtalkers); } else { if ($CFG->elluminate_max_talkers == '-1') { $mform->setDefault('maxtalkers', ELLUMINATELIVE_MAX_TALKERS); } else { $mform->setDefault('maxtalkers', $CFG->elluminate_max_talkers); } } $mform->addHelpButton('maxtalkers', 'maxtalkers', 'elluminate'); /// Don't allow choosing a boundary time if there is a globally defined default time. if ($CFG->elluminate_boundary_default != '-1') { $attributes = array('disabled' => 'true'); } else { $attributes = ''; } $boundaryselect = $mform->addElement('select', 'boundarytime', get_string('boundarytime', 'elluminate'), $elluminate_boundary_times, $attributes); if ($CFG->elluminate_boundary_default == '-1') { $mform->setDefault('boundarytime', ELLUMINATELIVE_BOUNDARY_DEFAULT); } else { $mform->setConstant('boundarytime', $CFG->elluminate_boundary_default); } $mform->addHelpButton('boundarytime', 'boundarytime', 'elluminate'); $mform->addElement('checkbox', 'boundarytimedisplay', get_string('boundarytimedisplay', 'elluminate')); $mform->disabledIf('boundarytimedisplay', 'boundarytime', 'eq', 0); $mform->addElement('modgrade', 'grade', get_string('gradeattendance', 'elluminate')); $mform->setDefault('grade', 0); $has_groupings = $DB->get_records('groupings', array('courseid' => $COURSE->id), 'name ASC'); if ($has_groupings) { if ($groupings = $DB->get_records('groupings', array('courseid' => $COURSE->id))) { foreach ($groupings as $grouping) { $options[$grouping->id] = format_string($grouping->name); } } $mform->addElement('select', 'grouping_id', get_string('grouping', 'group'), $options); $mform->addHelpButton('grouping_id', 'grouping', 'group'); //Set edit grouping id if (!empty($id)) { $mform->setDefault('grouping_id', $elluminate->groupingid); } } $this->standard_coursemodule_elements(); /// Add rules for group name dependent options defined earlier. $mform->disabledIf('groupname', 'groupsession', 'eq', 0); $this->add_action_buttons(); }
function definition() { global $CFG, $COURSE, $USER; $id = optional_param('update', '', PARAM_RAW); if (!empty($id)) { if (!($cm = get_coursemodule_from_id('elluminate', $id))) { error("Course Module ID was incorrect"); } if (!($elluminate = get_record("elluminate", "id", $cm->instance))) { error("Course module is incorrect"); } } if (!empty($id)) { if ($cm->groupmode != $elluminate->groupmode) { elluminate_check_for_group_change($cm, $elluminate); if (!($elluminate = get_record("elluminate", "id", $cm->instance))) { error("Course module is incorrect"); } //We're doing a redirect onto itself so that the changes are reflected on the UI //redirect($CFG->wwwroot . '/course/modedit.php?update=' . $cm->id. '&return=0'); } else { elluminate_check_for_new_groups($elluminate); } } if (!empty($elluminate)) { $participant = false; if ($elluminate->private) { //Checks to see if the user is a participant in the private meeting if (elluminate_is_participant_in_meeting($elluminate, $USER->id)) { //then checks to make sure that the user role has the privilege to join a meeting $participant = true; } } else { $participant = true; } if ($participant == false) { error('You need to be invited to this private session in order to edit it.'); } } $elluminate_boundary_times = array(0 => '0', 15 => '15', 30 => '30', 45 => '45', 60 => '60'); //------------------------------------------------------------------------------- $mform =& $this->_form; //------------------------------------------------------------------------------- $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('text', 'name', get_string('title', 'elluminate'), array('size' => '64', 'maxlength' => '64')); $mform->setType('name', PARAM_RAW); $mform->addRule('name', null, 'required', null, 'client'); $sessiontypes = array(); if ($COURSE->groupmodeforce == '0') { $sessiontypes[0] = get_string('course', 'elluminate'); $sessiontypes[1] = get_string('private', 'elluminate'); $has_groups = get_records('groups', 'courseid', $COURSE->id, 'name ASC'); if ($has_groups != false) { $sessiontypes[2] = get_string('group', 'elluminate'); } $enablegroupings = get_record("config", "name", "enablegroupings"); if ($enablegroupings->value == '1') { $has_groupings = get_records('groupings', 'courseid', $COURSE->id, 'name ASC'); if ($has_groupings != false) { $sessiontypes[3] = get_string('groupings', 'elluminate'); } } } else { if ($COURSE->groupmode == 0) { $sessiontypes[0] = get_string('course', 'elluminate'); $sessiontypes[1] = get_string('private', 'elluminate'); $enablegroupings = get_record("config", "name", "enablegroupings"); if ($enablegroupings->value == '1') { $has_groupings = get_records('groupings', 'courseid', $COURSE->id, 'name ASC'); if ($has_groupings != false) { $sessiontypes[3] = get_string('groupings', 'elluminate'); } } } else { if ($COURSE->groupmode > 0) { $has_groups = get_records('groups', 'courseid', $COURSE->id, 'name ASC'); if ($has_groups != false) { $sessiontypes[2] = get_string('group', 'elluminate'); } $enablegroupings = get_record("config", "name", "enablegroupings"); if ($enablegroupings->value == '1') { $has_groupings = get_records('groupings', 'courseid', $COURSE->id, 'name ASC'); if ($has_groupings != false) { $sessiontypes[3] = get_string('groupings', 'elluminate'); } } } } } $mform->addElement('select', 'sessiontype', 'Session Type', $sessiontypes); $mform->addElement('select', 'customname', get_string('appendgroupname', 'elluminate'), array(0 => 'None', 1 => 'Only Group Name', 2 => 'Append Group Name to Title')); $mform->addElement('text', 'sessionname', get_string('customsessionname', 'elluminate'), array('size' => '64', 'maxlength' => '64')); $mform->disabledIf('sessionname', 'customname', 'eq', 1); $mform->disabledIf('sessionname', 'customname', 'eq', 2); $mform->addElement('text', 'sessionname_state', 'Session Name State', array('size' => '64', 'maxlength' => '64')); if (!empty($id)) { $mform->addElement('hidden', 'isedit', 'true'); //This is a placeholder to do disables on. $mform->addElement('hidden', 'edit_groupmode', $elluminate->groupmode); if ($elluminate->sessiontype == '0') { $mform->setDefault('sessiontype', 0); } else { if ($elluminate->sessiontype == '1') { $mform->setDefault('sessiontype', 1); } else { if ($elluminate->sessiontype == '2') { $mform->setDefault('sessiontype', 2); } else { if ($elluminate->sessiontype == '3') { $mform->setDefault('sessiontype', 3); $mform->setDefault('grouping', $elluminate->groupid); } } } } $mform->disabledIf('sessiontype', 'isedit', 'eq', 'true'); } $mform->addElement('htmleditor', 'description', get_string('description')); $mform->setType('description', PARAM_RAW); $mform->setHelpButton('description', array('writing', 'questions', 'richtext'), false, 'editorhelpbutton'); $mform->addElement('checkbox', 'customdescription', get_string('customdescription', 'elluminate')); $mform->disabledIf('customdescription', 'sessiontype', 'eq', 0); $mform->disabledIf('customdescription', 'sessiontype', 'eq', 1); $mform->addElement('date_time_selector', 'timestart', get_string('meetingbegins', 'elluminate'), array('optional' => false, 'step' => 15)); $mform->setDefault('timestart', time() + 900); $mform->addElement('date_time_selector', 'timeend', get_string('meetingends', 'elluminate'), array('optional' => false, 'step' => 15)); $mform->setDefault('timeend', time() + 4500); $recording_options = array(ELLUMINATELIVE_RECORDING_NONE => get_string('disabled', 'elluminate'), ELLUMINATELIVE_RECORDING_MANUAL => get_string('manual', 'elluminate'), ELLUMINATELIVE_RECORDING_AUTOMATIC => get_string('automatic', 'elluminate')); $mform->addElement('select', 'recordingmode', get_string('recordmeeting', 'elluminate'), $recording_options); $mform->setDefault('recordingmode', ELLUMINATELIVE_RECORDING_MANUAL); $mform->setHelpButton('recordingmode', array('recording', get_string('helprecording', 'elluminate'), 'elluminate')); /// Don't allow choosing a boundary time if there is a globally defined default time. if ($CFG->elluminate_boundary_default != '-1') { $attributes = array('disabled' => 'true'); } else { $attributes = ''; } $boundaryselect = $mform->addElement('select', 'boundarytime', get_string('boundarytime', 'elluminate'), $elluminate_boundary_times, $attributes); if ($CFG->elluminate_boundary_default == '-1') { $mform->setDefault('boundarytime', ELLUMINATELIVE_BOUNDARY_DEFAULT); } else { $mform->setConstant('boundarytime', $CFG->elluminate_boundary_default); } $mform->setHelpButton('boundarytime', array('boundarytime', get_string('helpboundarytime', 'elluminate'), 'elluminate')); $mform->addElement('checkbox', 'boundarytimedisplay', get_string('boundarytimedisplay', 'elluminate')); $mform->disabledIf('boundarytimedisplay', 'boundarytime', 'eq', 0); $mform->addElement('modgrade', 'grade', get_string('gradeattendance', 'elluminate')); $mform->setDefault('grade', 0); //------------------------------------------------------------------------------- //$features = new stdClass; //$features->groups = false; //$features->groupings = false; //$features->groupmembersonly = false; //$features->gradecat = false; //$features->idnumber = false; //$this->standard_coursemodule_elements($features); $features = new stdClass(); $features->groupings = true; $features->groups = true; $features->groupmembersonly = true; $features->gradecat = true; $features->idnumber = true; $this->standard_coursemodule_elements($features); //------------------------------------------------------------------------------- /// Add rules for group name dependent options defined earlier. //$mform->disabledIf('customname', 'groupmode', 'eq', NOGROUPS); //$mform->disabledIf('customdescription', 'groupmode', 'eq', NOGROUPS); $mform->disabledIf('groupname', 'groupsession', 'eq', 0); // buttons $this->add_action_buttons(); }
function elluminate_update_instance($elluminate) { global $CFG; global $USER; $update_id = $elluminate->update; $meeting = get_record('elluminate', 'id', $elluminate->instance); $elluminate->creator = $meeting->creator; $elluminate->chairlist = $meeting->chairlist; /// The start and end times don't make sense. if ($elluminate->timestart > $elluminate->timeend) { $a = new stdClass(); $a->timestart = userdate($elluminate->timestart); $a->timeend = userdate($elluminate->timeend); redirect($CFG->wwwroot . '/course/modedit.php?update=' . $elluminate->coursemodule . '&return=1', get_string('invalidsessiontimes', 'elluminate', $a), 5); } if ($elluminate->timestart == $elluminate->timeend) { $a = new stdClass(); $a->timestart = userdate($elluminate->timestart); $a->timeend = userdate($elluminate->timeend); redirect($CFG->wwwroot . '/course/modedit.php?update=' . $elluminate->coursemodule . '&return=1', get_string('samesessiontimes', 'elluminate', $a), 5); } $timenow = time(); $yearinseconds = 31536000; $timedif = $elluminate->timeend - $elluminate->timestart; if ($timedif > $yearinseconds) { $a = new stdClass(); $a->timestart = userdate($elluminate->timestart); $a->timeend = userdate($elluminate->timeend); redirect($CFG->wwwroot . '/course/modedit.php?update=' . $elluminate->coursemodule . '&return=1', get_string('meetinglessthanyear', 'elluminate', $a), 5); } $year_later = $timenow + $yearinseconds; if ($elluminate->timestart > $year_later) { $a = new stdClass(); $a->timestart = userdate($elluminate->timestart); $a->timeend = userdate($elluminate->timeend); redirect($CFG->wwwroot . '/course/mod.php?id=' . $elluminate->course . '&section=' . $elluminate->section . '&sesskey=' . $USER->sesskey . '&add=elluminate', get_string('meetingstartoverayear', 'elluminate', $a), 5); } $elluminate->timemodified = time(); $elluminate->id = $elluminate->instance; /// The start and end times don't make sense. if ($elluminate->timestart > $elluminate->timeend) { /// Get the course module ID for this instance. $sql = "SELECT cm.id\n\t\t\t\t\t\t FROM {$CFG->prefix}modules m,\n\t\t\t\t\t\t {$CFG->prefix}course_modules cm\n\t\t\t\t\t\t WHERE m.name = 'elluminate'\n\t\t\t\t\t\t AND cm.module = m.id\n\t\t\t\t\t\t AND cm.instance = '{$elluminate->id}'"; if (!($cmid = get_field_sql($sql))) { redirect($CFG->wwwroot . '/mod/elluminate/view.php?id=' . $elluminate->id, 'The meeting start time of ' . userdate($elluminate->timestart) . ' is after the meeting end time of ' . userdate($end), 5); } redirect($CFG->wwwroot . '/course/mod.php?update=' . $cmid . '&return=true&' . 'sesskey=' . $USER->sesskey, 'The meeting start time of ' . userdate($elluminate->timestart) . ' is after the meeting end time of ' . userdate($end), 5); } /// If the grade value for attendance has changed, modify any existing attendance records. if ($elluminate->grade != $meeting->grade) { if ($attendance = get_records('elluminate_attendance', 'elluminateid', $meeting->id)) { foreach ($attendance as $attendee) { if ($attendee->grade > 0) { /// We're using a scale. if ($elluminate->grade < 0) { $grades = make_grades_menu($elluminate->grade); $attendee->grade = key($grades); /// We're using a numerical value. } else { $attendee->grade = $elluminate->grade; } update_record('elluminate_attendance', $attendee); elluminate_update_grades($elluminate, $attendee->userid); } } } } if (empty($elluminate->boundarytimedisplay)) { $elluminate->boundarytimedisplay = 0; } $elluminate->seats = 0; //$elluminate->sessionname = $elluminate->name; $search = array("<", ">", "&", "#", "%", "\"", "\\", "|"); $replace = ''; $databasesafe = array("'"); $replacedb = '\\\''; $elluminate->sessionname = str_replace($search, $replace, $elluminate->sessionname); $elluminate->sessionname = str_replace($databasesafe, $replacedb, $elluminate->sessionname); $elluminate->description = addslashes($elluminate->description); if (empty($elluminate->sessionname)) { redirect($CFG->wwwroot . '/course/modedit.php?update=' . $update_id . '&return=1', get_string('meetingnameempty', 'elluminate'), 5); } else { if (!ctype_alnum(substr($elluminate->sessionname, 0, 1))) { redirect($CFG->wwwroot . '/course/modedit.php?update=' . $update_id . '&return=1', get_string('meetingnamemustbeginwithalphanumeric', 'elluminate'), 5); } } if (!empty($meeting->meetingid)) { if (!($create_result = elluminate_update_meeting($meeting->meetingid, $elluminate->timestart, $elluminate->timeend, $elluminate->sessionname, '', '', $elluminate->private, $elluminate->seats, $elluminate->boundarytime, $elluminate->recordingmode, '', $elluminate->id))) { return false; } } $elluminate->name = htmlentities($elluminate->name); update_record('elluminate', $elluminate); elluminate_grade_item_update($elluminate); elluminate_check_for_new_groups($elluminate); if ($elluminate->sessiontype == '2' || $elluminate->sessiontype == '3') { if ($elluminate->groupmode != 0) { elluminate_update_group_records($elluminate); } } return true; }