Skip to content

Commit 30a11c7

Browse files
committed
Correctly include privacy provider fixture files.
1 parent 35b165c commit 30a11c7

File tree

17 files changed

+2704
-1390
lines changed

17 files changed

+2704
-1390
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,33 @@ jobs:
2828
fail-fast: false
2929
matrix:
3030
include:
31+
<<<<<<< HEAD
32+
=======
33+
- php: 8.1
34+
moodle-branch: MOODLE_401_STABLE
35+
database: pgsql
36+
- php: 8.1
37+
moodle-branch: MOODLE_401_STABLE
38+
database: mariadb
39+
40+
>>>>>>> 123e1fd (Pdfannotator comment subscription like forum fixes #20.)
3141
- php: 8.0
3242
moodle-branch: MOODLE_401_STABLE
3343
database: pgsql
3444
- php: 8.0
3545
moodle-branch: MOODLE_401_STABLE
3646
database: mariadb
3747

48+
<<<<<<< HEAD
3849
- php: 8.0
3950
moodle-branch: MOODLE_400_STABLE
4051
database: pgsql
4152
- php: 8.0
4253
moodle-branch: MOODLE_400_STABLE
4354
database: mariadb
4455

56+
=======
57+
>>>>>>> 123e1fd (Pdfannotator comment subscription like forum fixes #20.)
4558
- php: 7.4
4659
moodle-branch: MOODLE_401_STABLE
4760
database: pgsql

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: 94 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,29 @@
2929
*/
3030
class comment implements \renderable, \templatable {
3131

32+
/**
33+
* @var array An array of comments
34+
*/
3235
private $comments = [];
36+
37+
/**
38+
* @var bool Visibility of a question
39+
*/
3340
private $questionvisibility;
3441

3542
/**
3643
* Constructor of renderable for comments.
3744
*
38-
* @param object $data Comment or array of comments
39-
* @param object $cm Course module
45+
* @param stdClass $data Comment or array of comments
46+
* @param stdClass $cm course module object
4047
* @param object $context Context
41-
* @return type
4248
*/
4349
public function __construct($data, $cm, $context) {
4450
global $USER;
4551

4652
if (!is_array($data)) {
4753
$data = [$data];
4854
}
49-
5055
$report = has_capability('mod/pdfannotator:report', $context);
5156
$closequestion = has_capability('mod/pdfannotator:closequestion', $context);
5257
$closeanyquestion = has_capability('mod/pdfannotator:closeanyquestion', $context);
@@ -83,7 +88,7 @@ public function __construct($data, $cm, $context) {
8388
$this->addeditbutton($comment, $editanypost);
8489
$this->addhidebutton($comment, $seehiddencomments, $hidecomments);
8590
$this->adddeletebutton($comment, $deleteown, $deleteany);
86-
$this->addsubscribebutton($comment, $subscribe);
91+
$this->addsubscribebutton($comment, $subscribe, $cm);
8792
$this->addforwardbutton($comment, $forwardquestions, $cm);
8893
$this->addmarksolvedbutton($comment, $solve);
8994

@@ -94,8 +99,8 @@ public function __construct($data, $cm, $context) {
9499
}
95100

96101
if (!empty($comment->modifiedby) && ($comment->modifiedby != $comment->userid) && ($comment->userid != 0)) {
97-
$comment->modifiedby = get_string('modifiedby', 'pdfannotator') . ' '.
98-
pdfannotator_get_username($comment->modifiedby);
102+
$comment->modifiedby = get_string('modifiedby', 'pdfannotator') . ' ' .
103+
pdfannotator_get_username($comment->modifiedby);
99104
} else {
100105
$comment->modifiedby = null;
101106
}
@@ -112,8 +117,9 @@ public function __construct($data, $cm, $context) {
112117
/**
113118
* This function is required by any renderer to retrieve the data structure
114119
* passed into the template.
120+
*
115121
* @param \renderer_base $output
116-
* @return type
122+
* @return stdClass
117123
*/
118124
public function export_for_template(\renderer_base $output) {
119125
$data = [];
@@ -122,6 +128,12 @@ public function export_for_template(\renderer_base $output) {
122128
return $data;
123129
}
124130

131+
/**
132+
* Add css class to a comment
133+
*
134+
* @param object $comment
135+
* @param bool $owner
136+
*/
125137
private function addcssclasses($comment, $owner) {
126138
$comment->wrapperClass = 'chat-message comment-list-item';
127139
if ($comment->isquestion) {
@@ -137,6 +149,12 @@ private function addcssclasses($comment, $owner) {
137149
}
138150
}
139151

152+
/**
153+
* Set votes to a comment
154+
*
155+
* @param object $comment
156+
* @throws \coding_exception
157+
*/
140158
public function setvotes($comment) {
141159
if ($comment->usevotes && !$comment->isdeleted) {
142160
if ($comment->owner) {
@@ -164,7 +182,8 @@ public function setvotes($comment) {
164182

165183
/**
166184
* Add check icon if comment is marked as correct.
167-
* @param type $comment
185+
*
186+
* @param object $comment
168187
*/
169188
public function addsolvedicon($comment) {
170189
if ($comment->solved) {
@@ -180,9 +199,10 @@ public function addsolvedicon($comment) {
180199

181200
/**
182201
* Report comment if user is not the owner.
183-
* @param type $comment
184-
* @param type $owner
185-
* @param type $report
202+
*
203+
* @param object $comment
204+
* @param bool $report
205+
* @param stdClass $cm course module object
186206
*/
187207
private function addreportbutton($comment, $report, $cm) {
188208
if (!$comment->isdeleted && $report && !$comment->owner && !isset($comment->type)) {
@@ -194,10 +214,11 @@ private function addreportbutton($comment, $report, $cm) {
194214

195215
/**
196216
* Open/close question if user is owner of the question or manager.
197-
* @param type $comment
198-
* @param type $owner
199-
* @param type $closequestion
200-
* @param type $closeanyquestion
217+
*
218+
* @param object $comment
219+
* @param bool $closequestion
220+
* @param bool $closeanyquestion
221+
* @throws \coding_exception
201222
*/
202223
private function addcloseopenbutton($comment, $closequestion, $closeanyquestion) {
203224

@@ -216,9 +237,10 @@ private function addcloseopenbutton($comment, $closequestion, $closeanyquestion)
216237

217238
/**
218239
* Button for editing comment if user is owner of the comment or manager.
219-
* @param type $comment
220-
* @param type $owner
221-
* @param type $editanypost
240+
*
241+
* @param object $comment
242+
* @param bool $editanypost
243+
* @throws \coding_exception
222244
*/
223245
private function addeditbutton($comment, $editanypost) {
224246
if (!$comment->isdeleted && !isset($comment->type) && ($comment->owner || $editanypost)) {
@@ -229,6 +251,14 @@ private function addeditbutton($comment, $editanypost) {
229251
}
230252
}
231253

254+
/**
255+
* Add a hide button
256+
*
257+
* @param object $comment
258+
* @param bool $seehiddencomments
259+
* @param bool $hidecomments
260+
* @throws \coding_exception
261+
*/
232262
private function addhidebutton($comment, $seehiddencomments, $hidecomments) {
233263
// Don't need to hide personal notes.
234264
if ($this->questionvisibility == 'private') {
@@ -257,32 +287,53 @@ private function addhidebutton($comment, $seehiddencomments, $hidecomments) {
257287

258288
/**
259289
* Delete comment if user is owner of the comment or manager.
260-
* @param type $comment
261-
* @param type $owner
262-
* @param type $deleteown
263-
* @param type $deleteany
290+
*
291+
* @param object $comment
292+
* @param bool $deleteown
293+
* @param bool $deleteany
294+
* @throws \coding_exception
264295
*/
265296
private function adddeletebutton($comment, $deleteown, $deleteany) {
266297
if (!$comment->isdeleted && ($deleteany || ($deleteown && $comment->owner))) {
267298
$comment->buttons[] = ["classes" => "comment-delete-a", "text" => get_string('delete', 'pdfannotator'),
268299
"moodleicon" => ["key" => "delete", "component" => "pdfannotator",
269-
"title" => get_string('delete', 'pdfannotator')]];
300+
"title" => get_string('delete', 'pdfannotator')]];
270301
}
271302
}
272303

273-
private function addsubscribebutton($comment, $subscribe) {
304+
/**
305+
* Add a subscribe button
306+
*
307+
* @param object $comment
308+
* @param bool $subscribe
309+
* @param stdClass $cm course module object
310+
* @throws \coding_exception
311+
*/
312+
private function addsubscribebutton($comment, $subscribe, $cm) {
274313
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')];
314+
// Only set for textbox and drawing, and only if subscription mode is not disabled or forced.
315+
if ((pdfannotator_get_subscriptionmode($cm->instance) == PDFANNOTATOR_CHOOSESUBSCRIBE) ||
316+
(pdfannotator_get_subscriptionmode($cm->instance) == PDFANNOTATOR_INITIALSUBSCRIBE)) {
317+
if (!empty($comment->issubscribed)) {
318+
$comment->buttons[] = ["classes" => "comment-subscribe-a", "faicon" => ["class" => "fa-bell-slash"],
319+
"text" => get_string('unsubscribeQuestion', 'pdfannotator')];
320+
} else {
321+
$comment->buttons[] = ["classes" => "comment-subscribe-a", "faicon" => ["class" => "fa-bell"],
322+
"text" => get_string('subscribeQuestion', 'pdfannotator')];
323+
}
282324
}
283325
}
284326
}
285327

328+
/**
329+
* Add a forward button
330+
*
331+
* @param object $comment
332+
* @param bool $forwardquestions
333+
* @param stdClass $cm course module object
334+
* @throws \coding_exception
335+
* @throws \moodle_exception
336+
*/
286337
private function addforwardbutton($comment, $forwardquestions, $cm) {
287338
if (!isset($comment->type) && $comment->isquestion && !$comment->isdeleted && $forwardquestions &&
288339
$comment->visibility != 'private') {
@@ -291,22 +342,29 @@ private function addforwardbutton($comment, $forwardquestions, $cm) {
291342
$url = new moodle_url($CFG->wwwroot . '/mod/pdfannotator/view.php', $urlparams);
292343

293344
$comment->buttons[] = ["classes" => "comment-forward-a", "attributes" => ["name" => "onclick",
294-
"value" => "window.location.href = '$url';"], "faicon" => ["class" => "fa-share"],
295-
"text" => get_string('forward', 'pdfannotator')];
345+
"value" => "window.location.href = '$url';"],
346+
"faicon" => ["class" => "fa-share"], "text" => get_string('forward', 'pdfannotator')];
296347
}
297348
}
298349

350+
/**
351+
* Add a Mark as correct or a Remove mark as correct button
352+
*
353+
* @param object $comment
354+
* @param bool $solve
355+
* @throws \coding_exception
356+
*/
299357
private function addmarksolvedbutton($comment, $solve) {
300358
if ($solve && !$comment->isquestion && !$comment->isdeleted && !isset($comment->type) &&
301359
$this->questionvisibility != 'private') {
302360
if ($comment->solved) {
303361
$comment->buttons[] = ["classes" => "comment-solve-a", "text" => get_string('removeCorrect', 'pdfannotator'),
304362
"moodleicon" => ["key" => "i/completion-manual-n", "component" => "core",
305-
"title" => get_string('removeCorrect', 'pdfannotator')]];
363+
"title" => get_string('removeCorrect', 'pdfannotator')]];
306364
} else {
307365
$comment->buttons[] = ["classes" => "comment-solve-a", "text" => get_string('markCorrect', 'pdfannotator'),
308366
"moodleicon" => ["key" => "i/completion-manual-enabled", "component" => "core",
309-
"title" => get_string('markCorrect', 'pdfannotator')]];
367+
"title" => get_string('markCorrect', 'pdfannotator')]];
310368
}
311369
}
312370
}

0 commit comments

Comments
 (0)