From 06e081dbc5e45ef043373281fcdf415c251845d9 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Mon, 2 Dec 2013 19:50:18 +0100 Subject: [PATCH] Minor - Format code --- main/social/group_topics.php | 71 ++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/main/social/group_topics.php b/main/social/group_topics.php index b6d2be67c9..1ee0cef987 100644 --- a/main/social/group_topics.php +++ b/main/social/group_topics.php @@ -24,15 +24,15 @@ $usergroup = new UserGroup(); //todo @this validation could be in a function in group_portal_manager if (empty($group_id)) { api_not_allowed(true); - } else { $group_info = $usergroup->get($group_id); - if (empty($group_info)) { - api_not_allowed(true); - } + if (empty($group_info)) { + api_not_allowed(true); + } $is_member = $usergroup->is_group_member($group_id); - if ($group_info['visibility'] == GROUP_PERMISSION_CLOSED && !$is_member ) { + + if ($group_info['visibility'] == GROUP_PERMISSION_CLOSED && !$is_member) { api_not_allowed(true); } } @@ -46,43 +46,44 @@ if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') { exit; } } + $content = null; // save message group $currentToken = Security::getCurrentToken(); -if (isset($_POST['token']) && $_POST['token'] === $currentToken) { - if (isset($_POST['action'])) { - $title = isset($_POST['title']) ? $_POST['title'] : null; - $content = $_POST['content']; - $group_id = intval($_POST['group_id']); - $parent_id = intval($_POST['parent_id']); +if (isset($_POST['action'])) { + $title = isset($_POST['title']) ? $_POST['title'] : null; + $content = $_POST['content']; + $group_id = intval($_POST['group_id']); + $parent_id = intval($_POST['parent_id']); - if ($_POST['action'] == 'reply_message_group') { - $title = Text::cut($content, 50); - } - if ($_POST['action'] == 'edit_message_group') { - $edit_message_id = intval($_POST['message_id']); - $res = MessageManager::send_message(0, $title, $content, $_FILES, '', $group_id, $parent_id, $edit_message_id, 0, $topic_id); - } else { - if ($_POST['action'] == 'add_message_group' && !$is_member) { - api_not_allowed(); - } - $res = MessageManager::send_message(0, $title, $content, $_FILES, '', $group_id, $parent_id, 0, $topic_id); - } + if ($_POST['action'] == 'reply_message_group') { + $title = Text::cut($content, 50); + } - // display error messages - if (!$res) { - $social_right_content .= Display::return_message(get_lang('Error'),'error'); - } - $topic_id = isset($_GET['topic_id']) ? intval($_GET['topic_id']) : null; - if ($_POST['action'] == 'add_message_group') { - $topic_id = $res; - } - $message_id = $res; - } + if ($_POST['action'] == 'edit_message_group') { + $edit_message_id = intval($_POST['message_id']); + $res = MessageManager::send_message(0, $title, $content, $_FILES, '', $group_id, $parent_id, $edit_message_id, 0, $topic_id); + } else { + if ($_POST['action'] == 'add_message_group' && !$is_member) { + api_not_allowed(); + } + $res = MessageManager::send_message(0, $title, $content, $_FILES, '', $group_id, $parent_id, 0, $topic_id); + } + + // display error messages + if (!$res) { + $social_right_content .= Display::return_message(get_lang('Error'),'error'); + } + $topic_id = isset($_GET['topic_id']) ? intval($_GET['topic_id']) : null; + if ($_POST['action'] == 'add_message_group') { + $topic_id = $res; + } + $message_id = $res; } + $htmlHeadXtra[] = ''; $this_section = SECTION_SOCIAL;