Changeset 667
- Timestamp:
- 10/23/06 16:03:53 (2 years ago)
- Files:
-
- devel/_rss/index.php (modified) (1 diff)
- devel/_rss/subscriptions.php (modified) (1 diff)
- devel/lib/userlib.php (modified) (3 diffs)
- devel/mod/newsclient/lib.php (modified) (4 diffs)
- devel/search/personaltags.php (modified) (2 diffs)
- devel/units/magpie/function_actions.php (modified) (1 diff)
- devel/units/magpie/function_get_subscriptions.php (modified) (1 diff)
- devel/units/magpie/function_is_subscribed.php (modified) (1 diff)
- devel/units/magpie/function_subscriptions.php (modified) (3 diffs)
- devel/units/magpie/function_subscriptions_publish_to_blog.php (modified) (1 diff)
- devel/units/magpie/function_view.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
devel/_rss/index.php
r659 r667 3 3 require_once(dirname(dirname(__FILE__))."/includes.php"); 4 4 5 // global $page_owner; 6 5 7 run("weblogs:init"); 6 8 run("profile:init"); 7 run("rss:init"); 9 10 $username = trim(optional_param('profile_name','')); 11 $user_id = user_info_username("ident", $username); 12 if (!$user_id) { 13 $user_id = $page_owner; 14 } else { 15 $page_owner = $user_id; 16 $profile_id = $user_id; 17 } 18 19 run("rss:init"); // down here cos it sends $page_owner to rss function_actions.php 8 20 9 21 define('context','resources'); 10 global $page_owner; 11 templates_page_setup(); 12 $title = run("profile:display:name") ." :: " . __gettext("Feeds"); 22 templates_page_setup(); 13 23 14 run("rss:update:all",$page_owner); 15 $body = run("rss:view",$page_owner); 24 $title = run("profile:display:name", $user_id) ." :: " . __gettext("Feeds"); 25 26 run("rss:update:all", $user_id); 27 $body = run("rss:view", $user_id); 16 28 17 29 $body = templates_draw(array( devel/_rss/subscriptions.php
r659 r667 3 3 require_once(dirname(dirname(__FILE__))."/includes.php"); 4 4 5 global $page_owner;6 5 // global $page_owner; 6 7 7 run("weblogs:init"); 8 8 run("profile:init"); 9 run("rss:init"); 9 10 $username = trim(optional_param('profile_name','')); 11 $user_id = user_info_username("ident", $username); 12 if (!$user_id) { 13 $user_id = $page_owner; 14 } else { 15 $page_owner = $user_id; 16 $profile_id = $user_id; 17 } 18 19 run("rss:init"); // down here cos it sends $page_owner to rss function_actions.php 10 20 11 21 define('context','resources'); 12 13 templates_page_setup(); 14 15 $title = run("profile:display:name") ." :: " . __gettext("Feeds"); 22 templates_page_setup(); 16 23 17 $body = run("rss:subscriptions"); 24 $title = run("profile:display:name", $user_id) ." :: " . __gettext("Feeds"); 25 26 $body = run("rss:subscriptions", $user_id); 18 27 19 28 $body = templates_draw(array( devel/lib/userlib.php
r659 r667 47 47 $id_to_name_table[$user_id] = (array) get_record('users','ident',$user_id); 48 48 } 49 return $id_to_name_table[$user_id][$fieldname]; 49 if (isset($id_to_name_table[$user_id][$fieldname])) { 50 return $id_to_name_table[$user_id][$fieldname]; 51 } 50 52 } 51 53 … … 69 71 $name_to_id_table[$username] = (array) get_record('users','username',$username); 70 72 } 71 return $name_to_id_table[$username][$fieldname]; 73 if (isset($name_to_id_table[$username][$fieldname])){ 74 return $name_to_id_table[$username][$fieldname]; 75 } 72 76 } 73 77 … … 105 109 // Unset the flag first 106 110 user_flag_unset($flag_name, $user_id); 107 111 108 112 // Then add data 109 113 $flag = new StdClass; devel/mod/newsclient/lib.php
r659 r667 8 8 9 9 $page_owner = $profile_id; 10 $rss_username = user_info('username', $page_owner); 10 11 11 12 if (isloggedin() && user_info("user_type",$_SESSION['userid']) != "external") { … … 17 18 'html' => "<li><a href=\"{$CFG->wwwroot}{$_SESSION['username']}/feeds/\" >" .__gettext("Your Resources").'</a></li>'); 18 19 } 19 20 $rss_username = user_info('username', $page_owner);21 20 } 22 21 … … 24 23 25 24 if ($page_owner != -1) { 25 $PAGE->menu_sub[] = array( 'name' => 'newsfeed:subscription', 26 'html' => a_href( $CFG->wwwroot.$rss_username."/feeds/", 27 __gettext("Feeds"))); 26 28 if (run("permissions:check", "rss") && logged_on && $page_owner == $_SESSION['userid']) { 27 $PAGE->menu_sub[] = array( 'name' => 'newsfeed:subscription',28 'html' => a_href( $CFG->wwwroot.$_SESSION['username']."/feeds/",29 __gettext("Feeds")));30 29 $PAGE->menu_sub[] = array( 'name' => 'newsfeed:subscription:publish:blog', 31 30 'html' => a_href( $CFG->wwwroot."_rss/blog.php?page_owner=" . $_SESSION['userid'], … … 76 75 } 77 76 78 function newsclient_init() { 77 function newsclient_init() { 78 79 global $CFG; 80 81 $CFG->widgets->display['feed'] = "newsclient_widget_display"; 82 $CFG->widgets->edit['feed'] = "newsclient_widget_edit"; 83 $CFG->widgets->list[] = array( 84 'name' => __gettext("Feed widget"), 85 'description' => __gettext("Displays the latest entries from an external feed of your choice."), 86 'id' => "feed" 87 ); 88 89 } 90 91 function newsclient_widget_display($widget) { 92 93 global $CFG; 94 95 $feed_id = adash_get_data("feed_id",$widget->ident); 96 $feed_posts = adash_get_data("feed_posts",$widget->ident); 97 if (empty($feed_posts)) { 98 $feed_posts = 1; 99 } 100 101 if (!empty($feed_id)) { 102 103 if ($posts = get_records_sql("SELECT fp.*,f.name,f.siteurl,f.tagline FROM ".$CFG->prefix."feed_posts fp 104 JOIN ".$CFG->prefix."feeds f ON f.ident = fp.feed 105 WHERE f.ident = $feed_id ORDER BY fp.added DESC, fp.ident ASC limit $feed_posts")) { 106 107 foreach($posts as $post) { 108 $body .= "<h2><a href=\"" .$post->url . "\">". $post->title . "</a></h2>" . $post->body; 109 } 110 } else { 79 111 80 global $CFG; 81 82 $CFG->widgets->display['feed'] = "newsclient_widget_display"; 83 $CFG->widgets->edit['feed'] = "newsclient_widget_edit"; 84 $CFG->widgets->list[] = array( 85 'name' => __gettext("Feed widget"), 86 'description' => __gettext("Displays the latest entries from an external feed of your choice."), 87 'id' => "feed" 88 ); 112 $body .= "<p>" . __gettext("This feed is currently empty.") . "</p>"; 89 113 90 114 } 115 116 117 } else { 118 119 $body .= "<p>" . __gettext("This feed widget is undefined.") . "</p>"; 120 121 } 122 123 return $body; 124 125 } 91 126 92 function newsclient_widget_display($widget) { 93 94 global $CFG; 95 96 $feed_id = adash_get_data("feed_id",$widget->ident); 97 $feed_posts = adash_get_data("feed_posts",$widget->ident); 98 if (empty($feed_posts)) { 99 $feed_posts = 1; 127 function newsclient_widget_edit($widget) { 128 129 global $CFG, $page_owner; 130 131 $feed_id = adash_get_data("feed_id",$widget->ident); 132 $feed_posts = adash_get_data("feed_posts",$widget->ident); 133 if (empty($feed_posts)) { 134 $feed_posts = 1; 135 } 136 137 $body = "<h2>" . __gettext("Feeds dashboard widget") . "</h2>"; 138 $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>"; 139 140 $feed_subscriptions = get_records_sql('SELECT fs.ident AS subid, fs.autopost, fs.autopost_tag, f.* FROM '.$CFG->prefix.'feed_subscriptions fs 141 JOIN '.$CFG->prefix.'feeds f ON f.ident = fs.feed_id 142 WHERE fs.user_id = ? ORDER BY f.name ASC',array($page_owner)); 143 144 if (is_array($feed_subscriptions) && !empty($feed_subscriptions)) { 145 146 $body .= "<p><select name=\"dashboard_data[feed_id]\">\n"; 147 foreach ($feed_subscriptions as $subscription) { 148 if ($subscription->ident == $feed_id) { 149 $selected = "selected=\"selected\""; 150 } else { 151 $selected = ""; 100 152 } 101 102 if (!empty($feed_id)) { 103 104 if ($posts = get_records_sql("SELECT fp.*,f.name,f.siteurl,f.tagline FROM ".$CFG->prefix."feed_posts fp 105 JOIN ".$CFG->prefix."feeds f ON f.ident = fp.feed 106 WHERE f.ident = $feed_id ORDER BY fp.added DESC, fp.ident ASC limit $feed_posts")) { 107 108 foreach($posts as $post) { 109 $body .= "<h2><a href=\"" .$post->url . "\">". $post->title . "</a></h2>" . $post->body; 110 } 111 } else { 112 113 $body .= "<p>" . __gettext("This feed is currently empty.") . "</p>"; 114 115 } 116 117 118 } else { 119 120 $body .= "<p>" . __gettext("This feed widget is undefined.") . "</p>"; 121 122 } 123 124 return $body; 125 153 $body .= "<option value=\"" . $subscription->ident . "\" $selected>" . $subscription->name . "</option>\n"; 126 154 } 127 128 function newsclient_widget_edit($widget) { 129 130 global $CFG, $page_owner; 131 132 $feed_id = adash_get_data("feed_id",$widget->ident); 133 $feed_posts = adash_get_data("feed_posts",$widget->ident); 134 if (empty($feed_posts)) { 135 $feed_posts = 1; 136 } 137 138 $body = "<h2>" . __gettext("Feeds dashboard widget") . "</h2>"; 139 $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>"; 140 141 $feed_subscriptions = get_records_sql('SELECT fs.ident AS subid, fs.autopost, fs.autopost_tag, f.* FROM '.$CFG->prefix.'feed_subscriptions fs 142 JOIN '.$CFG->prefix.'feeds f ON f.ident = fs.feed_id 143 WHERE fs.user_id = ? ORDER BY f.name ASC',array($page_owner)); 144 145 if (is_array($feed_subscriptions) && !empty($feed_subscriptions)) { 146 147 $body .= "<p><select name=\"dashboard_data[feed_id]\">\n"; 148 foreach ($feed_subscriptions as $subscription) { 149 if ($subscription->ident == $feed_id) { 150 $selected = "selected=\"selected\""; 151 } else { 152 $selected = ""; 153 } 154 $body .= "<option value=\"" . $subscription->ident . "\" $selected>" . $subscription->name . "</option>\n"; 155 } 156 $body .= "</select></p>\n"; 157 158 $body .= "<p>" . __gettext("Then enter the number of feed entries you'd like to display:") . "</p>"; 159 160 $body .= "<p><input type=\"text\" name=\"dashboard_data[feed_posts]\" value=\"" . $feed_posts . "\" /></p>"; 161 162 } else { 163 164 $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>"; 165 166 } 167 168 return $body; 169 170 } 155 $body .= "</select></p>\n"; 156 157 $body .= "<p>" . __gettext("Then enter the number of feed entries you'd like to display:") . "</p>"; 158 159 $body .= "<p><input type=\"text\" name=\"dashboard_data[feed_posts]\" value=\"" . $feed_posts . "\" /></p>"; 160 161 } else { 162 163 $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>"; 164 165 } 166 167 return $body; 168 169 } 171 170 172 171 devel/search/personaltags.php
r659 r667 11 11 define("context","profile"); 12 12 13 templates_page_setup(); 14 global $page_owner; 13 // global $page_owner; 15 14 16 15 $username = trim(optional_param('profile_name','')); … … 18 17 if (!$user_id) { 19 18 $user_id = $page_owner; 19 } else { 20 $page_owner = $user_id; 21 $profile_id = $user_id; 20 22 } 23 24 templates_page_setup(); 21 25 22 26 $title = run("profile:display:name", $user_id) . " :: " . __gettext("Tags"); devel/units/magpie/function_actions.php
r659 r667 28 28 29 29 // Unsubscribe from an existing feed 30 case "unsubscribe": 30 case "unsubscribe": 31 31 $feed = optional_param('feed'); 32 32 if (!empty($feed) && run("rss:subscribed",$feed)) { devel/units/magpie/function_get_subscriptions.php
r269 r667 4 4 5 5 global $rss_subscriptions; 6 6 7 $parameter = (int) $parameter; 7 8 8 if ( !isset($rss_subscriptions)) {9 $rss_subscriptions = array();10 if ($subscriptions_var = get_records('feed_subscriptions', 'user_id',$USER->ident)) {9 if ($parameter && !isset($rss_subscriptions[$parameter])) { 10 $rss_subscriptions[$parameter] = array(); 11 if ($subscriptions_var = get_records('feed_subscriptions', 'user_id', $parameter)) { 11 12 foreach($subscriptions_var as $subscription) { 12 $rss_subscriptions[ ] = $subscription->feed_id;13 $rss_subscriptions[$parameter][] = $subscription->feed_id; 13 14 } 14 15 } devel/units/magpie/function_is_subscribed.php
r269 r667 1 1 <?php 2 2 // parameter is a feed id 3 // checks if $page_owner is subscribed to it 4 3 5 $run_result = false; 4 6 5 7 if (logged_on && isset($parameter)) { 6 8 7 9 global $page_owner; 8 10 $parameter = (int) $parameter; 9 11 10 if ($page_owner == $_SESSION['userid']) { 12 global $rss_subscriptions; 13 run("rss:subscriptions:get", $page_owner); 14 $run_result = in_array($parameter, $rss_subscriptions[$page_owner]); 11 15 12 global $rss_subscriptions;13 14 run("rss:subscriptions:get");15 16 $run_result = in_array($parameter, $rss_subscriptions);17 18 } else if (run("permissions:check", "profile")) {19 20 $num = count_records('feed_subscriptions','user_id',$page_owner,'ident',$parameter);21 if (!empty($num)) {22 $run_result = true;23 }24 25 }26 27 16 } 28 17 29 18 ?> devel/units/magpie/function_subscriptions.php
r659 r667 4 4 5 5 if (logged_on) { 6 7 global $rss_subscriptions; 8 run("rss:subscriptions:get"); 9 run("rss:update:all",$page_owner); 10 if ($USER->ident == $page_owner) { 6 7 $displayuser = (int) $parameter; 8 9 //global $rss_subscriptions; 10 //run("rss:subscriptions:get"); 11 12 run("rss:update:all",$displayuser); 13 if ($USER->ident == $displayuser) { 11 14 $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>"; 12 // $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 15 } 14 16 if ($feed_subscriptions = get_records_sql('SELECT fs.ident AS subid, fs.autopost, fs.autopost_tag, f.* FROM '.$CFG->prefix.'feed_subscriptions fs 15 17 JOIN '.$CFG->prefix.'feeds f ON f.ident = fs.feed_id 16 WHERE fs.user_id = ? ORDER BY f.name ASC',array($ page_owner))) {18 WHERE fs.user_id = ? ORDER BY f.name ASC',array($displayuser))) { 17 19 if (run("permissions:check", "profile")) { 18 20 $body .= "<form action=\"\" method=\"post\" >"; … … 30 32 $name = "<a href=\"".$feed->siteurl."\">" . stripslashes($feed->name) . "</a>"; 31 33 $column2 = "<a href=\"".url."_rss/individual.php?feed=".$feed->ident."\">". __gettext("View content") . "</a>"; 34 // this allows unsubscribing the *displayed* user from the feed (if you're admin), as opposed 35 // to the popular feeds page, which allows you to unsubscribe yourself from a feed. 36 // I think. 37 // maybe. 38 // Love, Sven 32 39 if (run("permissions:check", "profile")) { 33 40 $column2 .= " | <a href=\"".url."_rss/subscriptions.php?action=unsubscribe&feed=".$feed->ident … … 59 66 60 67 } else { 61 if ($_SESSION['userid'] == $ page_owner) {68 if ($_SESSION['userid'] == $displayuser) { 62 69 $body .= "<p>" . __gettext("You are not subscribed to any feeds.") . "</p>"; 63 70 } else { devel/units/magpie/function_subscriptions_publish_to_blog.php
r659 r667 6 6 if (logged_on) { 7 7 8 global $rss_subscriptions;9 run("rss:subscriptions:get");8 // global $rss_subscriptions; 9 // run("rss:subscriptions:get"); 10 10 if ($USER->ident == $page_owner) { 11 11 $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.)") . "</p>"; devel/units/magpie/function_view.php
r659 r667 30 30 $run_result .= <<< END 31 31 32 <a href="{$CFG->wwwroot}{$profile_name}/newsclient/all/skip={$display_feed_offset}"><< $back</a>33 32 <a href="{$CFG->wwwroot}{$profile_name}/newsclient/all/skip={$display_feed_offset}"><< $back</a> 33 34 34 END; 35 35 } … … 41 41 $next = __gettext("Next"); 42 42 $run_result .= <<< END 43 44 <a href="{$CFG->wwwroot}{$profile_name}/newsclient/all/skip={$display_feed_offset}">$next >></a>45 43 44 <a href="{$CFG->wwwroot}{$profile_name}/newsclient/all/skip={$display_feed_offset}">$next >></a> 45 46 46 END; 47 47 }
