message_for_group_form.inc.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. $app['template.show_footer'] = false;
  14. $app['template.show_header'] = false;
  15. $app['default_layout'] = 'default/layout/blank.tpl';
  16. api_block_anonymous_users();
  17. if (api_get_setting('allow_social_tool') !='true') {
  18. api_not_allowed();
  19. }
  20. $tok = Security::get_token();
  21. if (isset($_REQUEST['user_friend'])) {
  22. $info_user_friend=array();
  23. $info_path_friend=array();
  24. $userfriend_id = intval($_REQUEST['user_friend']);
  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. $url = api_get_path(WEB_PUBLIC_PATH).'main/social/group_topics.php?id='.$group_id.'&anchor_topic='.$anchor_topic.'&topics_page_nr='.$page_topic.$param_item_page;
  63. $form = new FormValidator('form', 'post', $url, null, array('enctype' => 'multipart/form-data'));
  64. $form->addElement('hidden', 'action', $allowed_action);
  65. $form->addElement('hidden', 'group_id', $group_id);
  66. $form->addElement('hidden', 'parent_id', $message_id);
  67. $form->addElement('hidden', 'message_id', $message_id);
  68. $form->addElement('hidden', 'token', $tok);
  69. if (api_get_setting('allow_message_tool')=='true') {
  70. // Normal message
  71. $user_info = api_get_user_info($userfriend_id);
  72. $height = 180;
  73. if ($allowed_action == 'add_message_group') {
  74. $form->addElement('text', 'title', get_lang('Title'));
  75. $height = 140;
  76. }
  77. $form->addElement('html_editor', 'content');
  78. $form->addElement('label', null, get_lang('AttachmentFiles'));
  79. $form->addElement('label', null, '<div id="link-more-attach">
  80. <a href="javascript://" onclick="return add_image_form()">'.get_lang('AddOneMoreFile').'</a>'
  81. );
  82. $form->addElement('html', '<span id="filepaths"></span>');
  83. $form->addElement('file', 'attach_1', sprintf(get_lang('MaximunFileSizeX'), Text::format_file_size(api_get_setting('message_max_upload_filesize'))));
  84. $form->addElement('html', '</div>');
  85. $form->addElement('button', 'submit', get_lang('SendMessage'));
  86. $form->display();
  87. }