message_for_group_form.inc.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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).'fckeditor/fckeditor.php';
  18. $tok = Security::get_token();
  19. if (isset($_REQUEST['user_friend'])) {
  20. $info_user_friend=array();
  21. $info_path_friend=array();
  22. $userfriend_id = intval($_REQUEST['user_friend']);
  23. // panel=1 send message
  24. // panel=2 send invitation
  25. $panel = Security::remove_XSS($_REQUEST['view_panel']);
  26. $info_user_friend = api_get_user_info($userfriend_id);
  27. $info_path_friend = UserManager::get_user_picture_path_by_id($userfriend_id,'web',false,true);
  28. }
  29. $group_id = isset($_GET['group_id']) ? intval($_GET['group_id']) : null;
  30. $message_id = isset($_GET['message_id']) ? intval($_GET['message_id']) : null;
  31. $actions = array('add_message_group', 'edit_message_group', 'reply_message_group');
  32. $allowed_action = (isset($_GET['action']) && in_array($_GET['action'],$actions))?Security::remove_XSS($_GET['action']):'';
  33. $to_group = '';
  34. $subject = '';
  35. $message = '';
  36. $usergroup = new UserGroup();
  37. if (!empty($group_id) && $allowed_action) {
  38. $group_info = $usergroup->get($group_id);
  39. $is_member = $usergroup->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. if (isset($_GET['topic_id'])) {
  58. $param_item_page .= '&topic_id='.intval($_GET['topic_id']);
  59. }
  60. $page_topic = isset($_GET['topics_page_nr']) ? intval($_GET['topics_page_nr']):1;
  61. $anchor_topic = isset($_GET['anchor_topic']) ? Security::remove_XSS($_GET['anchor_topic']): null;
  62. ?>
  63. <form name="form" action="group_topics.php?id=<?php echo $group_id ?>&anchor_topic=<?php echo $anchor_topic ?>&topics_page_nr=<?php echo $page_topic.$param_item_page ?>" method="POST" enctype="multipart/form-data">
  64. <input type="hidden" name="action" value="<?php echo $allowed_action ?>" />
  65. <input type="hidden" name="group_id" value="<?php echo $group_id ?>" />
  66. <input type="hidden" name="parent_id" value="<?php echo $message_id ?>" />
  67. <input type="hidden" name="message_id" value="<?php echo $message_id ?>" />
  68. <input type="hidden" name="token" value="<?php echo $tok ?>" />
  69. <table width="500px" border="0" height="220px">
  70. <tr height="180">
  71. <td align="left">
  72. <div id="id_content_panel_init">
  73. <dl>
  74. <?php
  75. if (api_get_setting('allow_message_tool')=='true') {
  76. //normal message
  77. $user_info = api_get_user_info($userfriend_id);
  78. //echo api_xml_http_response_encode(get_lang('To')).":&nbsp;&nbsp;".api_xml_http_response_encode($to_group);
  79. $height = 180;
  80. if ($allowed_action == 'add_message_group') {
  81. $height = 140;
  82. echo '<span style="color:red">*</span> '.api_xml_http_response_encode(get_lang('Title')).' :<br />';
  83. echo '<input id="txt_subject_id" name="title" type="text" style="width:450px;" value="'.$subject.'"><br /><br />';
  84. }
  85. //echo api_xml_http_response_encode(get_lang('Description')).' :<br />';
  86. $oFCKeditor = new FCKeditor('content') ;
  87. $oFCKeditor->ToolbarSet = 'messages';
  88. $oFCKeditor->Width = '95%';
  89. $oFCKeditor->Height = $height;
  90. $oFCKeditor->Value = $message;
  91. $return = $oFCKeditor->CreateHtml();
  92. echo $return;
  93. if ($allowed_action == 'add_message_group') {
  94. echo '<div><span style="color:red"> * </span>'.get_lang('FieldRequired').'</div>';
  95. }
  96. ?>
  97. <br /><br />
  98. <?php echo api_xml_http_response_encode(get_lang('AttachmentFiles')); ?> :<br />
  99. <span id="filepaths"><div id="filepath_1"><input type="file" name="attach_1" size="20" /></div></span>
  100. <div id="link-more-attach">
  101. <a href="javascript://" onclick="return add_image_form()">
  102. <?php echo get_lang('AddOneMoreFile') ?></a>
  103. </div>
  104. (<?php echo api_xml_http_response_encode(sprintf(get_lang('MaximunFileSizeX'), Text::format_file_size(api_get_setting('message_max_upload_filesize')))) ?>)
  105. <br />
  106. <br />
  107. <?php if ($allowed_action == 'add_message_group') { ?>
  108. <button class="btn 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>
  109. <?php } else { ?>
  110. <button class="btn 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>
  111. <?php } ?>
  112. <?php } ?>
  113. </dl>
  114. </td>
  115. </tr>
  116. </div>
  117. </table>
  118. </form>