send_message.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /* For licensing terms, see /dokeos_license.txt */
  3. $language_file = array('registration','messages','userInfo','admin');
  4. $cidReset=true;
  5. require_once '../inc/global.inc.php';
  6. require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
  7. require_once api_get_path(LIBRARY_PATH).'message.lib.php';
  8. require_once api_get_path(LIBRARY_PATH).'social.lib.php';
  9. if (api_is_anonymous()) {
  10. api_not_allowed();
  11. }
  12. $user_id = intval($_POST['user_id']);
  13. $panel_id = intval($_POST['panel_id']);
  14. $content_message = Security::remove_XSS($_POST['txt_content'],COURSEMANAGERLOWSECURITY); //check this is filtered on output
  15. $subject_message = Security::remove_XSS($_POST['txt_subject']); //check this is filtered on output
  16. $user_info = array();
  17. $user_info = api_get_user_info($user_id);
  18. if ($panel_id==2) {
  19. ?>
  20. <td height="20"><?php //echo api_xml_http_response_encode(get_lang('Info')).' :'; ?></td>
  21. <td height="20"><?php //echo api_xml_http_response_encode(get_lang('SocialUserInformationAttach')); ?></td>
  22. <td height="20"><?php echo api_xml_http_response_encode(get_lang('WriteAMessage')); ?> :<br/><textarea id="txt_area_invite" rows="3" cols="25"></textarea></td>
  23. <td height="20"><input type="button" value="<?php echo api_xml_http_response_encode(get_lang('SendInviteMessage')); ?>" onclick="action_database_panel('4','<?php echo $user_id;?>')" /></td>
  24. <?php
  25. }
  26. if ($panel_id==1) {
  27. ?>
  28. <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>
  29. <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>
  30. <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>
  31. <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>
  32. <?php
  33. }
  34. if ($panel_id==3) {
  35. ?>
  36. <dl>
  37. <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>
  38. <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>
  39. </dl>
  40. <?php
  41. // <dd><a href="'.api_get_path(WEB_PATH).'main/social/index.php#remote-tab-5"> echo api_xml_http_response_encode(get_lang('SocialSeeContacts'));</a></dd>
  42. }
  43. if ($panel_id==4) {
  44. if ($subject_message=='clear') {
  45. $subject_message=null;
  46. }
  47. SocialManager::send_invitation_friend_user($user_id,$subject_message,$content_message);
  48. } elseif ($panel_id==5) {
  49. SocialManager::send_invitation_friend_user($user_id,$subject_message,$content_message);
  50. }
  51. ?>