MDL-53345 forum: rename itemid

This commit is contained in:
Ben Kelada 2016-03-31 14:19:05 +11:00
parent e881c4f5c3
commit 48143990e0
2 changed files with 10 additions and 12 deletions

View File

@ -961,7 +961,7 @@ class mod_forum_external extends external_api {
'name' => new external_value(PARAM_ALPHANUM,
'The allowed keys (value format) are:
discussionsubscribe (bool); subscribe to the discussion?, default to true
itemid (int); the draft file area id for inline attachments
inlineattachmentsid (int); the draft file area id for inline attachments
attachmentsid (int); the draft file area id for attachments
'),
'value' => new external_value(PARAM_RAW, 'the value of the option,
@ -998,7 +998,7 @@ class mod_forum_external extends external_api {
// Validate options.
$options = array(
'discussionsubscribe' => true,
'itemid' => 0,
'inlineattachmentsid' => 0,
'attachmentsid' => null
);
foreach ($params['options'] as $option) {
@ -1007,7 +1007,7 @@ class mod_forum_external extends external_api {
case 'discussionsubscribe':
$value = clean_param($option['value'], PARAM_BOOL);
break;
case 'itemid':
case 'inlineattachmentsid':
$value = clean_param($option['value'], PARAM_INT);
break;
case 'attachmentsid':
@ -1051,7 +1051,7 @@ class mod_forum_external extends external_api {
$post->message = $params['message'];
$post->messageformat = FORMAT_HTML; // Force formatting for now.
$post->messagetrust = trusttext_trusted($context);
$post->itemid = $options['itemid'];
$post->itemid = $options['inlineattachmentsid'];
$post->attachments = $options['attachmentsid'];
$fakemform = $post->attachments;
if ($postid = forum_add_new_post($post, $fakemform)) {
@ -1128,7 +1128,7 @@ class mod_forum_external extends external_api {
'The allowed keys (value format) are:
discussionsubscribe (bool); subscribe to the discussion?, default to true
discussionpinned (bool); is the discussion pinned, default to false
itemid (int); the draft file area id for inline attachments
inlineattachmentsid (int); the draft file area id for inline attachments
attachmentsid (int); the draft file area id for attachments
'),
'value' => new external_value(PARAM_RAW, 'The value of the option,
@ -1168,7 +1168,7 @@ class mod_forum_external extends external_api {
$options = array(
'discussionsubscribe' => true,
'discussionpinned' => false,
'itemid' => 0,
'inlineattachmentsid' => 0,
'attachmentsid' => null
);
foreach ($params['options'] as $option) {
@ -1180,7 +1180,7 @@ class mod_forum_external extends external_api {
case 'discussionpinned':
$value = clean_param($option['value'], PARAM_BOOL);
break;
case 'itemid':
case 'inlineattachmentsid':
$value = clean_param($option['value'], PARAM_INT);
break;
case 'attachmentsid':
@ -1230,7 +1230,7 @@ class mod_forum_external extends external_api {
$discussion->message = $params['message'];
$discussion->messageformat = FORMAT_HTML; // Force formatting for now.
$discussion->messagetrust = trusttext_trusted($context);
$discussion->itemid = $options['itemid'];
$discussion->itemid = $options['inlineattachmentsid'];
$discussion->groupid = $groupid;
$discussion->mailnow = 0;
$discussion->subject = $params['subject'];

View File

@ -866,7 +866,7 @@ class mod_forum_external_testcase extends externallib_advanced_testcase {
$fs->create_file_from_string($filerecordinline, 'image contents (not really)');
$fs->create_file_from_string($filerecordattach, 'simple text attachment');
$options = array(array('name' => 'itemid', 'value' => $draftidinlineattach),
$options = array(array('name' => 'inlineattachmentsid', 'value' => $draftidinlineattach),
array('name' => 'attachmentsid', 'value' => $draftidattach));
$dummytext = 'Here is an inline image: <img src="' . $CFG->wwwroot
. "/draftfile.php/{$usercontext->id}/user/draft/{$draftidinlineattach}/{$filenameimg}"
@ -971,7 +971,6 @@ class mod_forum_external_testcase extends externallib_advanced_testcase {
$fs = get_file_storage();
$draftidinlineattach = file_get_unused_draft_itemid();
$draftidattach = file_get_unused_draft_itemid();
@ -989,7 +988,6 @@ class mod_forum_external_testcase extends externallib_advanced_testcase {
'filename' => $filenameimg,
);
// Create a file in a draft area for regular attachments.
$filerecordattach = $filerecord;
$attachfilename = 'attachment.txt';
@ -1002,7 +1000,7 @@ class mod_forum_external_testcase extends externallib_advanced_testcase {
"/draftfile.php/{$usercontext->id}/user/draft/{$draftidinlineattach}/{$filenameimg}" .
'" alt="inlineimage">.';
$options = array(array('name' => 'itemid', 'value' => $draftidinlineattach),
$options = array(array('name' => 'inlineattachmentsid', 'value' => $draftidinlineattach),
array('name' => 'attachmentsid', 'value' => $draftidattach));
$createddiscussion = mod_forum_external::add_discussion($forum->id, 'the inline attachment subject',
$dummytext, -1, $options);