*/ /** * Initialization */ $cidReset = true; api_block_anonymous_users(); if (api_get_setting('allow_social_tool') != 'true') { api_not_allowed(); return; } if (api_get_setting('allow_message_tool') != 'true') { api_not_allowed(true); return; } $usergroup = new UserGroup(); $this_section = SECTION_SOCIAL; $interbreadcrumb[]= array ('url' =>'profile.php','name' => get_lang('SocialNetwork')); $interbreadcrumb[]= array ('url' =>'#','name' => get_lang('Invitations')); $htmlHeadXtra[] = ' '; $show_message = null; $content = null; // easy links if (is_array($_GET) && count($_GET)>0) { foreach ($_GET as $key => $value) { switch ($key) { case 'accept': $user_role = $usergroup->get_user_group_role(api_get_user_id(), $value); if (in_array($user_role , array(GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER,GROUP_USER_PERMISSION_PENDING_INVITATION))) { $usergroup->update_user_role(api_get_user_id(), $value, GROUP_USER_PERMISSION_READER); $show_message = Display::return_message(get_lang('UserIsSubscribedToThisGroup'), 'success'); } elseif (in_array($user_role , array(GROUP_USER_PERMISSION_READER, GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_MODERATOR))) { $show_message = Display::return_message(get_lang('UserIsAlreadySubscribedToThisGroup'), 'warning'); } else { $show_message = Display::return_message(get_lang('UserIsNotSubscribedToThisGroup'), 'warning'); } break 2; case 'deny': // delete invitation $usergroup->delete_user_rel_group(api_get_user_id(), $value); $show_message = Display::return_message(get_lang('GroupInvitationWasDeny')); break 2; } } } $social_left_content = SocialManager::show_social_menu('invitations'); $social_right_content = '
'; $user_id = api_get_user_id(); $list_get_invitation = SocialManager::get_list_invitation_of_friends_by_user_id($user_id); $list_get_invitation_sent = SocialManager::get_list_invitation_sent_by_user_id($user_id); $pending_invitations = $usergroup->get_groups_by_user($user_id, GROUP_USER_PERMISSION_PENDING_INVITATION); $number_loop = count($list_get_invitation); $total_invitations = $number_loop + count($list_get_invitation_sent) + count($pending_invitations); if ($total_invitations == 0 && count($_GET) <= 0) { $social_right_content .= '
'.get_lang('TryAndFindSomeFriends').'
'; } if ($number_loop != 0) { $social_right_content .= '
'.Display::page_subheader(get_lang('InvitationReceived')).'
'; foreach ($list_get_invitation as $invitation) { $sender_user_id = $invitation['user_sender_id']; $social_right_content .= '
'; $picture = UserManager::get_user_picture_path_by_id($sender_user_id, 'web', false, true); $friends_profile = SocialManager::get_picture_user($sender_user_id, $picture['file'], 92); $user_info = api_get_user_info($sender_user_id); $title = Security::remove_XSS($invitation['title'], STUDENT, true); $content = Security::remove_XSS($invitation['content'], STUDENT, true); $date = api_convert_and_format_date($invitation['send_date'], DATE_TIME_FORMAT_LONG); $social_right_content .= '
'.api_get_person_name($user_info['firstName'], $user_info['lastName']).' : '.$content.'
'.get_lang('DateSend').' : '.$date.'
'; } } if (count($list_get_invitation_sent) > 0) { $social_right_content .= '
'.Display::page_subheader(get_lang('InvitationSent')).'
'; foreach ($list_get_invitation_sent as $invitation) { $sender_user_id = $invitation['user_receiver_id']; $social_right_content .= '
'; $picture = UserManager::get_user_picture_path_by_id($sender_user_id,'web', false, true); $friends_profile = SocialManager::get_picture_user($sender_user_id, $picture['file'], 92); $user_info = api_get_user_info($sender_user_id); $title = Security::remove_XSS($invitation['title'], STUDENT, true); $content = Security::remove_XSS($invitation['content'], STUDENT, true); $date = api_convert_and_format_date($invitation['send_date'], DATE_TIME_FORMAT_LONG); $social_right_content .= '
'.$user_info['complete_name'].'
'. $title.' : '.$content.'
'. get_lang('DateSend').' : '.$date.'
'; } } if (count($pending_invitations) > 0) { $social_right_content .= Display::page_subheader(get_lang('GroupsWaitingApproval')); $new_invitation = array(); foreach ($pending_invitations as $invitation) { $picture = $usergroup->get_picture_group($invitation['id'], $invitation['picture'],80); $img = ''; $invitation['picture'] = ''.$img.''; $invitation['name'] = ''.Text::cut($invitation['name'],120,true).''; $invitation['join'] = ''.get_lang('AcceptInvitation').''; $invitation['deny'] = ''.get_lang('DenyInvitation').''; $invitation['description'] = Text::cut($invitation['description'],220,true); $new_invitation[] = $invitation; } $social_right_content .= Display::return_sortable_grid('waiting_user', array(), $new_invitation, array('hide_navigation'=>true, 'per_page' => 100), array(), false, array(true, true, true,false,false,true,true,true,true)); } $social_right_content = Display::div($social_right_content, array('class' => 'span9')); $tpl = $app['template']; $tpl->assign('social_left_content', $social_left_content); $tpl->assign('social_right_content', $social_right_content); $tpl->assign('message', $show_message); $tpl->assign('content', $content); $social_layout = $tpl->get_template('layout/social_layout.tpl'); $tpl->display($social_layout);