*/ $cidReset = true; require_once __DIR__.'/../inc/global.inc.php'; api_block_anonymous_users(); if (api_get_setting('allow_social_tool') !== 'true') { api_not_allowed(); } $this_section = SECTION_SOCIAL; // prepare anchor for message group topic $anchor = ''; if (isset($_GET['anchor_topic'])) { $anchor = Security::remove_XSS($_GET['anchor_topic']); } else { $match = 0; $param_names = array_keys($_GET); foreach ($param_names as $param) { if (preg_match('/^items_(\d)_page_nr$/', $param, $match)) { break; } } if (isset($match[1])) { $anchor = 'topic_'.$match[1]; } } $htmlHeadXtra[] = ''; $allowed_views = ['mygroups', 'newest', 'pop']; $content = null; if (isset($_GET['view']) && in_array($_GET['view'], $allowed_views)) { if ($_GET['view'] == 'mygroups') { $interbreadcrumb[] = ['url' => 'groups.php', 'name' => get_lang('Groups')]; $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('My groups')]; } elseif ($_GET['view'] == 'newest') { $interbreadcrumb[] = ['url' => 'groups.php', 'name' => get_lang('Groups')]; $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Newest')]; } else { $interbreadcrumb[] = ['url' => 'groups.php', 'name' => get_lang('Groups')]; $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Popular')]; } } else { $interbreadcrumb[] = ['url' => 'groups.php', 'name' => get_lang('Groups')]; if (!isset($_GET['id'])) { $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Groups list')]; } else { //$interbreadcrumb[]= array ('url' =>'#','name' => get_lang('Group')); } } // getting group information $group_id = isset($_GET['id']) ? (int) $_GET['id'] : null; $relation_group_title = ''; $role = 0; $usergroup = new UserGroup(); if ($group_id != 0) { $groupInfo = $usergroup->get($group_id); $groupInfo['name'] = Security::remove_XSS($groupInfo['name']); $groupInfo['description'] = Security::remove_XSS($groupInfo['description']); $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($groupInfo)) { $usergroup->delete_user_rel_group($user_leaved, $group_id); Display::addFlash( Display::return_message(get_lang('User is not subscribed to this group'), 'confirmation', false) ); } } } // add a user to a group if its open if (isset($_GET['action']) && $_GET['action'] == 'join') { // 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 ($groupInfo['visibility'] == GROUP_PERMISSION_OPEN) { $usergroup->add_user_to_group($user_join, $group_id); Display::addFlash( Display::return_message(get_lang('User is subscribed to this group'), 'confirmation', false) ); } else { $usergroup->add_user_to_group( $user_join, $group_id, GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER ); Display::addFlash( Display::return_message(get_lang('Invitation sent'), 'confirmation', false) ); } } } } $create_thread_link = ''; $social_right_content = null; $socialForum = ''; $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') { $social_right_content .= Display::return_message(get_lang('Your message has been sent.'), 'confirmation', false); } $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 && $groupInfo['visibility'] == GROUP_PERMISSION_CLOSED) { if ($role == GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER) { $social_right_content .= Display::return_message(get_lang('You already sent an invitation')); } } if ($is_group_member || $groupInfo['visibility'] == GROUP_PERMISSION_OPEN) { if (!$is_group_member) { if (!in_array( $role, [GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER, GROUP_USER_PERMISSION_PENDING_INVITATION] )) { $social_right_content .= '