*/ $cidReset=true; $language_file = array('userInfo'); require_once '../inc/global.inc.php'; 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).'text.lib.php'; require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php'; api_block_anonymous_users(); $this_section = SECTION_SOCIAL; $htmlHeadXtra[] = ''; //jQuery $htmlHeadXtra[] = ''; $htmlHeadXtra[] = ''; // 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[] = ''; $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')); $interbreadcrumb[]= array ('url' =>'#','name' => get_lang('MessageList')); } Display :: display_header($tool_name, 'Groups'); // save message group if (isset($_POST['token']) && $_POST['token'] === $_SESSION['sec_token']) { if (isset($_POST['action'])) { $title = $_POST['title']; $content = $_POST['content']; $group_id = intval($_POST['group_id']); $parent_id = intval($_POST['parent_id']); 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); } else { $res = MessageManager::send_message(0, $title, $content, $_FILES, '', $group_id, $parent_id); } // display error messages if (is_string($res)) { Display::display_error_message($res); } if ($res === true) { $groups_user = GroupPortalManager::get_users_by_group($group_id); $group_info = GroupPortalManager::get_group_data($group_id); $admin_user_info = api_get_user_info(1); $sender_name = api_get_person_name($admin_user_info['lastName'], $admin_user_info['firstName'], null, PERSON_NAME_EMAIL_ADDRESS); $sender_email = $admin_user_info['mail']; $subject = sprintf(get_lang('ThereIsANewMessageInTheGroupX'),$group_info['name']); $link = api_get_path(WEB_PATH).'main/social/groups?'.$_SERVER['QUERY_STRING']; $text_link = ''.get_lang('ClickHereToSeeMessageGroup')."
\r\n
\r\n".get_lang('OrCopyPasteTheFollowingUrl')."
\r\n ".$link; $message = sprintf(get_lang('YouHaveReceivedANewMessageInTheGroupX'),$group_info['name'])."
$text_link"; foreach ($groups_user as $group_user) { if ($group_user == $current_user) continue; $group_user_info = api_get_user_info($group_user['user_id']); $recipient_name = api_get_person_name($group_user_info['lastName'], $group_user_info['firstName'], null, PERSON_NAME_EMAIL_ADDRESS); $recipient_email = $group_user_info['mail']; api_mail_html($recipient_name, $recipient_email, stripslashes($subject), $message, $sender_name, $sender_email); } } Security::clear_token(); } } // 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('messages_list',$group_id); } else { $show_menu = '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 '
'; $picture = GroupPortalManager::get_picture_group($group_id, $group_info['picture_uri'],160,'medium_'); $big_image = GroupPortalManager::get_picture_group($group_id, $group_info['picture_uri'],'','big_'); if (basename($picture['file']) != 'unknown_group.png') { echo '

'; } else { echo '

'; } 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 '
'; echo '

'.get_lang('Topics').'

'; if (GroupPortalManager::is_group_member($group_id)) { $content = MessageManager::display_messages_for_group($group_id); if (!empty($content)) { echo $content; } else { //echo get_lang('YouShouldCreateATopic'); echo ''.Display::return_icon('message_new.png', get_lang('NewTopic'), array('hspace'=>'6')).''; } } else { //echo get_lang('YouShouldJoinTheGroup'); echo ''.Display::return_icon('addd.gif', get_lang('YouShouldJoinTheGroup'), 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(); if (is_array($results) && count($results) > 0) { foreach ($results as $result) { $id = $result['id']; $url_open = ''; $url_close = ''; $name = api_strtoupper(cut($result['name'],25,true)); if ($result['relation_type'] == GROUP_USER_PERMISSION_ADMIN) { $name .= Display::return_icon('admin_star.png', get_lang('Admin'), array('style'=>'vertical-align:middle')); } elseif ($result['relation_type'] == GROUP_USER_PERMISSION_MODERATOR) { $name .= Display::return_icon('moderator_star.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'); $item_1 = '
'.$url_open.$result['picture_uri'].''.$url_close.Display::return_icon('linegroups.jpg','').'
'; $item_2 = ''; $item_3 = ''; if ($result['description'] != '') { $item_2 = '
'; $item_3 = '
'.cut($result['description'],100,true).'
'; } else { $item_2 = '
'; $item_3 = '
'; } $item_4 = '
'.$url_open.get_lang('SeeMore').$url_close.'
'; $grid_item_2 = $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 = api_strtoupper(cut($result['name'],30,true)); $picture = GroupPortalManager::get_picture_group($result['id'], $result['picture_uri'],80); $result['picture_uri'] = ''; $grid_item_1 = Display::return_icon('boxmygroups.jpg'); $item_1 = '
'.$url_open.$result['picture_uri'].''.$url_close.Display::return_icon('linegroups.jpg','').'
'; if ($result['description'] != '') { $item_2 = '
'; $item_3 = '
'.cut($result['description'],100,true).'
'; } else { $item_2 = '
'; $item_3 = '
'; } $item_4 = '
'.$url_open.get_lang('SeeMore').$url_close.'
'; $grid_item_2 = $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(); 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 = api_strtoupper(cut($result['name'],30,true)); $picture = GroupPortalManager::get_picture_group($result['id'], $result['picture_uri'],80); $result['picture_uri'] = ''; $grid_item_1 = Display::return_icon('boxmygroups.jpg'); $item_1 = '
'.$url_open.$result['picture_uri'].''.$url_close.Display::return_icon('linegroups.jpg').'
'; if ($result['description'] != '') { $item_2 = '
'; $item_3 = '
'.cut($result['description'],100,true).'
'; } else { $item_2 = '
'; $item_3 = '
'; } $item_4 = '
'.$url_open.get_lang('SeeMore').$url_close.'
'; $grid_item_2 = $item_1.$item_2.$item_3.$item_4; $grid_pop_groups[]= array($grid_item_1,$grid_item_2); } // display groups (newest, mygroups, pop) echo ''; } echo '
'; echo '
'; Display :: display_footer();