|
|
|
@ -109,17 +109,17 @@ $role = 0; |
|
|
|
|
$usergroup = new UserGroup(); |
|
|
|
|
|
|
|
|
|
if ($group_id != 0) { |
|
|
|
|
$group_info = $usergroup->get($group_id); |
|
|
|
|
$group_info['name'] = Security::remove_XSS($group_info['name']); |
|
|
|
|
$group_info['description'] = Security::remove_XSS($group_info['description']); |
|
|
|
|
$groupInfo = $usergroup->get($group_id); |
|
|
|
|
$groupInfo['name'] = Security::remove_XSS($groupInfo['name']); |
|
|
|
|
$groupInfo['description'] = Security::remove_XSS($groupInfo['description']); |
|
|
|
|
|
|
|
|
|
$interbreadcrumb[] = ['url' => '#', 'name' => $group_info['name']]; |
|
|
|
|
$interbreadcrumb[] = ['url' => '#', 'name' => $groupInfo['name']]; |
|
|
|
|
|
|
|
|
|
if (isset($_GET['action']) && $_GET['action'] == 'leave') { |
|
|
|
|
$user_leaved = intval($_GET['u']); |
|
|
|
|
// I can "leave me myself" |
|
|
|
|
if (api_get_user_id() == $user_leaved) { |
|
|
|
|
if (UserGroup::canLeave($group_info)) { |
|
|
|
|
if (UserGroup::canLeave($groupInfo)) { |
|
|
|
|
$usergroup->delete_user_rel_group($user_leaved, $group_id); |
|
|
|
|
Display::addFlash( |
|
|
|
|
Display::return_message(get_lang('UserIsNotSubscribedToThisGroup'), 'confirmation', false) |
|
|
|
@ -133,7 +133,7 @@ if ($group_id != 0) { |
|
|
|
|
// we add a user only if is a open group |
|
|
|
|
$user_join = intval($_GET['u']); |
|
|
|
|
if (api_get_user_id() == $user_join && !empty($group_id)) { |
|
|
|
|
if ($group_info['visibility'] == GROUP_PERMISSION_OPEN) { |
|
|
|
|
if ($groupInfo['visibility'] == GROUP_PERMISSION_OPEN) { |
|
|
|
|
$usergroup->add_user_to_group($user_join, $group_id); |
|
|
|
|
Display::addFlash( |
|
|
|
|
Display::return_message(get_lang('UserIsSubscribedToThisGroup'), 'confirmation', false) |
|
|
|
@ -155,9 +155,9 @@ $create_thread_link = ''; |
|
|
|
|
$social_right_content = null; |
|
|
|
|
$socialForum = ''; |
|
|
|
|
|
|
|
|
|
$group_info = $usergroup->get($group_id); |
|
|
|
|
$group_info['name'] = Security::remove_XSS($group_info['name']); |
|
|
|
|
$group_info['description'] = Security::remove_XSS($group_info['description']); |
|
|
|
|
$groupInfo = $usergroup->get($group_id); |
|
|
|
|
$groupInfo['name'] = Security::remove_XSS($groupInfo['name']); |
|
|
|
|
$groupInfo['description'] = Security::remove_XSS($groupInfo['description']); |
|
|
|
|
|
|
|
|
|
//Loading group information |
|
|
|
|
if (isset($_GET['status']) && $_GET['status'] == 'sent') { |
|
|
|
@ -167,13 +167,13 @@ if (isset($_GET['status']) && $_GET['status'] == 'sent') { |
|
|
|
|
$is_group_member = $usergroup->is_group_member($group_id); |
|
|
|
|
$role = $usergroup->get_user_group_role(api_get_user_id(), $group_id); |
|
|
|
|
|
|
|
|
|
if (!$is_group_member && $group_info['visibility'] == GROUP_PERMISSION_CLOSED) { |
|
|
|
|
if (!$is_group_member && $groupInfo['visibility'] == GROUP_PERMISSION_CLOSED) { |
|
|
|
|
if ($role == GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER) { |
|
|
|
|
$social_right_content .= Display::return_message(get_lang('YouAlreadySentAnInvitation')); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($is_group_member || $group_info['visibility'] == GROUP_PERMISSION_OPEN) { |
|
|
|
|
if ($is_group_member || $groupInfo['visibility'] == GROUP_PERMISSION_OPEN) { |
|
|
|
|
if (!$is_group_member) { |
|
|
|
|
if (!in_array( |
|
|
|
|
$role, |
|
|
|
@ -211,7 +211,7 @@ if ($is_group_member || $group_info['visibility'] == GROUP_PERMISSION_OPEN) { |
|
|
|
|
get_lang('YouShouldCreateATopic'), |
|
|
|
|
$createThreadUrl, |
|
|
|
|
[ |
|
|
|
|
'class' => 'ajax btn btn-primary', |
|
|
|
|
'class' => 'btn btn-primary', |
|
|
|
|
'title' => get_lang('ComposeMessage'), |
|
|
|
|
'data-title' => get_lang('ComposeMessage'), |
|
|
|
|
'data-size' => 'lg', |
|
|
|
@ -231,7 +231,7 @@ if ($is_group_member || $group_info['visibility'] == GROUP_PERMISSION_OPEN) { |
|
|
|
|
get_lang('NewTopic'), |
|
|
|
|
$createThreadUrl, |
|
|
|
|
[ |
|
|
|
|
'class' => 'ajax btn btn-default', |
|
|
|
|
'class' => 'btn btn-primary', |
|
|
|
|
'title' => get_lang('ComposeMessage'), |
|
|
|
|
'data-title' => get_lang('ComposeMessage'), |
|
|
|
|
'data-size' => 'lg', |
|
|
|
@ -242,13 +242,6 @@ if ($is_group_member || $group_info['visibility'] == GROUP_PERMISSION_OPEN) { |
|
|
|
|
$members = $usergroup->get_users_by_group($group_id, true); |
|
|
|
|
$member_content = ''; |
|
|
|
|
|
|
|
|
|
// My friends |
|
|
|
|
$friend_html = SocialManager::listMyFriendsBlock( |
|
|
|
|
api_get_user_id(), |
|
|
|
|
'', |
|
|
|
|
'' |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// Members |
|
|
|
|
if (count($members) > 0) { |
|
|
|
|
if ($role == GROUP_USER_PERMISSION_ADMIN) { |
|
|
|
@ -302,8 +295,10 @@ if ($is_group_member || $group_info['visibility'] == GROUP_PERMISSION_OPEN) { |
|
|
|
|
if (!empty($create_thread_link)) { |
|
|
|
|
$create_thread_link = Display::div($create_thread_link, ['class' => 'pull-right']); |
|
|
|
|
} |
|
|
|
|
$headers = [get_lang('Discussions'), get_lang('Members')]; |
|
|
|
|
$socialForum = Display::tabs($headers, [$content, $member_content], 'tabs'); |
|
|
|
|
|
|
|
|
|
$listTopic = $content; |
|
|
|
|
$listMembers = $member_content; |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
// if I already sent an invitation message |
|
|
|
|
if (!in_array( |
|
|
|
@ -323,15 +318,16 @@ $tpl = new Template(null); |
|
|
|
|
|
|
|
|
|
// Block Social Avatar |
|
|
|
|
SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'groups', $group_id); |
|
|
|
|
//Block Social Menu |
|
|
|
|
$social_menu_block = SocialManager::getMenuSocial('groups', $group_id); |
|
|
|
|
|
|
|
|
|
$tpl->setHelp('Groups'); |
|
|
|
|
$tpl->assign('create_link', $create_thread_link); |
|
|
|
|
$tpl->assign('is_group_member', $is_group_member); |
|
|
|
|
$tpl->assign('group_info', $group_info); |
|
|
|
|
$tpl->assign('social_friend_block', $friend_html); |
|
|
|
|
$tpl->assign('social_menu_block', $social_menu_block); |
|
|
|
|
$tpl->assign('social_forum', $socialForum); |
|
|
|
|
|
|
|
|
|
$tpl->assign('list_members', $listMembers); |
|
|
|
|
$tpl->assign('list_topic', $listTopic); |
|
|
|
|
|
|
|
|
|
$tpl->assign('social_right_content', $social_right_content); |
|
|
|
|
$social_layout = $tpl->get_template('social/group_view.tpl'); |
|
|
|
|
$tpl->display($social_layout); |
|
|
|
|
$social_layout = $tpl->get_template('social/group_view.html.twig'); |
|
|
|
|
$content = $tpl->fetch($social_layout); |
|
|
|
|
$tpl->assign('content', $content); |
|
|
|
|
$tpl->display_one_col_template(); |
|
|
|
|