Commit febfcabb authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review
Browse files

Merge "Bug 1631795: Made image in a wallpost public"

parents 7f80c859 d598dc1b
......@@ -170,7 +170,7 @@ serve_file($path, $title, $file->get('filetype'), $options);
/**
* Check if the image is embedded in an artefact of type:
* comment, annotation, annotationfeedback, blog, textbox, editnote, text.
* comment, annotation, annotationfeedback, blog, textbox, editnote, text, wallpost.
* Please check first that the fileid is of type ArtefactTypeImage and that the download
* is called with the embedded flag set.
*
......@@ -183,7 +183,7 @@ function check_is_embedded_image_visible($fileid, $includeresourcetypes = null,
$isvisible = false;
// Check for resource types a file may be embeded in.
$resourcetypes = array(
'comment', 'annotation', 'annotationfeedback', 'blog', 'textbox', 'editnote', 'text', 'introtext'
'comment', 'annotation', 'annotationfeedback', 'blog', 'textbox', 'editnote', 'text', 'introtext', 'wallpost'
);
if (!empty($includeresourcetypes)) {
if (!is_array($includeresourcetypes)) {
......
......@@ -16,5 +16,21 @@ function xmldb_blocktype_wall_upgrade($oldversion=0) {
if ($oldversion < 2009021801) {
set_config_plugin('blocktype', 'wall', 'defaultpostsizelimit', 1500); // 1500 characters
}
if ($oldversion < 2016101700) {
$posts = get_records_select_array('blocktype_wall_post',"text LIKE '%artefact/file/download.php%'");
require_once('embeddedimage.php');
foreach ($posts as $post) {
$newtext = EmbeddedImage::prepare_embedded_images($post->text, 'wallpost', $post->id, null, $post->from);
if ($post->text != $newtext) {
$updatedwallpost = new stdClass();
$updatedwallpost->id = $post->id;
$updatedwallpost->text = $newtext;
update_record('blocktype_wall_post', $updatedwallpost, 'id');
}
}
}
return true;
}
......@@ -53,6 +53,10 @@ $form = pieform(array(
function deletepost_submit(Pieform $form, $values) {
global $SESSION, $postid, $goto;
delete_records('blocktype_wall_post', 'id', $postid);
require_once('embeddedimage.php');
EmbeddedImage::remove_embedded_images('wallpost', $postid);
$SESSION->add_ok_msg(get_string('deletepostsuccess', 'blocktype.wall'));
redirect($goto);
}
......
......@@ -234,7 +234,18 @@ EOF;
'text' => $values['text'],
);
insert_record('blocktype_wall_post', $record);
$newid = insert_record('blocktype_wall_post', $record, 'id', true);
require_once('embeddedimage.php');
$newtext = EmbeddedImage::prepare_embedded_images($values['text'], 'wallpost', $newid);
// If there is an embedded image, update the src so users can have visibility
if ($values['text'] != $newtext) {
$updatedwallpost = new stdClass();
$updatedwallpost->id = $newid;
$updatedwallpost->text = $newtext;
update_record('blocktype_wall_post', $updatedwallpost, 'id');
}
activity_occurred('wallpost', $record, 'blocktype', 'wall');
$instance = new BlockInstance($values['instance']);
......
......@@ -12,5 +12,5 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2016011400;
$config->release = '1.1.0';
$config->version = 2016101700;
$config->release = '1.2.0';
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment