$string['replyforum'] = 'Reply to forum';
$string['rsssubscriberssdiscussions'] = 'Display the RSS feed for \'$a\' discussions';
$string['rsssubscriberssposts'] = 'Display the RSS feed for \'$a\' posts';
-$string['rsstype'] = "RSS feed for this forum";
-$string['rssarticles'] = "Number of RSS recent articles";
$string['search'] = 'Search';
$string['searchforums'] = 'Search forums';
$string['searcholderposts'] = 'Search older posts...';
$string['commentupdated'] = 'The comment has been updated.';
$string['concept'] = 'Concept';
$string['concepts'] = 'Concepts';
+$string['configenablerssfeeds'] = 'This switch will enable the possibility of RSS feeds for all glosaries. You will still need to turn feeds on manually in the settings for each glossary.';
$string['currentglossary'] = 'Current glossary';
$string['dateview'] = 'Browse by date';
$string['defaultapproval'] = 'Default approval status';
$string['ratingtime'] = 'Restrict ratings to entries with dates in this range:';
$string['rejectedentries'] = 'Rejected entries';
$string['rejectionrpt'] = 'Rejection Report';
+$string['rsssubscriberss'] = 'Display the RSS feed for \'$a\' concepts';
$string['searchindefinition'] = 'Search full text';
$string['secondaryglossary'] = 'Secondary glossary';
$string['sendinratings'] = 'Send in my latest ratings';
--- /dev/null
+<P ALIGN=CENTER><B>Number of RSS recent articles</B></P>
+
+<P>This option allows you to select the number of articles
+ to include in the RSS Feed.
+
+<P>A number between 5 and 20 should be appropiate for
+ most glossaries. Increase it if the glossary is very used.
+
--- /dev/null
+<P ALIGN=CENTER><B>RSS feed for this glossary</B></P>
+
+<P>This option allows you to enable RSS feeds in this glossary.
+
+<P>You can select between two types of feeds:
+
+<UL>
+<LI><B>With author:</B> Using this, generated feeds will include
+ the name of the autor in every article.
+
+<LI><B>Without author:</B> Using this, generated feeds won't include
+ the name of the autor in every article.
+</UL>
+
$string['configdebug'] = 'If you turn this on, then PHP\'s error_reporting will be increased so that more warnings are printed. This is only useful for developers.';
$string['configdeleteunconfirmed'] = 'If you are using email authentication, this is the period within which a response will be accepted from users. After this period, old unconfirmed accounts are deleted.';
$string['configenablerssfeeds'] = 'This switch will enable RSS feeds from across the site. To actually see any change you will need to enable RSS feeds in the individual modules too - go to the Modules settings under Admin Configuration.';
+$string['configenablerssfeedsdisabled'] = ' It is not available because RSS feeds are disabled in all the Site. To enable them, go to the Variables settings under Admin Configuration.';
$string['configerrorlevel'] = 'Choose the amount of PHP warnings that you want to be displayed. Normal is usually the best choice.';
$string['configfilteruploadedfiles'] = 'Enabling this setting will cause Moodle to process all uploaded HTML and text files with the filters before displaying them.';
$string['configforcelogin'] = 'Normally, the front page of the site and the course listings (but not courses) can be read by people without logging in to the site. If you want to force people to log in before they do ANYTHING on the site, then you should enable this setting.';
$string['returningtosite'] = 'Returning to this web site?';
$string['revert'] = 'Revert';
$string['role'] = 'Role';
+$string['rsstype'] = "RSS feed for this activity";
+$string['rssarticles'] = "Number of RSS recent articles";
$string['savechanges'] = 'Save changes';
$string['saveto'] = 'Save to';
$string['scale'] = 'Scale';
<?php
print_string("configenablerssfeeds","forum");
if ($CFG->enablerssfeeds == 0) {
- print_string("configenablerssfeedsdisabled","forum");
+ print_string("configenablerssfeedsdisabled");
}
?>
</td>
//Only show rss parameters if rss is activated at site and forum levels
if ($CFG->enablerssfeeds && $CFG->forum_enablerssfeeds) {
echo "<tr valign=top>";
- echo "<td align=right><p><b>".get_string("rsstype", "forum")."</b></p></td>";
+ echo "<td align=right><p><b>".get_string("rsstype")."</b></p></td>";
echo "<td>";
unset($choices);
$choices[0] = get_string("none");
$choices[1] = get_string("discussions", "forum");
$choices[2] = get_string("posts", "forum");
choose_from_menu ($choices, "rsstype", $form->rsstype, "");
- helpbutton("rsstype", get_string("rsstype", "forum"), "forum");
+ helpbutton("rsstype", get_string("rsstype"), "forum");
echo "</td>";
echo "</tr>";
echo "<tr valign=top>";
- echo "<td align=right><p><b>".get_string("rssarticles", "forum")."</b></p></td>";
+ echo "<td align=right><p><b>".get_string("rssarticles")."</b></p></td>";
echo "<td>";
unset($choices);
$choices[0] = "0";
$choices[40] = "40";
$choices[50] = "50";
choose_from_menu ($choices, "rssarticles", $form->rssarticles, "");
- helpbutton("rssarticles", get_string("rssarticles", "forum"), "forum");
+ helpbutton("rssarticles", get_string("rssarticles"), "forum");
echo "</td>";
echo "</tr>";
}
</td>
</tr>
+<tr valign=top>
+ <td align=right><p>glossary_enablerssfeeds:</td>
+ <td>
+ <?php
+ if ($CFG->enablerssfeeds == 0) {
+ print_string("no");
+ } else {
+ unset($options);
+ $options[0] = get_string("no");
+ $options[1] = get_string("yes");
+
+ choose_from_menu ($options, "glossary_enablerssfeeds", $CFG->glossary_enablerssfeeds, "", "", "");
+ }
+ ?>
+ </td>
+ <td>
+ <?php
+ print_string("configenablerssfeeds","glossary");
+ if ($CFG->enablerssfeeds == 0) {
+ print_string("configenablerssfeedsdisabled");
+ }
+ ?>
+ </td>
+</tr>
<tr>
<td colspan=3 align=center>
<input type="submit" value="<?php print_string("savechanges") ?>"></td>
set_config("textfilters", $CFG->textfilters);
}
}
+
+ if ($oldversion < 2004050900) {
+ table_column("glossary","","rsstype","tinyint","2", "unsigned", "0", "", "entbypage");
+ table_column("glossary","","rssarticles","tinyint","2", "unsigned", "0", "", "rsstype");
+ set_config("glossary_enablerssfeeds",0);
+ }
return true;
}
defaultapproval tinyint(2) unsigned NOT NULL default '1',
globalglossary tinyint(2) unsigned NOT NULL default '0',
entbypage tinyint(3) unsigned NOT NULL default '10',
- assessed int(10) unsigned NOT NULL default '0',
- assesstimestart int(10) unsigned NOT NULL default '0',
- assesstimefinish int(10) unsigned NOT NULL default '0',
- scale int(10) NOT NULL default '0',
+ rsstype tinyint(2) unsigned NOT NULL default '0',
+ rssarticles tinyint(2) unsigned NOT NULL default '0',
+ assessed int(10) unsigned NOT NULL default '0',
+ assesstimestart int(10) unsigned NOT NULL default '0',
+ assesstimefinish int(10) unsigned NOT NULL default '0',
+ scale int(10) NOT NULL default '0',
timecreated int(10) unsigned NOT NULL default '0',
timemodified int(10) unsigned NOT NULL default '0',
PRIMARY KEY (id)
showspecial number(2) default '1' not null,
showall number(2) default '1' not null,
showalphabet number(2) default '1' not null,
+ rsstype number(2) default '0' NOT NULL,
+ rssarticles number(2) default '0' NOT NULL,
timecreated number(10) default '0' not null,
timemodified number(10) default '0' not null
);
}
}
+ if ($oldversion < 2004050900) {
+ table_column("glossary","","rsstype","integer","2", "unsigned", "0", "", "entbypage");
+ table_column("glossary","","rssarticles","integer","2", "unsigned", "0", "", "rsstype");
+ set_config("glossary_enablerssfeeds",0);
+ }
+
return true;
}
defaultapproval int2 NOT NULL default '1',
globalglossary int2 NOT NULL default '0',
entbypage int NOT NULL default '10',
- assessed int4 NOT NULL default '0',
- assesstimestart int4 NOT NULL default '0',
- assesstimefinish int4 NOT NULL default '0',
- scale int4 NOT NULL default '0',
+ rsstype integer NOT NULL default '0',
+ rssarticles integer NOT NULL default '0',
+ assessed int4 NOT NULL default '0',
+ assesstimestart int4 NOT NULL default '0',
+ assesstimefinish int4 NOT NULL default '0',
+ scale int4 NOT NULL default '0',
timecreated int4 NOT NULL default '0',
timemodified int4 NOT NULL default '0',
PRIMARY KEY (id)
if (!isset($form->showspecial)) {
$form->showspecial = 1;
}
+ if (!isset($form->rsstype)) {
+ $form->rsstype = 0;
+ }
+ if (!isset($form->rssarticles)) {
+ $form->rssarticles = 0;
+ }
?>
<FORM name="form" method="post" action="<?=$ME ?>">
<CENTER>
</select> <?php helpbutton("shows", get_string("showall", "glossary"), "glossary") ?>
</TD>
</TR>
+<?php
+ //Only show rss parameters if rss is activated at site and glossary levels
+ if ($CFG->enablerssfeeds && $CFG->glossary_enablerssfeeds) {
+ echo "<tr valign=top>";
+ echo "<td align=right><p><b>".get_string("rsstype")."</b></p></td>";
+ echo "<td>";
+ unset($choices);
+ $choices[0] = get_string("none");
+ $choices[1] = get_string("withauthor", "glossary");
+ $choices[2] = get_string("withoutauthor", "glossary");
+ choose_from_menu ($choices, "rsstype", $form->rsstype, "");
+ helpbutton("rsstype", get_string("rsstype"), "glossary");
+ echo "</td>";
+ echo "</tr>";
+
+ echo "<tr valign=top>";
+ echo "<td align=right><p><b>".get_string("rssarticles")."</b></p></td>";
+ echo "<td>";
+ unset($choices);
+ $choices[0] = "0";
+ $choices[1] = "1";
+ $choices[2] = "2";
+ $choices[3] = "3";
+ $choices[4] = "4";
+ $choices[5] = "5";
+ $choices[10] = "10";
+ $choices[15] = "15";
+ $choices[20] = "20";
+ $choices[25] = "25";
+ $choices[30] = "30";
+ $choices[40] = "40";
+ $choices[50] = "50";
+ choose_from_menu ($choices, "rssarticles", $form->rssarticles, "");
+ helpbutton("rssarticles", get_string("rssarticles"), "glossary");
+ echo "</td>";
+ echo "</tr>";
+ }
+?>
<tr>
<td align=right valign=top><p><b><?php print_string("allowratings", "glossary") ?>:</b></p></td>
<td>
--- /dev/null
+<?PHP // $Id$
+ //This file adds support to rss feeds generation
+
+ //This function is the main entry point to glossary
+ //rss feeds generation. Foreach site glossary with rss enabled
+ //build one XML rss structure.
+ function glossary_rss_feeds() {
+
+ global $CFG;
+
+ $status = true;
+
+ //Check CFG->enablerssfeeds
+ if (empty($CFG->enablerssfeeds)) {
+ //Some debug...
+ if ($CFG->debug > 7) {
+ echo "DISABLED (admin variables)";
+ }
+ //Check CFG->glossary_enablerssfeeds
+ } else if (empty($CFG->glossary_enablerssfeeds)) {
+ //Some debug...
+ if ($CFG->debug > 7) {
+ echo "DISABLED (module configuration)";
+ }
+ //It's working so we start...
+ } else {
+ //Iterate over all glossaries
+ if ($glossaries = get_records("glossary")) {
+ foreach ($glossaries as $glossary) {
+ if (!empty($glossary->rsstype) && !empty($glossary->rssarticles) && $status) {
+ //Some debug...
+ if ($CFG->debug > 7) {
+ echo "ID: $glossary->id->";
+ }
+ //Get the XML contents
+ $result = glossary_rss_feed($glossary);
+ //Save the XML contents to file
+ if (!empty($result)) {
+ $status = rss_save_file("glossary",$glossary,$result);
+ }
+ //Some debug...
+ if ($CFG->debug > 7) {
+ if (empty($result)) {
+ echo "(empty) ";
+ } else {
+ if (!empty($status)) {
+ echo "OK ";
+ } else {
+ echo "FAIL ";
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return $status;
+ }
+
+ //This function return the XML rss contents about the glossary record passed as parameter
+ //It returns false if something is wrong
+ function glossary_rss_feed($glossary) {
+
+ global $CFG;
+
+ $status = true;
+
+ //Check CFG->enablerssfeeds
+ if (empty($CFG->enablerssfeeds)) {
+ //Some debug...
+ if ($CFG->debug > 7) {
+ echo "DISABLED (admin variables)";
+ }
+ //Check CFG->glossary_enablerssfeeds
+ } else if (empty($CFG->glossary_enablerssfeeds)) {
+ //Some debug...
+ if ($CFG->debug > 7) {
+ echo "DISABLED (module configuration)";
+ }
+ //It's working so we start...
+ } else {
+ //Check the glossary has rss activated
+ if (!empty($glossary->rsstype) && !empty($glossary->rssarticles)) {
+ //Depending of the glossary->rsstype, we are going to execute, different sqls
+ if ($glossary->rsstype == 1) { //With author RSS
+ $items = glossary_rss_feed_withauthor($glossary);
+ } else { //Without author RSS
+ $items = glossary_rss_feed_withoutauthor($glossary);
+
+ }
+ //Now, if items, we begin building the structure
+ if (!empty($items)) {
+ //First all rss feeds common headers
+ $header = rss_standard_header($glossary->name,
+ $CFG->wwwroot."/mod/glossary/view.php?f=".$glossary->id,
+ $glossary->intro);
+ //Now all the rss items
+ if (!empty($header)) {
+ $articles = rss_add_items($items);
+ }
+ //Now all rss feeds common footers
+ if (!empty($header) && !empty($articles)) {
+ $footer = rss_standard_footer();
+ }
+ //Now, if everything is ok, concatenate it
+ if (!empty($header) && !empty($articles) && !empty($footer)) {
+ $status = $header.$articles.$footer;
+ } else {
+ $status = false;
+ }
+ } else {
+ $status = false;
+ }
+ }
+ }
+ return $status;
+ }
+
+ //This function returns "items" record array to be used to build the rss feed
+ //for a Type=with author glossary
+ function glossary_rss_feed_withauthor($glossary) {
+
+ global $CFG;
+
+ $items = array();
+
+ if ($recs = get_records_sql ("SELECT e.id entryid,
+ e.concept entryconcept,
+ e.definition entrydefinition,
+ e.format entryformat,
+ e.timecreated entrytimecreated,
+ u.id userid,
+ u.firstname userfirstname,
+ u.lastname userlastname
+ FROM {$CFG->prefix}glossary_entries e,
+ {$CFG->prefix}user u
+ WHERE e.glossaryid = '$glossary->id' AND
+ u.id = e.userid
+ ORDER BY e.timecreated desc")) {
+ //Iterate over each entry to get glossary->rssarticles records
+ $articlesleft = $glossary->rssarticles;
+ $item = NULL;
+ $user = NULL;
+ foreach ($recs as $rec) {
+ unset($item);
+ unset($user);
+ $item->title = $rec->entryconcept;
+ $user->firstname = $rec->userfirstname;
+ $user->lastname = $rec->userlastname;
+ $item->author = fullname($user);
+ $item->pubdate = $rec->entrytimecreated;
+ $item->link = $CFG->wwwroot."/mod/glossary/showentry.php?courseid=".$glossary->course."&eid=".$rec->entryid;
+ $item->description = format_text($rec->entrydefinition,$rec->entryformat,NULL,$glossary->course);
+ $items[] = $item;
+ $articlesleft--;
+ if ($articlesleft < 1) {
+ break;
+ }
+ }
+ }
+ return $items;
+ }
+
+ //This function returns "items" record array to be used to build the rss feed
+ //for a Type=without author glossary
+ function glossary_rss_feed_withoutauthor($glossary) {
+
+ global $CFG;
+
+ $items = array();
+
+ if ($recs = get_records_sql ("SELECT e.id entryid,
+ e.concept entryconcept,
+ e.definition entrydefinition,
+ e.format entryformat,
+ e.timecreated entrytimecreated,
+ u.id userid,
+ u.firstname userfirstname,
+ u.lastname userlastname
+ FROM {$CFG->prefix}glossary_entries e,
+ {$CFG->prefix}user u
+ WHERE e.glossaryid = '$glossary->id' AND
+ u.id = e.userid
+ ORDER BY e.timecreated desc")) {
+ //Iterate over each entry to get glossary->rssarticles records
+ $articlesleft = $glossary->rssarticles;
+ $item = NULL;
+ $user = NULL;
+ foreach ($recs as $rec) {
+ unset($item);
+ unset($user);
+ $item->title = $rec->entryconcept;
+ $user->firstname = $rec->userfirstname;
+ $user->lastname = $rec->userlastname;
+ //$item->author = fullname($user);
+ $item->pubdate = $rec->entrytimecreated;
+ $item->link = $CFG->wwwroot."/mod/glossary/showentry.php?courseid=".$glossary->course."&eid=".$rec->entryid;
+ $item->description = format_text($rec->entrydefinition,$rec->entryformat,NULL,$glossary->course);
+ $items[] = $item;
+ $articlesleft--;
+ if ($articlesleft < 1) {
+ break;
+ }
+ }
+ }
+ return $items;
+ }
+
+?>
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
/////////////////////////////////////////////////////////////////////////////////
-$module->version = 2004022200; // The current module version (Date: YYYYMMDDXX)
-$module->requires = 2004013101; // Requires this Moodle version
+$module->version = 2004050900; // The current module version (Date: YYYYMMDDXX)
+$module->requires = 2004050300; // Requires this Moodle version
$module->cron = 0; // Period for cron to check this module (secs)
$release = "0.5 development"; // User-friendly version number
/// This page prints a particular instance of glossary
require_once("../../config.php");
require_once("lib.php");
+ require_once("$CFG->dirroot/rss/rsslib.php");
+
global $CFG, $THEME, $USER;
$debug = 0;
$CFG->startpagetime = microtime();
"$navigation <A HREF=index.php?id=$course->id>$strglossaries</A> -> $glossary->name",
"", "", true, update_module_button($cm->id, $course->id, $strglossary),
navmenu($course, $cm));
+
+ //If rss are activated at site and glossary level and this glossary has rss defined, show link
+ if ($CFG->enablerssfeeds && $CFG->glossary_enablerssfeeds && $glossary->rsstype and $glossary->rssarticles) {
+ echo '<table width="100%" border="0" cellpadding="3" cellspacing="0"><tr valign="top"><td align="right">';
+ $tooltiptext = get_string("rsssubscriberss","glossary",$glossary->name);
+ rss_print_link($course->id, $USER->id, "glossary", $glossary->id, $tooltiptext);
+ echo '</td></tr></table>';
+ }
echo '<p align="center"><font size="3"><b>' . stripslashes_safe($glossary->name);
if ( $isuserframe and $mode != 'search') {