message_for_group_form.inc.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
  10. require_once api_get_path(LIBRARY_PATH).'fckeditor/fckeditor.php';
  11. $tok = Security::get_token();
  12. if (api_is_anonymous()) {
  13. api_not_allowed();
  14. }
  15. if (api_get_setting('allow_message_tool') != 'true' && api_get_setting('allow_social_tool') != 'true') {
  16. api_not_allowed();
  17. }
  18. if ( isset($_REQUEST['user_friend']) ) {
  19. $info_user_friend=array();
  20. $info_path_friend=array();
  21. $userfriend_id=Security::remove_XSS($_REQUEST['user_friend']);
  22. // panel=1 send message
  23. // panel=2 send invitation
  24. $panel=Security::remove_XSS($_REQUEST['view_panel']);
  25. $info_user_friend=api_get_user_info($userfriend_id);
  26. $info_path_friend=UserManager::get_user_picture_path_by_id($userfriend_id,'web',false,true);
  27. }
  28. $group_id = intval($_GET['group_id']);
  29. $message_id = intval($_GET['message_id']);
  30. $actions = array('add_message_group','edit_message_group','reply_message_group');
  31. $allowed_action = (isset($_GET['action']) && in_array($_GET['action'],$actions))?Security::remove_XSS($_GET['action']):'';
  32. $to_group = '';
  33. $subject = '';
  34. $message = '';
  35. if (!empty($group_id) && $allowed_action) {
  36. $group_info = GroupPortalManager::get_group_data($group_id);
  37. $to_group = $group_info['name'];
  38. if (!empty($message_id)) {
  39. $message_info = MessageManager::get_message_by_id($message_id);
  40. if ($allowed_action == 'reply_message_group') {
  41. $subject = get_lang('Reply').': '.api_xml_http_response_encode($message_info['title']);
  42. } else {
  43. $subject = api_xml_http_response_encode($message_info['title']);
  44. $message = api_xml_http_response_encode($message_info['content']);
  45. }
  46. }
  47. }
  48. $page_item = !empty($_GET['topics_page_nr'])?intval($_GET['topics_page_nr']):1;
  49. $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)):'';
  50. $page_topic = !empty($_GET['topics_page_nr'])?intval($_GET['topics_page_nr']):1;
  51. ?>
  52. <form name="form" action="groups.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">
  53. <input type="hidden" name="action" value="<?php echo $allowed_action ?>" />
  54. <input type="hidden" name="group_id" value="<?php echo $group_id ?>" />
  55. <input type="hidden" name="parent_id" value="<?php echo $message_id ?>" />
  56. <input type="hidden" name="message_id" value="<?php echo $message_id ?>" />
  57. <input type="hidden" name="token" value="<?php echo $tok ?>" />
  58. <table width="600" border="0" height="220">
  59. <tr height="180">
  60. <td align="left">
  61. <div id="id_content_panel_init">
  62. <dl>
  63. <?php
  64. if (api_get_setting('allow_message_tool')=='true') {
  65. //normal message
  66. $user_info=api_get_user_info($userfriend_id);
  67. echo api_xml_http_response_encode(get_lang('To')); ?> :&nbsp;&nbsp;&nbsp;&nbsp;<?php echo api_xml_http_response_encode($to_group); ?>
  68. <br />
  69. <br /><span style="color:red">*</span><?php echo api_xml_http_response_encode(get_lang('Subject')); ?> :<br />
  70. <input id="txt_subject_id" name="title" type="text" style="width:450px;" value="<?php echo $subject ?>"><br/>
  71. <br /><?php echo api_xml_http_response_encode(get_lang('Message')); ?> :<br />
  72. <?php
  73. $oFCKeditor = new FCKeditor('content') ;
  74. $oFCKeditor->ToolbarSet = 'messages';
  75. $oFCKeditor->Width = '100%';
  76. $oFCKeditor->Height = '130';
  77. $oFCKeditor->Value = $message;
  78. $return = $oFCKeditor->CreateHtml();
  79. echo $return;
  80. ?>
  81. <br /><?php echo api_xml_http_response_encode(get_lang('AttachmentFiles')); ?> :<br />
  82. <span id="filepaths"><div id="filepath_1"><input type="file" name="attach_1" size="20" /></div></span>
  83. <div id="link-more-attach"><a href="javascript://" onclick="return add_image_form()"><?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>
  84. <br />
  85. <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>
  86. <div><span style="color:red">*</span><?php echo get_lang('FieldRequired') ?></div>
  87. <?php } ?>
  88. </dl>
  89. </td>
  90. </tr>
  91. </div>
  92. </table>
  93. </form>