diff --git a/blocks/rss_client/block_rss_client.php b/blocks/rss_client/block_rss_client.php index 665c86699be..718e0d288df 100644 --- a/blocks/rss_client/block_rss_client.php +++ b/blocks/rss_client/block_rss_client.php @@ -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).'...'; + } + } } ?> \ No newline at end of file diff --git a/blocks/rss_client/block_rss_client_action.php b/blocks/rss_client/block_rss_client_action.php index 895178c8e7c..55b8e231378 100644 --- a/blocks/rss_client/block_rss_client_action.php +++ b/blocks/rss_client/block_rss_client_action.php @@ -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)) { diff --git a/blocks/rss_client/db/mysql.php b/blocks/rss_client/db/mysql.php index 2f9b98f8a9b..dd11ffca44d 100644 --- a/blocks/rss_client/db/mysql.php +++ b/blocks/rss_client/db/mysql.php @@ -1,6 +1,6 @@ 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 = ''. + $feedicons = ''. ''. get_string('edit').' '. ''. + onclick="return confirm(\''. get_string('deletefeedconfirm', 'block_rss_client') .'\');">'. ''. get_string('delete').''; } else { $feedicons = ''; } - $feedinfo = '
' - .$feedtitle .'
'. $feed->url .'
'.$feed->description.'
'; + $feedinfo = '
'. $feedtitle .'
'. $feed->url .'
'.$feed->description.'
'; $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 = '
'."\n"; $returnstring .= '
'."\n"; - if ($act == 'rss_edit') { + if ($act == 'rssedit') { $returnstring .= $strupdatefeed; } else { $returnstring .= $straddfeed; } $returnstring .= "\n".'
'."\n"; $returnstring .= '
'. get_string('customtitlelabel', 'block_rss_client'); - $returnstring .= '
'."\n"; $returnstring .= ''."\n"; - if ($act == 'rss_edit') { + if ($act == 'rssedit') { $returnstring .= ''. "\n"; } @@ -491,7 +491,7 @@ function rss_get_form($act='none', $url='', $rssid='', $preferredtitle='', $cour $validatestring = "". get_string('validatefeed', 'block_rss_client').""; - if ($act == 'rss_edit') { + if ($act == 'rssedit') { $returnstring .= $stredit; } else { $returnstring .= $stradd;