message_for_group_form.inc.php 5.5 KB

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