function voiceshadow_update_instance($voiceshadow) { global $USER, $DB, $CFG; for ($i = 1; $i <= 5; $i++) { $name1 = "submitfile_{$i}"; $name2 = "var{$i}"; if (!empty($voiceshadow->{$name1})) { if ($file = voiceshadow_getfile($voiceshadow->{$name1})) { $voiceshadow->{$name2} = $file->id; $DB->set_field("files", "filearea", "public", array("id" => $file->id)); $DB->set_field("files", "filearea", "public", array("id" => $file->id + 1)); } else { unset($voiceshadow->{$name2}); //Не удалять предыдущую запись | Или 0 для удаления } } else { unset($voiceshadow->{$name2}); //Не удалять предыдущую запись } } $voiceshadow->timemodified = time(); $voiceshadow->id = $voiceshadow->instance; voiceshadow_grade_item_update($voiceshadow); return $DB->update_record('voiceshadow', $voiceshadow); }
$ids = $DB->insert_record("voiceshadow_files", $data); } $DB->set_field("voiceshadow_files", "var", $selectaudiomodel, array("id" => $ids)); redirect("view.php?id={$id}", get_string('postsubmited', 'voiceshadow')); } if ($a == 'add' && $act == 'addcomment' && isset($summary)) { $data = new object(); $data->instance = $id; $data->userid = $USER->id; $data->summary = $summary; $data->speechtext = $speechtext; $data->filename = $filename; $data->fileid = $fileid; $data->time = time(); if (!empty($submitfile)) { if ($file = voiceshadow_getfile($submitfile)) { if (mimeinfo('type', $file->filename) == 'audio/wav') { $data->itemoldid = $file->id; $add = new stdClass(); $add->itemid = $file->id; $add->type = mimeinfo('type', $file->filename); $add->status = 'open'; $add->name = md5($CFG->wwwroot . '_' . time()); $DB->insert_record("voiceshadow_process", $add); } else { if (mimeinfo('type', $file->filename) == 'audio/mp3') { $data->itemid = $file->id; } } } }