Fix send messages in social tool

1.10.x
Angel Fernando Quiroz Campos 11 years ago
parent a55d3d227a
commit fe10482ebb
  1. 4
      main/inc/lib/message.lib.php
  2. 2
      main/inc/lib/social.lib.php
  3. 50
      main/social/profile.php
  4. 44
      main/template/default/social/form_modals.tpl
  5. 3
      main/template/default/social/profile.tpl

@ -1389,8 +1389,8 @@ class MessageManager
$form = new FormValidator('send_message', null, 'post', null, array('id' => $id.'_form', 'class' => 'form-vertical')); $form = new FormValidator('send_message', null, 'post', null, array('id' => $id.'_form', 'class' => 'form-vertical'));
$form->addElement('text', 'subject', get_lang('Subject'), array('id' => 'subject_id', 'class' => 'span5')); $form->addElement('text', 'subject', get_lang('Subject'), array('id' => 'subject_id', 'class' => 'span5'));
$form->addElement('textarea', 'content', get_lang('Message'), array('id' => 'content_id', 'rows' => '5', 'class' => 'span5')); $form->addElement('textarea', 'content', get_lang('Message'), array('id' => 'content_id', 'rows' => '5', 'class' => 'span5'));
$div = Display::div($form->return_form(), array('id' => $id.'_div', 'style' => 'display:none'));
return $div; return $form->return_form();
} }
public static function generate_invitation_form($id, $params = array()) public static function generate_invitation_form($id, $params = array())

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

@ -144,47 +144,6 @@ function checkLength( o, n, min, max ) {
} }
} }
function send_message_to_user(user_id) {
var subject = $( "#subject_id" );
var content = $( "#content_id" );
$("#send_message_form").show();
$("#send_message_div").dialog({
modal:true,
height:350,
buttons: {
"'. addslashes(get_lang('Send')).'": function() {
var bValid = true;
bValid = bValid && checkLength( subject, "subject", 1, 255 );
bValid = bValid && checkLength( content, "content", 1, 255 );
if ( bValid ) {
var url = "'.$ajax_url.'?a=send_message&user_id="+user_id;
var params = $("#send_message_form").serialize();
$.ajax({
url: url+"&"+params,
success:function(data) {
$("#message_ajax_reponse").attr("class", "");
$("#message_ajax_reponse").html(data);
$("#message_ajax_reponse").show();
$("#send_message_div").dialog({ buttons:{}});
$("#send_message_form").hide();
$("#send_message_div").dialog("close");
$("#subject_id").val("");
$("#content_id").val("");
}
});
}
}
},
close: function() {
}
});
$("#send_message_div").dialog("open");
//prevent the browser to follow the link
}
function send_invitation_to_user(user_id) { function send_invitation_to_user(user_id) {
var content = $( "#content_invitation_id" ); var content = $( "#content_invitation_id" );
$("#send_invitation_form").show(); $("#send_invitation_form").show();
@ -878,7 +837,7 @@ if ($show_full_profile) {
$socialRightInformation .= SocialManager::social_wrapper_div($more_info, 4); $socialRightInformation .= SocialManager::social_wrapper_div($more_info, 4);
} }
} }
$social_right_content .= MessageManager::generate_message_form('send_message');
$social_right_content .= MessageManager::generate_invitation_form('send_invitation'); $social_right_content .= MessageManager::generate_invitation_form('send_invitation');
@ -895,6 +854,13 @@ $tpl->assign('social_skill_block', $social_skill_block);
$tpl->assign('social_session_block', $social_session_block); $tpl->assign('social_session_block', $social_session_block);
$tpl->assign('socialRightInformation', $socialRightInformation); $tpl->assign('socialRightInformation', $socialRightInformation);
$tpl->assign('socialAutoExtendLink', $socialAutoExtendLink); $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');
$tpl->assign('formModals', $formModals);
$social_layout = $tpl->get_template('social/profile.tpl'); $social_layout = $tpl->get_template('social/profile.tpl');
$tpl->display($social_layout); $tpl->display($social_layout);

@ -0,0 +1,44 @@
<div class="modal fade" id="send-message-modal" tabindex="-1" role="dialog" aria-labelledby="send-message-modal-title" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="{{ 'Close' | get_lang }}">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" id="send-message-modal-title">{{ 'SendMessage' | get_lang }}</h4>
</div>
<div class="modal-body">
<div id="send-message-alert"></div>
{{ messageForm }}
</div>
<div class="modal-footer">
<button type="button" id="btn-send-message" class="btn btn-primary">{{ 'Send' | get_lang }}</button>
</div>
</div>
</div>
</div>
<script>
$(document).on('ready', function() {
var $sendMessageModal = $('#send-message-modal');
$('#btn-to-send-message').on('click', function(e) {
e.preventDefault();
$sendMessageModal.modal('show');
});
$('#btn-send-message').on('click', function(e) {
e.preventDefault();
var $frmSendMessage = $sendMessageModal.find('.modal-body form'),
url = '{{ _p.web_ajax }}message.ajax.php?a=send_message&user_id={{ friendId }}';
$.get(url, $frmSendMessage.serialize(), function(response) {
$('#send-message-alert').html(response);
$frmSendMessage[0].reset();
});
});
});
</script>

@ -33,4 +33,7 @@
</div> </div>
</div> </div>
{% if formModals is defined %}
{{ formModals }}
{% endif %}
{% endblock %} {% endblock %}
Loading…
Cancel
Save