Commit | Line | Data |
---|---|---|
bbd0e548 DW |
1 | <?PHP |
2 | // This file is part of Moodle - http://moodle.org/ | |
3 | // | |
4 | // Moodle is free software: you can redistribute it and/or modify | |
5 | // it under the terms of the GNU General Public License as published by | |
6 | // the Free Software Foundation, either version 3 of the License, or | |
7 | // (at your option) any later version. | |
8 | // | |
9 | // Moodle is distributed in the hope that it will be useful, | |
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | // GNU General Public License for more details. | |
13 | // | |
14 | // You should have received a copy of the GNU General Public License | |
15 | // along with Moodle. If not, see <http://www.gnu.org/licenses/>. | |
16 | ||
17 | /** | |
18 | * This file contains the moodle hooks for the submission comments plugin | |
19 | * | |
20 | * @package assignsubmission_comments | |
21 | * @copyright 2012 NetSpot {@link http://www.netspot.com.au} | |
22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | |
23 | */ | |
24 | defined('MOODLE_INTERNAL') || die(); | |
25 | ||
26 | /** | |
27 | * | |
28 | * Callback method for data validation---- required method for AJAXmoodle based comment API | |
29 | * | |
30 | * @param stdClass $options | |
31 | * @return bool | |
32 | */ | |
33 | function assignsubmission_comments_comment_validate(stdClass $options) { | |
34 | ||
35 | return true; | |
36 | } | |
37 | ||
38 | /** | |
39 | * Permission control method for submission plugin ---- required method for AJAXmoodle based comment API | |
40 | * | |
41 | * @param stdClass $options | |
42 | * @return array | |
43 | */ | |
44 | function assignsubmission_comments_comment_permissions(stdClass $options) { | |
45 | ||
46 | return array('post' => true, 'view' => true); | |
47 | } | |
48 | ||
49 | /** | |
50 | * Callback to force the userid for all comments to be the userid of the submission and NOT the global $USER->id. This | |
51 | * is required by the upgrade code. Note the comment area is used to identify upgrades. | |
52 | * | |
53 | * @param stdClass $comment | |
54 | * @param stdClass $param | |
55 | */ | |
56 | function assignsubmission_comments_comment_add(stdClass $comment, stdClass $param) { | |
57 | ||
58 | global $DB; | |
59 | if ($comment->commentarea == 'submission_comments_upgrade') { | |
60 | $submissionid = $comment->itemid; | |
61 | $submission = $DB->get_record('assign_submission', array('id' => $submissionid)); | |
62 | ||
63 | $comment->userid = $submission->userid; | |
64 | $comment->commentarea = 'submission_comments'; | |
65 | } | |
66 | } | |
67 |