Exemplo n.º 1
0
/**
 *  This function is in lib and not in BlogInfo because entries being searched
 *   might be found in any number of blogs rather than just one.
 *
 *   $@param ...
 */
function blog_print_html_formatted_entries($postid, $filtertype, $filterselect, $tagid, $tag)
{
    global $CFG, $USER, $OUTPUT;
    $blogpage = optional_param('blogpage', 0, PARAM_INT);
    $bloglimit = optional_param('limit', get_user_preferences('blogpagesize', 10), PARAM_INT);
    $start = $blogpage * $bloglimit;
    $sitecontext = get_context_instance(CONTEXT_SYSTEM);
    $morelink = '<br />&nbsp;&nbsp;';
    $totalentries = get_viewable_entry_count($postid, $bloglimit, $start, $filtertype, $filterselect, $tagid, $tag, $sort = 'created DESC');
    $blogEntries = blog_fetch_entries($postid, $bloglimit, $start, $filtertype, $filterselect, $tagid, $tag, $sort = 'created DESC', true);
    $pagingbar = moodle_paging_bar::make($totalentries, $blogpage, $bloglimit, get_baseurl($filtertype, $filterselect));
    $pagingbar->pagevar = 'blogpage';
    echo $OUTPUT->paging_bar($pagingbar);
    if ($CFG->enablerssfeeds) {
        blog_rss_print_link($filtertype, $filterselect, $tag);
    }
    if (has_capability('moodle/blog:create', $sitecontext)) {
        //the user's blog is enabled and they are viewing their own blog
        $addlink = '<div class="addbloglink">';
        $addlink .= '<a href="' . $CFG->wwwroot . '/blog/edit.php?action=add' . '">' . get_string('addnewentry', 'blog') . '</a>';
        $addlink .= '</div>';
        echo $addlink;
    }
    if ($blogEntries) {
        $count = 0;
        foreach ($blogEntries as $blogEntry) {
            blog_print_entry($blogEntry, 'list', $filtertype, $filterselect);
            //print this entry.
            $count++;
        }
        $pagingbar = moodle_paging_bar::make($totalentries, $blogpage, $bloglimit, get_baseurl($filtertype, $filterselect));
        $pagingbar->pagevar = 'blogpage';
        echo $OUTPUT->paging_bar($pagingbar);
        if (!$count) {
            print '<br /><div style="text-align:center">' . get_string('noentriesyet', 'blog') . '</div><br />';
        }
        print $morelink . '<br />' . "\n";
        return;
    }
    $output = '<br /><div style="text-align:center">' . get_string('noentriesyet', 'blog') . '</div><br />';
    print $output;
}
Exemplo n.º 2
0
if (!empty($courseid)) {
    $returnurl .= '&amp;courseid=' . $courseid;
}
$strblogs = get_string('blogs', 'blog');
if ($action == 'delete') {
    if (!$existing) {
        error('Incorrect blog post id');
    }
    if (data_submitted() and $confirm and confirm_sesskey()) {
        do_delete($existing);
        redirect($returnurl);
    } else {
        $optionsyes = array('id' => $id, 'action' => 'delete', 'confirm' => 1, 'sesskey' => sesskey(), 'courseid' => $courseid);
        $optionsno = array('userid' => $existing->userid, 'courseid' => $courseid);
        print_header("{$SITE->shortname}: {$strblogs}", $SITE->fullname);
        blog_print_entry($existing);
        echo '<br />';
        notice_yesno(get_string('blogdeleteconfirm', 'blog'), 'edit.php', 'index.php', $optionsyes, $optionsno, 'post', 'get');
        print_footer();
        die;
    }
}
require_once 'edit_form.php';
$blogeditform = new blog_edit_form(null, compact('existing', 'sitecontext'));
if ($blogeditform->is_cancelled()) {
    redirect($returnurl);
} else {
    if ($blogeditform->no_submit_button_pressed()) {
        no_submit_button_actions($blogeditform, $sitecontext);
    } else {
        if ($fromform = $blogeditform->get_data()) {