Changeset 252
- Timestamp:
- 02/15/06 22:57:55 (3 years ago)
- Files:
-
- devel/_rss/subscriptions.php (modified) (1 diff)
- devel/units/magpie/function_actions.php (modified) (2 diffs)
- devel/units/magpie/function_subscriptions.php (modified) (2 diffs)
- devel/units/magpie/function_update.php (modified) (3 diffs)
- devel/units/magpie/function_update_all_cron.php (modified) (1 diff)
- devel/units/magpie/menu_sub.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
devel/_rss/subscriptions.php
r112 r252 11 11 define('context','resources'); 12 12 13 $title = run("profile:display:name") ." :: " . gettext(" External feeds");13 $title = run("profile:display:name") ." :: " . gettext("Feeds"); 14 14 15 15 $body = run("rss:subscriptions",$feed); devel/units/magpie/function_actions.php
r167 r252 2 2 3 3 4 if (logged_on && isset($_REQUEST['action']) ) {4 if (logged_on && isset($_REQUEST['action']) && run("permissions:check", "profile")) { 5 5 6 6 global $page_owner; 7 8 if ($page_owner != $_SESSION['userid']) { 9 $page_username = db_query("select username from users where ident = $page_owner"); 10 $page_username = $page_username->username; 11 } else { 12 $page_username = $_SESSION['username']; 13 } 7 14 8 15 switch($_REQUEST['action']) { … … 57 64 } 58 65 break; 66 case "rss:subscriptions:update": if (isset($_REQUEST['keywords'])) { 67 db_query("update feed_subscriptions set autopost = 'no' where user_id = '$page_owner'"); 68 if (is_array($_REQUEST['keywords']) && sizeof($_REQUEST['keywords']) > 0) { 69 foreach($_REQUEST['keywords'] as $key => $keyword_set) { 70 $keyword_set = trim($keyword_set); 71 if (strlen($keyword_set) > 128) { 72 $keyword_set = substr($keyword_set, 0, 128); 73 } 74 $key = (int) $key; 75 db_query("update feed_subscriptions set autopost_tag = \"".addslashes($keyword_set)."\" where ident = $key and user_id = $page_owner"); 76 } 77 } 78 if (isset($_REQUEST['feedautopost']) && is_array($_REQUEST['feedautopost']) && sizeof($_REQUEST['feedautopost']) > 0) { 79 foreach($_REQUEST['feedautopost'] as $autopost) { 80 $autopost = (int) $autopost; 81 $feedurl = db_query("select feeds.url from feed_subscriptions left join feeds on feeds.ident = feed_subscriptions.feed_id where feed_subscriptions.ident = $autopost"); 82 if (is_array($feedurl) && sizeof($feedurl) > 0) { 83 $feedurl = $feedurl[0]->url; 84 if (substr_count($feedurl,url) > 0 && substr_count($feedurl,"/".$page_username."/") > 0) { 85 $messages[] = gettext("Feed not imported to blog: You cannot import a feed from this account."); 86 echo $feedurl; 87 } else { 88 db_query("update feed_subscriptions set autopost = 'yes' where ident = $autopost and user_id = $page_owner"); 89 } 90 } 91 } 92 } 93 $messages[] = "Your changes were saved."; 94 } 59 95 60 96 } devel/units/magpie/function_subscriptions.php
r167 r252 11 11 if ($_SESSION['userid'] == $page_owner) { 12 12 $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>"; 13 $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.)") . "</p>"; 13 14 } 14 15 15 $feed_subscriptions = db_query("select feed s.* from feed_subscriptions join feeds on feeds.ident = feed_subscriptions.feed_id where feed_subscriptions.user_id = ". $page_owner . " order by feeds.name asc");16 $feed_subscriptions = db_query("select feed_subscriptions.ident as subid, feed_subscriptions.autopost, feed_subscriptions.autopost_tag, feeds.* from feed_subscriptions join feeds on feeds.ident = feed_subscriptions.feed_id where feed_subscriptions.user_id = ". $page_owner . " order by feeds.name asc"); 16 17 if (sizeof($feed_subscriptions) > 0) { 18 19 if (run("permissions:check", "profile")) { 20 $body .= "<form action=\"\" method=\"post\" >"; 21 } 17 22 18 23 $body .= run("templates:draw", array( … … 24 29 ); 25 30 26 foreach($feed_subscriptions as $feed) { 27 28 $name = "<a href=\"".$feed->siteurl."\">" . stripslashes($feed->name) . "</a>"; 29 $column2 = "<a href=\"".url."_rss/individual.php?feed=".$feed->ident."\">". gettext("View content") . "</a>"; 30 if (run("permissions:check", "profile")) { 31 $column2 .= " | <a href=\"".url."_rss/subscriptions.php?action=unsubscribe&feed=".$feed->ident."&profile_id=$page_owner\" onClick=\"return confirm('".gettext("Are you sure you want to unsubscribe from this feed?")."')\">" . gettext("Unsubscribe") . "</a>"; 32 } 33 34 $body .= run("templates:draw", array( 31 foreach($feed_subscriptions as $feed) { 32 33 if (run("permissions:check", "profile")) { 34 $name = "<input type=\"checkbox\" name=\"feedautopost[]\" value=\"" . $feed->subid . "\" "; 35 if ($feed->autopost == "yes") { 36 $name .= " checked=\"checked\""; 37 38 } 39 $name .= " />"; 40 } 41 $name .= "<a href=\"".$feed->siteurl."\">" . stripslashes($feed->name) . "</a>"; 42 if (run("permissions:check", "profile")) { 43 $name .= "<br />"; 44 $name .= gettext("Keywords: ") . "<input type=\"text\" name=\"keywords[" . $feed->subid . "]\" value=\"" . htmlentities(stripslashes($feed->autopost_tag)) . "\" />"; 45 } 46 47 $column2 = "<a href=\"".url."_rss/individual.php?feed=".$feed->ident."\">". gettext("View content") . "</a>"; 48 if (run("permissions:check", "profile")) { 49 $column2 .= " | <a href=\"".url."_rss/subscriptions.php?action=unsubscribe&feed=".$feed->ident."&profile_id=$page_owner\" onClick=\"return confirm('".gettext("Are you sure you want to unsubscribe from this feed?")."')\">" . gettext("Unsubscribe") . "</a>"; 50 } 51 52 $body .= run("templates:draw", array( 53 'context' => 'adminTable', 54 'name' => date("F j, Y, g:i a",$feed->last_updated), 55 'column1' => $name, 56 'column2' => $column2 57 ) 58 ); 59 60 } 61 62 if (run("permissions:check", "profile")) { 63 64 $body .= run("templates:draw", array( 35 65 'context' => 'adminTable', 36 'name' => date("F j, Y, g:i a",$feed->last_updated),37 'column1' => $name,38 'column2' => $column266 'name' => "<input type=\"hidden\" name=\"action\" value=\"rss:subscriptions:update\" />", 67 'column1' => "<input type=\"submit\" value=\"" . gettext("Update") . "\" />", 68 'column2' => "" 39 69 ) 40 70 ); 41 71 72 $body .= "</form>"; 73 } 74 75 } else { 76 if ($_SESSION['userid'] == $page_owner) { 77 $body .= "<p>" . gettext("You are not subscribed to any feeds.") . "</p>"; 78 } else { 79 $body .= "<p>" . gettext("No feeds were found.") . "</p>"; 80 } 42 81 } 43 82 44 } else { 45 if ($_SESSION['userid'] == $page_owner) { 46 $body .= "<p>" . gettext("You are not subscribed to any feeds.") . "</p>"; 47 } else { 48 $body .= "<p>" . gettext("No feeds were found.") . "</p>"; 83 if (run("permissions:check", "profile")) { 84 $body .= "<p>". gettext("To subscribe to a new feed, enter its address below:") . "</p>"; 85 $body .= "<form action=\"\" method=\"post\">"; 86 $body .= run("templates:draw", array( 87 'context' => 'adminTable', 88 'name' => " ", 89 'column1' => "<input type=\"text\" name=\"url\" value=\"http://\" style=\"width: 100%\" />", 90 'column2' => "<input type=\"submit\" value=\"".gettext("Subscribe") . "\" />" 91 ) 92 ); 93 $body .= "<input type=\"hidden\" name=\"action\" value=\"subscribe-new\" /></form>"; 49 94 } 50 } 51 52 if (run("permissions:check", "profile")) { 53 $body .= "<p>". gettext("To subscribe to a new feed, enter its address below:") . "</p>"; 54 $body .= "<form action=\"\" method=\"post\">"; 55 $body .= run("templates:draw", array( 56 'context' => 'adminTable', 57 'name' => " ", 58 'column1' => "<input type=\"text\" name=\"url\" value=\"http://\" style=\"width: 100%\" />", 59 'column2' => "<input type=\"submit\" value=\"".gettext("Subscribe") . "\" />" 60 ) 61 ); 62 $body .= "<input type=\"hidden\" name=\"action\" value=\"subscribe-new\" /></form>"; 63 } 64 $run_result .= $body; 95 $run_result .= $body; 65 96 66 97 } devel/units/magpie/function_update.php
r106 r252 12 12 13 13 if (sizeof($feed) > 0 && $subscribers > 0) { 14 14 15 $update_time = 1; 16 /* 15 17 if ($subscribers > 10) { 16 18 $update_time = 3600; … … 22 24 $update_time = 14400; 23 25 } 24 26 */ 25 27 $feed = $feed[0]; 26 if ($feed->last_updated < (time() - $update_time)) { 28 // if ($feed->last_updated < (time() - $update_time)) { 29 if (1 == 1) { 30 27 31 db_query("update feeds set last_updated = " . time() . " where ident = $parameter"); 28 32 if ($rss = run("rss:get", $feed->url)) { … … 82 86 } else { 83 87 db_query("insert into feed_posts set title = '".addslashes($title)."', body = '".addslashes($description)."', posted = '".addslashes($posted)."', url = '".addslashes($url)."', feed = $parameter, added = $added"); 88 $weblogs = db_query("select user_id, autopost_tag from feed_subscriptions where feed_id = $parameter and autopost = 'yes'"); 89 if (is_array($weblogs) && sizeof($weblogs) > 0) { 90 $body = "<p><a href=\"$url\">$url</a></p>" . addslashes($description); 91 foreach($weblogs as $weblog) { 92 db_query("insert into weblog_posts set title = '".addslashes($title)."', body = '$body', access = 'PUBLIC', owner = " . $weblog->user_id . ", weblog = " . $weblog->user_id . ", posted = $added"); 93 $id = db_id(); 94 $tags = trim($weblog->autopost_tag); 95 if ($tags != "") { 96 $tags = explode(",",$tags); 97 foreach($tags as $tag) { 98 $tag = trim($tag); 99 if ($tag != "") { 100 $tag = addslashes($tag); 101 db_query("insert into tags set tag = '$tag', tagtype = 'weblog', ref = $id, access = 'PUBLIC', owner = " . $weblog->user_id); 102 } 103 } 104 } 105 } 106 } 84 107 } 85 108 } devel/units/magpie/function_update_all_cron.php
r59 r252 7 7 8 8 // Get all subscriptions 9 $subscriptions = db_query("select ident, url, last_updated from feeds where last_updated < (UNIX_TIMESTAMP() - 3600)");9 $subscriptions = db_query("select ident, url, last_updated from feeds where last_updated <= (UNIX_TIMESTAMP() - 0)"); 10 10 if (sizeof($subscriptions > 0)) { 11 11 foreach($subscriptions as $subscription) { devel/units/magpie/menu_sub.php
r112 r252 11 11 $run_result .= run("templates:draw", array( 12 12 'context' => 'submenuitem', 13 'name' => gettext(" External feeds"),13 'name' => gettext("Feeds"), 14 14 'location' => url . $rss_username . "/feeds/" 15 15 )
