]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-8578 new capability for adding and replying to news in forum
authorskodak <skodak>
Fri, 2 Mar 2007 19:41:31 +0000 (19:41 +0000)
committerskodak <skodak>
Fri, 2 Mar 2007 19:41:31 +0000 (19:41 +0000)
lang/en_utf8/forum.php
mod/forum/db/access.php
mod/forum/discuss.php
mod/forum/lib.php
mod/forum/post.php
mod/forum/version.php

index 8c08790e8a2526535cd347e29384fcca32458101..8d6c1e875e5a2277efa33593c896d22b07d25616 100644 (file)
@@ -69,6 +69,7 @@ $string['existingsubscribers'] = 'Existing subscribers';
 $string['forcesubscribe'] = 'Force everyone to be subscribed';
 $string['forcesubscribeq'] = 'Force everyone to be subscribed?';
 $string['forum'] = 'Forum';
+$string['forum:addnews'] = 'Add news';
 $string['forum:createattachment'] = 'Create attachments';
 $string['forum:deleteanypost'] = 'Delete any posts (anytime)';
 $string['forum:deleteownpost'] = 'Delete own posts (within deadline)';
@@ -78,6 +79,7 @@ $string['forum:movediscussions'] = 'Move discussions';
 $string['forum:throttlingapplies'] = 'Throttling applies';
 $string['forum:rate'] = 'Rate posts';
 $string['forum:replypost'] = 'Reply to posts';
+$string['forum:replynews'] = 'Reply to news';
 $string['forum:splitdiscussions'] = 'Split discussions';
 $string['forum:startdiscussion'] = 'Start new discussions';
 $string['forum:viewanyrating'] = 'View any ratings';
index 2519629d475804acb0d174d4e8254d0952fc6666..a230b8e975009f1560a24c9d2a9e798b9e41abc3 100644 (file)
@@ -85,6 +85,32 @@ $mod_forum_capabilities = array(
         )
     ),
 
+    'mod/forum:addnews' => array(
+
+        'riskbitmask' => RISK_SPAM,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_MODULE,
+        'legacy' => array(
+            'teacher' => CAP_ALLOW,
+            'editingteacher' => CAP_ALLOW,
+            'admin' => CAP_ALLOW
+        )
+    ),
+
+    'mod/forum:replynews' => array(
+
+        'riskbitmask' => RISK_SPAM,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_MODULE,
+        'legacy' => array(
+            'teacher' => CAP_ALLOW,
+            'editingteacher' => CAP_ALLOW,
+            'admin' => CAP_ALLOW
+        )
+    ),
+
     'mod/forum:viewrating' => array(
 
         'captype' => 'read',
index 9736f6c6c752462f1c6174f8a32fc8ade81ef889..4d11370abc962f13c4d4ac807dba99ed5de00a20 100644 (file)
                     (ismember($discussion->groupid) || $mygroupid == $discussion->groupid) );
         }
     } else {
-        if (!has_capability('mod/forum:replypost', $modcontext)) {
+        if ($forum->type == 'news') {
+            $capname = 'mod/forum:replynews';
+        } else {
+            $capname = 'mod/forum:replypost';
+        }
+
+        if (!has_capability($capname, $modcontext)) {
             $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
             if (!has_capability('moodle/legacy:guest', $coursecontext, NULL, false)) {  // User is a guest here!
                 $canreply = false;
index d0e356b265076e7063887ef25d00182b34b002d9..06b2afea43cd91127610360b38e47353d92ee841 100644 (file)
@@ -2923,7 +2923,13 @@ function forum_user_can_post_discussion($forum, $currentgroup=false, $groupmode=
     }
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
 
-    if (!has_capability('mod/forum:startdiscussion', $context)) {
+    if ($forum->type == 'news') {
+        $capname = 'mod/forum:addnews';
+    } else {
+        $capname = 'mod/forum:startdiscussion';
+    }
+
+    if (!has_capability($capname, $context)) {
         return false;
     }
 
@@ -2957,11 +2963,17 @@ function forum_user_can_post($forum, $user=NULL) {
     }
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
 
-    if (isset($user)) {
-        $canreply = has_capability('mod/forum:replypost', $context, $user->id, false)
+    if ($forum->type == 'news') {
+        $capname = 'mod/forum:replynews';
+    } else {
+        $capname = 'mod/forum:replypost';
+    }
+
+    if (!empty($user)) {
+        $canreply = has_capability($capname, $context, $user->id, false)
                 && !has_capability('moodle/legacy:guest', $context, $user->id, false);
     } else {
-        $canreply = has_capability('mod/forum:replypost', $context, NULL, false)
+        $canreply = has_capability($capname, $context, NULL, false)
                 && !has_capability('moodle/legacy:guest', $context, NULL, false);
     }
 
index 5ef4958b57eb844373f41fd76fddd2dedc37e9a7..19951d7f6e698819fbec0ca5f9046815e551ad60 100644 (file)
                     $timemessage = 4;
                 }
 
-                if ($fromform->mailnow) {
+                if (!empty($fromform->mailnow)) {
                     $message .= get_string("postmailnow", "forum");
                     $timemessage = 4;
                 } else {
index 966e4ed0a281922ef3134fcdca9dde880ea2cdc9..236ee2363a3c096720cf08726fb6f8d5a53029d6 100644 (file)
@@ -5,8 +5,8 @@
 //  This fragment is called by /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2007020200;
-$module->requires = 2007020200;  // Requires this Moodle version
+$module->version  = 2007020201;
+$module->requires = 2007020201;  // Requires this Moodle version
 $module->cron     = 60;
 
 ?>