Note: You are currently viewing documentation for Moodle 2.0. Up-to-date documentation for the latest stable version is available here: Make News on Front Page viewable to Teachers only.

Make News on Front Page viewable to Teachers only: Difference between revisions

From MoodleDocs
No edit summary
No edit summary
 
(12 intermediate revisions by 3 users not shown)
Line 1: Line 1:
In /index.php, look for '''case FRONTPAGENEWS:'''
The hack that was performed for this option in Moodle v1.9 is no longer an appropriate hack in Moodle 2. Better option is to use Roles, Permissions and Capabilities.


case FRONTPAGENEWS:
That is, create a new [[Create_custom_roles|Custom Role]], give it the Capabilities of viewing the News Forum in the Front Page then ensure that the Authenticated User, the Authenticated User on Front Page and Guest Roles do not have that option allowed.
<font color="#cc0000">if (isteacherinanycourse()) {</font>
if ($SITE->newsitems) { // Print forums only when needed
require_once($CFG->dirroot .'/mod/forum/lib.php');
if (! $newsforum = forum_get_course_forum($SITE->id, 'news')) {
error('Could not find or create a main news forum for the site');
}
if (isset($USER->id)) {
$SESSION->fromdiscussion = $CFG->wwwroot;
if (forum_is_subscribed($USER->id, $newsforum->id)) {
$subtext = get_string('unsubscribe', 'forum');
} else {
$subtext = get_string('subscribe', 'forum');
}
$headertext = '&lt;table width="100%" border="0" cellspacing="0" cellpadding="0">&lt;tr>'.
'&lt;td&gt;&lt;div class="title"&gt;'.$newsforum->name.'&lt;/div&gt;&lt;/td&gt;'.
'&lt;td&gt;&lt;div class="link"&gt;&lt;a href="mod/forum/subscribe.php?id='.$newsforum->id.'"&gt;'.$subtext.'&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;'.
'&lt;/tr&gt;&lt;/table&gt;';
} else {
$headertext = $newsforum->name;
}
print_heading_block($headertext);
forum_print_latest_discussions($SITE, $newsforum, $SITE->newsitems);
}
<font color="#cc0000">}</font>
break;

Latest revision as of 03:38, 24 July 2011

The hack that was performed for this option in Moodle v1.9 is no longer an appropriate hack in Moodle 2. Better option is to use Roles, Permissions and Capabilities.

That is, create a new Custom Role, give it the Capabilities of viewing the News Forum in the Front Page then ensure that the Authenticated User, the Authenticated User on Front Page and Guest Roles do not have that option allowed.