mirror of
https://github.com/moodle/moodle.git
synced 2025-05-31 13:09:25 +02:00
Removed $forum->open, $forum->assesspublic from code. Fixed bug in upgrade
code, changed module config form to accomdate removal of forum.assesspublic and forum.open.
This commit is contained in:
parent
efc7316caa
commit
f0da6b858e
@ -71,9 +71,7 @@
|
||||
fwrite ($bf,full_tag("TYPE",4,false,$forum->type));
|
||||
fwrite ($bf,full_tag("NAME",4,false,$forum->name));
|
||||
fwrite ($bf,full_tag("INTRO",4,false,$forum->intro));
|
||||
fwrite ($bf,full_tag("OPEN",4,false,$forum->open));
|
||||
fwrite ($bf,full_tag("ASSESSED",4,false,$forum->assessed));
|
||||
fwrite ($bf,full_tag("ASSESSPUBLIC",4,false,$forum->assesspublic));
|
||||
fwrite ($bf,full_tag("ASSESSTIMESTART",4,false,$forum->assesstimestart));
|
||||
fwrite ($bf,full_tag("ASSESSTIMEFINISH",4,false,$forum->assesstimefinish));
|
||||
fwrite ($bf,full_tag("MAXBYTES",4,false,$forum->maxbytes));
|
||||
|
@ -229,12 +229,10 @@ function forum_upgrade($oldversion) {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
// Upgrades for new roles and capabilities support.
|
||||
if ($oldversion < 2006081800) {
|
||||
// Upgrades for new roles and capabilities support.
|
||||
$forummodid = get_record('modules', 'name', 'forum');
|
||||
|
||||
|
||||
if ($forums = get_records('forum')) {
|
||||
|
||||
if (!$studentroles = get_roles_with_capability('moodle/legacy:student', CAP_ALLOW)) {
|
||||
@ -247,9 +245,11 @@ function forum_upgrade($oldversion) {
|
||||
foreach ($forums as $forum) {
|
||||
|
||||
if ($forum->type == 'teacher') {
|
||||
|
||||
// Teacher forums should be converted to normal forums that
|
||||
// use the Roles System to implement the old behavior.
|
||||
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
|
||||
// Delete empty teacher forums.
|
||||
if (count_records('forum_discussions', 'forum', $forum->id) == 0) {
|
||||
delete_records('forum', 'id', $forum->id);
|
||||
@ -356,10 +356,11 @@ function forum_upgrade($oldversion) {
|
||||
break;
|
||||
}
|
||||
// Drop column forum.open.
|
||||
modify_database('','ALTER TABLE prefix_forum DROP COLUMN open;');
|
||||
modify_database('', 'ALTER TABLE prefix_forum DROP COLUMN open;');
|
||||
|
||||
|
||||
// $forum->assessed defines who can rate posts:
|
||||
// $forum->assessed defines whether forum rating is turned
|
||||
// on (1 or 2) and who can rate posts:
|
||||
// 1 = Everyone can rate posts
|
||||
// 2 = Only teachers can rate posts
|
||||
switch ($forum->assessed) {
|
||||
@ -389,12 +390,12 @@ function forum_upgrade($oldversion) {
|
||||
break;
|
||||
}
|
||||
// Drop column forum.assesspublic.
|
||||
modify_database('','ALTER TABLE prefix_forum DROP COLUMN assesspublic;');
|
||||
modify_database('', 'ALTER TABLE prefix_forum DROP COLUMN assesspublic;');
|
||||
}
|
||||
} // End foreach $teacherforums.
|
||||
} // End if.
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
|
@ -4,8 +4,8 @@
|
||||
require_once("lib.php");
|
||||
require_once("$CFG->libdir/rsslib.php");
|
||||
|
||||
$id = optional_param('id',0,PARAM_INT); // course
|
||||
$subscribe = optional_param('subscribe',null,PARAM_INT); // Subscribe/Unsubscribe all forums
|
||||
$id = optional_param('id', 0, PARAM_INT); // Course id
|
||||
$subscribe = optional_param('subscribe', null, PARAM_INT); // Subscribe/Unsubscribe all forums
|
||||
|
||||
if ($id) {
|
||||
if (! $course = get_record("course", "id", $id)) {
|
||||
@ -89,10 +89,18 @@
|
||||
}
|
||||
|
||||
foreach ($forums as $forum) {
|
||||
|
||||
$cm = get_coursemodule_from_instance("forum", $forum->id, $course->id);
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
|
||||
if (!has_capability('mod/forum:viewforum', $context)) {
|
||||
if (isset($forum->keyreference)) {
|
||||
unset($learningforums[$forum->keyreference]);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (!isset($forum->visible)) {
|
||||
$forum->visible = instance_is_visible("forum", $forum);
|
||||
$cm = get_coursemodule_from_instance("forum", $forum->id, $course->id);
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
if (!$forum->visible and !has_capability('moodle/course:viewhiddenactivities', $context)) {
|
||||
if (isset($forum->keyreference)) {
|
||||
unset($learningforums[$forum->keyreference]);
|
||||
@ -468,4 +476,4 @@
|
||||
|
||||
print_footer($course);
|
||||
|
||||
?>
|
||||
?>
|
@ -94,10 +94,10 @@ function forum_add_instance($forum) {
|
||||
|
||||
$forum->timemodified = time();
|
||||
|
||||
if (!$forum->userating) {
|
||||
if (!$forum->assessed) {
|
||||
$forum->assessed = 0;
|
||||
}
|
||||
|
||||
|
||||
if (!empty($forum->ratingtime)) {
|
||||
$forum->assesstimestart = make_timestamp($forum->startyear, $forum->startmonth, $forum->startday,
|
||||
$forum->starthour, $forum->startminute, 0);
|
||||
@ -145,10 +145,10 @@ function forum_update_instance($forum) {
|
||||
$forum->timemodified = time();
|
||||
$forum->id = $forum->instance;
|
||||
|
||||
if (empty($forum->userating)) {
|
||||
if (empty($forum->assessed)) {
|
||||
$forum->assessed = 0;
|
||||
}
|
||||
|
||||
|
||||
if (!empty($forum->ratingtime)) {
|
||||
$forum->assesstimestart = make_timestamp($forum->startyear, $forum->startmonth, $forum->startday,
|
||||
$forum->starthour, $forum->startminute, 0);
|
||||
@ -1583,7 +1583,6 @@ function forum_get_course_forum($courseid, $type) {
|
||||
$forum->name = addslashes(get_string("namenews", "forum"));
|
||||
$forum->intro = addslashes(get_string("intronews", "forum"));
|
||||
$forum->forcesubscribe = FORUM_FORCESUBSCRIBE;
|
||||
$forum->open = 1; // 0 - no, 1 - posts only, 2 - discuss and post
|
||||
$forum->assessed = 0;
|
||||
if ($courseid == SITEID) {
|
||||
$forum->name = get_string("sitenews");
|
||||
@ -1593,14 +1592,12 @@ function forum_get_course_forum($courseid, $type) {
|
||||
case "social":
|
||||
$forum->name = addslashes(get_string("namesocial", "forum"));
|
||||
$forum->intro = addslashes(get_string("introsocial", "forum"));
|
||||
$forum->open = 2; // 0 - no, 1 - posts only, 2 - discuss and post
|
||||
$forum->assessed = 0;
|
||||
$forum->forcesubscribe = 0;
|
||||
break;
|
||||
case "teacher":
|
||||
$forum->name = addslashes(get_string("nameteacher", "forum"));
|
||||
$forum->intro = addslashes(get_string("introteacher", "forum"));
|
||||
$forum->open = 2; // 0 - no, 1 - posts only, 2 - discuss and post
|
||||
$forum->assessed = 0;
|
||||
$forum->forcesubscribe = 0;
|
||||
break;
|
||||
@ -1984,7 +1981,7 @@ function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link
|
||||
|
||||
$canviewallratings = has_capability('mod/forum:viewanyrating', $modcontext);
|
||||
|
||||
if (($canviewallratings or $ratings->assesspublic) and !$mypost) {
|
||||
if ($canviewallratings and !$mypost) {
|
||||
forum_print_ratings_mean($post->id, $ratings->scale, $canviewallratings);
|
||||
if (!empty($ratings->allow)) {
|
||||
echo ' ';
|
||||
@ -2095,7 +2092,7 @@ function forum_print_discussion_header(&$post, $forum, $group=-1, $datestring=""
|
||||
echo "</td>\n";
|
||||
}
|
||||
|
||||
if ($forum->open or $forum->type == 'teacher') { // Show the column with replies
|
||||
if (has_capability('mod/forum:viewdiscussion', $modcontext)) { // Show the column with replies
|
||||
echo '<td class="replies">';
|
||||
echo '<a href="'.$CFG->wwwroot.'/mod/forum/discuss.php?d='.$post->discussion.'">';
|
||||
echo $post->replies.'</a>';
|
||||
@ -2794,14 +2791,14 @@ function forum_user_can_post_discussion($forum, $currentgroup=false, $groupmode=
|
||||
return (!forum_user_has_posted_discussion($forum->id, $USER->id));
|
||||
} else if ($currentgroup) {
|
||||
return (has_capability('moodle/site:accessallgroups', $context)
|
||||
or (ismember($currentgroup) and $forum->open == 2));
|
||||
or ismember($currentgroup));
|
||||
} else {
|
||||
//else it might be group 0 in visible mode
|
||||
if ($groupmode == VISIBLEGROUPS){
|
||||
return ($forum->open == 2 and ismember($currentgroup));
|
||||
return (ismember($currentgroup));
|
||||
}
|
||||
else {
|
||||
return ($forum->open == 2);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2815,11 +2812,6 @@ function forum_user_can_post_discussion($forum, $currentgroup=false, $groupmode=
|
||||
*/
|
||||
function forum_user_can_post($forum, $user=NULL) {
|
||||
|
||||
if (!$forum->open) {
|
||||
// No point doing the more expensive has_capability checks.
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $forum->course)) {
|
||||
error('Course Module ID was incorrect');
|
||||
}
|
||||
@ -3084,7 +3076,7 @@ function forum_print_latest_discussions($course, $forum, $maxdiscussions=5, $dis
|
||||
if ($groupmode > 0) {
|
||||
echo '<th class="header group">'.get_string('group').'</th>';
|
||||
}
|
||||
if ($forum->open or $forum->type == 'teacher') {
|
||||
if (has_capability('mod/forum:viewdiscussion', $context)) {
|
||||
echo '<th class="header replies">'.get_string('replies', 'forum').'</th>';
|
||||
/// If the forum can be tracked, display the unread column.
|
||||
if ($cantrack) {
|
||||
@ -3208,7 +3200,6 @@ function forum_print_discussion($course, $forum, $discussion, $post, $mode, $can
|
||||
$ratingsmenuused = false;
|
||||
if ($forum->assessed and !empty($USER->id)) {
|
||||
if ($ratings->scale = make_grades_menu($forum->scale)) {
|
||||
$ratings->assesspublic = $forum->assesspublic;
|
||||
$ratings->assesstimestart = $forum->assesstimestart;
|
||||
$ratings->assesstimefinish = $forum->assesstimefinish;
|
||||
$ratings->allow = $canrate;
|
||||
|
@ -14,10 +14,7 @@
|
||||
$form->open = 2;
|
||||
}
|
||||
if (!isset($form->assessed)) {
|
||||
$form->assessed = 1;
|
||||
}
|
||||
if (!isset($form->assesspublic)) {
|
||||
$form->assesspublic = 1;
|
||||
$form->assessed = 0;
|
||||
}
|
||||
if (!isset($form->forcesubscribe)) {
|
||||
$form->forcesubscribe = 0;
|
||||
@ -105,6 +102,17 @@
|
||||
<?php print_textarea($usehtmleditor, 20, 50, 680, 400, 'intro', $form->intro); ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?php print_string('allowdiscussions', 'forum', strtolower("$course->student")) ?>:</b></td>
|
||||
<td>
|
||||
<?php
|
||||
choose_from_menu($FORUM_OPEN_MODES, 'open', $form->open, '');
|
||||
helpbutton('allowdiscussions', get_string('allowdiscussions',
|
||||
'forum', moodle_strtolower("$course->student")), 'forum');
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"><b><?php print_string('forcesubscribeq', 'forum') ?>:</b></td>
|
||||
<td>
|
||||
@ -149,7 +157,8 @@
|
||||
<?php
|
||||
//Only show rss parameters if rss is activated at site and forum levels
|
||||
if ($CFG->enablerssfeeds
|
||||
&& isset($CFG->forum_enablerssfeeds) && $CFG->forum_enablerssfeeds) {
|
||||
&& isset($CFG->forum_enablerssfeeds)
|
||||
&& $CFG->forum_enablerssfeeds) {
|
||||
echo '<tr valign="top">';
|
||||
echo '<td align="right"><b>'.get_string('rsstype').':</b></td>';
|
||||
echo '<td>';
|
||||
@ -195,13 +204,14 @@
|
||||
echo '<script type="text/javascript">';
|
||||
echo " var subitemstime = ['startday','startmonth','startyear','starthour', 'startminute',".
|
||||
"'finishday','finishmonth','finishyear','finishhour','finishminute'];";
|
||||
echo " var subitemsall = ['assessed', 'assesspublic', 'ratingtime', 'scale', ".
|
||||
"'startday','startmonth','startyear','starthour', 'startminute',".
|
||||
"'finishday','finishmonth','finishyear','finishhour','finishminute'];";
|
||||
|
||||
echo " var subitemsall = ['ratingtime', 'scale', ".
|
||||
"'startday','startmonth','startyear','starthour', 'startminute',".
|
||||
"'finishday','finishmonth','finishyear','finishhour','finishminute'];";
|
||||
echo '</script>';
|
||||
|
||||
echo '<input name="userating" type="checkbox" alt="'.get_string('ratingsuse', 'forum').'" value="1" ';
|
||||
echo " onclick=\"return lockoptions('form','userating', subitemsall)\" ";
|
||||
echo '<input name="assessed" type="checkbox" alt="'.get_string('ratingsuse', 'forum').'" value="1" ';
|
||||
echo " onclick=\"return lockoptions('form','assessed', subitemsall)\" ";
|
||||
if ($form->assessed) {
|
||||
echo ' checked="checked" ';
|
||||
}
|
||||
@ -257,7 +267,7 @@
|
||||
echo '<input type="hidden" name="hfinishminute" value="0" />';
|
||||
|
||||
echo '<script type="text/javascript">';
|
||||
echo "lockoptions('form','userating', subitemsall);";
|
||||
echo "lockoptions('form','assessed', subitemsall);";
|
||||
echo '</script>';
|
||||
|
||||
if (empty($form->ratingtime)) {
|
||||
|
@ -53,9 +53,7 @@
|
||||
$forum->type = backup_todb($info['MOD']['#']['TYPE']['0']['#']);
|
||||
$forum->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
|
||||
$forum->intro = backup_todb($info['MOD']['#']['INTRO']['0']['#']);
|
||||
$forum->open = backup_todb($info['MOD']['#']['OPEN']['0']['#']);
|
||||
$forum->assessed = backup_todb($info['MOD']['#']['ASSESSED']['0']['#']);
|
||||
$forum->assesspublic = backup_todb($info['MOD']['#']['ASSESSPUBLIC']['0']['#']);
|
||||
$forum->assesstimestart = backup_todb($info['MOD']['#']['ASSESSTIMESTART']['0']['#']);
|
||||
$forum->assesstimefinish = backup_todb($info['MOD']['#']['ASSESSTIMEFINISH']['0']['#']);
|
||||
$forum->maxbytes = backup_todb($info['MOD']['#']['MAXBYTES']['0']['#']);
|
||||
|
@ -5,7 +5,7 @@
|
||||
// This fragment is called by /admin/index.php
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$module->version = 2006080900;
|
||||
$module->version = 2006081800;
|
||||
$module->requires = 2006080900; // Requires this Moodle version
|
||||
$module->cron = 60;
|
||||
|
||||
|
@ -61,14 +61,13 @@
|
||||
$navigation = "<a href=\"index.php?id=$course->id\">$strforums</a> ->";
|
||||
|
||||
|
||||
/// Check whether the should be able to view this forum.
|
||||
/// Check whether the user should be able to view this forum.
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
|
||||
if (!has_capability('mod/forum:viewforum', $context)) {
|
||||
error('You do not have the permission to view this forum');
|
||||
}
|
||||
|
||||
|
||||
if ($cm->id) {
|
||||
add_to_log($course->id, "forum", "view forum", "view.php?id=$cm->id", "$forum->id", $cm->id);
|
||||
} else {
|
||||
@ -78,7 +77,7 @@
|
||||
print_header_simple(format_string($forum->name), "",
|
||||
"$navigation ".format_string($forum->name), "", "", true, $buttontext, navmenu($course, $cm));
|
||||
|
||||
if (empty($cm->visible) and !has_capability('moodle/course:manageactivities', $context)) {
|
||||
if (empty($cm->visible) and !has_capability('moodle/course:viewhiddenactivities', $context)) {
|
||||
notice(get_string("activityiscurrentlyhidden"));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user