]> git.mjollnir.org Git - moodle.git/commitdiff
Removed $forum->open, $forum->assesspublic from code. Fixed bug in upgrade
authorvyshane <vyshane>
Mon, 21 Aug 2006 06:56:04 +0000 (06:56 +0000)
committervyshane <vyshane>
Mon, 21 Aug 2006 06:56:04 +0000 (06:56 +0000)
code, changed module config form to accomdate removal of forum.assesspublic
and forum.open.

mod/forum/backuplib.php
mod/forum/db/mysql.php
mod/forum/index.php
mod/forum/lib.php
mod/forum/mod.html
mod/forum/restorelib.php
mod/forum/version.php
mod/forum/view.php

index 06f4f51dc01c39a9cae8c421b0e89a2d99575c9a..7bf899599cd8055d6f8597f4e31f9ac3eb86cc4d 100644 (file)
@@ -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));
index 9d638ef4164d3ed625d0feb6af6053e8ac581851..7ec65aee11c8864a0f7bc02f24865b278df6ed04 100644 (file)
@@ -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;
   
index c62d400577478637c6eea5343bc301c4ef1a5bb3..77d4b2402aba573a020e1ebed7cc3f4e8f99e424 100644 (file)
@@ -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)) {
         }
 
         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]);
 
     print_footer($course);
 
-?>
+?>
\ No newline at end of file
index 4c65e3af1d33cafbabd15514fd1958ec76e20c14..087bb68c3c42515a9126c3d3c28b48155e80d966 100644 (file)
@@ -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 '&nbsp;';
@@ -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;
index 5c5a2a5b74f1d18d4cafd0abb90bdc6f4d069854..15afffc8c87f8effa0a9d7ca46cb78876d92317e 100644 (file)
         $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;
         <?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>
 <?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>';
             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" ';
             }
             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)) {
index 463aca3d4264f635721ab39b236b247665d81071..c7c7d99e66dbd33c0465e378ee22903fc86b7b3b 100644 (file)
@@ -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']['#']);
index 1e54d56e09ae0d82770352ceaf1f42a1737581a4..ce44c5255d77084254f3f3bbcb7f84bc09fa8f5d 100644 (file)
@@ -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;
 
index 0519a3089818451a0b4cf987948a97709a5aa5b7..9b6c0f5d9bf1faa03fbd7a9b77a8b2ee8eae91ec 100644 (file)
     $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"));
     }