/** * Build an HTML list of attachments for this entry with links to them * * @param object $entry to process * @return string html rendering of attachments list */ function dialogue_print_attachments($entry) { global $CFG; require_once $CFG->dirroot . '/lib/filelib.php'; $filearea = dialogue_file_area_name($entry); $imagereturn = ''; $output = ''; if ($basedir = dialogue_file_area($entry)) { if ($files = get_directory_list($basedir)) { $output .= '<p>' . get_string('attachment', 'dialogue'); foreach ($files as $file) { $icon = mimeinfo('icon', $file); $type = mimeinfo('type', $file); if ($CFG->slasharguments) { $ffurl = "{$CFG->wwwroot}/file.php/{$filearea}/{$file}"; } else { $ffurl = "{$CFG->wwwroot}/file.php?file=/{$filearea}/{$file}"; } $image = "<img src=\"{$CFG->pixpath}/f/{$icon}\" class=\"icon\" alt=\"\" />"; $output .= "<a href=\"{$ffurl}\">{$image}</a> " . "<a href=\"{$ffurl}\">{$file}</a><br />"; } $output .= '</p>'; } } return $output; }
$entry->conversationid = $conversation->id; $entry->userid = $USER->id; $entry->recipientid = $recipient->id; $entry->timecreated = $timenow; $entry->timemodified = $timenow; // reverse the dialogue default value $entry->mailed = !$dialogue->maildefault; $entry->text = addslashes($params->firstentry); if (!($entry->id = insert_record('dialogue_entries', $entry))) { error('Insert Entries: Could not insert dialogue record!'); } add_to_log($course->id, 'dialogue', 'add entry', "view.php?id={$cm->id}", $entry->id, $cm->id); if (isset($srcattachment)) { $entry->attachment = $srcattachment->attachment; $srcdir = dialogue_file_area($srcattachment); $dstdir = dialogue_file_area($entry); copy($srcdir . '/' . $entry->attachment, $dstdir . '/' . $entry->attachment); set_field('dialogue_entries', 'attachment', $entry->attachment, 'id', $entry->id); } elseif ($entry->attachment = dialogue_add_attachment($entry, 'attachment', $messages)) { $srcattachment = clone $entry; set_field('dialogue_entries', 'attachment', $entry->attachment, 'id', $entry->id); } dialogue_mark_conversation_read($conversation->id, $USER->id); $n++; } $a = new stdClass(); $a->edittime = $dialogue->edittime; $a->number = $n; if ($n > 1) { // return to dialogue page if more than one recipent redirect("view.php?id={$cm->id}", get_string('numberofentriesadded', 'dialogue', $a));