Example #1
0
/**
 * 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;
}
         error('Update Subject: can not get conversation record');
     }
     if (empty($params->subject)) {
         redirect("view.php?id={$cm->id}&amp;pane={$params->pane}", get_string('nosubject', 'dialogue'));
     } elseif (!set_field('dialogue_conversations', 'subject', $params->subject, 'id', $params->cid)) {
         error('Update subject: could not update conversation record');
     }
     redirect("view.php?id={$cm->id}&amp;pane={$params->pane}", get_string('subjectadded', 'dialogue'));
 } else {
     if ($params->action == 'editreply') {
         /****************** edit a reply ****************************************/
         $entry = get_record('dialogue_entries', 'id', $params->entryid);
         if (isset($_POST['reply' . $entry->conversationid])) {
             $reply = addslashes(clean_param($_POST['reply' . $entry->conversationid], PARAM_CLEANHTML));
             if ($params->deleteattachment && $entry->attachment) {
                 $dir = dialogue_file_area_name($entry);
                 unlink($CFG->dataroot . '/' . $dir . '/' . $entry->attachment);
                 set_field('dialogue_entries', 'attachment', '', 'id', $entry->id);
             }
             set_field('dialogue_entries', 'text', $reply, 'id', $entry->id);
             set_field('dialogue_entries', 'timemodified', time(), 'id', $entry->id);
             if ($entry->attachment = dialogue_add_attachment($entry, 'attachment', $messages)) {
                 set_field('dialogue_entries', 'attachment', $entry->attachment, 'id', $entry->id);
             }
             add_to_log($course->id, 'dialogue', 'edit entry', "view.php?id={$cm->id}", $entry->id, $cm->id);
             redirect("dialogues.php?id={$cm->id}&amp;pane={$params->pane}&amp;action=printdialogue&amp;cid={$entry->conversationid}", get_string('replyupdated', 'dialogue'));
         }
         $mform = new mod_dialogue_reply_form('dialogues.php', array('conversationid' => $entry->conversationid, 'currentattachment' => $entry->attachment));
         $mform->set_data(array('id' => $cm->id, 'entryid' => $entry->id, 'action' => 'editreply', "reply{$entry->conversationid}" => $entry->text));
         $mform->display();
     } else {