@@ -83,7 +83,7 @@ public function __construct($data, $cm, $context) {
8383 $ this ->addeditbutton ($ comment , $ editanypost );
8484 $ this ->addhidebutton ($ comment , $ seehiddencomments , $ hidecomments );
8585 $ this ->adddeletebutton ($ comment , $ deleteown , $ deleteany );
86- $ this ->addsubscribebutton ($ comment , $ subscribe );
86+ $ this ->addsubscribebutton ($ comment , $ subscribe, $ cm );
8787 $ this ->addforwardbutton ($ comment , $ forwardquestions , $ cm );
8888 $ this ->addmarksolvedbutton ($ comment , $ solve );
8989
@@ -270,15 +270,26 @@ private function adddeletebutton($comment, $deleteown, $deleteany) {
270270 }
271271 }
272272
273- private function addsubscribebutton ($ comment , $ subscribe ) {
273+ /**
274+ * Add a subscribe button
275+ *
276+ * @param object $comment
277+ * @param bool $subscribe
278+ * @param stdClass $cm course module object
279+ * @throws \coding_exception
280+ */
281+ private function addsubscribebutton ($ comment , $ subscribe , $ cm ) {
274282 if (!isset ($ comment ->type ) && $ comment ->isquestion && $ subscribe && $ comment ->visibility != 'private ' ) {
275- // Only set for textbox and drawing.
276- if (!empty ($ comment ->issubscribed )) {
277- $ comment ->buttons [] = ["classes " => "comment-subscribe-a " , "faicon " => ["class " => "fa-bell-slash " ],
278- "text " => get_string ('unsubscribeQuestion ' , 'pdfannotator ' )];
279- } else {
280- $ comment ->buttons [] = ["classes " => "comment-subscribe-a " , "faicon " => ["class " => "fa-bell " ],
281- "text " => get_string ('subscribeQuestion ' , 'pdfannotator ' )];
283+ // Only set for textbox and drawing, and only if subscription mode is not disabled or forced.
284+ if ((pdfannotator_get_subscriptionmode ($ cm ->instance ) == PDFANNOTATOR_CHOOSESUBSCRIBE ) ||
285+ (pdfannotator_get_subscriptionmode ($ cm ->instance ) == PDFANNOTATOR_INITIALSUBSCRIBE )) {
286+ if (!empty ($ comment ->issubscribed )) {
287+ $ comment ->buttons [] = ["classes " => "comment-subscribe-a " , "faicon " => ["class " => "fa-bell-slash " ],
288+ "text " => get_string ('unsubscribeQuestion ' , 'pdfannotator ' )];
289+ } else {
290+ $ comment ->buttons [] = ["classes " => "comment-subscribe-a " , "faicon " => ["class " => "fa-bell " ],
291+ "text " => get_string ('subscribeQuestion ' , 'pdfannotator ' )];
292+ }
282293 }
283294 }
284295 }
0 commit comments