send_message.php 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @package chamilo.messages
  5. */
  6. /**
  7. * Code
  8. */
  9. $language_file = array('registration','messages','userInfo','admin');
  10. $cidReset = true;
  11. require_once '../inc/global.inc.php';
  12. if (api_is_anonymous()) {
  13. api_not_allowed();
  14. }
  15. $user_id = intval($_POST['user_id']);
  16. $panel_id = intval($_POST['panel_id']);
  17. $content_message = $_POST['txt_content'];
  18. $subject_message = $_POST['txt_subject'];
  19. $user_info = array();
  20. $user_info = api_get_user_info($user_id);
  21. if ($panel_id == 2 || $panel_id == 4 ) {
  22. if (empty($content_message)) {
  23. ?>
  24. <div id="display_response_id" style="height:200px;">
  25. <?php echo api_xml_http_response_encode(get_lang('AddPersonalMessage')); ?> :<br /><br />
  26. <textarea id="txt_area_invite" rows="5" cols="40"></textarea><br />
  27. <?php echo api_xml_http_response_encode(get_lang('YouShouldWriteAMessage')); ?><br /><br />
  28. <button class="save" type="button" value="<?php echo api_xml_http_response_encode(get_lang('SocialAddToFriends')); ?>" onclick="action_database_panel('4','<?php echo $user_id;?>')" >
  29. <?php echo api_xml_http_response_encode(get_lang('SendInvitation')) ?></button>
  30. </div>
  31. <?php
  32. }
  33. } elseif ($panel_id==1) {
  34. if (empty($content_message) || empty($subject_message)) {
  35. ?>
  36. <td height="20"><?php echo api_xml_http_response_encode(get_lang('To')); ?> &nbsp;:&nbsp;&nbsp;&nbsp;&nbsp;<?php echo api_xml_http_response_encode(api_get_person_name($user_info['firstName'], $user_info['lastName'])); ?></td>
  37. <td height="20"><?php echo api_xml_http_response_encode(get_lang('Subject')); ?> :<br/><input id="txt_subject_id" type="text" style="width:200px;"></td>
  38. <td height="20"><?php echo api_xml_http_response_encode(get_lang('Message')); ?> :<br/><textarea id="txt_area_invite" rows="3" cols="25"></textarea></td>
  39. <td height="20"><input type="button" value="<?php echo api_xml_http_response_encode(get_lang('NewMessage')); ?>" onclick="hide_display_message()" />&nbsp;&nbsp;&nbsp; <input type="button" value="<?php echo api_xml_http_response_encode(get_lang('SendMessage')); ?>" onclick="action_database_panel('5','<?php echo $user_id;?>')" /></td>
  40. <?php
  41. }
  42. }elseif ($panel_id==3) {
  43. ?>
  44. <dl>
  45. <dd><a href="javascript:void(0)" onclick="change_panel('2','<?php echo $user_id; ?>')"><?php echo api_xml_http_response_encode(get_lang('SendInviteMessage')); ?></a></dd>
  46. <dd><a href="javascript:void(0)" onclick="change_panel('1','<?php echo $user_id; ?>')"><?php echo api_xml_http_response_encode(get_lang('SendMessage'));?></a></dd>
  47. </dl>
  48. <?php
  49. }elseif($panel_id == 5 && empty($subject_message)) {
  50. ?>
  51. <div id="display_response_id" style="height:200px;">
  52. <?php echo api_xml_http_response_encode(get_lang('To')); ?> :&nbsp;&nbsp;&nbsp;&nbsp;<?php echo api_xml_http_response_encode(api_get_person_name($user_info['firstName'], $user_info['lastName'])); ?>
  53. <br />
  54. <br /><span style="color:red">*</span><?php echo api_xml_http_response_encode(get_lang('Subject')); ?> :<br /><input id="txt_subject_id" type="text" style="width:300px;"><br/>
  55. <br /><?php echo api_xml_http_response_encode(get_lang('Message')); ?> :<br /><textarea id="txt_area_invite" rows="3" cols="40"></textarea>
  56. <?php echo Display::display_error_message(api_xml_http_response_encode(get_lang('YouShouldWriteASubject'))); ?>
  57. <button class="save" type="button" value="<?php echo api_xml_http_response_encode(get_lang('SendMessage')); ?>" onclick="action_database_panel('5','<?php echo $user_id;?>')">
  58. <?php echo api_xml_http_response_encode(get_lang('SendMessage')) ?></button>
  59. </div>
  60. <?php
  61. }
  62. if ($panel_id==4 && !empty($content_message)) {
  63. if ($subject_message=='clear') {
  64. $subject_message=null;
  65. }
  66. SocialManager::send_invitation_friend_user($user_id, $subject_message, $content_message);
  67. } elseif ($panel_id==5 && !empty($subject_message) ) {
  68. SocialManager::send_invitation_friend_user($user_id, $subject_message, $content_message);
  69. }