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; }