/**
* This class is for a block which defines a block for display on
- * any Moodle page.
+ * any Moodle page.
*/
class block_rss_client extends block_base {
function get_content() {
global $CFG, $editing, $COURSE, $USER;
-
+
if (!empty($COURSE)) {
$this->courseid = $COURSE->id;
}
if (!empty($this->config)) {
if (!empty($this->config->rssid)) {
- if (is_array($this->config->rssid)) {
+ if (is_array($this->config->rssid)) {
$rssidarray = $this->config->rssid;
} else { // Make an array of the single value
$rssidarray = array($this->config->rssid);
$shownumentries = intval($this->config->shownumentries);
}
}
-
+
$context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
-
+
if (has_capability('block/rss_client:createsharedfeeds', $context)
|| has_capability('block/rss_client:createprivatefeeds', $context)) {
return '<a href="'. $CFG->wwwroot .'/blocks/rss_client/block_rss_client_error.php?error='. urlencode($rsserror) .'">Error loading a feed.</a><br />'; //Daryl Hawes note: localize this line
}
}
-
+
if ($shownumentries > 0 && $shownumentries < count($rss->items) ) {
$rss->items = array_slice($rss->items, 0, $shownumentries);
}
$feedtitle = $this->format_title($rss_record->preferredtitle);
}
// print_object($rss);
- if (isset($this->config) &&
- isset($this->config->block_rss_client_show_channel_image) &&
+ if (isset($this->config) &&
+ isset($this->config->block_rss_client_show_channel_image) &&
$this->config->block_rss_client_show_channel_image &&
isset($rss->image) && isset($rss->image['link']) && isset($rss->image['title']) && isset($rss->image['url']) ) {
$returnstring .= "\n".'<div class="image" title="'. $rss->image['title'] .'"><a href="'. $rss->image['link'] .'"><img src="'. $rss->image['url'] .'" alt="'. $rss->image['title'] .'" /></a></div>';
if ($display_description && !empty($item['description'])) {
$item['description'] = break_up_long_words($item['description'], 30);
$returnstring .= '<div class="description">'.
- format_text($item['description'], FORMAT_MOODLE, $formatoptions, $this->courseid) .
+ format_text($item['description'], FORMAT_MOODLE, $formatoptions, $this->courseid) .
'</div>';
}
$returnstring .= "</li>\n";
if (!empty($rss->channel['link'])) {
$rss->channel['link'] = str_replace('&', '&', $rss->channel['link']);
-
+
if (!empty($this->config) && isset($this->config->block_rss_client_show_channel_link) && $this->config->block_rss_client_show_channel_link) {
$this->content->footer = '<a href="'. $rss->channel['link'] .'">'. get_string('clientchannellink', 'block_rss_client') .'</a>';
}
if ($act == 'updfeed') {
-
+
if (!$managefeeds) {
error(get_string('noguestpost', 'forum').
' You are not allowed to make modifications to this RSS feed at this time.',
$referrer);
}
-
-
+
+
if (empty($url)) {
error( 'URL not defined for rss feed' );
}
redirect($referrer, $message);
} else if ($act == 'addfeed' ) {
-
+
$canaddprivfeeds = has_capability('block/rss_client:createprivatefeeds', $context);
$canaddsharedfeeds = has_capability('block/rss_client:createsharedfeeds', $context);
-
+
if (!$canaddprivfeeds && !$canaddsharedfeeds) {
error('You do not have the permission to add RSS feeds');
}
$dataobject->title = '';
$dataobject->url = addslashes($url);
$dataobject->preferredtitle = addslashes($preferredtitle);
-
+
if ($shared == 1 && $canaddsharedfeeds) {
$dataobject->shared = 1;
} else {
$dataobject->shared = 0;
}
-
+
$rssid = insert_record('block_rss_client', $dataobject);
if (!$rssid) {
error('There was an error trying to add a new rss feed:'. $url);
}
if (!empty($rss->channel['title'])) {
$dataobject->title = addslashes($rss->channel['title']);
- }
+ }
if (!update_record('block_rss_client', $dataobject)) {
error('There was an error trying to update rss feed with id:'. $rssid);
}
rss_print_form($act, $url, $rssid, $preferredtitle, $shared, $id, $context);
} else if ($act == 'delfeed') {
-
+
if (!$managefeeds) {
error(get_string('noguestpost', 'forum').
' You are not allowed to make modifications to this RSS feed at this time.',
if (file_exists($CFG->dirroot .'/blog/lib.php')) {
//Blog module is installed - provide "blog this" link
print '<td align="right">'."\n";
-
+
/// MDL-9291, blog this feature needs further discussion/implementation
/// temporarily disabling for now.
-
+
// print '<img src="'. $CFG->pixpath .'/blog/blog.gif" alt="'. get_string('blogthis', 'blog').'" title="'. get_string('blogthis', 'blog') .'" border="0" align="middle" />'."\n";
//print '<a href="'. $CFG->wwwroot .'/blog/blogthis.php?userid='. $USER->id .'&act=use&item='. $y .'&rssid='. $rssid .'"><small><strong>'. get_string('blogthis', 'blog') .'</strong></small></a>'."\n";
} else {
$error = required_param('error', PARAM_CLEAN);
-print_header(get_string('error'),
- get_string('error'),
+print_header(get_string('error'),
+ get_string('error'),
get_string('error') );
print clean_text(urldecode($error));
print_footer();
-?>
\ No newline at end of file
+?>
<td align="right">block_rss_client_num_entries:</td>
<td>
<input name="block" type="hidden" value="<?php echo intval($_REQUEST['block']); ?>" />
- <input name="block_rss_client_num_entries" type="text" size="5" value="<?php
+ <input name="block_rss_client_num_entries" type="text" size="5" value="<?php
if(isset($CFG->block_rss_client_num_entries)) {
p($CFG->block_rss_client_num_entries);
} else {
<tr valign="top">
<td align="right">block_rss_timeout:</td>
<td>
- <input name="block_rss_timeout" type="text" size="5" value="<?php
+ <input name="block_rss_timeout" type="text" size="5" value="<?php
if(isset($CFG->block_rss_timeout)) {
p($CFG->block_rss_timeout);
} else {
// things are not quite working yet to allow this - revisit later
// also 'everybody' should be 'site members' or something clearer since
// it does not include guests
- $options = array (
+ $options = array (
SUBMITTERS_ALL_ACCOUNT_HOLDERS => get_string('everybody'),
SUBMITTERS_ADMIN_ONLY => get_string('administrators'),
SUBMITTERS_ADMIN_AND_TEACHER => get_string('administratorsandteachers') );
<input type="submit" value="<?php print_string('savechanges') ?>" /></td>
</tr>
<tr>
- <td colspan="3" align="center"><a href=" <?php echo $CFG->wwwroot; ?>/blocks/rss_client/block_rss_client_action.php?id=<?php
+ <td colspan="3" align="center"><a href=" <?php echo $CFG->wwwroot; ?>/blocks/rss_client/block_rss_client_action.php?id=<?php
if (!isset($id)) {
$id = '';
}
<?php print_string('displaydescriptionlabel', 'block_rss_client') ?>
</td>
<td class="value">
- <?php
+ <?php
if(! isset($CFG->block_rss_client_display_description) ) {
$CFG->block_rss_client_display_description = '0';
}
<?php print_string('choosefeedlabel', 'block_rss_client') ?>
</td>
<td class="value">
- <?php
+ <?php
$selectedarray = array();
if (isset($this->config) && isset($this->config->rssid)) {
if (is_array($this->config->rssid)) {
}
}
global $USER;
-
+
if ($rssfeeds = get_records_select('block_rss_client', 'userid = '.$USER->id.' OR shared = 1')) {
foreach($rssfeeds as $rssfeed) {
if (!empty($rssfeed->preferredtitle)) {
$feedtitle = stripslashes_safe($rssfeed->preferredtitle);
} else {
$feedtitle = stripslashes_safe($rssfeed->title);
- }
+ }
$checked = '';
if (in_array($rssfeed->id, $selectedarray)) {
$checked = 'checked="checked"';
} else {
$context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
print_string('nofeeds', 'block_rss_client');
-
+
if (has_capability('block/rss_client:createprivatefeeds', $context)
|| has_capability('block/rss_client:createsharedfeeds', $context)) {
-
+
$addrsspage = $page->url_get_full(array('instanceid' => $this->instance->id,
'sesskey' => $USER->sesskey,
'blockaction' => 'config',
<tr valign="top">
<td class="label"><?php print_string('uploadlabel'); ?></td>
- <?php
+ <?php
$title = '';
if (!empty($this->config) && !empty($this->config->title)) {
$title = $this->config->title;
if (has_capability('moodle/site:manageblocks', $context)) {
$script = $page->url_get_full(array('instanceid' => $this->instance->id, 'sesskey' => $USER->sesskey, 'blockaction' => 'config', 'currentaction' => 'configblock', 'id' => $id, 'section' => 'rss'));
- $row[] = new tabobject('configblock', $script,
+ $row[] = new tabobject('configblock', $script,
get_string('configblock', 'block_rss_client'));
}
$script = $page->url_get_full(array('instanceid' => $this->instance->id, 'sesskey' => $USER->sesskey, 'blockaction' => 'config', 'currentaction' => 'managefeeds', 'id' => $id, 'section' => 'rss'));
-$row[] = new tabobject('managefeeds', $script,
+$row[] = new tabobject('managefeeds', $script,
get_string('managefeeds', 'block_rss_client'));
$tabs[] = $row;