<?php

global $USER, $CFG, $page_owner;
$body = '';
if (logged_on) {
    if ($USER->ident == $page_owner) {
        $body .= "<p>" . __gettext("Click a box below to automatically import content from a feed into your blog. You can also add default keywords for content from that feed. (You should only do this if you have the legal right to use this resource - in other words, you must have permission from the content owner, as the feed's content will appear in your blog as if you had written it.)") . "</p>";
    }
    if ($feed_subscriptions = newsclient_get_subscriptions_user($page_owner, true)) {
        if (run("permissions:check", "profile")) {
            $body .= "<form action=\"\" method=\"post\" >";
        }
        $body .= templates_draw(array('context' => 'adminTable', 'name' => "<b>" . __gettext("Last updated") . "</b>", 'column1' => "<b>" . __gettext("Resource name") . "</b>", 'column2' => "&nbsp;"));
        foreach ($feed_subscriptions as $feed) {
            if (run("permissions:check", "profile")) {
                $name = "<input type=\"checkbox\" name=\"feedautopost[]\" value=\"" . $feed->subid . "\" ";
                $name .= "onclick=\"if (this.checked) return confirm('" . __gettext("Are you sure you want to import this content into your personal blog?\\nYou should make sure you own it or have permission from the copyright holder.") . "')\" ";
                if ($feed->autopost == "yes") {
                    $name .= " checked=\"checked\"";
                }
                $name .= " />";
            }
            $name .= "\r\n                <a href=\"" . $feed->siteurl . "\">" . stripslashes($feed->name) . "</a>\r\n                <a href=\"" . $feed->url . "\"><img src=\"{$CFG->wwwroot}mod/template/icons/rss.png\" border=\"0\" alt=\"rss\" /></a>\r\n            ";
            if (run("permissions:check", "profile")) {
                $name .= "<br />";
                $name .= __gettext("Keywords: ") . "<input type=\"text\" name=\"keywords[" . $feed->subid . "]\" value=\"" . htmlspecialchars($feed->autopost_tag) . "\" />";
            }
            $column2 = "<a href=\"" . url . "_rss/individual.php?feed=" . $feed->ident . "\">" . __gettext("View content") . "</a>";
            $body .= templates_draw(array('context' => 'adminTable', 'name' => strftime("%B %d %Y, %H:%M", $feed->last_updated), 'column1' => $name, 'column2' => $column2));
        }
        if (run("permissions:check", "profile")) {
Example #2
0
function newsclient_widget_edit($widget)
{
    global $CFG, $page_owner;
    $feed_id = widget_get_data("feed_id", $widget->ident);
    $feed_posts = widget_get_data("feed_posts", $widget->ident);
    if (empty($feed_posts)) {
        $feed_posts = 1;
    }
    $body = "<h2>" . __gettext("Feeds widget") . "</h2>";
    $body .= "<p>" . __gettext("This widget displays the last couple of entries from an external feed you have subscribed to. To begin, select the feed from your subscriptions below:") . "</p>";
    $feed_subscriptions = newsclient_get_subscriptions_user($page_owner, true);
    if (is_array($feed_subscriptions) && !empty($feed_subscriptions)) {
        $body .= "<p><select name=\"widget_data[feed_id]\">\n";
        foreach ($feed_subscriptions as $subscription) {
            if ($subscription->ident == $feed_id) {
                $selected = "selected=\"selected\"";
            } else {
                $selected = "";
            }
            $body .= "<option value=\"" . $subscription->ident . "\" {$selected}>" . $subscription->name . "</option>\n";
        }
        $body .= "</select></p>\n";
        $body .= "<p>" . __gettext("Then enter the number of feed entries you'd like to display:") . "</p>";
        $body .= "<p><input type=\"text\" name=\"widget_data[feed_posts]\" value=\"" . $feed_posts . "\" /></p>";
    } else {
        $body .= "<p>" . sprintf(__gettext("You can't select a feed for this widget because you don't have any feed subscriptions. Click on <a href=\"%s\">Your</a> Resources to subscribe to a feed."), $CFG->wwwroot . $_SESSION['username'] . "/feeds/") . "</p>";
    }
    return $body;
}
Example #3
0
$output = '';
if ($user_id) {
    $owner = $CFG->wwwroot . $username . '/';
    $niceusername = run("profile:display:name", $user_id);
    $descr = sprintf(__gettext("Feed subscriptions for %s"), $niceusername);
    $output .= <<<END
<opml version="1.1">
\t<head>
\t\t<title>{$descr}</title>
\t\t<dateCreated>{$date}</dateCreated>
\t\t<ownerName>{$owner}</ownerName>
\t</head>
\t<body>
\t
END;
    if ($subscriptions_var = newsclient_get_subscriptions_user($user_id, true)) {
        foreach ($subscriptions_var as $afeed) {
            //var_dump($afeed);
            $output .= '<outline type="rss" title="' . htmlspecialchars($afeed->name) . '" htmlUrl="' . htmlspecialchars($afeed->siteurl) . '" xmlUrl="' . htmlspecialchars($afeed->url) . '" text="' . htmlspecialchars($afeed->name) . '" />' . "\n";
        }
    } else {
        $output .= '<outline text="' . __gettext("No subscriptions found") . '" />' . "\n";
    }
    $output .= <<<END
\t
\t</body>
</opml>
END;
} else {
    $descr = sprintf(__gettext("Username not found: %s"), $username);
    $output .= <<<END
<?php

global $USER;
if (logged_on) {
    global $rss_subscriptions;
    $parameter = (int) $parameter;
    if ($parameter && !isset($rss_subscriptions[$parameter])) {
        $rss_subscriptions[$parameter] = array();
        if ($subscriptions_var = newsclient_get_subscriptions_user($parameter, false)) {
            foreach ($subscriptions_var as $subscription) {
                $rss_subscriptions[$parameter][] = $subscription->feed_id;
            }
        }
    }
    $run_result = $rss_subscriptions;
}
<?php

global $USER, $CFG, $page_owner;
$body = '';
//if (logged_on) {
//a user's aggregator (rss:view) is public, so the feed list might as well be too
$displayuser = (int) $parameter;
run("rss:update:all", $displayuser);
if ($USER->ident == $displayuser) {
    $body .= "<p>" . __gettext("Feeds are information streams from other sites. You will often see a link to an 'RSS' feed while browsing; enter the link address into the 'add feed' box at the bottom of the page to read that information from within your learning landscape.") . "</p>";
}
if ($feed_subscriptions = newsclient_get_subscriptions_user($displayuser, true)) {
    if (run("permissions:check", "profile")) {
        $body .= "<form action=\"\" method=\"post\" >";
    }
    $body .= templates_draw(array('context' => 'adminTable', 'name' => "<b>" . __gettext("Last updated") . "</b>", 'column1' => "<b>" . __gettext("Resource name") . "</b>", 'column2' => "&nbsp;"));
    foreach ($feed_subscriptions as $feed) {
        $name = "\r\n            <a href=\"" . $feed->siteurl . "\">" . $feed->name . "</a>\r\n            <a href=\"" . $feed->url . "\"><img src=\"{$CFG->wwwroot}mod/template/icons/rss.png\" border=\"0\" alt=\"rss\" /></a>\r\n            ";
        $column2 = "<a href=\"" . url . "_rss/individual.php?feed=" . $feed->ident . "\">" . __gettext("View content") . "</a>";
        // this allows unsubscribing the *displayed* user from the feed (if you're admin), as opposed
        // to the popular feeds page, which allows you to unsubscribe yourself from a feed.
        // I think.
        // maybe.
        // Love, Sven
        if (run("permissions:check", "profile")) {
            $column2 .= " | <a href=\"" . url . "_rss/subscriptions.php?action=unsubscribe&amp;feed=" . $feed->ident . "&amp;feed_owner=" . $page_owner . "\" onclick=\"return confirm('" . __gettext("Are you sure you want to unsubscribe from this feed?") . "')\">" . __gettext("Unsubscribe") . "</a>";
        }
        $body .= templates_draw(array('context' => 'adminTable', 'name' => strftime("%B %d %Y, %H:%M", $feed->last_updated), 'column1' => $name, 'column2' => $column2));
    }
    $username = user_info("username", $displayuser);
    $opml = '<a href="' . $CFG->wwwroot . '_rss/opml.php?profile_name=' . $username . '">' . __gettext("Subscription list as OPML") . '</a>';