mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
fixing rsslib, and added code to check if rss not enabled, blog rss button will not be printed
This commit is contained in:
parent
5046492815
commit
bd70af134d
2 changed files with 22 additions and 37 deletions
42
blog/lib.php
42
blog/lib.php
|
@ -32,18 +32,6 @@
|
||||||
$SESSION->blog_editing_enabled = false;
|
$SESSION->blog_editing_enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Verify that a user is logged in based on the session
|
|
||||||
* @return bool True if user has a valid login session
|
|
||||||
*/
|
|
||||||
function blog_isLoggedIn() {
|
|
||||||
global $USER;
|
|
||||||
if (!isguest() && isset($USER) and isset($USER->id) and $USER->id) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* blog_user_has_rights - returns true if user is the blog's owner or a moodle admin.
|
* blog_user_has_rights - returns true if user is the blog's owner or a moodle admin.
|
||||||
*
|
*
|
||||||
|
@ -137,10 +125,12 @@
|
||||||
|
|
||||||
print_paging_bar(get_viewable_entry_count($userid, $postid, $limit, $start,$filtertype, $filterselect, $tagid, $tag, $sort='lastmodified DESC'), $blogpage, $bloglimit, get_baseurl($filtertype, $filterselect), 'blogpage');
|
print_paging_bar(get_viewable_entry_count($userid, $postid, $limit, $start,$filtertype, $filterselect, $tagid, $tag, $sort='lastmodified DESC'), $blogpage, $bloglimit, get_baseurl($filtertype, $filterselect), 'blogpage');
|
||||||
|
|
||||||
|
if ($CFG->enablerssfeeds) {
|
||||||
blog_rss_print_link($filtertype, $filterselect, $tag);
|
blog_rss_print_link($filtertype, $filterselect, $tag);
|
||||||
|
}
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
if (blog_isLoggedIn()) {
|
if (isloggedin() && !isguest()) {
|
||||||
//the user's blog is enabled and they are viewing their own blog
|
//the user's blog is enabled and they are viewing their own blog
|
||||||
$addlink = '<div align="center">';
|
$addlink = '<div align="center">';
|
||||||
$addlink .= '<a href="'.$CFG->wwwroot .'/blog/edit.php'.'">'. get_string('addnewentry', 'blog').'</a>';
|
$addlink .= '<a href="'.$CFG->wwwroot .'/blog/edit.php'.'">'. get_string('addnewentry', 'blog').'</a>';
|
||||||
|
@ -185,40 +175,33 @@
|
||||||
* display the entry in its abbreviated format (eg. index page)
|
* display the entry in its abbreviated format (eg. index page)
|
||||||
*/
|
*/
|
||||||
function blog_print_entry($blogEntry, $viewtype='full', $filtertype='', $filterselect='', $mode='loud') {
|
function blog_print_entry($blogEntry, $viewtype='full', $filtertype='', $filterselect='', $mode='loud') {
|
||||||
global $CFG, $THEME, $USER;
|
|
||||||
|
global $USER, $CFG, $course, $ME;
|
||||||
|
|
||||||
$template['body'] = get_formatted_entry_body($blogEntry->summary, $blogEntry->format);
|
$template['body'] = get_formatted_entry_body($blogEntry->summary, $blogEntry->format);
|
||||||
$template['countofextendedbody'] = 0;
|
|
||||||
|
|
||||||
$template['title'] = '<a name="'. $blogEntry->subject .'"></a>';
|
$template['title'] = '<a name="'. $blogEntry->subject .'"></a>';
|
||||||
//enclose the title in nolink tags so that moodle formatting doesn't autolink the text
|
//enclose the title in nolink tags so that moodle formatting doesn't autolink the text
|
||||||
$template['title'] .= '<span class="nolink">'. stripslashes_safe($blogEntry->subject);
|
$template['title'] .= '<span class="nolink">'. stripslashes_safe($blogEntry->subject);
|
||||||
$template['title'] .= '</span>';
|
$template['title'] .= '</span>';
|
||||||
|
|
||||||
// add editing controls if allowed
|
|
||||||
$template['userid'] = $blogEntry->userid;
|
$template['userid'] = $blogEntry->userid;
|
||||||
$template['author'] = fullname(get_record('user','id',$blogEntry->userid));
|
$template['author'] = fullname(get_record('user','id',$blogEntry->userid));
|
||||||
$template['lastmod'] = userdate($blogEntry->lastmodified);
|
$template['lastmod'] = userdate($blogEntry->lastmodified);
|
||||||
$template['created'] = userdate($blogEntry->created);
|
$template['created'] = userdate($blogEntry->created);
|
||||||
|
$template['publishstate'] = $blogEntry->publishstate;
|
||||||
|
|
||||||
/// preventing user to browse blogs that they aren't supposed to see
|
/// preventing user to browse blogs that they aren't supposed to see
|
||||||
if (!blog_user_can_view_user_post($template['userid'])) {
|
if (!blog_user_can_view_user_post($template['userid'])) {
|
||||||
error ('you can not view this post');
|
error ('you can not view this post');
|
||||||
}
|
}
|
||||||
blog_print_entry_content ($template, $blogEntry->id, $filtertype, $filterselect, $mode);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//forum style printing of blogs
|
|
||||||
function blog_print_entry_content ($template, $entryid, $filtertype='', $filterselect='', $mode='loud') {
|
|
||||||
global $USER, $CFG, $course, $ME;
|
|
||||||
|
|
||||||
$stredit = get_string('edit');
|
$stredit = get_string('edit');
|
||||||
$strdelete = get_string('delete');
|
$strdelete = get_string('delete');
|
||||||
|
|
||||||
$user = get_record('user','id',$template['userid']);
|
$user = get_record('user','id',$template['userid']);
|
||||||
|
|
||||||
echo '<div align="center"><table cellspacing="0" class="forumpost" width="100%">';
|
/// Start printing of the blog
|
||||||
|
|
||||||
|
echo '<div align="center"><table cellspacing="0" class="forumpost blogpost blog_'.$template['publishstate'].'" width="100%">';
|
||||||
|
|
||||||
echo '<tr class="header"><td class="picture left">';
|
echo '<tr class="header"><td class="picture left">';
|
||||||
print_user_picture($template['userid'], SITEID, $user->picture);
|
print_user_picture($template['userid'], SITEID, $user->picture);
|
||||||
|
@ -245,7 +228,7 @@
|
||||||
|
|
||||||
if ($blogtags = get_records_sql('SELECT t.* FROM '.$CFG->prefix.'tags t, '.$CFG->prefix.'blog_tag_instance ti
|
if ($blogtags = get_records_sql('SELECT t.* FROM '.$CFG->prefix.'tags t, '.$CFG->prefix.'blog_tag_instance ti
|
||||||
WHERE t.id = ti.tagid
|
WHERE t.id = ti.tagid
|
||||||
AND ti.entryid = '.$entryid)) {
|
AND ti.entryid = '.$blogEntry->id)) {
|
||||||
echo '<p />';
|
echo '<p />';
|
||||||
print_string('tags');
|
print_string('tags');
|
||||||
echo ': ';
|
echo ': ';
|
||||||
|
@ -261,17 +244,18 @@
|
||||||
|
|
||||||
if (isset($USER->id)) {
|
if (isset($USER->id)) {
|
||||||
if (($template['userid'] == $USER->id) or isadmin()) {
|
if (($template['userid'] == $USER->id) or isadmin()) {
|
||||||
echo '<a href="'.$CFG->wwwroot.'/blog/edit.php?editid='.$entryid.'&sesskey='.sesskey().'">'.$stredit.'</a>';
|
echo '<a href="'.$CFG->wwwroot.'/blog/edit.php?editid='.$blogEntry->id.'&sesskey='.sesskey().'">'.$stredit.'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($template['userid'] == $USER->id) or isadmin()) {
|
if (($template['userid'] == $USER->id) or isadmin()) {
|
||||||
echo '| <a href="'.$CFG->wwwroot.'/blog/edit.php?act=del&editid='.$entryid.'&sesskey='.sesskey().'">'.$strdelete.'</a>';
|
echo '| <a href="'.$CFG->wwwroot.'/blog/edit.php?act=del&editid='.$blogEntry->id.'&sesskey='.sesskey().'">'.$strdelete.'</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
|
|
||||||
echo '</td></tr></table></div>'."\n\n";
|
echo '</td></tr></table></div>'."\n\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -69,19 +69,20 @@
|
||||||
|
|
||||||
/// Get all the posts from the database
|
/// Get all the posts from the database
|
||||||
|
|
||||||
$blogFilter =& new BlogFilter(0, 0, 20, 0, $type, $id, $tagid);
|
//$blogFilter =& new BlogFilter(0, 0, 20, 0, $type, $id, $tagid);
|
||||||
$blogposts = $blogFilter->fetch_entries();
|
|
||||||
|
$blogposts = fetch_entries(0, 0, 20, 0, $type, $id, $tagid); //$blogFilter->fetch_entries();
|
||||||
|
|
||||||
/// Now generate an array of RSS items
|
/// Now generate an array of RSS items
|
||||||
if ($blogposts) {
|
if ($blogposts) {
|
||||||
$items = array();
|
$items = array();
|
||||||
foreach ($blogposts as $blogpost) {
|
foreach ($blogposts as $blogpost) {
|
||||||
$item = NULL;
|
$item = NULL;
|
||||||
$item->author = $blogpost->entryAuthorName;
|
$item->author = fullname(get_record('user','id',$blogpost->userid));
|
||||||
$item->title = $blogpost->entryTitle;
|
$item->title = $blogpost->subject;
|
||||||
$item->pubdate = $blogpost->entryLastModified;
|
$item->pubdate = $blogpost->lastmodified;
|
||||||
$item->link = $CFG->wwwroot.'/blog/index.php?postid='.$blogpost->entryId;
|
$item->link = $CFG->wwwroot.'/blog/index.php?postid='.$blogpost->id;
|
||||||
$item->description = format_text($blogpost->entryBody, $blogpost->entryFormat);
|
$item->description = format_text($blogpost->summary, $blogpost->format);
|
||||||
$items[] = $item;
|
$items[] = $item;
|
||||||
}
|
}
|
||||||
$articles = rss_add_items($items); /// Change structure to XML
|
$articles = rss_add_items($items); /// Change structure to XML
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue