From 79b4fb128295d973c39e9aa6a59d9001832b1a0e Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Tue, 28 Oct 2014 14:27:05 +0800 Subject: [PATCH] MDL-46215 mod_forum: Only add text on discussion view Do not show the status text in the thread list. --- mod/forum/lib.php | 2 ++ mod/forum/subscribe_ajax.php | 3 ++- .../moodle-mod_forum-subscriptiontoggle-debug.js | 3 ++- .../moodle-mod_forum-subscriptiontoggle-min.js | 2 +- .../moodle-mod_forum-subscriptiontoggle.js | 3 ++- mod/forum/yui/src/subscriptiontoggle/js/toggle.js | 3 ++- 6 files changed, 11 insertions(+), 5 deletions(-) diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 3452e4bb0f4..1ecd6c33623 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -3791,6 +3791,7 @@ function forum_get_discussion_subscription_icon($forum, $discussionid, $returnur 'class' => 'discussiontoggle iconsmall', 'data-forumid' => $forum->id, 'data-discussionid' => $discussionid, + 'data-includetext' => $includetext, )); } else { $o .= html_writer::link($subscriptionlink, @@ -3800,6 +3801,7 @@ function forum_get_discussion_subscription_icon($forum, $discussionid, $returnur 'class' => 'discussiontoggle iconsmall', 'data-forumid' => $forum->id, 'data-discussionid' => $discussionid, + 'data-includetext' => $includetext, )); } diff --git a/mod/forum/subscribe_ajax.php b/mod/forum/subscribe_ajax.php index 28b7c6b86cf..cbee96ea9f5 100644 --- a/mod/forum/subscribe_ajax.php +++ b/mod/forum/subscribe_ajax.php @@ -29,6 +29,7 @@ require_once($CFG->dirroot . '/mod/forum/lib.php'); $forumid = required_param('forumid', PARAM_INT); // The forum to subscribe or unsubscribe. $discussionid = optional_param('discussionid', null, PARAM_INT); // The discussionid to subscribe. $sesskey = optional_param('sesskey', null, PARAM_RAW); +$includetext = optional_param('includetext', false, PARAM_BOOL); $forum = $DB->get_record('forum', array('id' => $forumid), '*', MUST_EXIST); $course = $DB->get_record('course', array('id' => $forum->course), '*', MUST_EXIST); @@ -56,6 +57,6 @@ if (\mod_forum\subscriptions::is_subscribed($USER->id, $forum, $discussion->id, } // Now return the updated subscription icon. -$return->icon = forum_get_discussion_subscription_icon($forum, $discussion->id, null, true); +$return->icon = forum_get_discussion_subscription_icon($forum, $discussion->id, null, $includetext); echo json_encode($return); die; diff --git a/mod/forum/yui/build/moodle-mod_forum-subscriptiontoggle/moodle-mod_forum-subscriptiontoggle-debug.js b/mod/forum/yui/build/moodle-mod_forum-subscriptiontoggle/moodle-mod_forum-subscriptiontoggle-debug.js index 879a241652d..44313f095bc 100644 --- a/mod/forum/yui/build/moodle-mod_forum-subscriptiontoggle/moodle-mod_forum-subscriptiontoggle-debug.js +++ b/mod/forum/yui/build/moodle-mod_forum-subscriptiontoggle/moodle-mod_forum-subscriptiontoggle-debug.js @@ -48,7 +48,8 @@ Y.extend(SubscriptionToggle, Y.Base, { data: { sesskey: M.cfg.sesskey, forumid: clickedLink.getData('forumid'), - discussionid: clickedLink.getData('discussionid') + discussionid: clickedLink.getData('discussionid'), + includetext: clickedLink.getData('includetext') }, context: this, 'arguments': { diff --git a/mod/forum/yui/build/moodle-mod_forum-subscriptiontoggle/moodle-mod_forum-subscriptiontoggle-min.js b/mod/forum/yui/build/moodle-mod_forum-subscriptiontoggle/moodle-mod_forum-subscriptiontoggle-min.js index 19bf4f9486b..b920e9f22d8 100644 --- a/mod/forum/yui/build/moodle-mod_forum-subscriptiontoggle/moodle-mod_forum-subscriptiontoggle-min.js +++ b/mod/forum/yui/build/moodle-mod_forum-subscriptiontoggle/moodle-mod_forum-subscriptiontoggle-min.js @@ -1 +1 @@ -YUI.add("moodle-mod_forum-subscriptiontoggle",function(e,t){function n(){n.superclass.constructor.apply(this,arguments)}var r="moodle-mod_forum-subscriptiontoggle";e.extend(n,e.Base,{initializer:function(){e.delegate("click",this._toggleSubscription,e.config.doc.body,".discussionsubscription .discussiontoggle",this)},_toggleSubscription:function(t){var n=t.currentTarget;e.io(this.get("uri"),{data:{sesskey:M.cfg.sesskey,forumid:n.getData("forumid"),discussionid:n.getData("discussionid")},context:this,arguments:{clickedLink:n},on:{complete:this._handleCompletion}}),t.preventDefault()},_handleCompletion:function(t,n,r){var i;try{i=e.JSON.parse(n.response);if(i.error)return e.use("moodle-core-notification-ajaxexception",function(){return new M.core.ajaxException(i)}),this}catch(s){return e.use("moodle-core-notification-exception",function(){return new M.core.exception(s)}),this}if(!i.icon)return;var o=r.clickedLink.ancestor(".discussionsubscription");o&&o.set("innerHTML",i.icon)}},{NAME:"subscriptionToggle",ATTRS:{uri:{value:M.cfg.wwwroot+"/mod/forum/subscribe_ajax.php"}}});var i=e.namespace("M.mod_forum.subscriptiontoggle");i.init=function(e){return new n(e)}},"@VERSION@",{requires:["base-base","io-base"]}); +YUI.add("moodle-mod_forum-subscriptiontoggle",function(e,t){function n(){n.superclass.constructor.apply(this,arguments)}var r="moodle-mod_forum-subscriptiontoggle";e.extend(n,e.Base,{initializer:function(){e.delegate("click",this._toggleSubscription,e.config.doc.body,".discussionsubscription .discussiontoggle",this)},_toggleSubscription:function(t){var n=t.currentTarget;e.io(this.get("uri"),{data:{sesskey:M.cfg.sesskey,forumid:n.getData("forumid"),discussionid:n.getData("discussionid"),includetext:n.getData("includetext")},context:this,arguments:{clickedLink:n},on:{complete:this._handleCompletion}}),t.preventDefault()},_handleCompletion:function(t,n,r){var i;try{i=e.JSON.parse(n.response);if(i.error)return e.use("moodle-core-notification-ajaxexception",function(){return new M.core.ajaxException(i)}),this}catch(s){return e.use("moodle-core-notification-exception",function(){return new M.core.exception(s)}),this}if(!i.icon)return;var o=r.clickedLink.ancestor(".discussionsubscription");o&&o.set("innerHTML",i.icon)}},{NAME:"subscriptionToggle",ATTRS:{uri:{value:M.cfg.wwwroot+"/mod/forum/subscribe_ajax.php"}}});var i=e.namespace("M.mod_forum.subscriptiontoggle");i.init=function(e){return new n(e)}},"@VERSION@",{requires:["base-base","io-base"]}); diff --git a/mod/forum/yui/build/moodle-mod_forum-subscriptiontoggle/moodle-mod_forum-subscriptiontoggle.js b/mod/forum/yui/build/moodle-mod_forum-subscriptiontoggle/moodle-mod_forum-subscriptiontoggle.js index a45deb0adb0..66692237d92 100644 --- a/mod/forum/yui/build/moodle-mod_forum-subscriptiontoggle/moodle-mod_forum-subscriptiontoggle.js +++ b/mod/forum/yui/build/moodle-mod_forum-subscriptiontoggle/moodle-mod_forum-subscriptiontoggle.js @@ -48,7 +48,8 @@ Y.extend(SubscriptionToggle, Y.Base, { data: { sesskey: M.cfg.sesskey, forumid: clickedLink.getData('forumid'), - discussionid: clickedLink.getData('discussionid') + discussionid: clickedLink.getData('discussionid'), + includetext: clickedLink.getData('includetext') }, context: this, 'arguments': { diff --git a/mod/forum/yui/src/subscriptiontoggle/js/toggle.js b/mod/forum/yui/src/subscriptiontoggle/js/toggle.js index 2c6eb5a6343..d269baa7fc0 100644 --- a/mod/forum/yui/src/subscriptiontoggle/js/toggle.js +++ b/mod/forum/yui/src/subscriptiontoggle/js/toggle.js @@ -46,7 +46,8 @@ Y.extend(SubscriptionToggle, Y.Base, { data: { sesskey: M.cfg.sesskey, forumid: clickedLink.getData('forumid'), - discussionid: clickedLink.getData('discussionid') + discussionid: clickedLink.getData('discussionid'), + includetext: clickedLink.getData('includetext') }, context: this, 'arguments': {