Skip to content
Browse files

moved a method from rss client action script to rsslib since it's nee…

…ded by the new tabs in the instance config
  • Loading branch information...
1 parent c1f2b37 commit 59f6d311bfdec1b119c7ae5ee0eb8cd17c900bb8 dhawes committed May 15, 2005
Showing with 80 additions and 7 deletions.
  1. +80 −7 lib/rsslib.php
View
87 lib/rsslib.php
@@ -340,20 +340,29 @@ function rss_full_tag($tag,$level=0,$endline=true,$content,$to_utf=true) {
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 = '<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') {
+ $returnstring .= $strupdatefeed;
+ } else {
+ $returnstring .= $straddfeed;
+ }
+ $returnstring .= "\n".'<br /><input type="text" size="60" maxlength="256" name="url" value="';
+ if ($act == 'rss_edit') {
+ $returnstring .= $url;
+ }
+ $returnstring .= '" />'."\n";
+ $returnstring .= '<br />'. get_string('block_rss_custom_title_label', 'block_rss_client');
+ $returnstring .= '<br /><input type="text" size="60" maxlength="64" name="preferredtitle" value="';
+ if ($act == 'rss_edit') {
+ $returnstring .= $preferredtitle;
+ }
+ $returnstring .= '" />'."\n";
+
+ $returnstring .= '<input type="hidden" name="act" value="';
+ if ($act == 'rss_edit') {
+ $returnstring .= 'updfeed';
+ } else {
+ $returnstring .= 'addfeed';
+ }
+ $returnstring .= '" />'."\n";
+ if ($act == 'rss_edit') {
+ $returnstring .= '<input type="hidden" name="rssid" value="'. $rssid .'" />'. "\n";
+ }
+ $returnstring .= '<input type="hidden" name="blogid" value="'. $blogid .'" />'."\n";
+ $returnstring .= '<input type="hidden" name="user" value="'. $USER->id .'" />'."\n";
+ $returnstring .= '<br /><input type="submit" value="';
+ $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('validate_feed', 'block_rss_client')."</a>";
+ if ($act == 'rss_edit') {
+ $returnstring .= $stredit;
+ } else {
+ $returnstring .= $stradd;
+ }
+ $returnstring .= '" />&nbsp;'. $validatestring .'</form>'."\n";
+ $returnstring .= '</td></tr></tbody></table>'."\n";
+
+ if ($printnow){
+ print $returnstring;
+ }
+ return $returnstring;
+}
?>

0 comments on commit 59f6d31

Please sign in to comment.
Something went wrong with that request. Please try again.