$blocks->block_id = $block_id; $blocks->course_id = $course_id; $blocks->all_users_enrolled = $all; $blocks->student = $student; $blocks->instructor = $instructor; $blocks->recipient = $selected; voiceemail_update_blocks_instance($blocks); //redirection to the course page parentRedirection("{$CFG->wwwroot}/course/view.php?id={$course_id}"); } else { if ($type == "other") { $emailTo = implode(";", $users); } else { $emailTo = voiceemail_getEnrolledUsers($course_id, $type); } $vtAction = new VtAction($USER->email); //get the voice email linked to this block $voiceemail = get_record("voiceemail_resources", "block", $block_id); if (empty($voiceemail)) { $vmail = $vtAction->createVMmail("Voice email for the course " . $course_id . " and the block " . $block_id); storeVmailResource($vmail->getRid(), $course_id, $block_id); } else { $vmail = $vtAction->getResource($voiceemail->rid); } if ($vmail->error == "error") { //have to display the error return false; } $currentUser = $vtAction->createUser($USER->firstname . "_" . $USER->lastname, $USER->email); $currentUserRights = $vtAction->createUserRights($vmail->getType(), voiceemail_getRole($context)); $resourceOptions =& $vmail->options;
function voiceemail_update_instance($voicetool) { /// Given an object containing all the necessary data, /// (defined by the form in mod.html) this function /// will update an existing instance with new data. global $USER; //get the course_module instance linked to the liveclassroom instance if (!($cm = get_coursemodule_from_instance("voiceemail", $voicetool->instance, $voicetool->course))) { wimba_add_log(WIMBA_ERROR, voiceemail_LOGS, "Problem to update the instance : " . $voicetool->instance); error("Course Module ID was incorrect"); } if ($voicetool->section != $cm->section) { //Find the right section in the course_section if (!($section = get_record("course_sections", "id", $cm->section))) { return false; } //delete in the course section if (!delete_mod_from_section($cm->id, $cm->section)) { return false; } //update the course module section if (!($sectionid = add_mod_to_section($voicetool))) { wimba_add_log(WIMBA_ERROR, voiceemail_LOGS, "Problem to update the instance : " . $voicetool->instance); error("Could not add the new course module to that section"); } //update the course modules if (!set_field("course_modules", "section", $sectionid, "id", $cm->id)) { wimba_add_log(WIMBA_ERROR, voiceemail_LOGS, "Problem to update the instance : " . $voicetool->instance); error("Could not update the course module with the correct section"); } } $voicetool->timemodified = time(); //Create the Voice E-mail linked to this actvity $paramVMail = array(); $paramVMail["name"] = $voicetool->name; $paramVMail["audio_format"] = $voicetool->audio_format; $paramVMail["max_length"] = $voicetool->max_length; $paramVMail["reply_link"] = $voicetool->reply_link; $paramVMail["subject"] = $voicetool->subject; $paramVMail["recipients"] = voiceemail_getEnrolledUsers($voicetool->course, $voicetool->recipients_email); $vtAction = new VtAction($USER->email, $paramVMail); $vt = $vtAction->updateVMmail($voicetool->rid, $voicetool->name); if ($vt->error == "error") { return false; } $resource_id = updateVmailResource($vt->getRid(), $voicetool->course); //default availability if (empty($resource_id)) { return false; } $voicetool->rid = $resource_id; $voicetool->id = $voicetool->instance; if (!($voicetool->id = update_record('voiceemail', $voicetool))) { return false; } if (isset($voicetool->calendar_event) && $voicetool->calendar_event) { //no problem voiceemail_addCalendarEvent($voicetool, $voicetool->instance); } else { voiceemail_deleteCalendarEvent($voicetool->instance); } wimba_add_log(WIMBA_INFO, voiceemail_LOGS, "Update of the instance : " . $voicetool->id); return $voicetool->id; }