Social: Fix creation of topic in groups - refs BT#21101

pull/5156/head
christianbeeznst 2 years ago
parent 0c2d922231
commit c84e964eb7
  1. 4
      assets/vue/components/usergroup/GroupDiscussions.vue
  2. 2
      public/main/inc/lib/message.lib.php
  3. 10
      public/main/inc/lib/notification.lib.php
  4. 9
      public/main/social/group_topics.php
  5. 2
      public/main/social/message_for_group_form.inc.php

@ -2,7 +2,7 @@
<div> <div>
<div class="discussions-header"> <div class="discussions-header">
<h2>Discussions</h2> <h2>Discussions</h2>
<a :href="threadCreationUrl" class="btn btn-primary create-thread-btn"> <a :href="threadCreationUrl" class="btn btn-primary create-thread-btn ajax">
<i class="pi pi-plus"></i> {{ t("Create thread") }} <i class="pi pi-plus"></i> {{ t("Create thread") }}
</a> </a>
</div> </div>
@ -29,9 +29,11 @@
import { ref, onMounted, computed } from 'vue' import { ref, onMounted, computed } from 'vue'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import axios from 'axios' import axios from 'axios'
import { useI18n } from "vue-i18n"
const route = useRoute() const route = useRoute()
const discussions = ref([]) const discussions = ref([])
const groupId = ref(route.params.group_id) const groupId = ref(route.params.group_id)
const { t } = useI18n()
onMounted(async () => { onMounted(async () => {
if (groupId.value) { if (groupId.value) {

@ -366,7 +366,7 @@ class MessageManager
); );
// Adding more sense to the message group // Adding more sense to the message group
$subject = sprintf(get_lang('There is a new message in group %s'), $group_info['name']); $subject = sprintf(get_lang('There is a new message in group %s'), $group_info['title']);
$new_user_list = []; $new_user_list = [];
foreach ($user_list as $user_data) { foreach ($user_list as $user_data) {
$new_user_list[] = $user_data['id']; $new_user_list[] = $user_data['id'];

@ -171,7 +171,7 @@ class Notification extends Model
break; break;
case self::NOTIFICATION_TYPE_GROUP: case self::NOTIFICATION_TYPE_GROUP:
if (!empty($senderInfo)) { if (!empty($senderInfo)) {
$senderName = $senderInfo['group_info']['name']; $senderName = $senderInfo['group_info']['title'];
$newTitle .= sprintf(get_lang('You have received a new message in group %s'), $senderName); $newTitle .= sprintf(get_lang('You have received a new message in group %s'), $senderName);
$senderName = api_get_person_name( $senderName = api_get_person_name(
$senderInfo['user_info']['firstname'], $senderInfo['user_info']['firstname'],
@ -397,7 +397,7 @@ class Notification extends Model
case self::NOTIFICATION_TYPE_GROUP: case self::NOTIFICATION_TYPE_GROUP:
$topicPage = isset($_REQUEST['topics_page_nr']) ? (int) $_REQUEST['topics_page_nr'] : 0; $topicPage = isset($_REQUEST['topics_page_nr']) ? (int) $_REQUEST['topics_page_nr'] : 0;
if (!empty($senderInfo)) { if (!empty($senderInfo)) {
$senderName = $senderInfo['group_info']['name']; $senderName = $senderInfo['group_info']['title'];
$newMessageText = sprintf(get_lang('You have received a new message in group %s'), $senderName); $newMessageText = sprintf(get_lang('You have received a new message in group %s'), $senderName);
$senderName = Display::url( $senderName = Display::url(
$senderInfoName, $senderInfoName,
@ -405,7 +405,7 @@ class Notification extends Model
); );
$newMessageText .= '<br />'.get_lang('User').': '.$senderName; $newMessageText .= '<br />'.get_lang('User').': '.$senderName;
} }
$groupUrl = api_get_path(WEB_CODE_PATH).'social/group_topics.php?id='.$senderInfo['group_info']['id'].'&topic_id='.$senderInfo['group_info']['topic_id'].'&msg_id='.$senderInfo['group_info']['msg_id'].'&topics_page_nr='.$topicPage; $groupUrl = api_get_path(WEB_PATH).'resources/usergroups/show/'.$senderInfo['group_info']['id'];
$linkToNewMessage = Display::url(get_lang('See message'), $groupUrl); $linkToNewMessage = Display::url(get_lang('See message'), $groupUrl);
break; break;
} }
@ -519,6 +519,8 @@ class Notification extends Model
/** @var array $decodedResult */ /** @var array $decodedResult */
$decodedResult = json_decode($result, true); $decodedResult = json_decode($result, true);
return intval($decodedResult['success']); $return = isset($decodedResult['success']) ? (int) $decodedResult['success'] : 0;
return $return;
} }
} }

@ -68,7 +68,7 @@ if (isset($_POST['action'])) {
if ('edit_message_group' === $_POST['action']) { if ('edit_message_group' === $_POST['action']) {
$edit_message_id = intval($_POST['message_id']); $edit_message_id = intval($_POST['message_id']);
$res = MessageManager::send_message( $res = MessageManager::send_message(
0, api_get_user_id(),
$title, $title,
$content, $content,
$_FILES, $_FILES,
@ -83,7 +83,7 @@ if (isset($_POST['action'])) {
api_not_allowed(true); api_not_allowed(true);
} }
$res = MessageManager::send_message( $res = MessageManager::send_message(
0, api_get_user_id(),
$title, $title,
$content, $content,
$_FILES, $_FILES,
@ -99,6 +99,9 @@ if (isset($_POST['action'])) {
if (!$res) { if (!$res) {
Display::addFlash(Display::return_message(get_lang('Error'), 'error')); Display::addFlash(Display::return_message(get_lang('Error'), 'error'));
} }
header('Location: ' . api_get_path(WEB_PATH).'resources/usergroups/show/'.$group_id);
exit;
$topic_id = isset($_GET['topic_id']) ? intval($_GET['topic_id']) : null; $topic_id = isset($_GET['topic_id']) ? intval($_GET['topic_id']) : null;
if ('add_message_group' === $_POST['action']) { if ('add_message_group' === $_POST['action']) {
$topic_id = $res; $topic_id = $res;
@ -178,7 +181,7 @@ $(function() {
$this_section = SECTION_SOCIAL; $this_section = SECTION_SOCIAL;
$interbreadcrumb[] = ['url' => 'groups.php', 'name' => get_lang('Groups')]; $interbreadcrumb[] = ['url' => 'groups.php', 'name' => get_lang('Groups')];
$interbreadcrumb[] = ['url' => 'group_view.php?id='.$group_id, 'name' => Security::remove_XSS($group_info['name'])]; $interbreadcrumb[] = ['url' => 'group_view.php?id='.$group_id, 'name' => Security::remove_XSS($group_info['title'])];
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Discussions')]; $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Discussions')];
$social_left_content = null; //SocialManager::show_social_menu('member_list', $group_id); $social_left_content = null; //SocialManager::show_social_menu('member_list', $group_id);

@ -36,7 +36,7 @@ if (!empty($group_id) && $allowed_action) {
api_not_allowed(true); api_not_allowed(true);
} }
$to_group = $group_info['name']; $to_group = $group_info['title'];
if (!empty($message_id)) { if (!empty($message_id)) {
/*$message_info = MessageManager::get_message_by_id($message_id); /*$message_info = MessageManager::get_message_by_id($message_id);
if ('reply_message_group' === $allowed_action) { if ('reply_message_group' === $allowed_action) {

Loading…
Cancel
Save