Ejemplo n.º 1
0
/**
 * @param . $post argument is a reference to the post object which is used to store information for the form
 * @param . $bloginfo_arg argument is reference to a blogInfo object.
 * @todo complete documenting this function. enable trackback and pingback between entries on the same server
 */
function do_edit($post, $blogeditform)
{
    global $CFG, $USER, $returnurl;
    $post->lastmodified = time();
    $dir = blog_file_area_name($post);
    if ($blogeditform->save_files($dir) and $newfilename = $blogeditform->get_new_filename()) {
        $post->attachment = $newfilename;
    }
    // update record
    if (update_record('post', $post)) {
        // delete all tags associated with this entry
        //delete_records('blog_tag_instance', 'entryid', $post->id);
        //delete_records('tag_instance', 'itemid', $post->id, 'itemtype', 'blog');
        untag_an_item('blog', $post->id);
        // add them back
        add_tags_info($post->id);
        add_to_log(SITEID, 'blog', 'update', 'index.php?userid=' . $post->userid . '&postid=' . $post->id, $post->subject);
    } else {
        error('There was an error updating this post in the database', $returnurl);
    }
}
Ejemplo n.º 2
0
function blog_print_attachments($blogentry, $return = NULL)
{
    // if return=html, then return a html string.
    // if return=text, then return a text-only string.
    // otherwise, print HTML for non-images, and return image HTML
    global $CFG;
    $filearea = blog_file_area_name($blogentry);
    $imagereturn = "";
    $output = "";
    if ($basedir = blog_file_area($blogentry)) {
        if ($files = get_directory_list($basedir)) {
            $strattachment = get_string("attachment", "forum");
            foreach ($files as $file) {
                include_once $CFG->libdir . '/filelib.php';
                $icon = mimeinfo("icon", $file);
                $type = mimeinfo("type", $file);
                $ffurl = get_file_url("{$filearea}/{$file}");
                $image = "<img src=\"{$CFG->pixpath}/f/{$icon}\" class=\"icon\" alt=\"\" />";
                if ($return == "html") {
                    $output .= "<a href=\"{$ffurl}\">{$image}</a> ";
                    $output .= "<a href=\"{$ffurl}\">{$file}</a><br />";
                } else {
                    if ($return == "text") {
                        $output .= "{$strattachment} {$file}:\n{$ffurl}\n";
                    } else {
                        if (in_array($type, array('image/gif', 'image/jpeg', 'image/png'))) {
                            // Image attachments don't get printed as links
                            $imagereturn .= "<br /><img src=\"{$ffurl}\" alt=\"\" />";
                        } else {
                            echo "<a href=\"{$ffurl}\">{$image}</a> ";
                            echo filter_text("<a href=\"{$ffurl}\">{$file}</a><br />");
                        }
                    }
                }
            }
        }
    }
    if ($return) {
        return $output;
    }
    return $imagereturn;
}