From 59f6d311bfdec1b119c7ae5ee0eb8cd17c900bb8 Mon Sep 17 00:00:00 2001 From: dhawes Date: Sun, 15 May 2005 02:46:15 +0000 Subject: [PATCH] moved a method from rss client action script to rsslib since it's needed by the new tabs in the instance config --- lib/rsslib.php | 87 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 80 insertions(+), 7 deletions(-) diff --git a/lib/rsslib.php b/lib/rsslib.php index ee5784a8f90..ec3a17f3ad8 100644 --- a/lib/rsslib.php +++ b/lib/rsslib.php @@ -340,20 +340,29 @@ define('SUBMITTERS_ADMIN_ONLY', 1); define('SUBMITTERS_ADMIN_AND_TEACHER', 2); /** - * @param int $rssid . + * @param int $userid If present only entries added by this userid will be displayed + * @param int $rssid If present the rss entry matching this id alone will be displayed */ -function rss_display_feeds($rssid='none') { +function rss_display_feeds($userid='', $rssid='') { global $db, $USER, $CFG; global $blogid; //hackish, but if there is a blogid it would be good to preserve it $rsspix = $CFG->pixpath .'/i/rss.gif'; $closeTable = false; - if ($rssid != 'none'){ - $feeds = get_records('block_rss_client', 'id', $rssid); - } else { - $feeds = get_records('block_rss_client'); - } + $select = ''; + + if (!isadmin()) { + $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; + } else if ($rssid != ''){ + $select = 'id='. $rssid; + } + $feeds = get_records_select('block_rss_client', $select); if ($feeds){ $closeTable = true; @@ -409,4 +418,68 @@ function rss_unhtmlentities($string) { $trans_tbl = array_flip ($trans_tbl); return strtr ($string, $trans_tbl); } + +/** + * Prints or returns a form for managing rss feed entries. + * @param string $act . + * @param string $url . + * @param int $rssid . + * @param bool $printnow True if the generated form should be printed out, false if the string should be returned from this function quietly + */ +function rss_get_form($act='none', $url='', $rssid='', $preferredtitle='', $printnow=true) { + global $USER, $CFG, $_SERVER, $blockid, $blockaction; + global $blogid; //hackish, but if there is a blogid it would be good to preserve it + $stredit = get_string('edit'); + $stradd = get_string('add'); + $strupdatefeed = get_string('block_rss_update_feed', 'block_rss_client'); + $straddfeed = get_string('block_rss_add_feed', 'block_rss_client'); + + $returnstring = '
'."\n"; + + $returnstring .= '
'."\n"; + if ($act == 'rss_edit') { + $returnstring .= $strupdatefeed; + } else { + $returnstring .= $straddfeed; + } + $returnstring .= "\n".'
'."\n"; + $returnstring .= '
'. get_string('block_rss_custom_title_label', 'block_rss_client'); + $returnstring .= '
'."\n"; + + $returnstring .= ''."\n"; + if ($act == 'rss_edit') { + $returnstring .= ''. "\n"; + } + $returnstring .= ''."\n"; + $returnstring .= ''."\n"; + $returnstring .= '
". get_string('validate_feed', 'block_rss_client').""; + if ($act == 'rss_edit') { + $returnstring .= $stredit; + } else { + $returnstring .= $stradd; + } + $returnstring .= '" /> '. $validatestring .'
'."\n"; + $returnstring .= '
'."\n"; + + if ($printnow){ + print $returnstring; + } + return $returnstring; +} ?>