Skip to content

Commit 6b58a7e

Browse files
committed
Configure subscriptions to discussions like in forum activity.
1 parent bea2d65 commit 6b58a7e

File tree

16 files changed

+1325
-36
lines changed

16 files changed

+1325
-36
lines changed

.github/workflows/moodle-plugin-ci.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,6 @@ jobs:
8080
moodle-branch: MOODLE_400_STABLE
8181
database: mariadb
8282

83-
- php: 7.4
84-
moodle-branch: MOODLE_311_STABLE
85-
database: pgsql
86-
- php: 7.4
87-
moodle-branch: MOODLE_311_STABLE
88-
database: mariadb
89-
9083
steps:
9184
- name: Check out repository code
9285
uses: actions/checkout@v4

backup/moodle2/backup_pdfannotator_stepslib.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ protected function define_structure() {
5555
// 2. Define each element separately.
5656
$pdfannotator = new backup_nested_element('pdfannotator', array('id'), array(
5757
'name', 'intro', 'introformat', 'usevotes', 'useprint', 'useprintcomments', 'use_studenttextbox', 'use_studentdrawing',
58-
'useprivatecomments', 'useprotectedcomments', 'timecreated', 'timemodified'));
58+
'useprivatecomments', 'useprotectedcomments', 'forcesubscribe', 'timecreated', 'timemodified'));
5959

6060
$annotations = new backup_nested_element('annotations');
6161
$annotation = new backup_nested_element('annotation', array('id'), array('page', 'userid', 'annotationtypeid',

classes/output/comment.php

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)