MDL-20219 Deleted external blog block, and preferences link from blog_menu block. Placed these as links in settings block instead

This commit is contained in:
nicolasconnault 2009-09-15 07:57:54 +00:00
parent ca497f4f7c
commit 2367726155
6 changed files with 17 additions and 106 deletions

View File

@ -1,92 +0,0 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Block for managing external blogs. This block will appear only on a user's blog page, not
* on any other blog listing page (site, course, module etc). It may be filtered by tag.
*
* @package moodlecore
* @subpackage blog
* @copyright 2009 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once($CFG->dirroot .'/blog/lib.php');
/**
* External Blog Block class
*/
class block_blog_externals extends block_base {
function init() {
global $USER, $DB;
$this->title = get_string('blockexternalstitle', 'blog');
$this->content_type = BLOCK_TYPE_TEXT;
$this->version = 2009101509;
// See if a deletion has been requested
$delete = optional_param('delete_blog_external', false, PARAM_INT);
if ($delete && ($external_blog = $DB->get_record('blog_external', array('id' => $delete)))) {
// Check caps and userid matching $USER->id
if ($external_blog->userid == $USER->id) {
$DB->delete_records('blog_external', array('id' => $delete));
}
}
}
function get_content() {
global $CFG, $USER, $DB, $PAGE, $OUTPUT;
// This block should not appear if $CFG->useexternalblogs is off
if (empty($CFG->bloglevel)) {
$this->content->text = '';
return $this->content;
}
// don't display menu block if block is set at site level, and user is not logged in
if ($CFG->bloglevel < BLOG_GLOBAL_LEVEL && !(isloggedin() && !isguest())) {
$this->content->text = '';
return $this->content;
}
$output = '';
$this->content = new stdClass;
$this->content->footer = '';
$external_blogs = $DB->get_records('blog_external', array('userid' => $USER->id));
$external_blog_url = $CFG->wwwroot.'/blog/external.php?returnurl='.urlencode($PAGE->url->out());
foreach ($external_blogs as $id => $eb) {
$strdelete = get_string('delete') . " $eb->name";
$delete_url = new moodle_url();
$delete_url->param('delete_blog_external', $id);
$deleteicon = '<a href="'.$delete_url->out().'" class="delete">' .
'<img src="'.$OUTPUT->old_icon_url('t/delete').'" alt="'.$strdelete.'" title="'.$strdelete.'" />' .
"</a>\n";
$output .= '<li><a href="'.$external_blog_url.'&amp;id='.$id.'" title="'.$eb->name.'">'.shorten_text($eb->name, 20)."</a>$deleteicon</li>\n";
}
$this->content->text = '<ul class="list">'. $output ."</ul>\n";
$this->content->text .= '<div class="newlink"><a href="'.$external_blog_url.'">'.get_string('addnewexternalblog', 'blog').'</a></div>';
return $this->content;
}
}

View File

@ -120,11 +120,6 @@ class block_blog_menu extends block_base {
$menulist->add_item($OUTPUT->link($myentrieslink));
}
// show link to manage blog prefs
$blogpreflink = html_link::make(new moodle_url($CFG->wwwroot .'/blog/preferences.php', array('userid' => $USER->id)), get_string('blogpreferences', 'blog'));
$blogpreflink->disableifcurrent = true;
$menulist->add_item($OUTPUT->link($blogpreflink));
// show Add entry link
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
if (has_capability('moodle/blog:create', $sitecontext)) {

View File

@ -208,6 +208,7 @@ if (!empty($entryid)) {
$filters['entry'] = $entryid;
}
$blogheaders = blog_get_headers();
blog_extend_settings_navigation($PAGE->settingsnav);
// prints the tabs
$showroles = !empty($userid);

View File

@ -597,3 +597,17 @@ function blog_get_headers() {
return $headers;
}
function blog_extend_settings_navigation($settingsnav) {
global $USER, $PAGE, $FULLME, $CFG, $DB, $OUTPUT;
$blogkey = $settingsnav->add(get_string('blogadministration', 'blog'));
$blog = $settingsnav->get($blogkey);
$blog->forceopen = true;
$blog->add(get_string('preferences', 'blog'), new moodle_url('preferences.php'), navigation_node::TYPE_SETTING);
if ($CFG->useexternalblogs && $CFG->maxexternalblogsperuser > 0) {
$blog->add(get_string('externalblogs', 'blog'), new moodle_url('external.php'), navigation_node::TYPE_SETTING);
}
return $blogkey;
}

View File

@ -13,6 +13,7 @@ $string['blockrecenttitle'] = 'Recent Blog Entries';
$string['blocktagstitle'] = 'Blog Tags';
$string['blocktitle'] = 'Blog tags block title';
$string['blog'] = 'Blog';
$string['blogadministration'] = 'Blog administration';
$string['blogdeleteconfirm'] = 'Delete this blog?';
$string['blogdisable'] = 'Blogging is disabled!';
$string['blogentries'] = 'Blog entries';
@ -73,6 +74,7 @@ $string['numberoftags'] = 'Number of tags to display';
$string['pagesize'] = 'Number of blog entries per Page';
$string['permalink'] = 'Permalink';
$string['personalblogs'] = 'Users can only see their own blog';
$string['preferences'] = 'Preferences';
$string['publishto'] = 'Publish to';
$string['publishtocourse'] = 'Users sharing a course with you';
$string['publishtocourseassoc'] = 'Members of the associated course';

View File

@ -1993,15 +1993,6 @@ body.has_navigation_bar {
width: auto;
}
.block_blog_externals a.delete {
margin-left: 6px;
}
.block_blog_externals div.newlink {
margin-top: 10px;
text-align: center;
width: 100%;
}
/***
*** Calendar
***/