Merged from HEAD: fixing bug 4244: rss client block long titles and broken editing link. Partly backporting daryls fix, part my own fix
This commit is contained in:
@@ -23,7 +23,7 @@ define('BLOCK_RSS_SECONDARY_CACHE_ENABLED', true);
|
||||
|
||||
function init() {
|
||||
$this->title = get_string('feedstitle', 'block_rss_client');
|
||||
$this->version = 2004112000;
|
||||
$this->version = 2004112001;
|
||||
}
|
||||
|
||||
function preferred_width() {
|
||||
@@ -194,9 +194,9 @@ define('BLOCK_RSS_SECONDARY_CACHE_ENABLED', true);
|
||||
}
|
||||
|
||||
if (empty($rss_record->preferredtitle)) {
|
||||
$feedtitle = stripslashes_safe(rss_unhtmlentities($rss->channel['title']));
|
||||
$feedtitle = $this->format_title(stripslashes_safe(rss_unhtmlentities($rss->channel['title'])));
|
||||
} else {
|
||||
$feedtitle = stripslashes_safe($rss_record->preferredtitle);
|
||||
$feedtitle = $this->format_title(stripslashes_safe($rss_record->preferredtitle));
|
||||
}
|
||||
// print_object($rss);
|
||||
if (isset($this->config) &&
|
||||
@@ -269,5 +269,15 @@ define('BLOCK_RSS_SECONDARY_CACHE_ENABLED', true);
|
||||
$this->instance_config_save($this->config);
|
||||
return $returnstring;
|
||||
}
|
||||
|
||||
// just strips the title down and adds ... for excessively long titles.
|
||||
function format_title($title,$max=64) {
|
||||
if (strlen($title) <= $max) {
|
||||
return $title;
|
||||
}
|
||||
else {
|
||||
return substr($title,0,$max-3).'...';
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -74,7 +74,7 @@ if ( isset($rssid) ) {
|
||||
//assign categories to other uses than personal
|
||||
if (isset($rss_record) && !( isadmin() || $submitters == SUBMITTERS_ALL_ACCOUNT_HOLDERS ||
|
||||
($submitters == SUBMITTERS_ADMIN_AND_TEACHER && $isteacher) ||
|
||||
( ($act == 'rss_edit' || $act == 'delfeed' || $act == 'updfeed') && $USER->id == $rss_record->userid) ) ) {
|
||||
( ($act == 'rssedit' || $act == 'delfeed' || $act == 'updfeed') && $USER->id == $rss_record->userid) ) ) {
|
||||
error(get_string('noguestpost', 'forum').' You are not allowed to make modifications to this RSS feed at this time.', $referrer);
|
||||
}
|
||||
|
||||
@@ -121,6 +121,14 @@ if ($act == 'updfeed') {
|
||||
$dataobject->userid = $USER->id;
|
||||
$dataobject->description = '';
|
||||
$dataobject->title = '';
|
||||
|
||||
// attempting to replace feed and rss url types with http
|
||||
// it appears that the rss feed validator will validate these url types but magpie will not load them
|
||||
$url = str_replace ("feed://", "http://", "$url");
|
||||
$url = str_replace ("FEED://", "http://", "$url");
|
||||
$url = str_replace ("rss://", "http://", "$url");
|
||||
$url = str_replace ("RSS://", "http://", "$url");
|
||||
|
||||
$dataobject->url = addslashes($url);
|
||||
$dataobject->preferredtitle = addslashes($preferredtitle);
|
||||
|
||||
@@ -161,7 +169,7 @@ if ($act == 'updfeed') {
|
||||
rss_display_feeds($id);
|
||||
rss_print_form($act, $dataobject->url, $dataobject->id, $dataobject->preferredtitle, $id);
|
||||
*/
|
||||
} else if ( isset($rss_record) && $act == 'rss_edit' ) {
|
||||
} else if ( isset($rss_record) && $act == 'rssedit' ) {
|
||||
|
||||
$preferredtitle = stripslashes_safe($rss_record->preferredtitle);
|
||||
if (empty($preferredtitle)) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php //$Id$
|
||||
|
||||
function block_rss_client_upgrade($oldversion) {
|
||||
function rss_client_upgrade($oldversion) {
|
||||
/// This function does anything necessary to upgrade
|
||||
/// older versions to match current functionality
|
||||
|
||||
@@ -10,6 +10,12 @@ function block_rss_client_upgrade($oldversion) {
|
||||
# Do something ...
|
||||
}
|
||||
|
||||
if ($oldversion < 2004112001) {
|
||||
// title and description should be TEXT as we don't have control over their length.
|
||||
table_column('block_rss_client','title','title','text',10,'unsigned','');
|
||||
table_column('block_rss_client','description','description','text',10,'unsigned','');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
CREATE TABLE prefix_block_rss_client (
|
||||
`id` int(11) NOT NULL auto_increment,
|
||||
`userid` int(11) NOT NULL default '0',
|
||||
`title` varchar(64) NOT NULL default '',
|
||||
`title` text NOT NULL default '',
|
||||
`preferredtitle` varchar(64) NOT NULL default '',
|
||||
`description` varchar(128) NOT NULL default '',
|
||||
`description` text NOT NULL default '',
|
||||
`url` varchar(255) NOT NULL default '',
|
||||
PRIMARY KEY (`id`)
|
||||
) TYPE=MyISAM COMMENT='Remote news feed information. Contains the news feed id, the userid of the user who added the feed, the title of the feed itself and a description of the feed contents along with the url used to access the remote feed. Preferredtitle is a field for future use - intended to allow for custom titles rather than those found in the feed.';
|
||||
@@ -1,11 +1,16 @@
|
||||
<?php
|
||||
|
||||
function block_rss_client_upgrade($oldversion) {
|
||||
function rss_client_upgrade($oldversion) {
|
||||
/// This function does anything necessary to upgrade
|
||||
/// older versions to match current functionality
|
||||
|
||||
global $CFG;
|
||||
|
||||
if ($oldversion < 2004112001) {
|
||||
// title and description should be TEXT as we don't have control over their length.
|
||||
table_column('block_rss_client','title','title','text');
|
||||
table_column('block_rss_client','description','description','text');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
CREATE TABLE prefix_block_rss_client (
|
||||
id SERIAL PRIMARY KEY,
|
||||
userid INTEGER NOT NULL default '0',
|
||||
title varchar(64) NOT NULL default '',
|
||||
title text NOT NULL default '',
|
||||
preferredtitle varchar(64) NOT NULL default '',
|
||||
description varchar(128) NOT NULL default '',
|
||||
description text NOT NULL default '',
|
||||
url varchar(255) NOT NULL default ''
|
||||
);
|
||||
|
||||
+17
-17
@@ -333,9 +333,9 @@ define('MAGPIE_CACHE_ON', true); //might want to expose as an admin config optio
|
||||
define('MAGPIE_CACHE_FRESH_ONLY', false); //should be exposed as an admin config option
|
||||
define('MAGPIE_CACHE_AGE', $CFG->block_rss_timeout);
|
||||
if ($CFG->debug) {
|
||||
define('MAGPIE_DEBUG', true);
|
||||
define('MAGPIE_DEBUG', $CFG->debug); // magpie, like moodle, takes an integer debug
|
||||
} else {
|
||||
define('MAGPIE_DEBUG', false);
|
||||
define('MAGPIE_DEBUG', 0); // 0 is DEBUG off for magpie
|
||||
}
|
||||
|
||||
// defines for config var block_rss_client_submitters
|
||||
@@ -357,12 +357,12 @@ function rss_display_feeds($courseid='', $userid='', $rssid='') {
|
||||
$select = '';
|
||||
|
||||
if (!isadmin()) {
|
||||
$userid = $USER->id;
|
||||
$userid = $USER->id;
|
||||
}
|
||||
|
||||
if ($userid != '' && is_numeric($userid)) {
|
||||
// if a user is specified and not an admin then only show their own feeds
|
||||
$select = 'userid='. $userid;
|
||||
// if a user is specified and not an admin then only show their own feeds
|
||||
$select = 'userid='. $userid;
|
||||
} else if ($rssid != ''){
|
||||
$select = 'id='. $rssid;
|
||||
}
|
||||
@@ -393,19 +393,18 @@ function rss_display_feeds($courseid='', $userid='', $rssid='') {
|
||||
|
||||
if ($feed->userid == $USER->id || isadmin()) {
|
||||
|
||||
$feedicons = '<a href="'. $CFG->wwwroot .'/blocks/rss_client/block_rss_client_action.php?id='. $courseid .'&act=rss_edit&rssid='. $feed->id .'&blogid='. $blogid .'">'.
|
||||
$feedicons = '<a href="'. $CFG->wwwroot .'/blocks/rss_client/block_rss_client_action.php?id='. $courseid .'&act=rssedit&rssid='. $feed->id .'&blogid='. $blogid .'">'.
|
||||
'<img src="'. $CFG->pixpath .'/t/edit.gif" alt="'. get_string('edit').'" title="'. get_string('edit') .'" /></a> '.
|
||||
|
||||
'<a href="'. $CFG->wwwroot .'/blocks/rss_client/block_rss_client_action.php?id='. $courseid .'&act=delfeed&rssid='. $feed->id.'&blogid='. $blogid .'"
|
||||
onclick="return confirm(\''. get_string('deletefeedconfirm', 'block_rss_client') .'\');">'.
|
||||
onclick="return confirm(\''. get_string('deletefeedconfirm', 'block_rss_client') .'\');">'.
|
||||
'<img src="'. $CFG->pixpath .'/t/delete.gif" alt="'. get_string('delete').'" title="'. get_string('delete') .'" /></a>';
|
||||
}
|
||||
else {
|
||||
$feedicons = '';
|
||||
}
|
||||
|
||||
$feedinfo = '<div class="title"><a href="'. $CFG->wwwroot .'/blocks/rss_client/block_rss_client_action.php?id='. $courseid .'&act=view&rssid='.$feed->id .'&blogid='. $blogid .'">'
|
||||
.$feedtitle .'</a></div><div class="url"><a href="'. $feed->url .'">'. $feed->url .'</a></div><div class="description">'.$feed->description.'</div>';
|
||||
$feedinfo = '<div class="title"><a href="'. $CFG->wwwroot .'/blocks/rss_client/block_rss_client_action.php?id='. $courseid .'&act=view&rssid='.$feed->id .'&blogid='. $blogid .'">'. $feedtitle .'</a></div><div class="url"><a href="'. $feed->url .'">'. $feed->url .'</a></div><div class="description">'.$feed->description.'</div>';
|
||||
|
||||
$table->add_data(array($feedinfo, $feedicons));
|
||||
}
|
||||
@@ -434,7 +433,7 @@ function rss_print_form($act='none', $url='', $rssid='', $preferredtitle='', $co
|
||||
}
|
||||
/**
|
||||
* Prints or returns a form for managing rss feed entries.
|
||||
* @param string $act The current action. If "rss_edit" then and "update" button is used, otherwise "add" is used.
|
||||
* @param string $act The current action. If "rssedit" then and "update" button is used, otherwise "add" is used.
|
||||
* @param string $url The url of the feed that is being updated or NULL
|
||||
* @param int $rssid The dataabse id of the feed that is being updated or NULL
|
||||
* @param int $id The id of the course that is currently being viewed if applicable
|
||||
@@ -451,36 +450,37 @@ function rss_get_form($act='none', $url='', $rssid='', $preferredtitle='', $cour
|
||||
$returnstring = '<table align="center"><tbody><tr><td>'."\n";
|
||||
$returnstring .= '<form action="'. $CFG->wwwroot .'/blocks/rss_client/block_rss_client_action.php" method="POST" name="block_rss">'."\n";
|
||||
|
||||
if ($act == 'rss_edit') {
|
||||
if ($act == 'rssedit') {
|
||||
$returnstring .= $strupdatefeed;
|
||||
} else {
|
||||
$returnstring .= $straddfeed;
|
||||
}
|
||||
|
||||
$returnstring .= "\n".'<br /><input type="text" size="60" maxlength="256" name="url" value="';
|
||||
if ($act == 'rss_edit') {
|
||||
if ($act == 'rssedit') {
|
||||
$returnstring .= $url;
|
||||
}
|
||||
|
||||
$returnstring .= '" />'."\n";
|
||||
$returnstring .= '<br />'. get_string('customtitlelabel', 'block_rss_client');
|
||||
$returnstring .= '<br /><input type="text" size="60" maxlength="64" name="preferredtitle" value="';
|
||||
// $returnstring .= '<br /><input type="text" size="60" maxlength="64" name="preferredtitle" value="';
|
||||
$returnstring .= '<br /><input type="text" size="60" maxlength="128" name="preferredtitle" value="';
|
||||
|
||||
if ($act == 'rss_edit') {
|
||||
if ($act == 'rssedit') {
|
||||
$returnstring .= $preferredtitle;
|
||||
}
|
||||
|
||||
$returnstring .= '" />'."\n";
|
||||
$returnstring .= '<input type="hidden" name="act" value="';
|
||||
|
||||
if ($act == 'rss_edit') {
|
||||
if ($act == 'rssedit') {
|
||||
$returnstring .= 'updfeed';
|
||||
} else {
|
||||
$returnstring .= 'addfeed';
|
||||
}
|
||||
|
||||
$returnstring .= '" />'."\n";
|
||||
if ($act == 'rss_edit') {
|
||||
if ($act == 'rssedit') {
|
||||
$returnstring .= '<input type="hidden" name="rssid" value="'. $rssid .'" />'. "\n";
|
||||
}
|
||||
|
||||
@@ -491,7 +491,7 @@ function rss_get_form($act='none', $url='', $rssid='', $preferredtitle='', $cour
|
||||
$validatestring = "<a href=\"#\"
|
||||
onClick=\"window.open('http://feedvalidator.org/check.cgi?url='+document.block_rss.elements['url'].value,'validate','width=640,height=480,scrollbars=yes,status=yes,resizable=yes');return true;\">". get_string('validatefeed', 'block_rss_client')."</a>";
|
||||
|
||||
if ($act == 'rss_edit') {
|
||||
if ($act == 'rssedit') {
|
||||
$returnstring .= $stredit;
|
||||
} else {
|
||||
$returnstring .= $stradd;
|
||||
|
||||
Reference in New Issue
Block a user