message_for_group_form.inc.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Form for group message
  5. * @package chamilo.social
  6. */
  7. $language_file = array('registration', 'admin');
  8. $cidReset = true;
  9. require_once '../inc/global.inc.php';
  10. api_block_anonymous_users();
  11. if (api_get_setting('allow_social_tool') != 'true') {
  12. api_not_allowed();
  13. }
  14. $tok = Security::get_token();
  15. if (isset($_REQUEST['user_friend'])) {
  16. $userfriend_id = intval($_REQUEST['user_friend']);
  17. // panel=1 send message
  18. // panel=2 send invitation
  19. $panel = Security::remove_XSS($_REQUEST['view_panel']);
  20. $info_user_friend = api_get_user_info($userfriend_id);
  21. $info_path_friend = UserManager::get_user_picture_path_by_id(
  22. $userfriend_id,
  23. 'web',
  24. false,
  25. true
  26. );
  27. }
  28. $group_id = intval($_GET['group_id']);
  29. $message_id = isset($_GET['message_id']) ? intval($_GET['message_id']) : null;
  30. $actions = array(
  31. 'add_message_group',
  32. 'edit_message_group',
  33. 'reply_message_group'
  34. );
  35. $allowed_action = (isset($_GET['action']) && in_array($_GET['action'], $actions)) ? Security::remove_XSS($_GET['action']) : '';
  36. $to_group = '';
  37. $subject = '';
  38. $message = '';
  39. if (!empty($group_id) && $allowed_action) {
  40. $group_info = GroupPortalManager::get_group_data($group_id);
  41. $is_member = GroupPortalManager::is_group_member($group_id);
  42. if ($group_info['visibility'] == GROUP_PERMISSION_CLOSED && !$is_member) {
  43. api_not_allowed(true);
  44. }
  45. $to_group = $group_info['name'];
  46. if (!empty($message_id)) {
  47. $message_info = MessageManager::get_message_by_id($message_id);
  48. if ($allowed_action == 'reply_message_group') {
  49. $subject = get_lang('Reply') . ': ' . api_xml_http_response_encode(
  50. $message_info['title']
  51. );
  52. //$message = api_xml_http_response_encode($message_info['content']);
  53. } else {
  54. $subject = api_xml_http_response_encode($message_info['title']);
  55. $message = api_xml_http_response_encode($message_info['content']);
  56. }
  57. }
  58. }
  59. $page_item = !empty($_GET['topics_page_nr']) ? intval($_GET['topics_page_nr']) : 1;
  60. $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)) : '';
  61. $param_item_page .= isset($_GET['topic_id']) ? '&topic_id=' . intval($_GET['topic_id']) : null;
  62. $page_topic = !empty($_GET['topics_page_nr']) ? intval($_GET['topics_page_nr']) : 1;
  63. $anchor = isset($_GET['anchor_topic']) ? Security::remove_XSS($_GET['anchor_topic']) : null;
  64. $form = new FormValidator(
  65. 'add_post',
  66. 'post',
  67. api_get_path(WEB_CODE_PATH)."social/group_topics.php?id=$group_id&anchor_topic=$anchor&topics_page_nr=$page_topic"."$param_item_page",
  68. null,
  69. array('enctype' => 'multipart/form-data')
  70. );
  71. $form->addHidden('action', $allowed_action);
  72. $form->addHidden('group_id', $group_id);
  73. $form->addHidden('parent_id', $message_id);
  74. $form->addHidden('message_id',$message_id );
  75. $form->addHidden('token', $tok);
  76. if (api_get_setting('allow_message_tool') == 'true') {
  77. //normal message
  78. $user_info = api_get_user_info($userfriend_id);
  79. $height = 180;
  80. if ($allowed_action == 'add_message_group') {
  81. $form->addText('title', get_lang('Title'));
  82. $height = 140;
  83. }
  84. $config = array();
  85. $config['ToolbarSet'] = 'Messages';
  86. $form->addHtmlEditor(
  87. 'content',
  88. get_lang('Content'),
  89. false,
  90. false,
  91. $config
  92. );
  93. $form->addHtml('<span id="filepaths"><div id="filepath_1">');
  94. $form->addFile('attach_1', get_lang('AttachmentFiles'));
  95. $form->addHtml('</div></span>');
  96. $form->addLabel(null,
  97. ' <div id="link-more-attach">
  98. <a href="javascript://" onclick="return add_image_form()">
  99. ' . get_lang('AddOneMoreFile') . '</a>
  100. </div>'
  101. );
  102. $form->addLabel(null,
  103. api_xml_http_response_encode(
  104. sprintf(
  105. get_lang('MaximunFileSizeX'),
  106. format_file_size(
  107. api_get_setting('message_max_upload_filesize')
  108. )
  109. )
  110. )
  111. );
  112. $form->addElement('style_submit_button', 'submit', get_lang('SendMessage'));
  113. Display::display_no_header();
  114. //Display::display_reduced_header();
  115. $form->display();
  116. }
  117. /*
  118. ?>
  119. <button class="btn save"
  120. onclick="if(validate_text_empty(this.form.title.value,'<?php echo get_lang(
  121. 'YouShouldWriteASubject'
  122. ) ?>')){return false;}" type="submit"
  123. value="<?php echo api_xml_http_response_encode(
  124. get_lang('SendMessage')
  125. ); ?>"><?php echo api_xml_http_response_encode(
  126. get_lang('SendMessage')
  127. ) ?></button>
  128. <?php } else { ?>
  129. <button class="btn save" type="submit"
  130. value="<?php echo api_xml_http_response_encode(
  131. get_lang('SendMessage')
  132. ); ?>"><?php echo api_xml_http_response_encode(
  133. get_lang('SendMessage')
  134. ) ?></button>
  135. <?php } ?>
  136. <?php } ?>
  137. </dl>
  138. </td>
  139. </tr>
  140. </div>
  141. </table>
  142. </form>
  143. */