message_for_group_form.inc.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. $language_file = array('registration','messages','userInfo','admin');
  4. $cidReset=true;
  5. require_once '../inc/global.inc.php';
  6. api_block_anonymous_users();
  7. if (api_get_setting('allow_social_tool') !='true') {
  8. api_not_allowed();
  9. }
  10. require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
  11. require_once api_get_path(LIBRARY_PATH).'message.lib.php';
  12. require_once api_get_path(LIBRARY_PATH).'social.lib.php';
  13. require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
  14. require_once api_get_path(LIBRARY_PATH).'fckeditor/fckeditor.php';
  15. $tok = Security::get_token();
  16. if (isset($_REQUEST['user_friend'])) {
  17. $info_user_friend=array();
  18. $info_path_friend=array();
  19. $userfriend_id=Security::remove_XSS($_REQUEST['user_friend']);
  20. // panel=1 send message
  21. // panel=2 send invitation
  22. $panel=Security::remove_XSS($_REQUEST['view_panel']);
  23. $info_user_friend = api_get_user_info($userfriend_id);
  24. $info_path_friend = UserManager::get_user_picture_path_by_id($userfriend_id,'web',false,true);
  25. }
  26. $group_id = intval($_GET['group_id']);
  27. $message_id = intval($_GET['message_id']);
  28. $actions = array('add_message_group', 'edit_message_group', 'reply_message_group');
  29. $allowed_action = (isset($_GET['action']) && in_array($_GET['action'],$actions))?Security::remove_XSS($_GET['action']):'';
  30. $to_group = '';
  31. $subject = '';
  32. $message = '';
  33. if (!empty($group_id) && $allowed_action) {
  34. $group_info = GroupPortalManager::get_group_data($group_id);
  35. $is_member = GroupPortalManager::is_group_member($group_id);
  36. if ($group_info['visibility'] == GROUP_PERMISSION_CLOSED && !$is_member) {
  37. api_not_allowed(true);
  38. }
  39. $to_group = $group_info['name'];
  40. if (!empty($message_id)) {
  41. $message_info = MessageManager::get_message_by_id($message_id);
  42. if ($allowed_action == 'reply_message_group') {
  43. $subject = get_lang('Reply').': '.api_xml_http_response_encode($message_info['title']);
  44. } else {
  45. $subject = api_xml_http_response_encode($message_info['title']);
  46. $message = api_xml_http_response_encode($message_info['content']);
  47. }
  48. }
  49. }
  50. $page_item = !empty($_GET['topics_page_nr'])?intval($_GET['topics_page_nr']):1;
  51. $param_item_page = isset($_GET['items_page_nr']) && isset($_GET['topic_id'])?('&items_'.intval($_GET['topic_id']).'_page_nr='.(!empty($_GET['topics_page_nr'])?intval($_GET['topics_page_nr']):1)):'';
  52. $param_item_page .= '&topic_id='.intval($_GET['topic_id']);
  53. $page_topic = !empty($_GET['topics_page_nr'])?intval($_GET['topics_page_nr']):1;
  54. ?>
  55. <form name="form" action="group_topics.php?id=<?php echo $group_id ?>&anchor_topic=<?php echo Security::remove_XSS($_GET['anchor_topic']) ?>&topics_page_nr=<?php echo $page_topic ?><?php echo $param_item_page ?>" method="POST" enctype="multipart/form-data">
  56. <input type="hidden" name="action" value="<?php echo $allowed_action ?>" />
  57. <input type="hidden" name="group_id" value="<?php echo $group_id ?>" />
  58. <input type="hidden" name="parent_id" value="<?php echo $message_id ?>" />
  59. <input type="hidden" name="message_id" value="<?php echo $message_id ?>" />
  60. <input type="hidden" name="token" value="<?php echo $tok ?>" />
  61. <table width="600" border="0" height="220">
  62. <tr height="180">
  63. <td align="left">
  64. <div id="id_content_panel_init">
  65. <dl>
  66. <?php
  67. if (api_get_setting('allow_message_tool')=='true') {
  68. //normal message
  69. $user_info=api_get_user_info($userfriend_id);
  70. echo api_xml_http_response_encode(get_lang('To')).":&nbsp;&nbsp;".api_xml_http_response_encode($to_group);
  71. if ($allowed_action == 'add_message_group') {
  72. echo '<br /><br /><span style="color:red">*</span> '.api_xml_http_response_encode(get_lang('Subject')).' :<br />';
  73. echo '<input id="txt_subject_id" name="title" type="text" style="width:450px;" value="'.$subject.'"><br />';
  74. }
  75. echo '<br /><br />'.api_xml_http_response_encode(get_lang('Message')).' :<br />';
  76. $oFCKeditor = new FCKeditor('content') ;
  77. $oFCKeditor->ToolbarSet = 'messages';
  78. $oFCKeditor->Width = '100%';
  79. $oFCKeditor->Height = '130';
  80. $oFCKeditor->Value = $message;
  81. $return = $oFCKeditor->CreateHtml();
  82. echo $return;
  83. ?>
  84. <br /><?php echo api_xml_http_response_encode(get_lang('AttachmentFiles')); ?> :<br />
  85. <span id="filepaths"><div id="filepath_1"><input type="file" name="attach_1" size="20" /></div></span>
  86. <div id="link-more-attach"><a href="javascript://" onclick="return add_image_form()">
  87. <?php echo get_lang('AddOneMoreFile') ?></a>&nbsp;(<?php echo api_xml_http_response_encode(sprintf(get_lang('MaximunFileSizeX'),format_file_size(api_get_setting('message_max_upload_filesize')))) ?>)</div>
  88. <br />
  89. <button class="save" onclick="if(validate_text_empty(this.form.title.value,'<?php echo get_lang('YouShouldWriteASubject')?>')){return false;}" type="submit" value="<?php echo api_xml_http_response_encode(get_lang('SendMessage')); ?>"><?php echo api_xml_http_response_encode(get_lang('SendMessage')) ?></button>
  90. <div><span style="color:red">*</span><?php echo get_lang('FieldRequired') ?></div>
  91. <?php } ?>
  92. </dl>
  93. </td>
  94. </tr>
  95. </div>
  96. </table>
  97. </form>