RSS client block: users can now add their own rss feeds and pick from their feeds and admin feeds. users don't see feeds added by other nonadmin users. this is probably only useful for my moodle since they can't edit any other pages

This commit is contained in:
mjollnir_ 2006-01-16 03:02:42 +00:00
parent 33a9fd4745
commit d5250d2f13
3 changed files with 25 additions and 13 deletions

View File

@ -103,14 +103,16 @@ define('BLOCK_RSS_SECONDARY_CACHE_ENABLED', true);
if ( $userisloggedin && ($submitters == SUBMITTERS_ALL_ACCOUNT_HOLDERS || ($submitters == SUBMITTERS_ADMIN_AND_TEACHER && $isteacher)) ) {
$page = page_create_object($this->instance->pagetype, $this->instance->pageid);
if (isset($this->config)) {
// this instance is configured - show Add/Edit feeds link
$script = $page->url_get_full(array('instanceid' => $this->instance->id, 'sesskey' => $USER->sesskey, 'blockaction' => 'config', 'currentaction' => 'managefeeds', 'id' => $this->courseid));
$output .= '<div align="center"><a title="'. get_string('feedsaddedit', 'block_rss_client') .'" href="'. $script .'">'. get_string('feedsaddedit', 'block_rss_client') .'</a></div>';
} else {
// this instance has not been configured yet - show configure link
$script = $page->url_get_full(array('instanceid' => $this->instance->id, 'sesskey' => $USER->sesskey, 'blockaction' => 'config', 'currentaction' => 'configblock', 'id' => $this->courseid));
$output .= '<div align="center"><a title="'. get_string('feedsconfigurenewinstance', 'block_rss_client') .'" href="'. $script.'">'. get_string('feedsconfigurenewinstance', 'block_rss_client') .'</a></div>';
if ($page->user_allowed_editing()) { // for SUBMITTERS_ALL_ACCOUNT_HOLDERS we're going to run into trouble later if we show it and then they don't have write access to the page.
if (isset($this->config)) {
// this instance is configured - show Add/Edit feeds link
$script = $page->url_get_full(array('instanceid' => $this->instance->id, 'sesskey' => $USER->sesskey, 'blockaction' => 'config', 'currentaction' => 'managefeeds', 'id' => $this->courseid));
$output .= '<div align="center"><a title="'. get_string('feedsaddedit', 'block_rss_client') .'" href="'. $script .'">'. get_string('feedsaddedit', 'block_rss_client') .'</a></div>';
} else {
// this instance has not been configured yet - show configure link
$script = $page->url_get_full(array('instanceid' => $this->instance->id, 'sesskey' => $USER->sesskey, 'blockaction' => 'config', 'currentaction' => 'configblock', 'id' => $this->courseid));
$output .= '<div align="center"><a title="'. get_string('feedsconfigurenewinstance', 'block_rss_client') .'" href="'. $script.'">'. get_string('feedsconfigurenewinstance', 'block_rss_client') .'</a></div>';
}
}
}

View File

@ -42,13 +42,15 @@
$selected = '0';
$CFG->block_rss_client_submitters = 0;
}
// SUBMITTERS_ALL_ACCOUNT_HOLDERS => get_string('everybody')
// removed everybody option for 1.5 beta
// 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 ( SUBMITTERS_ADMIN_ONLY => get_string('administrators'),
SUBMITTERS_ADMIN_AND_TEACHER => get_string('administratorsandteachers') );
$options = array (
SUBMITTERS_ALL_ACCOUNT_HOLDERS => get_string('everybody'),
SUBMITTERS_ADMIN_ONLY => get_string('administrators'),
SUBMITTERS_ADMIN_AND_TEACHER => get_string('administratorsandteachers') );
choose_from_menu ($options, 'block_rss_client_submitters', $selected);
?>

View File

@ -74,7 +74,15 @@ if ($currentaction == 'configblock') {
$selectedarray = array($this->config->rssid);
}
}
if ($rssfeeds = get_records('block_rss_client')) {
global $USER;
$admins = get_admins();
$adminsql = '';
if (!empty($admins)) {
foreach ($admins as $admin) {
$adminsql = ' OR userid = '.$admin->id;
}
}
if ($rssfeeds = get_records_select('block_rss_client','userid = '.$USER->id . $adminsql)) {
foreach($rssfeeds as $rssfeed) {
if (!empty($rssfeed->preferredtitle)) {
$feedtitle = stripslashes_safe($rssfeed->preferredtitle);
@ -158,7 +166,7 @@ if ($currentaction == 'configblock') {
global $act, $url, $rssid, $preferredtitle;
print '<table cellpadding="9" cellspacing="0" class="blockconfigtable">';
print '<tr valign="top"><td>';
rss_display_feeds($id);
rss_display_feeds($id,$USER->id);
print '</form>'; //not sure that this is needed
rss_print_form($act, $url, $rssid, $preferredtitle, $id);
print '</td></tr></table>';