Files
moodle/blocks/rss_client/config_instance.html
T
tjhunt e92c286c20 block contexts: MDL-19098 every block should have a context
even non-course and sticky blocks.

The parent context is block_instances.parentcontextid.

The block context should be used for checking permissions directly
related to the block, like moodle/block:view or moodle/site:manageblocks.

However, if the block is displaying information about the current page,
for example the participants block showing who 'here', then it may be
better to use the context of the page where the bloack is appearing -
in other words $this->page->context - to check permissions about the
user's ability to see participants here.

Or, if the block is displaying something stronly related to courses,
for example, a course meny block, the block should probably use the
context for $this->page->course to check permissions.
2009-07-13 08:37:34 +00:00

178 lines
6.4 KiB
HTML

<?php // $Id$ //
require_once($CFG->libdir .'/rsslib.php');
$id = optional_param('id', SITEID, PARAM_INT);
//create a page object for url_get_full()
$page = $this->page;
/// Print tabs at top
$currentaction = optional_param('currentaction', '', PARAM_ALPHA);
if (empty($currentaction) || $currentaction == 'configblock') {
$currentaction = 'configblock';
} else {
$currentaction = 'managefeeds';
}
include('config_instance_tabs.php');
if ($currentaction == 'configblock') {
print_box_start();
?>
<table cellpadding="9" cellspacing="0" class="blockconfigtable">
<tr valign="top">
<td class="label">
<?php print_string('displaydescriptionlabel', 'block_rss_client') ?>
</td>
<td class="value">
<?php
if(! isset($CFG->block_rss_client_display_description) ) {
$CFG->block_rss_client_display_description = '0';
}
$selected = $CFG->block_rss_client_display_description;
if (isset($this->config) && isset($this->config->display_description)) {
$selected = $this->config->display_description;
}
$options[0] = get_string('no');
$options[1] = get_string('yes');
choose_from_menu ($options, 'display_description', $selected);
?>
</td>
</tr>
<tr valign="top">
<td class="label">
<?php print_string('shownumentrieslabel', 'block_rss_client') ?>
</td>
<td class="value">
<input name="shownumentries" type="text" size="5" value="<?php
if(! isset($CFG->block_rss_client_num_entries) ) {
$CFG->block_rss_client_num_entries = '5';
}
$numentries = $CFG->block_rss_client_num_entries;
if (isset($this->config) && isset($this->config->shownumentries)) {
$numentries = intval($this->config->shownumentries);
}
p($numentries);
?>" />
</td>
</tr>
<tr valign="top">
<td class="label">
<?php print_string('choosefeedlabel', 'block_rss_client') ?>
</td>
<td class="value">
<?php
$selectedarray = array();
if (isset($this->config) && isset($this->config->rssid)) {
if (is_array($this->config->rssid)) {
// rssid is an array of rssids
$selectedarray = $this->config->rssid;
} else {
// rssid is a single rssid
$selectedarray = array($this->config->rssid);
}
}
global $USER;
if ($rssfeeds = $DB->get_records_select('block_rss_client', 'userid = ? OR shared = 1', array($USER->id))) {
foreach($rssfeeds as $rssfeed) {
if (!empty($rssfeed->preferredtitle)) {
$feedtitle = $rssfeed->preferredtitle;
} else {
$feedtitle = $rssfeed->title;
}
$checked = '';
if (in_array($rssfeed->id, $selectedarray)) {
$checked = 'checked="checked"';
}
$checkbox = '<input type="checkbox" name="rssid[]" id="rssid" value="'. $rssfeed->id .'" '. $checked .' />';
print $checkbox . $feedtitle .'<br />'."\n";
}
} else {
print_string('nofeeds', 'block_rss_client');
if (has_capability('block/rss_client:createprivatefeeds', $this->context)
|| has_capability('block/rss_client:createsharedfeeds', $this->context)) {
$addrsspage = $page->url->out(array('instanceid' => $this->instance->id,
'sesskey' => sesskey(),
'blockaction' => 'config',
'currentaction' => 'managefeeds',
'id' => $id));
print '&nbsp;<a href="'.$addrsspage.'">'. get_string('editnewsfeeds', 'block_rss_client') .'</a><br />';
}
}
?>
</td>
</tr>
<tr valign="top">
<td class="label"><?php print_string('uploadlabel'); ?></td>
<?php
$title = '';
if (!empty($this->config) && !empty($this->config->title)) {
$title = $this->config->title;
}
?>
<td class="value"><input type="text" name="title" size="30" value="<?php echo $title; ?>" />
</td>
</tr>
<tr valign="top">
<td class="label"><?php print_string('clientshowchannellinklabel', 'block_rss_client'); ?></td>
<td class="value">
<?php
if (isset($this->config) && isset($this->config->block_rss_client_show_channel_link)) {
$selected = $this->config->block_rss_client_show_channel_link;
} else {
$selected = '0';
}
$options = array ( '0' => get_string('no'),
'1' => get_string('yes') );
choose_from_menu ($options, 'block_rss_client_show_channel_link', $selected);
?>
</td>
</tr>
<tr valign="top">
<td class="label"><?php print_string('clientshowimagelabel', 'block_rss_client'); ?></td>
<td class="value">
<?php
if (isset($this->config) && isset($this->config->block_rss_client_show_channel_image)) {
$selected = $this->config->block_rss_client_show_channel_image;
} else {
$selected = '0';
}
$options = array ( '0' => get_string('no'),
'1' => get_string('yes') );
choose_from_menu ($options, 'block_rss_client_show_channel_image', $selected);
?>
</td>
</tr>
<tr>
<td colspan="2" class="submit">
<input type="submit" value="<?php print_string('savechanges') ?>" />
</td>
</tr>
</table>
<?php
print_box_end();
print "<!-- code came from " . __FILE__ . " at line " . __LINE__ . ". -->\n";
} else {
global $act, $url, $rssid, $preferredtitle, $shared;
print '</div></form></div>'; // Closes off page form
print_box_start();
rss_display_feeds($id, $USER->id, '', $context);
rss_print_form($act, $url, $rssid, $preferredtitle, $shared, $id, $this->context);
print_box_end();
}
?>