From d445d3d8e77b44129ffc6cc38179582a67d98e41 Mon Sep 17 00:00:00 2001 From: Dean Stringer Date: Mon, 23 Feb 2009 14:50:08 +1300 Subject: [PATCH] module : oublog : UOW tweaks for other group commenting option --- .../en_utf8/help/oublog/allowcommentsnongroup.html | 9 +++ mod/oublog/lang/en_utf8/oublog.php | 4 +- mod/oublog/lib.php | 3 +- mod/oublog/locallib.php | 7 ++ mod/oublog/mod_form.php | 10 +++- mod/oublog/view.php | 64 ++++++++++++-------- mod/oublog/viewpost.php | 9 +++- 7 files changed, 76 insertions(+), 30 deletions(-) create mode 100755 mod/oublog/lang/en_utf8/help/oublog/allowcommentsnongroup.html diff --git a/mod/oublog/lang/en_utf8/help/oublog/allowcommentsnongroup.html b/mod/oublog/lang/en_utf8/help/oublog/allowcommentsnongroup.html new file mode 100755 index 0000000..4a51b2c --- /dev/null +++ b/mod/oublog/lang/en_utf8/help/oublog/allowcommentsnongroup.html @@ -0,0 +1,9 @@ +

OU blog

+ +

Comments from Other Groups

+ +

When you set up a blog and you are intending to use Group mode you can choose whether members of other groups are allowed to add comments to that post.

+ +

If you set the option "Comments Not Allowed" then only members of the group that owns the blog will be able to make comments.

+ +

When you set the option to "Allow Comments" then anyone who has access to view the blog will be able to also make comments.

diff --git a/mod/oublog/lang/en_utf8/oublog.php b/mod/oublog/lang/en_utf8/oublog.php index c00fad0..89984cb 100644 --- a/mod/oublog/lang/en_utf8/oublog.php +++ b/mod/oublog/lang/en_utf8/oublog.php @@ -21,6 +21,8 @@ $string['message'] = 'Message'; $string['tags'] = 'Tags'; $string['allowcomments'] = 'Allow comments'; $string['nocomments'] = 'Comments not allowed'; +$string['allowcommentsnongroup'] = 'Comments from other groups'; +$string['nocommentsnongroup'] = 'Comments not allowed from non group members'; $string['visibility'] = 'Who can read this?'; $string['maxvisibility'] = 'Maximum visibility'; $string['yes'] = 'Yes'; @@ -131,4 +133,4 @@ $string['overviewnumentrylog1'] = 'entry since last log in'; $string['overviewnumentrylog'] = 'entries since last log in'; $string['overviewnumentryvw1'] = 'entry since last viewed'; $string['overviewnumentryvw'] = 'entries since last viewed'; -?> \ No newline at end of file +?> diff --git a/mod/oublog/locallib.php b/mod/oublog/locallib.php index 508c6ea..0624ee9 100644 --- a/mod/oublog/locallib.php +++ b/mod/oublog/locallib.php @@ -34,6 +34,13 @@ define('OUBLOG_COMMENTS_ALLOW', 1); /**#@-*/ /**#@+ + * Constants defining the ability to post comments if not in the group + */ +define('OUBLOG_COMMENTS_NONGROUP_PREVENT', 0); +define('OUBLOG_COMMENTS_ALLOW_NONGROUP', 1); +/**#@-*/ + +/**#@+ * Constant defining the number of posts to display per page */ define('OUBLOG_POSTS_PER_PAGE', 20); diff --git a/mod/oublog/mod_form.php b/mod/oublog/mod_form.php index 817f6a4..40f3278 100644 --- a/mod/oublog/mod_form.php +++ b/mod/oublog/mod_form.php @@ -45,6 +45,14 @@ class mod_oublog_mod_form extends moodleform_mod { $mform->setType('allowcomments', PARAM_INT); $mform->setHelpButton('allowcomments', array('allowcomments', get_string('allowcomments', 'oublog'), 'oublog')); + /// Adding the "allowcommentsnongroup" field + $options = array(OUBLOG_COMMENTS_ALLOW_NONGROUP => get_string('allowcomments', 'oublog'), + OUBLOG_COMMENTS_NONGROUP_PREVENT => get_string('nocomments', 'oublog')); + + $mform->addElement('select', 'allowcommentsnongroup', get_string('allowcommentsnongroup', 'oublog'), $options); + $mform->setType('allowcommentsnongroup', PARAM_INT); + $mform->setHelpButton('allowcommentsnongroup', array('allowcommentsnongroup', get_string('allowcommentsnongroup', 'oublog'), 'oublog')); + /// Adding the "maxvisibility" field $options = array(OUBLOG_VISIBILITY_COURSEUSER => get_string('visiblecourseusers', 'oublog'), OUBLOG_VISIBILITY_LOGGEDINUSER => get_string('visibleloggedinusers', 'oublog'), @@ -133,4 +141,4 @@ class mod_oublog_mod_form extends moodleform_mod { } -?> \ No newline at end of file +?> diff --git a/mod/oublog/view.php b/mod/oublog/view.php index 1671849..0811f31 100644 --- a/mod/oublog/view.php +++ b/mod/oublog/view.php @@ -101,12 +101,13 @@ $DISABLESAMS=true; /// Set-up groups $currentgroup = groups_get_activity_group($cm, true); $groupmode = groups_get_activity_groupmode($cm); - if($groupmode==VISIBLEGROUPS && !groups_is_member($currentgroup) && - !has_capability('moodle/site:accessallgroups',$context)) { + !has_capability('moodle/site:accessallgroups', $context)) { $canpost=false; - $canmanageposts=false; - $cancomment=false; + if (!$oublog->allowcommentsnongroup) { + $cancomment=false; + } + $canmanageposts=false; $canaudit=false; } @@ -224,6 +225,34 @@ if($hasleft=!empty($CFG->showblocksonmodpages) && (blocks_have_content($pagebloc print ''; } diff --git a/mod/oublog/viewpost.php b/mod/oublog/viewpost.php index 2748161..5993830 100644 --- a/mod/oublog/viewpost.php +++ b/mod/oublog/viewpost.php @@ -67,6 +67,13 @@ $DISABLESAMS=true; /// Set-up groups $currentgroup = groups_get_activity_group($cm, true); $groupmode = groups_get_activity_groupmode($cm); + if($groupmode==VISIBLEGROUPS && !groups_is_member($currentgroup) && + !has_capability('moodle/site:accessallgroups', $context)) { + if (!$oublog->allowcommentsnongroup) { + $cancomment=false; + } + } + /// Generate extra navigation $extranav = array(); @@ -198,4 +205,4 @@ $DISABLESAMS=true; /// Finish the page echo '
'; print_footer($course); -?> \ No newline at end of file +?> -- 1.5.5.4