Permalink
Browse files

Merge branch 'MDL-61309-33' of git://github.com/andrewnicols/moodle i…

…nto MOODLE_33_STABLE
  • Loading branch information...
dmonllao authored and junpataleta committed May 9, 2018
2 parents 4458f71 + 21e93fd commit af90c1bc4b9134668ce3d690af525c129699ef26
@@ -162,6 +162,7 @@ public function process_message(\stdClass $record, \stdClass $messagedata) {
$addpost->subject = $subject;
$addpost->parent = $post->id;
$addpost->itemid = file_get_unused_draft_itemid();
$addpost->deleted = 0;
list ($message, $format) = self::remove_quoted_text($messagedata);
$addpost->message = $message;

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,123 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Privacy Subsystem implementation for mod_forum.
*
* @package mod_forum
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_forum\privacy;
use \core_privacy\request\approved_contextlist;
use \core_privacy\request\writer;
use \core_privacy\metadata\item_collection;
defined('MOODLE_INTERNAL') || die();
/**
* Subcontext subcontext_info trait.
*
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
trait subcontext_info {
/**
* Get the discussion part of the subcontext.
*
* @param \stdClass $discussion The discussion
* @return array
*/
protected static function get_discussion_area(\stdClass $discussion) {
$pathparts = [];
if (!empty($discussion->groupname)) {
$pathparts[] = get_string('groups');
$pathparts[] = $discussion->groupname;
}
$parts = [
$discussion->id,
$discussion->name,
];
$discussionname = implode('-', $parts);
$pathparts[] = get_string('discussions', 'mod_forum');
$pathparts[] = $discussionname;
return $pathparts;
}
/**
* Get the post part of the subcontext.
*
* @param \stdClass $post The post.
* @return array
*/
protected static function get_post_area(\stdClass $post) {
$parts = [
$post->created,
$post->subject,
$post->id,
];
$area[] = implode('-', $parts);
return $area;
}
/**
* Get the parent subcontext for the supplied forum, discussion, and post combination.
*
* @param \stdClass $post The post.
* @return array
*/
protected static function get_post_area_for_parent(\stdClass $post) {
global $DB;
$subcontext = [];
if ($parent = $DB->get_record('forum_posts', ['id' => $post->parent], 'id, created, subject')) {
$subcontext = array_merge($subcontext, static::get_post_area($parent));
}
$subcontext = array_merge($subcontext, static::get_post_area($post));
return $subcontext;
}
/**
* Get the subcontext for the supplied forum, discussion, and post combination.
*
* @param \stdClass $forum The forum.
* @param \stdClass $discussion The discussion
* @param \stdClass $post The post.
* @return array
*/
protected static function get_subcontext($forum, $discussion = null, $post = null) {
$subcontext = [];
if (null !== $discussion) {
$subcontext += self::get_discussion_area($discussion);
if (null !== $post) {
$subcontext[] = get_string('posts', 'mod_forum');
$subcontext = array_merge($subcontext, static::get_post_area_for_parent($post));
}
}
return $subcontext;
}
}
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="mod/forum/db" VERSION="20171012" COMMENT="XMLDB file for Moodle mod/forum"
<XMLDB PATH="mod/forum/db" VERSION="20180329" COMMENT="XMLDB file for Moodle mod/forum"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
@@ -80,6 +80,7 @@
<FIELD NAME="attachment" TYPE="char" LENGTH="100" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="totalscore" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="mailnow" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="deleted" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
@@ -228,5 +228,23 @@ function xmldb_forum_upgrade($oldversion) {
upgrade_mod_savepoint(true, 2017051501, 'forum');
}
// Automatically generated Moodle v3.4.0 release upgrade line.
// Put any upgrade step following this.
if ($oldversion < 2017051502) {
// Define field deleted to be added to forum_posts.
$table = new xmldb_table('forum_posts');
$field = new xmldb_field('deleted', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'mailnow');
// Conditionally launch add field deleted.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Forum savepoint reached.
upgrade_mod_savepoint(true, 2017051502, 'forum');
}
return true;
}
@@ -219,7 +219,7 @@
print_error("notexists", 'forum', "$CFG->wwwroot/mod/forum/view.php?f=$forum->id");
}
if (!forum_user_can_see_post($forum, $discussion, $post, null, $cm)) {
if (!forum_user_can_see_post($forum, $discussion, $post, null, $cm, false)) {
print_error('noviewdiscussionspermission', 'forum', "$CFG->wwwroot/mod/forum/view.php?id=$forum->id");
}
@@ -249,8 +249,7 @@ public static function get_forum_discussion_posts($discussionid, $sortby = "crea
$allposts = forum_get_all_discussion_posts($discussion->id, $sort, $forumtracked);
foreach ($allposts as $post) {
if (!forum_user_can_see_post($forum, $discussion, $post, null, $cm)) {
if (!forum_user_can_see_post($forum, $discussion, $post, null, $cm, false)) {
$warning = array();
$warning['item'] = 'post';
$warning['itemid'] = $post->id;
@@ -275,6 +274,23 @@ public static function get_forum_discussion_posts($discussionid, $sortby = "crea
$post->children = array();
}
if (!forum_user_can_see_post($forum, $discussion, $post, null, $cm)) {
// The post is available, but has been marked as deleted.
// It will still be available but filled with a placeholder.
$post->userid = null;
$post->userfullname = null;
$post->userpictureurl = null;
$post->subject = get_string('privacy:request:delete:post:subject', 'mod_forum');
$post->message = get_string('privacy:request:delete:post:message', 'mod_forum');
$post->deleted = true;
$posts[] = $post;
continue;
}
$post->deleted = false;
if (forum_is_author_hidden($post, $forum)) {
$post->userid = null;
$post->userfullname = null;
@@ -345,7 +361,8 @@ public static function get_forum_discussion_posts_returns() {
'canreply' => new external_value(PARAM_BOOL, 'The user can reply to posts?'),
'postread' => new external_value(PARAM_BOOL, 'The post was read'),
'userfullname' => new external_value(PARAM_TEXT, 'Post author full name'),
'userpictureurl' => new external_value(PARAM_URL, 'Post author picture.', VALUE_OPTIONAL)
'userpictureurl' => new external_value(PARAM_URL, 'Post author picture.', VALUE_OPTIONAL),
'deleted' => new external_value(PARAM_BOOL, 'This post has been removed.'),
), 'post'
)
),
@@ -848,7 +865,8 @@ public static function add_discussion_post($postid, $subject, $message, $options
$post->messageformat = FORMAT_HTML; // Force formatting for now.
$post->messagetrust = trusttext_trusted($context);
$post->itemid = $options['inlineattachmentsid'];
$post->attachments = $options['attachmentsid'];
$post->attachments = $options['attachmentsid'];
$post->deleted = 0;
$fakemform = $post->attachments;
if ($postid = forum_add_new_post($post, $fakemform)) {
@@ -225,6 +225,7 @@
$string['forum:canoverridediscussionlock'] = 'Reply to locked discussions';
$string['forumauthorhidden'] = 'Author (hidden)';
$string['forumblockingalmosttoomanyposts'] = 'You are approaching the posting threshold. You have posted {$a->numposts} times in the last {$a->blockperiod} and the limit is {$a->blockafter} posts.';
$string['forumbodydeleted'] = 'The content of this forum post has been removed and can no longer be accessed.';
$string['forumbodyhidden'] = 'This post cannot be viewed by you, probably because you have not posted in the discussion, the maximum editing time hasn\'t passed yet, the discussion has not started or the discussion has expired.';
$string['forum:canposttomygroups'] = 'Can post to all groups you have access to';
$string['forum:createattachment'] = 'Create attachments';
@@ -247,6 +248,7 @@
$string['forums'] = 'Forums';
$string['forum:splitdiscussions'] = 'Split discussions';
$string['forum:startdiscussion'] = 'Start new discussions';
$string['forumsubjectdeleted'] = 'This forum post has been removed';
$string['forumsubjecthidden'] = 'Subject (hidden)';
$string['forumtracked'] = 'Unread posts are being tracked';
$string['forumtrackednot'] = 'Unread posts are not being tracked';
@@ -424,6 +426,56 @@
$string['posttoforum'] = 'Post to forum';
$string['postupdated'] = 'Your post was updated';
$string['potentialsubscribers'] = 'Potential subscribers';
$string['privacy:digesttypenone'] = 'We do not hold any data relating to a preferred forum digest type for this forum.';
$string['privacy:digesttypepreference'] = 'You have chosen to receive the following forum digest type: "{$a->type}".';
$string['privacy:discussionsubscriptionpreference'] = 'You have chosen the following discussion subscription preference for this forum: "{$a->preference}"';
$string['privacy:metadata:core_tag'] = 'The forum makes use of the tag subsystem to support tagging of posts.';
$string['privacy:metadata:core_rating'] = 'The forum makes use of the rating subsystem to support the rating of posts.';
$string['privacy:metadata:forum_digests'] = 'Information about the digest preferences for each forum.';
$string['privacy:metadata:forum_digests:forum'] = 'The forum subscribed to.';
$string['privacy:metadata:forum_digests:maildigest'] = 'The digest preference.';
$string['privacy:metadata:forum_digests:userid'] = 'The ID of the user with the digest preference.';
$string['privacy:metadata:forum_discussion_subs'] = 'Information about the subscriptions to individual forum discussions.';
$string['privacy:metadata:forum_discussion_subs:discussionid'] = 'The ID of the discussion that was subscribed to.';
$string['privacy:metadata:forum_discussion_subs:preference'] = 'The start time of the subscription.';
$string['privacy:metadata:forum_discussion_subs:userid'] = 'The ID of the user with the discussion subscription.';
$string['privacy:metadata:forum_discussions'] = 'Information about the individual forum discussions that a user has created.';
$string['privacy:metadata:forum_discussions:assessed'] = 'TODOD - what does this field store';
$string['privacy:metadata:forum_discussions:name'] = 'The name of the discussion, as chosen by the author.';
$string['privacy:metadata:forum_discussions:timemodified'] = 'The time that the discussion was last modified.';
$string['privacy:metadata:forum_discussions:userid'] = 'The ID of the user who created the discussion';
$string['privacy:metadata:forum_discussions:usermodified'] = 'The ID of the user who last modified the discussion in some way.';
$string['privacy:metadata:forum_posts'] = 'Information about the digest preferences for each forum.';
$string['privacy:metadata:forum_posts:created'] = 'The time that the post was created.';
$string['privacy:metadata:forum_posts:discussion'] = 'The discussion that the post is in.';
$string['privacy:metadata:forum_posts:message'] = 'The message of the forum post.';
$string['privacy:metadata:forum_posts:modified'] = 'The time that the post was last modified.';
$string['privacy:metadata:forum_posts:parent'] = 'The parent post that was replied to.';
$string['privacy:metadata:forum_posts:subject'] = 'The subject of the forum post.';
$string['privacy:metadata:forum_posts:totalscore'] = 'The message of the forum post.';
$string['privacy:metadata:forum_posts:userid'] = 'The ID of the user who authored the forum post.';
$string['privacy:metadata:forum_read'] = 'Information about which posts have been read by the user.';
$string['privacy:metadata:forum_read:discussionid'] = 'The discussion that the post is in.';
$string['privacy:metadata:forum_read:firstread'] = 'The first time that the post was read.';
$string['privacy:metadata:forum_read:lastread'] = 'The most recent time that the post was read.';
$string['privacy:metadata:forum_read:postid'] = 'The post that was read.';
$string['privacy:metadata:forum_read:userid'] = 'The ID of the user that this record relates to.';
$string['privacy:metadata:forum_subscriptions'] = 'Information about which forums the user has subscribed to.';
$string['privacy:metadata:forum_subscriptions:forum'] = 'The forum that was subscribed to.';
$string['privacy:metadata:forum_subscriptions:userid'] = 'The ID of the user that this forum subscription relates to.';
$string['privacy:metadata:forum_track_prefs'] = 'Information about which forums the user has chosen to track post reads for.';
$string['privacy:metadata:forum_track_prefs:forumid'] = 'The forum that has read tracking enabled.';
$string['privacy:metadata:forum_track_prefs:userid'] = 'The ID of the user that this forum tracking preference relates to.';
$string['privacy:metadata:preference:autosubscribe'] = 'Whether to subscribe to discussions when replying to posts within them.';
$string['privacy:metadata:preference:maildigest'] = 'The site-wide mail digest preference.';
$string['privacy:metadata:preference:markasreadonnotification'] = 'Whether to mark forum posts as read when receiving them as messages.';
$string['privacy:metadata:preference:trackforums'] = 'Whether to enable read tracking.';
$string['privacy:postwasread'] = 'This post was first read on {$a->firstread} and most recently read on {$a->lastread}';
$string['privacy:readtrackingdisabled'] = 'You have chosen to not track which posts that you have read within this forum.';
$string['privacy:request:delete:discussion:name'] = 'Delete at the request of the author';
$string['privacy:request:delete:post:message'] = 'The content of this post has been deleted at the request of its author.';
$string['privacy:request:delete:post:subject'] = 'Delete at the request of the author';
$string['privacy:subscribedtoforum'] = 'You are subscribed to this forum.';
$string['processingdigest'] = 'Processing email digest for user {$a}';
$string['processingpost'] = 'Processing post {$a}';
$string['prune'] = 'Split';
Oops, something went wrong.

0 comments on commit af90c1b

Please sign in to comment.