Browse Source

Allow send message to specified user

Angel Fernando Quiroz Campos 10 years ago
parent
commit
dcc7a779de

+ 1 - 1
main/inc/lib/social.lib.php

@@ -760,7 +760,7 @@ class SocialManager extends UserManager
 
             // My friend profile.
             if ($user_id != api_get_user_id()) {
-                $html .= '<li><a href="#" id="btn-to-send-message" title="'.get_lang('SendMessage').'">';
+                $html .= '<li><a href="#" class="btn-to-send-message" data-send-to="' . $user_id . '" title="'.get_lang('SendMessage').'">';
                 $html .= Display::return_icon('compose_message.png', get_lang('SendMessage')).'&nbsp;&nbsp;'.get_lang('SendMessage').'</a></li>';
             }
 

+ 0 - 1
main/social/profile.php

@@ -856,7 +856,6 @@ $tpl->assign('socialRightInformation', $socialRightInformation);
 $tpl->assign('socialAutoExtendLink', $socialAutoExtendLink);
 
 $formModalTpl =  new Template();
-$formModalTpl->assign('friendId', $friendId);
 $formModalTpl->assign('messageForm', MessageManager::generate_message_form('send_message'));
 $formModals = $formModalTpl->fetch('default/social/form_modals.tpl');
 

+ 6 - 2
main/template/default/social/form_modals.tpl

@@ -22,9 +22,13 @@
     $(document).on('ready', function() {
         var $sendMessageModal = $('#send-message-modal');
 
-        $('#btn-to-send-message').on('click', function(e) {
+        var sendToUser = 0;
+
+        $('.btn-to-send-message').on('click', function(e) {
             e.preventDefault();
 
+            sendToUser = $(this).data('send-to');
+
             $sendMessageModal.modal('show');
         });
 
@@ -32,7 +36,7 @@
             e.preventDefault();
 
             var $frmSendMessage = $sendMessageModal.find('.modal-body form'),
-                url = '{{ _p.web_ajax }}message.ajax.php?a=send_message&user_id={{ friendId }}';
+                url = '{{ _p.web_ajax }}message.ajax.php?a=send_message&user_id=' + sendToUser;
 
             $.get(url, $frmSendMessage.serialize(), function(response) {
                 $('#send-message-alert').html(response);