api_not_allowed(); } $table_message = Database::get_main_table(TABLE_MESSAGE); $usergroup = new UserGroup(); $form = new FormValidator('add_group'); $usergroup->setGroupType($usergroup::SOCIAL_CLASS); $usergroup->setForm($form, 'add', array()); if ($form->validate()) { $values = $form->exportValues(); $values['group_type'] = UserGroup::SOCIAL_CLASS; $values['relation_type'] = GROUP_USER_PERMISSION_ADMIN; $groupId = $usergroup->save($values); Display::addFlash(DIsplay::return_message(get_lang('GroupAdded'))); header('Location: group_view.php?id=' . $groupId); exit; } $nameTools = get_lang('AddGroup'); $this_section = SECTION_SOCIAL; $interbreadcrumb[] = array('url' => 'home.php', 'name' => get_lang('Social')); $interbreadcrumb[] = array('url' => 'groups.php', 'name' => get_lang('Groups')); $interbreadcrumb[] = array('url' => '#', 'name' => $nameTools); $social_avatar_block = SocialManager::show_social_avatar_block('group_add'); $social_menu_block = SocialManager::show_social_menu('group_add'); $social_right_content = $form->returnForm(); $tpl = new Template(null); SocialManager::setSocialUserBlock($tpl, $user_id, null, null); $tpl->setHelp('Groups'); $tpl->assign('social_menu_block', $social_menu_block); $tpl->assign('social_right_content', $social_right_content); $social_layout = $tpl->get_template('social/add_groups.tpl'); $tpl->display($social_layout);
} $create_thread_link = ''; if ($group_id != 0) { $social_avatar_block = SocialManager::show_social_avatar_block( 'groups', $group_id ); $social_menu_block = SocialManager::show_social_menu('groups', $group_id); } else { $show_menu = 'browse_groups'; if (isset($_GET['view']) && $_GET['view'] == 'mygroups') { $show_menu = $_GET['view']; } $social_avatar_block = SocialManager::show_social_avatar_block( $show_menu, $group_id ); $social_menu_block = SocialManager::show_social_menu($show_menu, $group_id); } $social_right_content = null; if ($group_id != 0) { $group_info = GroupPortalManager::get_group_data($group_id); //Loading group information if (isset($_GET['status']) && $_GET['status'] == 'sent') { $social_right_content .= Display::return_message( get_lang('MessageHasBeenSent'), 'confirmation',
if (is_array($personal_course_list)) { foreach ($personal_course_list as $my_course) { if ($i<=10) { $list[] = SocialManager::get_logged_user_course_html($my_course, $i); $course_list_code[] = array('code'=> $my_course['code']); } else { break; } $i++; } //to avoid repeted courses $course_list_code = array_unique_dimensional($course_list_code); } $social_avatar_block = SocialManager::show_social_avatar_block('shared_profile', null, $user_id); $social_menu_block = SocialManager::show_social_menu('shared_profile', null, $user_id, $show_full_profile); //Setting some session info $user_info = api_get_user_info($my_user_id); $sessionList = SessionManager::getSessionsFollowedByUser($my_user_id, $user_info['status']); $htmlSessionList = null; foreach ($sessionList as $session) { $htmlSessionList .= '<div>'; $htmlSessionList .= Display::return_icon('session.png', get_lang('Session')); $htmlSessionList .= $session['name']; $htmlSessionList .= '</div>'; } // My friends $friend_html = listMyFriends($user_id, $link_shared ,$show_full_profile);
/** * Generate the social block for a user * @param Template $template * @param int $userId The user id * @param string $groupBlock Optional. Highlight link possible values: * group_add, home, messages, messages_inbox, messages_compose, * messages_outbox, invitations, shared_profile, friends, groups, search * @param int $groupId Optional. Group ID * @param boolean $show_full_profile - Optional. Shows the Full Profile or Not * @return string The HTML code with the social block */ public static function setSocialUserBlock($template, $userId, $groupBlock = '', $groupId = 0, $show_full_profile = true) { if (api_get_setting('social.allow_social_tool') != 'true') { return ''; } $socialAvatarBlock = SocialManager::show_social_avatar_block($groupBlock, $groupId, $userId); $profileEditionLink = null; if (api_get_user_id() == $userId) { $profileEditionLink = Display::getProfileEditionLink($userId); } $vCardUserLink = Display::getVCardUserLink($userId); $userInfo = api_get_user_info($userId, true, false, true, true); $template->addGlobal('user', $userInfo); $template->addGlobal('social_avatar_block', $socialAvatarBlock); $template->addGlobal('profile_edition_link', $profileEditionLink); //If not friend $show_full_profile is False and the user can't see Email Address and Vcard Download Link if ($show_full_profile) { //Added the link to export the vCard to the Template $template->addGlobal('vcard_user_link', $vCardUserLink); } if (api_get_setting('platform.gamification_mode') === '1') { $gamificationPoints = GamificationUtils::getTotalUserPoints($userId, $userInfo['status']); $template->addGlobal('gamification_points', $gamificationPoints); } $chatEnabled = api_is_global_chat_enabled(); $template->addGlobal('chat_enabled', $chatEnabled); $templateName = $template->render('@template_style/social/user_block.html.twig'); if (in_array($groupBlock, ['groups', 'group_edit', 'member_list'])) { $templateName = $template->render('@template_style/social/group_block.html.twig'); } $template->addGlobal('social_avatar_block', $templateName); }
/** * Generate the social block for a user * @param Template $template * @param int $userId The user id * @param string $groupBlock Optional. Highlight link possible values: * group_add, home, messages, messages_inbox, messages_compose, * messages_outbox, invitations, shared_profile, friends, groups, search * @param int $groupId Optional. Group ID * @return string The HTML code with the social block */ public static function setSocialUserBlock(Template $template, $userId, $groupBlock = '', $groupId = 0) { if (api_get_setting('allow_social_tool') != 'true') { return ''; } $socialAvatarBlock = SocialManager::show_social_avatar_block($groupBlock, $groupId, $userId); $profileEditionLink = null; if (api_get_user_id() == $userId) { $profileEditionLink = Display::getProfileEditionLink($userId); } $vCardUserLink = Display::getVCardUserLink($userId); $userInfo = api_get_user_info($userId, true, false, true); $template->assign('user', $userInfo); $template->assign('social_avatar_block', $socialAvatarBlock); $template->assign('profile_edition_link', $profileEditionLink); //Added the link to export the vCard to the Template $template->assign('vcard_user_link', $vCardUserLink); if (api_get_setting('gamification_mode') === '1') { $gamificationPoints = GamificationUtils::getTotalUserPoints($userId, $userInfo['status']); $template->assign('gamification_points', $gamificationPoints); } $chatEnabled = api_is_global_chat_enabled(); $template->assign('chat_enabled', $chatEnabled); $templateName = $template->get_template('social/user_block.tpl'); if (in_array($groupBlock, ['groups', 'group_edit', 'member_list'])) { $templateName = $template->get_template('social/group_block.tpl'); } $template->assign('social_avatar_block', $template->fetch($templateName)); }
if (empty($_GET['id'])) { $id_message = $_GET['id_send']; $source = 'outbox'; $show_menu = 'messages_outbox'; } else { $id_message = $_GET['id']; $source = 'inbox'; $show_menu = 'messages_inbox'; } $message = ''; //LEFT COLUMN if (api_get_setting('allow_social_tool') == 'true') { $social_avatar_block = SocialManager::show_social_avatar_block($show_menu); $social_menu_block = SocialManager::show_social_menu($show_menu); $message .='<div class="span9">'; } //MAIN CONTENT $message .= MessageManager::show_message_box($id_message,$source); if (api_get_setting('allow_social_tool') == 'true') { $message .='</div>'; } if (!empty($message)) { $social_right_content .= $message; } else { api_not_allowed(); }
$(ident).attr("alt",""); $(ident).attr("title",""); } function clear_form () { $("input[@type=radio]").attr("checked", false); $("div#div_qualify_image").html(""); $("div#div_info_user").html(""); } </script>'; $interbreadcrumb[] = array('url' => 'profile.php', 'name' => get_lang('SocialNetwork')); $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Friends')); $social_avatar_block = SocialManager::show_social_avatar_block('friends'); $social_menu_block = SocialManager::show_social_menu('friends'); $user_id = api_get_user_id(); $user_id = api_get_user_id(); $name_search = isset($_POST['search_name_q']) ? $_POST['search_name_q'] : null; $number_friends = 0; if (isset($name_search) && $name_search != 'undefined') { $friends = SocialManager::get_friends($user_id, null, $name_search); } else { $friends = SocialManager::get_friends($user_id); } $social_right_content = '<div class="span8">';
) . get_lang('SessionAddTypeUnique') . '</a>'; $link_add_type_multiple = Display::return_icon('multiple.gif') . get_lang( 'SessionAddTypeMultiple' ); } else { $link_add_type_unique = Display::return_icon('single.gif') . get_lang( 'SessionAddTypeUnique' ); $link_add_type_multiple = '<a href="' . api_get_self( ) . '?id=' . $group_id . '&add=' . $add . '&add_type=multiple">' . Display::return_icon( 'multiple.gif' ) . get_lang('SessionAddTypeMultiple') . '</a>'; } $social_avatar_block = SocialManager::show_social_avatar_block( 'invite_friends', $group_id ); $social_menu_block = SocialManager::show_social_menu( 'invite_friends', $group_id ); $social_right_content = '<h2>' . Security::remove_XSS( $group_info['name'], STUDENT, true ) . '</h2>'; if (count($nosessionUsersList) == 0) { $friends = SocialManager::get_friends(api_get_user_id()); if ($friends == 0) { $social_right_content .= get_lang(
foreach ($sessionCourseSubscriptions as $subscription) { $session = $subscription->getSession(); if (array_key_exists($session->getId(), $sessionList)) { continue; } if ($currentSession && $currentSession->getId() === $session->getId()) { $allowAccess = true; } $sessionList[$session->getId()] = $session; } if ($currentSession && !$allowAccess) { api_not_allowed(true); } $template = new Template($nameTools); $template->assign('user', $user); $template->assign('user_avatar', SocialManager::show_social_avatar_block('home', 0, $user->getId())); $template->assign('gamification_stars', GamificationUtils::getTotalUserStars($user->getId(), $user->getStatus())); $template->assign('gamification_points', GamificationUtils::getTotalUserPoints($user->getId(), $user->getStatus())); $template->assign('gamification_progress', GamificationUtils::getTotalUserProgress($user->getId(), $user->getStatus())); $template->assign('sessions', $sessionList); $template->assign('current_session', $currentSession); if ($currentSession) { $sessionData = []; $sessionCourses = $currentSession->getCourses(); foreach ($sessionCourses as $sessionCourse) { $course = $sessionCourse->getCourse(); $courseData = ['title' => $course->getTitle(), 'stats' => []]; $learningPathList = new LearnpathList($user->getId(), $course->getCode(), $currentSession->getId()); foreach ($learningPathList->list as $learningPathId => $learningPath) { $courseData['stats'][] = [$learningPath['lp_name'], 'newscorm/lp_controller.php?' . http_build_query(['action' => 'stats', 'cidReq' => $course->getCode(), 'id_session' => $currentSession->getId(), 'gidReq' => 0, 'lp_id' => $learningPathId]) . api_get_cidreq()]; }
) ) { $table_user = Database :: get_main_table(TABLE_MAIN_USER); $sql = "UPDATE $table_user SET picture_uri = '$new_picture' WHERE user_id = " . api_get_user_id(); $result = Database::query($sql); } } } } $user_info = UserManager :: get_user_info_by_id(api_get_user_id()); $social_avatar_block = SocialManager::show_social_avatar_block('home'); $social_menu_block = SocialManager::show_social_menu('home'); $socialRightContent = '<div class="span5">'; $socialRightContent .= '<div class="well_border">'; $socialRightContent .= '<h3>' . get_lang('ContactInformation') . '</h3>'; $list = array( array( 'title' => get_lang('Name'), 'content' => api_get_person_name( $user_info['firstname'], $user_info['lastname'] ) ), array('title' => get_lang('Email'), 'content' => $user_info['email']),
$interbreadcrumb[] = array('url' => 'profile.php', 'name' => get_lang('SocialNetwork')); $query = isset($_GET['q']) ? Security::remove_XSS($_GET['q']): null; $query_search_type = isset($_GET['search_type']) && in_array($_GET['search_type'], array('0','1','2')) ? $_GET['search_type'] : null; $extra_fields = UserManager::get_extra_filtrable_fields(); $query_vars = array('q' => $query, 'search_type' => $query_search_type); if (!empty($extra_fields)) { foreach ($extra_fields as $extra_field) { $field_name = 'field_' . $extra_field['variable']; if (isset($_GET[$field_name]) && $_GET[$field_name] != '0') { $query_vars[$field_name] = $_GET[$field_name]; } } } $social_avatar_block = SocialManager::show_social_avatar_block('search'); $social_menu_block = SocialManager::show_social_menu('search'); $social_right_content = '<div class="span9">'.UserManager::get_search_form($query).'</div>'; $groups = array(); $totalGroups = array(); // I'm searching something if ($query != '' || ($query_vars['search_type']=='1' && count($query_vars)>2) ) { $itemPerPage = 9; if ($_GET['search_type']=='0' || $_GET['search_type']=='1') { $page = isset($_GET['users_page_nr']) ? intval($_GET['users_page_nr']) : 1; $totalUsers = UserManager::get_all_user_tags($_GET['q'], 0, 0, $itemPerPage, true); $from = intval(($page - 1) * $itemPerPage);
if (isset($_GET['action']) && $_GET['action']=='set_moderator') { // we add a user only if is a open group $user_moderator= intval($_GET['u']); //if i'm the admin if (GroupPortalManager::is_group_admin($group_id)) { GroupPortalManager::update_user_role($user_moderator, $group_id, GROUP_USER_PERMISSION_MODERATOR); $show_message = get_lang('UserChangeToModerator'); } } $users = GroupPortalManager::get_users_by_group($group_id, true, array(GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER), 0, 1000); $new_member_list = array(); $social_avatar_block = SocialManager::show_social_avatar_block('waiting_list', $group_id); $social_menu_block = SocialManager::show_social_menu('waiting_list', $group_id); if (!empty($show_message)){ $social_right_content .= Display :: return_message($show_message); } // Display form foreach($users as $user) { switch ($user['relation_type']) { case GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER: $user['link'] = '<a href="group_waiting_list.php?id='.$group_id.'&u='.$user['user_id'].'&action=accept">'.Display::return_icon('invitation_friend.png', get_lang('AddNormalUser')).'</a>'; $user['link'] .= '<a href="group_waiting_list.php?id='.$group_id.'&u='.$user['user_id'].'&action=set_moderator">'.Display::return_icon('social_moderator_add.png', get_lang('AddModerator')).'</a>'; $user['link'] .= '<a href="group_waiting_list.php?id='.$group_id.'&u='.$user['user_id'].'&action=deny">'.Display::return_icon('user_delete.png', get_lang('DenyEntry')).'</a>'; break; } $new_member_list[] = $user;
} 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 GroupPortalManager::delete_user_rel_group(api_get_user_id(), $value); $show_message = Display::return_message(get_lang('GroupInvitationWasDeny')); break 2; } } } $social_avatar_block = SocialManager::show_social_avatar_block('invitations'); $social_menu_block = SocialManager::show_social_menu('invitations'); $social_right_content = '<div class="span9"> <div id="id_response" align="center"></div> </div></div>'; $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 = GroupPortalManager::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 .= '<div class="row"><div class="span9"><a class="btn" href="search.php">'.get_lang('TryAndFindSomeFriends').'</a></div></div>';
$show_message = get_lang('UserIsNotSubscribedToThisGroup'); } break 2; case 'deny': // delete invitation GroupPortalManager::delete_user_rel_group( api_get_user_id(), $value ); $show_message = get_lang('GroupInvitationWasDeny'); break 2; } } } $social_avatar_block = SocialManager::show_social_avatar_block('myfiles'); $social_menu_block = SocialManager::show_social_menu('myfiles'); $actions = null; if (isset($_GET['cidReq'])) { $actions = '<a href="' . api_get_path( WEB_CODE_PATH ) . 'document/document.php?cidReq=' . Security::remove_XSS( $_GET['cidReq'] ) . '&id_session=' . Security::remove_XSS( $_GET['id_session'] ) . '&gidReq=' . Security::remove_XSS( $_GET['gidReq'] ) . '&id=' . Security::remove_XSS( $_GET['parent_id'] ) . '">' . Display::return_icon(
if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('allow_message_tool') == 'true') { $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'</a>'; } if (api_get_setting('allow_message_tool') == 'true') { $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.Display::return_icon('message_new.png',get_lang('ComposeMessage')).'</a>'; $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png',get_lang('Inbox')).'</a>'; $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.Display::return_icon('outbox.png',get_lang('Outbox')).'</a>'; } $social_right_content .= '</div>'; } } // LEFT COLUMN $social_left_content = null; if (api_get_setting('allow_social_tool') == 'true') { $social_avatar_block = SocialManager::show_social_avatar_block('messages'); $social_menu_block = SocialManager::show_social_menu('messages'); $social_right_content .= '<div class="span9">'; $social_right_content .= '<div class="actions">'; $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php?f=social">'.Display::return_icon('back.png', get_lang('Back'), array(), 32).'</a>'; $social_right_content .= '</div>'; $social_right_content .= '</div>'; $social_right_content .= '<div class="span9">'; } // MAIN CONTENT if (!isset($_POST['compose'])) { if(isset($_GET['re_id'])) { $social_right_content .= show_compose_reply_to_message($_GET['re_id'], api_get_user_id()); } elseif(isset($_GET['send_to_user'])) { $social_right_content .= show_compose_to_user($_GET['send_to_user']);
$interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Thread')); $social_right_content = '<div class="breadcrumb"> <a href="groups.php?id=' . $group_id . '">' . Security::remove_XSS( $group_info['name'], STUDENT, true ) . '</a> <span class="divider">/</span> <a href="groups.php?id=' . $group_id . '#tabs_2">' . get_lang( 'Discussions' ) . '</a> </div> '; $social_avatar_block = SocialManager::show_social_avatar_block( 'member_list', $group_id ); $social_menu_block = SocialManager::show_social_menu('member_list', $group_id); if (!empty($show_message)) { $social_right_content .= Display::return_message( $show_message, 'confirmation' ); } $social_right_content .= MessageManager::display_message_for_group( $group_id, $topic_id, $is_member, $message_id );
$tok = Security::get_token(); header('Location: groups.php?id='.$group_id.'&action=show_message&message='.urlencode(get_lang('GroupUpdated')).'&sec_token='.$tok); exit(); } // Group picture $image_path = GroupPortalManager::get_group_picture_path_by_id($group_id, 'web'); $image_dir = $image_path['dir']; $image = $image_path['file']; $image_file = ($image != '' ? $image_dir.$image : api_get_path(WEB_CODE_PATH).'img/unknown_group.jpg'); $image_size = api_getimagesize($image_file); // get the path,width and height from original picture $big_image = $image_dir.'big_'.$image; $big_image_size = api_getimagesize($big_image); $big_image_width = $big_image_size['width']; $big_image_height = $big_image_size['height']; $url_big_image = $big_image.'?rnd='.time(); $social_avatar_block = SocialManager::show_social_avatar_block('group_edit', $group_id); $social_menu_block = SocialManager::show_social_menu('group_edit', $group_id); $social_right_content = $form->return_form(); $tpl = new Template($tool_name); $tpl->set_help('Groups'); $tpl->assign('social_avatar_block', $social_avatar_block); $tpl->assign('social_menu_block', $social_menu_block); $tpl->assign('social_right_content', $social_right_content); $social_layout = $tpl->get_template('layout/social_layout.tpl'); $tpl->display($social_layout);