function voiceemail_add_instance($voicetool) { /// Given an object containing all the necessary data, /// (defined by the form in mod.html) this function /// will create a new instance and return the id number /// of the new instance. global $USER; //get the resource information(type and id) $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"] = ""; if (isset($voicetool->subject)) { $paramVMail["subject"] = $voicetool->subject; } $paramVMail["recipients"] = voiceemail_getEnrolledUsers($voicetool->course, $voicetool->recipients_email); $vtAction = new VtAction($USER->email, $paramVMail); $vt = $vtAction->createVMmail($voicetool->name); if ($vt === false || $vt->error == "error") { error(get_string('problem_vt', 'voiceemail')); return false; } $resource_id = storeVmailResource($vt->getRid(), $voicetool->course); //default availability if (empty($resource_id)) { return false; } $voicetool->rid = $resource_id; if (!($voicetool->id = insert_record('voiceemail', $voicetool))) { wimba_add_log(WIMBA_ERROR, voiceemail_LOGS, "Problem to add a new instance"); return false; } if (isset($voicetool->calendar_event) && $voicetool->calendar_event == true) { voiceemail_addCalendarEvent($voicetool, $voicetool->id); } wimba_add_log(WIMBA_INFO, voiceemail_LOGS, "Add Instance" . $voicetool->id); //for the debug wimba_add_log(WIMBA_DEBUG, voiceemail_LOGS, print_r($voicetool, true)); return $voicetool->id; }
$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; $resourceOptions->setFrom($USER->email); $resourceOptions->setTo($emailTo); $vtSession = $vtAction->getVtSession($vmail, $currentUser, $currentUserRights); redirection($servername . "/" . $vmail->getType() . "?action=display_popup&nid=" . $vtSession->getNid()); }