*/ $cidReset=true; $language_file = array('userInfo'); require_once '../inc/global.inc.php'; api_block_anonymous_users(); if (api_get_setting('allow_social_tool') !='true') { api_not_allowed(); } require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php'; require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php'; require_once api_get_path(LIBRARY_PATH).'social.lib.php'; require_once api_get_path(LIBRARY_PATH).'message.lib.php'; require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php'; $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; } } $anchor = 'topic_'.$match[1]; } $htmlHeadXtra[] = api_get_jquery_ui_js(); $htmlHeadXtra[] = ''; $allowed_views = array('mygroups','newest','pop'); $interbreadcrumb[]= array ('url' =>'home.php','name' => get_lang('Social')); if (isset($_GET['view']) && in_array($_GET['view'],$allowed_views)) { if ($_GET['view'] == 'mygroups') { $interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups')); $interbreadcrumb[]= array ('url' =>'#','name' => get_lang('MyGroups')); } else if ( $_GET['view'] == 'newest') { $interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups')); $interbreadcrumb[]= array ('url' =>'#','name' => get_lang('Newest')); } else { $interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups')); $interbreadcrumb[]= array ('url' =>'#','name' => get_lang('Popular')); } } else { $interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups')); if (!isset($_GET['id'])) { $interbreadcrumb[]= array ('url' =>'#','name' => get_lang('GroupList')); } } Display :: display_header($tool_name, 'Groups'); // getting group information $group_id = intval($_GET['id']); $relation_group_title = ''; $my_group_role = 0; if ($group_id != 0 ) { $user_leave_message = false; $user_added_group_message = false; $group_info = GroupPortalManager::get_group_data($group_id); if (isset($_GET['action']) && $_GET['action']=='leave') { $user_leaved = intval($_GET['u']); //I can "leave me myself" if (api_get_user_id() == $user_leaved) { GroupPortalManager::delete_user_rel_group($user_leaved, $group_id); $user_leave_message = true; } } // 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 ($group_info['visibility'] == GROUP_PERMISSION_OPEN) { GroupPortalManager::add_user_to_group($user_join, $group_id); $user_added_group_message = true; } else { GroupPortalManager::add_user_to_group($user_join, $group_id, GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER); $user_added_group_message = true; } } } } echo '
'; echo '
'; //this include the social menu div if ($group_id != 0 ) { SocialManager::show_social_menu('groups',$group_id); } else { $show_menu = 'browse_groups'; if (isset($_GET['view']) && $_GET['view'] == 'mygroups') { $show_menu = $_GET['view']; } SocialManager::show_social_menu($show_menu); } echo '
'; echo '
'; if ($group_id != 0 ) { $group_info = GroupPortalManager::get_group_data($group_id); //Loading group information if (isset($_GET['status']) && $_GET['status']=='sent') { Display::display_confirmation_message(get_lang('MessageHasBeenSent'), false); } if ($user_leave_message) { Display::display_confirmation_message(get_lang('UserIsNotSubscribedToThisGroup'), false); } if ($user_added_group_message) { Display::display_confirmation_message(get_lang('UserIsSubscribedToThisGroup'), false); } // details about the current group echo '
'; echo '
'; //Group's title echo '

'.$group_info['name'].'

'; //Group's description echo ''; echo ''; //Privacy echo ''; if (!empty($relation_group_title)) { /* echo '';*/ } //Group's tags if (!empty($tags)) { echo '
'.get_lang('Tags').' : '.$tags.'
'; } echo '
'; echo '
'; echo '
'; //-- Show message groups echo '
'; if (GroupPortalManager::is_group_member($group_id)) { $content = MessageManager::display_messages_for_group($group_id); if (empty($content)) { $content = ''.Display::return_icon('compose_message.png', get_lang('NewTopic'), array('hspace'=>'6')).get_lang('YouShouldCreateATopic').''; } else { $create_thread_link = ''.Display::return_icon('compose_message.png', get_lang('NewTopic'), array('hspace'=>'6')).get_lang('NewTopic').''; $content = $create_thread_link.$content; } $members = GroupPortalManager::get_users_by_group($group_id); $member_content = ''; //Members if (count($members) > 0) { $min_count_members = 4; $i = 1; $member_content .= Display::url(Display::return_icon('edit.gif', get_lang('EditMembersList')).' '.get_lang('EditMembersList'), 'group_members.php?id='.$group_id); foreach($members as $member) { if ($i > $min_count_members) break; // if is a member if (in_array($member['relation_type'] , array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_READER,GROUP_USER_PERMISSION_MODERATOR))) { //add icons if ($member['relation_type'] == GROUP_USER_PERMISSION_ADMIN) { $icon= Display::return_icon('social_group_admin.png', get_lang('Admin')); } elseif ($member['relation_type'] == GROUP_USER_PERMISSION_MODERATOR) { $icon= Display::return_icon('social_group_moderator.png', get_lang('Moderator')); } else{ $icon= ''; } $image_path = UserManager::get_user_picture_path_by_id($member['user_id'], 'web', false, true); $picture = UserManager::get_picture_user($member['user_id'], $image_path['file'], 60, USER_IMAGE_SIZE_MEDIUM); $member_content .= '
'; $member_name = Display::url(api_get_person_name(cut($member['firstname'],15),cut($member['lastname'],15)).' '.$icon, 'profile.php?u='.$member['user_id']); $member_content .= Display::div(' '.$member_name); $member_content .= '
'; $i++; } } } $headers = array(get_lang('Messages'), get_lang('Members')); echo Display::tabs($headers, array($content, $member_content),'tabs'); } else { // if I already sent an invitation message if (!in_array($my_group_role, array(GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER, GROUP_USER_PERMISSION_PENDING_INVITATION))) { echo ''.Display::return_icon('group_join.png', get_lang('YouShouldJoinTheGroup'), array('hspace'=>'6')).''; } elseif ($my_group_role == GROUP_USER_PERMISSION_PENDING_INVITATION) { echo ''.Display::return_icon('group_join.png', get_lang('YouHaveBeenInvitedJoinNow'), array('hspace'=>'6')).''; } } echo '
'; // end layout messages } else { // My groups ----- $results = GroupPortalManager::get_groups_by_user(api_get_user_id(), 0); $grid_my_groups = array(); $my_group_list = array(); if (is_array($results) && count($results) > 0) { foreach ($results as $result) { $id = $result['id']; $my_group_list[] = $id; $url_open = ''; $url_close = ''; $name = cut($result['name'],25,true); if ($result['relation_type'] == GROUP_USER_PERMISSION_ADMIN) { $name .= ' '.Display::return_icon('social_group_admin.png', get_lang('Admin'), array('style'=>'vertical-align:middle')); } elseif ($result['relation_type'] == GROUP_USER_PERMISSION_MODERATOR) { $name .= ' '.Display::return_icon('social_group_moderator.png', get_lang('Moderator'), array('style'=>'vertical-align:middle')); } $count_users_group = count(GroupPortalManager::get_users_by_group($id, false, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_READER, GROUP_USER_PERMISSION_MODERATOR), 0 , 1000)); if ($count_users_group == 1 ) { $count_users_group = $count_users_group.' '.get_lang('Member'); } else { $count_users_group = $count_users_group.' '.get_lang('Members'); } $picture = GroupPortalManager::get_picture_group($result['id'], $result['picture_uri'],80); $result['picture_uri'] = ''; //$grid_item_1 = Display::return_icon('boxmygroups.jpg',get_lang('MyGroups')); $item_0 = Display::div($result['picture_uri'], array('class'=>'box_description_group_image')); $members = Display::span($count_users_group, array('class'=>'box_description_group_member')); $item_1 = Display::div(Display::tag('h3', $url_open.$name.$url_close).$members, array('class'=>'box_description_group_title')); $item_2 = ''; $item_3 = ''; if ($result['description'] != '') { $item_3 = '
'.cut($result['description'],100,true).'
'; } else { $item_2 = '
'; $item_3 = '
'; } /*$join_url = ''.Display::return_icon('group_join.png', get_lang('JoinGroup'), array('hspace'=>'6')).''.get_lang('JoinGroup').' '; $item_4 = '
'.$join_url. $url_open.get_lang('SeeMore').$url_close.'
';*/ $grid_item_2 = $item_0.$item_1.$item_2.$item_3.$item_4; $grid_my_groups[]= array($grid_item_1,$grid_item_2); } } // Newest groups $results = GroupPortalManager::get_groups_by_age(4,false); $grid_newest_groups = array(); foreach ($results as $result) { $id = $result['id']; $url_open = ''; $url_close = ''; $count_users_group = count(GroupPortalManager::get_users_by_group($id, false, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_READER, GROUP_USER_PERMISSION_MODERATOR), 0 , 1000)); if ($count_users_group == 1 ) { $count_users_group = $count_users_group.' '.get_lang('Member'); } else { $count_users_group = $count_users_group.' '.get_lang('Members'); } $name = cut($result['name'],30,true); $picture = GroupPortalManager::get_picture_group($result['id'], $result['picture_uri'],80); $result['picture_uri'] = ''; $item_0 = Display::div($result['picture_uri'], array('class'=>'box_description_group_image')); $members = Display::span($count_users_group, array('class'=>'box_description_group_member')); $item_1 = Display::div(Display::tag('h3', $url_open.$name.$url_close).$members, array('class'=>'box_description_group_title')); if ($result['description'] != '') { $item_3 = '
'.cut($result['description'],100,true).'
'; } else { $item_2 = '
'; $item_3 = '
'; } //Avoiding my groups $join_url = ''; if (!in_array($id,$my_group_list)) { $join_url = ''.Display::return_icon('group_join.png', get_lang('JoinGroup'), array('hspace'=>'6')).''.get_lang('JoinGroup').' '; } $item_4 = '
'.$join_url.'
'; $grid_item_2 = $item_0.$item_1.$item_2.$item_3.$item_4; $grid_newest_groups[]= array($grid_item_1,$grid_item_2); } // Pop groups $results = GroupPortalManager::get_groups_by_popularity(4,false); $grid_pop_groups = array(); if (is_array($results) && count($results) > 0) { foreach ($results as $result) { $id = $result['id']; $url_open = ''; $url_close = ''; $count_users_group = count(GroupPortalManager::get_users_by_group($id, false, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_READER, GROUP_USER_PERMISSION_MODERATOR), 0 , 1000)); if ($count_users_group == 1 ) { $count_users_group = $count_users_group.' '.get_lang('Member'); } else { $count_users_group = $count_users_group.' '.get_lang('Members'); } $name = cut($result['name'],30,true); $picture = GroupPortalManager::get_picture_group($result['id'], $result['picture_uri'],80); $result['picture_uri'] = ''; $item_0 = Display::div($result['picture_uri'], array('class'=>'box_description_group_image')); $members = Display::span($count_users_group, array('class'=>'box_description_group_member')); $item_1 = Display::div(Display::tag('h3', $url_open.$name.$url_close).$members, array('class'=>'box_description_group_title')); if ($result['description'] != '') { $item_3 = '
'.cut($result['description'],100,true).'
'; } else { $item_2 = '
'; $item_3 = '
'; } $join_url = ''; if (!in_array($id,$my_group_list)) { $join_url = ''.Display::return_icon('group_join.png', get_lang('JoinGroup'), array('hspace'=>'6')).''.get_lang('JoinGroup').' '; } $item_4 = '
'.$join_url.'
'; $grid_item_2 = $item_0.$item_1.$item_2.$item_3.$item_4; $grid_pop_groups[]= array($grid_item_2); } } // Display groups (newest, mygroups, pop) if (isset($_GET['view']) && in_array($_GET['view'],$allowed_views)) { $view_group = $_GET['view']; switch ($view_group) { case 'mygroups' : if (count($grid_my_groups) > 0) { $my_group_content = Display::return_sortable_grid('mygroups', array(), $grid_my_groups, array('hide_navigation'=>true, 'per_page' => 2), $query_vars, false, array(true, true, true,false)); } if (api_get_setting('allow_students_to_create_groups_in_social') == 'true') { $create_group_item = ''.Display::return_icon('group_add.png',get_lang('CreateASocialGroup'),array('hspace'=>'6','style'=>'float:left')).get_lang('CreateASocialGroup').''; $my_group_content = $create_group_item. $my_group_content; } else { if (api_is_allowed_to_edit(null,true)) { $create_group_item = ''.Display::return_icon('group_add.png',get_lang('CreateASocialGroup'),array('hspace'=>'6','style'=>'float:left')).get_lang('CreateASocialGroup').''; $my_group_content = $create_group_item. $my_group_content; } } break; case 'newest' : if (count($grid_newest_groups) > 0) { $newest_content = Display::return_sortable_grid('newest', array(), $grid_newest_groups, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, true, true,false)); } if (api_is_platform_admin() || api_get_setting('allow_students_to_create_groups_in_social') == 'true') { if (empty($grid_newest_groups)) { //echo ''.get_lang('YouShouldCreateAGroup').''; } } break; default : if (count($grid_pop_groups) > 0) { $popular_content = Display::return_sortable_grid('popular', array(), $grid_pop_groups, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, true, true,true,true)); } if (api_is_platform_admin() || api_get_setting('allow_students_to_create_groups_in_social') == 'true') { if (empty($grid_pop_groups)) { //echo ''.get_lang('YouShouldCreateAGroup').''; } } break; } } else { if (count($grid_my_groups) > 0) { $my_group_content = Display::return_sortable_grid('mygroups', array(), $grid_my_groups, array('hide_navigation'=>true, 'per_page' => 2), $query_vars, false, array(true, true, true,false)); } if (api_get_setting('allow_students_to_create_groups_in_social') == 'true') { $create_group_item = ''.Display::return_icon('group_add.png',get_lang('CreateASocialGroup'),array('hspace'=>'6','style'=>'float:left')).get_lang('CreateASocialGroup').''; $my_group_content = $create_group_item. $my_group_content; } else { if (api_is_allowed_to_edit(null,true)) { $create_group_item = ''.Display::return_icon('group_add.png',get_lang('CreateASocialGroup'),array('hspace'=>'6','style'=>'float:left')).get_lang('CreateASocialGroup').''; $my_group_content = $create_group_item. $my_group_content; } } if (count($grid_newest_groups) > 0) { $newest_content = Display::return_sortable_grid('mygroups', array(), $grid_newest_groups, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, true, true,false)); } if (count($grid_pop_groups) > 0) { $popular_content = Display::return_sortable_grid('mygroups', array(), $grid_pop_groups, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, true, true,true,true)); } } $headers = array(get_lang('MyGroups'), get_lang('Newest'), get_lang('Popular')); echo Display::tabs($headers, array($my_group_content, $newest_content, $popular_content),'tab_browse'); } echo '
'; echo '
'; Display :: display_footer();