forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
nicolasconnault
committed
Sep 4, 2009
1 parent
5fc6d58
commit cae8370
Showing
46 changed files
with
3,908 additions
and
1,126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?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.'&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; | ||
} | ||
} |
Oops, something went wrong.