Skip to content

Commit

Permalink
Enable mentioning in quick modify too - fixes elkarte#2098 thanks Bur…
Browse files Browse the repository at this point in the history
…ke Knight for suggesting

Signed-off-by: emanuele <emanuele45@gmail.com>
  • Loading branch information
emanuele45 committed Jul 25, 2015
1 parent cb5e50f commit 916d671
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
32 changes: 32 additions & 0 deletions sources/controllers/Post.controller.php
Expand Up @@ -2099,6 +2099,38 @@ public function action_jsmodify()

if (!$post_errors->hasErrors())
{
if (!empty($modSettings['mentions_enabled']))
{
if (!empty($_REQUEST['uid']))
{
$query_params = array();
$query_params['member_ids'] = array_unique(array_map('intval', $_REQUEST['uid']));
require_once(SUBSDIR . '/Members.subs.php');
$mentioned_members = membersBy('member_ids', $query_params, true);
$replacements = 0;
$actually_mentioned = array();
foreach ($mentioned_members as $member)
{
$_POST['message'] = str_replace('@' . $member['real_name'], '[member=' . $member['id_member'] . ']' . $member['real_name'] . '[/member]', $_POST['message'], $replacements);
if ($replacements > 0)
$actually_mentioned[] = $member['id_member'];
}
}

if (!empty($actually_mentioned))
{
require_once(CONTROLLERDIR . '/Mentions.controller.php');
$mentions = new Mentions_Controller();
$mentions->setData(array(
'id_member' => $actually_mentioned,
'type' => 'men',
'id_msg' => $row['id_msg'],
'status' => $row['approved'] ? 'new' : 'unapproved',
));
$mentions->action_add();
}
}

$msgOptions = array(
'id' => $row['id_msg'],
'subject' => isset($_POST['subject']) ? $_POST['subject'] : null,
Expand Down
8 changes: 7 additions & 1 deletion themes/default/Display.template.php
Expand Up @@ -593,7 +593,13 @@ function template_quickreply_below()
sTemplateSubjectNormal: ', JavaScriptEscape('%subject%'), ',
sTemplateTopSubject: ', JavaScriptEscape($txt['topic'] . ': %subject% &nbsp;(' . $context['num_views_text'] . ')'), ',
sTemplateInfoNormal: ', JavaScriptEscape('<a href="' . $scripturl . '?topic=' . $context['current_topic'] . '.msg%msg_id%#msg%msg_id%" rel="nofollow">%subject%</a><span class="smalltext modified" id="modified_%msg_id%"></span>'), ($context['can_reply'] && !empty($options['display_quick_reply'])) ? ',
sFormRemoveAccessKeys: \'postmodify\'' : '', '
sFormRemoveAccessKeys: \'postmodify\'' : '', ',
funcOnAfterCreate: function () {
// Attach AtWho to the quick edit box
add_elk_mention(\'#quick_edit_body_container textarea\');
var i = all_elk_mentions.length - 1;
all_elk_mentions[i].oMention = new elk_mentions(all_elk_mentions[i].oOptions);
}
});
aIconLists[aIconLists.length] = new IconList({
Expand Down
14 changes: 13 additions & 1 deletion themes/default/scripts/topic.js
Expand Up @@ -536,7 +536,8 @@ QuickModify.prototype.modifyCancel = function ()
QuickModify.prototype.modifySave = function (sSessionId, sSessionVar)
{
var i = 0,
x = [];
x = [],
uIds = [];

// We cannot save if we weren't in edit mode.
if (!this.bInEditMode)
Expand All @@ -558,10 +559,21 @@ QuickModify.prototype.modifySave = function (sSessionId, sSessionVar)
}
}

var oInputs = document.forms.quickModForm.getElementsByTagName('input');
for (i = 0; i < oInputs.length; i++)
{
if (oInputs[i].name == 'uid[]')
{
uIds.push('uid[' + i + ']=' + parseInt(oInputs[i].value));
}
}

x[x.length] = 'subject=' + escape(document.forms.quickModForm.subject.value.replace(/&#/g, "&#38;#").php_to8bit()).replace(/\+/g, "%2B");
x[x.length] = 'message=' + escape(document.forms.quickModForm.message.value.replace(/&#/g, "&#38;#").php_to8bit()).replace(/\+/g, "%2B");
x[x.length] = 'topic=' + parseInt(document.forms.quickModForm.elements.topic.value);
x[x.length] = 'msg=' + parseInt(document.forms.quickModForm.elements.msg.value);
if (uIds.length > 0)
x[x.length] = uIds.join("&");

// Send in the XMLhttp request and let's hope for the best.
ajax_indicator(true);
Expand Down

0 comments on commit 916d671

Please sign in to comment.