From 18afd677b98ec23c247c4eca416b418021b473a2 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Sun, 4 Jul 2021 10:14:32 +0200 Subject: [PATCH] Remove unused code --- public/main/admin/user_information.php | 20 +- public/main/admin/user_linking_requests.php | 20 +- public/main/auth/justification.php | 10 +- public/main/inc/ajax/social.ajax.php | 42 -- public/main/inc/lib/api.lib.php | 2 +- .../main/inc/lib/database.constants.inc.php | 2 - public/main/inc/lib/social.lib.php | 474 +----------------- public/main/inc/lib/usermanager.lib.php | 72 +-- public/main/social/group_invitation.php | 2 +- public/main/social/group_members.php | 4 +- public/main/social/promoted_messages.php | 4 +- public/main/social/search.php | 254 ---------- public/main/social/terms.php | 2 +- public/main/social/view_promoted_message.php | 2 +- .../default/admin/user_information.html.twig | 6 +- 15 files changed, 40 insertions(+), 876 deletions(-) delete mode 100644 public/main/social/search.php diff --git a/public/main/admin/user_information.php b/public/main/admin/user_information.php index 278fa1c603..107f33b05a 100644 --- a/public/main/admin/user_information.php +++ b/public/main/admin/user_information.php @@ -225,7 +225,7 @@ foreach ($data as $label => $item) { /** * Show social activity. */ -if ('true' === api_get_setting('allow_social_tool')) { +if (false) { $data = []; $messagesSent = ''; // Calculate values @@ -238,19 +238,19 @@ if ('true' === api_get_setting('allow_social_tool')) { $wallMessagesPosted = SocialManager::getCountWallPostedMessages($userId); $data[] = [get_lang('Wall messages posted by him/herself'), $wallMessagesPosted]; - $friends = SocialManager::getCountFriends($userId); - $data[] = [get_lang('Friends'), $friends]; + //$friends = SocialManager::getCountFriends($userId); + //$data[] = [get_lang('Friends'), $friends]; - $countSent = SocialManager::getCountInvitationSent($userId); - $data[] = [get_lang('Invitation sent'), $countSent]; + //$countSent = SocialManager::getCountInvitationSent($userId); + //$data[] = [get_lang('Invitation sent'), $countSent]; - $countReceived = SocialManager::get_message_number_invitation_by_user_id($userId); - $data[] = [get_lang('Invitation received'), $countReceived]; + //$countReceived = SocialManager::get_message_number_invitation_by_user_id($userId); + //$data[] = [get_lang('Invitation received'), $countReceived]; $params['social'] = [ - 'friends' => $friends, - 'invitation_sent' => $countSent, - 'invitation_received' => $countReceived, + ///'friends' => $friends, + // 'invitation_sent' => $countSent, + //'invitation_received' => $countReceived, 'messages_posted' => $wallMessagesPosted, 'messages_sent' => $messagesSent, 'messages_received' => $messagesReceived, diff --git a/public/main/admin/user_linking_requests.php b/public/main/admin/user_linking_requests.php index 7bc61a44f9..0fbbacb8b8 100644 --- a/public/main/admin/user_linking_requests.php +++ b/public/main/admin/user_linking_requests.php @@ -23,13 +23,13 @@ if (!empty($action) && $hrm && $assignedId) { /** @var UserRelUser $request */ $request = $em->getRepository(UserRelUser::class) ->findOneBy([ - 'userId' => $assignedId, - 'friendUserId' => $hrm->getId(), - 'relationType' => USER_RELATION_TYPE_HRM_REQUEST, + 'user' => $assignedId, + 'friend' => $hrm->getId(), + 'relationType' => UserRelUser::USER_RELATION_TYPE_HRM_REQUEST, ]); if ($request) { - $request->setRelationType(USER_RELATION_TYPE_RRHH); + $request->setRelationType(UserRelUser::USER_RELATION_TYPE_RRHH); $em->persist($request); $em->flush(); @@ -44,9 +44,9 @@ if (!empty($action) && $hrm && $assignedId) { /** @var UserRelUser $request */ $request = $em->getRepository(UserRelUser::class) ->findOneBy([ - 'userId' => $assignedId, - 'friendUserId' => $hrm->getId(), - 'relationType' => USER_RELATION_TYPE_HRM_REQUEST, + 'user' => $assignedId, + 'friend' => $hrm->getId(), + 'relationType' => UserRelUser::USER_RELATION_TYPE_HRM_REQUEST, ]); if ($request) { @@ -64,9 +64,9 @@ if (!empty($action) && $hrm && $assignedId) { /** @var UserRelUser $request */ $request = $em->getRepository(UserRelUser::class) ->findOneBy([ - 'userId' => $assignedId, - 'friendUserId' => $hrm->getId(), - 'relationType' => USER_RELATION_TYPE_RRHH, + 'user' => $assignedId, + 'friend' => $hrm->getId(), + 'relationType' => UserRelUser::USER_RELATION_TYPE_RRHH, ]); if ($request) { diff --git a/public/main/auth/justification.php b/public/main/auth/justification.php index 621ad88f6c..2391e1df26 100644 --- a/public/main/auth/justification.php +++ b/public/main/auth/justification.php @@ -199,15 +199,7 @@ $justification = $tabs.$formValidator->returnForm().$userJustificationList; $tpl = new Template(get_lang('ModifyProfile')); SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'home'); -$menu = SocialManager::show_social_menu( - 'home', - null, - api_get_user_id(), - false, - false -); - -$tpl->assign('social_menu_block', $menu); +$tpl->assign('social_menu_block', ''); $tpl->assign('social_right_content', $justification); $social_layout = $tpl->get_template('social/edit_profile.tpl'); diff --git a/public/main/inc/ajax/social.ajax.php b/public/main/inc/ajax/social.ajax.php index eff98fb101..daaa4a9128 100644 --- a/public/main/inc/ajax/social.ajax.php +++ b/public/main/inc/ajax/social.ajax.php @@ -15,48 +15,6 @@ $action = isset($_GET['a']) ? $_GET['a'] : null; $current_user_id = api_get_user_id(); switch ($action) { - case 'add_friend': - if (api_is_anonymous()) { - echo ''; - break; - } - $relation_type = USER_RELATION_TYPE_UNKNOWN; //Unknown contact - if (isset($_GET['is_my_friend'])) { - $relation_type = USER_RELATION_TYPE_FRIEND; //My friend - } - - if (isset($_GET['friend_id'])) { - $my_current_friend = $_GET['friend_id']; - UserManager::relate_users($current_user_id, $my_current_friend, $relation_type); - UserManager::relate_users($my_current_friend, $current_user_id, $relation_type); - SocialManager::invitation_accepted($my_current_friend, $current_user_id); - Display::addFlash( - Display::return_message(get_lang('Added contact to list'), 'success') - ); - - header('Location: '.api_get_path(WEB_CODE_PATH).'social/invitations.php'); - exit; - } - break; - case 'deny_friend': - if (api_is_anonymous()) { - echo ''; - break; - } - $relation_type = USER_RELATION_TYPE_UNKNOWN; //Contact unknown - if (isset($_GET['is_my_friend'])) { - $relation_type = USER_RELATION_TYPE_FRIEND; //my friend - } - if (isset($_GET['denied_friend_id'])) { - SocialManager::invitation_denied($_GET['denied_friend_id'], $current_user_id); - Display::addFlash( - Display::return_message(get_lang('Invitation denied'), 'success') - ); - - header('Location: '.api_get_path(WEB_CODE_PATH).'social/invitations.php'); - exit; - } - break; case 'show_my_friends': if (api_is_anonymous()) { echo ''; diff --git a/public/main/inc/lib/api.lib.php b/public/main/inc/lib/api.lib.php index 27f9eaa936..b12744b0fa 100644 --- a/public/main/inc/lib/api.lib.php +++ b/public/main/inc/lib/api.lib.php @@ -363,7 +363,7 @@ define('USER_RELATION_TYPE_FRIEND', 3); define('USER_RELATION_TYPE_GOODFRIEND', 4); // should be deprecated is useless define('USER_RELATION_TYPE_ENEMY', 5); // should be deprecated is useless define('USER_RELATION_TYPE_DELETED', 6); -define('USER_RELATION_TYPE_RRHH', 7); +//define('USER_RELATION_TYPE_RRHH', 7); define('USER_RELATION_TYPE_BOSS', 8); define('USER_RELATION_TYPE_HRM_REQUEST', 9); diff --git a/public/main/inc/lib/database.constants.inc.php b/public/main/inc/lib/database.constants.inc.php index 3c1557a608..f7cdb581e3 100644 --- a/public/main/inc/lib/database.constants.inc.php +++ b/public/main/inc/lib/database.constants.inc.php @@ -16,12 +16,10 @@ define('DB_COURSE_PREFIX', 'c_'); // Main database tables define('TABLE_MAIN_COURSE', 'course'); define('TABLE_MAIN_USER', 'user'); -define('TABLE_MAIN_CLASS', 'class_item'); define('TABLE_MAIN_ADMIN', 'admin'); define('TABLE_MAIN_COURSE_CLASS', 'course_rel_class'); define('TABLE_MAIN_COURSE_USER', 'course_rel_user'); define('TABLE_MAIN_COURSE_CATALOGUE_USER', 'course_rel_user_catalogue'); -define('TABLE_MAIN_CLASS_USER', 'class_user'); define('TABLE_MAIN_CATEGORY', 'course_category'); define('TABLE_MAIN_COURSE_REL_CATEGORY', 'course_rel_category'); define('TABLE_MAIN_SYSTEM_ANNOUNCEMENTS', 'sys_announcement'); diff --git a/public/main/inc/lib/social.lib.php b/public/main/inc/lib/social.lib.php index cadab68f4f..5e29aed2ad 100644 --- a/public/main/inc/lib/social.lib.php +++ b/public/main/inc/lib/social.lib.php @@ -4,6 +4,7 @@ use Chamilo\CoreBundle\Entity\Message; use Chamilo\CoreBundle\Entity\MessageAttachment; +use Chamilo\CoreBundle\Entity\UserRelUser; use Chamilo\CoreBundle\Framework\Container; use Chamilo\CourseBundle\Entity\CForumPost; use Chamilo\CourseBundle\Entity\CForumThread; @@ -79,7 +80,7 @@ class SocialManager extends UserManager WHERE user_id='.((int) $user_id).' AND friend_user_id='.((int) $user_friend).' AND - uf.relation_type <> '.USER_RELATION_TYPE_RRHH.' + uf.relation_type <> '.UserRelUser::USER_RELATION_TYPE_RRHH.' LIMIT 1 )'; } else { @@ -127,37 +128,6 @@ class SocialManager extends UserManager } } - /** - * Get count of friends from user. - * - * @param int $userId - * - * @return int - */ - public static function getCountFriends($userId) - { - $table = Database::get_main_table(TABLE_MAIN_USER_REL_USER); - $userId = (int) $userId; - if (empty($userId)) { - return 0; - } - - $sql = 'SELECT count(friend_user_id) count - FROM '.$table.' - WHERE - relation_type NOT IN ('.USER_RELATION_TYPE_DELETED.', '.USER_RELATION_TYPE_RRHH.') AND - friend_user_id<>'.$userId.' AND - user_id='.$userId; - $res = Database::query($sql); - if (Database::num_rows($res)) { - $row = Database::fetch_array($res, 'ASSOC'); - - return (int) $row['count']; - } - - return 0; - } - /** * Gets friends id list. * @@ -222,32 +192,6 @@ class SocialManager extends UserManager return $list; } - /** - * Get number messages of the inbox. - * - * @author isaac flores paz - * - * @param int $userId user receiver id - * - * @return int - */ - public static function get_message_number_invitation_by_user_id($userId) - { - $table = Database::get_main_table(TABLE_MESSAGE); - $userId = (int) $userId; - $sql = 'SELECT COUNT(*) as count_message_in_box FROM '.$table.' - WHERE - user_receiver_id='.$userId.' AND - msg_status = '.MESSAGE_STATUS_INVITATION_PENDING; - $res = Database::query($sql); - $row = Database::fetch_array($res, 'ASSOC'); - if ($row) { - return (int) $row['count_message_in_box']; - } - - return 0; - } - /** * Get number of messages sent to other users. * @@ -621,420 +565,6 @@ class SocialManager extends UserManager return $template->fetch($template->get_template('social/avatar_block.tpl')); } - /** - * Shows the right menu of the Social Network tool. - * - * @param string $show highlight link possible values: - * group_add, - * home, - * messages, - * messages_inbox, - * messages_compose , - * messages_outbox, - * invitations, - * shared_profile, - * friends, - * groups search - * @param int $group_id group id - * @param int $user_id user id - * @param bool $show_full_profile show profile or not (show or hide the user image/information) - * @param bool $show_delete_account_button - */ - public static function show_social_menu( - $show = '', - $group_id = 0, - $user_id = 0, - $show_full_profile = false, - $show_delete_account_button = false - ) { - $user_id = (int) $user_id; - $group_id = (int) $group_id; - - if (empty($user_id)) { - $user_id = api_get_user_id(); - } - - $usergroup = new UserGroupModel(); - $show_groups = [ - 'groups', - 'group_messages', - 'messages_list', - 'group_add', - 'mygroups', - 'group_edit', - 'member_list', - 'invite_friends', - 'waiting_list', - 'browse_groups', - ]; - - // get count unread message and total invitations - /*ount_unread_message = MessageManager::getCountNewMessagesFromDB(api_get_user_id()); - $count_unread_message = !empty($count_unread_message) ? Display::badge($count_unread_message) : null;*/ - $count_unread_message = null; - - $number_of_new_messages_of_friend = self::get_message_number_invitation_by_user_id(api_get_user_id()); - $group_pending_invitations = $usergroup->get_groups_by_user( - api_get_user_id(), - GROUP_USER_PERMISSION_PENDING_INVITATION, - false - ); - $group_pending_invitations = count($group_pending_invitations); - $total_invitations = $number_of_new_messages_of_friend + $group_pending_invitations; - $total_invitations = (!empty($total_invitations) ? Display::badge($total_invitations) : ''); - - $filesIcon = Display::return_icon('sn-files.png', get_lang('My files'), null, ICON_SIZE_SMALL); - $friendsIcon = Display::return_icon('sn-friends.png', get_lang('Friends'), null, ICON_SIZE_SMALL); - $groupsIcon = Display::return_icon('sn-groups.png', get_lang('Social groups'), null, ICON_SIZE_SMALL); - $homeIcon = Display::return_icon('sn-home.png', get_lang('Home'), null, ICON_SIZE_SMALL); - $invitationsIcon = Display::return_icon('sn-invitations.png', get_lang('Invitations'), null, ICON_SIZE_SMALL); - $messagesIcon = Display::return_icon('sn-message.png', get_lang('Messages'), null, ICON_SIZE_SMALL); - $sharedProfileIcon = Display::return_icon('sn-profile.png', get_lang('My shared profile')); - $searchIcon = Display::return_icon('sn-search.png', get_lang('Search'), null, ICON_SIZE_SMALL); - $portfolioIcon = Display::return_icon('wiki_task.png', get_lang('Portfolio')); - $personalDataIcon = Display::return_icon('database.png', get_lang('Personal data')); - $messageSocialIcon = Display::return_icon('promoted_message.png', get_lang('PromotedMessages')); - - $forumCourseId = api_get_configuration_value('global_forums_course_id'); - $groupUrl = api_get_path(WEB_CODE_PATH).'social/groups.php'; - if (!empty($forumCourseId)) { - $courseInfo = api_get_course_info_by_id($forumCourseId); - if (!empty($courseInfo)) { - $groupUrl = api_get_path(WEB_CODE_PATH).'forum/index.php?cid='.$courseInfo['real_id']; - } - } - - $html = ''; - $active = null; - if (!in_array( - $show, - ['shared_profile', 'groups', 'group_edit', 'member_list', 'waiting_list', 'invite_friends'] - )) { - $links = ''; - $html .= Display::panelCollapse( - get_lang('Social network'), - $links, - 'social-network-menu', - null, - 'sn-sidebar', - 'sn-sidebar-collapse' - ); - } - - if (!empty($group_id) && in_array($show, $show_groups)) { - $html .= $usergroup->show_group_column_information( - $group_id, - api_get_user_id(), - $show - ); - } - - if ('shared_profile' === $show) { - $links = ''; - } - } - - // My friend profile. - if ($user_id != api_get_user_id()) { - $sendMessageText = get_lang('Send message'); - $sendMessageIcon = Display::return_icon( - 'new-message.png', - $sendMessageText - ); - $sendMessageUrl = api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?'.http_build_query([ - 'a' => 'get_user_popup', - 'user_id' => $user_id, - ]); - - $links .= '
  • '; - $links .= Display::url( - "$sendMessageIcon $sendMessageText", - $sendMessageUrl, - [ - 'class' => 'ajax', - 'title' => $sendMessageText, - 'data-title' => $sendMessageText, - ] - ); - $links .= '
  • '; - - if (api_get_configuration_value('allow_portfolio_tool')) { - $links .= ' -
  • - - '.$portfolioIcon.' '.get_lang('Portfolio').' - -
  • - '; - } - } - - // Check if I already sent an invitation message - $invitationSentList = self::get_list_invitation_sent_by_user_id(api_get_user_id()); - - if (isset($invitationSentList[$user_id]) && is_array($invitationSentList[$user_id]) && - count($invitationSentList[$user_id]) > 0 - ) { - $links .= '
  • '. - Display::return_icon('invitation.png', get_lang('You already sent an invitation')) - .'  '.get_lang('You already sent an invitation').'
  • '; - } else { - if (!$show_full_profile) { - $links .= '
  • - '. - Display::return_icon('invitation.png', get_lang('Invite to join my group of friends')).' '.get_lang('Send invitation'). - '
  • '; - } - } - - $links .= ''; - $html .= Display::panelCollapse( - get_lang('Social network'), - $links, - 'social-network-menu', - null, - 'sn-sidebar', - 'sn-sidebar-collapse' - ); - - if ($show_full_profile && $user_id == api_get_user_id()) { - // Announcements - $announcements = []; - $announcementsByCourse = AnnouncementManager::getAnnouncementCourseTotalByUser($user_id); - - if (!empty($announcementsByCourse)) { - foreach ($announcementsByCourse as $announcement) { - $resourceLink = $announcement->getFirstResourceLink(); - $course = $resourceLink->getCourse(); - //$courseInfo = api_get_course_info_by_id($announcement->getCId()); - if ($course) { - $url = Display::url( - Display::return_icon( - 'announcement.png', - get_lang('Announcements') - ).$course->getName(), - api_get_path(WEB_CODE_PATH).'announcements/announcements.php?cid='.$course->getId() - ); - $announcements[] = Display::tag('li', $url); - } - } - } - - if (!empty($announcements)) { - $html .= '
    '; - $html .= ''; - $html .= '
    '; - } - } - } - - if ($show_delete_account_button) { - $html .= '
    '; - $html .= ''; - $html .= '
    '; - } - $html .= ''; - - return $html; - } - /** * Displays a sortable table with the list of online users. * diff --git a/public/main/inc/lib/usermanager.lib.php b/public/main/inc/lib/usermanager.lib.php index f81a25958b..aee6199114 100644 --- a/public/main/inc/lib/usermanager.lib.php +++ b/public/main/inc/lib/usermanager.lib.php @@ -6,6 +6,7 @@ use Chamilo\CoreBundle\Entity\ExtraFieldSavedSearch; use Chamilo\CoreBundle\Entity\SkillRelUser; use Chamilo\CoreBundle\Entity\SkillRelUserComment; use Chamilo\CoreBundle\Entity\User; +use Chamilo\CoreBundle\Entity\UserRelUser; use Chamilo\CoreBundle\Framework\Container; use Chamilo\CoreBundle\Repository\GroupRepository; use Chamilo\CoreBundle\Repository\Node\UserRepository; @@ -4134,67 +4135,6 @@ class UserManager return $js.$form->returnForm(); } - /** - * Allow to register contact to social network. - * - * @param int $friend_id user friend id - * @param int $my_user_id user id - * @param int $relation_type relation between users see constants definition - * - * @return bool - */ - public static function relate_users($friend_id, $my_user_id, $relation_type) - { - $tbl_my_friend = Database::get_main_table(TABLE_MAIN_USER_REL_USER); - - $friend_id = (int) $friend_id; - $my_user_id = (int) $my_user_id; - $relation_type = (int) $relation_type; - - $sql = 'SELECT COUNT(*) as count FROM '.$tbl_my_friend.' - WHERE - friend_user_id='.$friend_id.' AND - user_id='.$my_user_id.' AND - relation_type NOT IN('.USER_RELATION_TYPE_RRHH.', '.USER_RELATION_TYPE_BOSS.') '; - $result = Database::query($sql); - $row = Database::fetch_array($result, 'ASSOC'); - $current_date = api_get_utc_datetime(); - - if (0 == $row['count']) { - $sql = 'INSERT INTO '.$tbl_my_friend.'(friend_user_id,user_id,relation_type,last_edit) - VALUES ('.$friend_id.','.$my_user_id.','.$relation_type.',"'.$current_date.'")'; - Database::query($sql); - - return true; - } - - $sql = 'SELECT COUNT(*) as count, relation_type FROM '.$tbl_my_friend.' - WHERE - friend_user_id='.$friend_id.' AND - user_id='.$my_user_id.' AND - relation_type NOT IN('.USER_RELATION_TYPE_RRHH.', '.USER_RELATION_TYPE_BOSS.') '; - $result = Database::query($sql); - $row = Database::fetch_array($result, 'ASSOC'); - - if (1 == $row['count']) { - //only for the case of a RRHH or a Student BOSS - if ($row['relation_type'] != $relation_type && - (USER_RELATION_TYPE_RRHH == $relation_type || USER_RELATION_TYPE_BOSS == $relation_type) - ) { - $sql = 'INSERT INTO '.$tbl_my_friend.'(friend_user_id,user_id,relation_type,last_edit) - VALUES ('.$friend_id.','.$my_user_id.','.$relation_type.',"'.$current_date.'")'; - } else { - $sql = 'UPDATE '.$tbl_my_friend.' SET relation_type='.$relation_type.' - WHERE friend_user_id='.$friend_id.' AND user_id='.$my_user_id; - } - Database::query($sql); - - return true; - } - - return false; - } - /** * @param int $userId * @@ -4221,8 +4161,8 @@ class UserManager WHERE access_url_id = ".api_get_current_access_url_id()." AND uru.user_id = '$userId' AND - relation_type = '".USER_RELATION_TYPE_RRHH."' - $orderBy + relation_type = '".UserRelUser::USER_RELATION_TYPE_RRHH."' + $orderBy "; $result = Database::query($sql); @@ -4394,13 +4334,13 @@ class UserManager case DRH: $drhConditions .= " AND friend_user_id = '$userId' AND - relation_type = '".USER_RELATION_TYPE_RRHH."' + relation_type = '".UserRelUser::USER_RELATION_TYPE_RRHH."' "; break; case COURSEMANAGER: $drhConditions .= " AND friend_user_id = '$userId' AND - relation_type = '".USER_RELATION_TYPE_RRHH."' + relation_type = '".UserRelUser::USER_RELATION_TYPE_RRHH."' "; $sessionConditionsCoach .= " AND @@ -4705,7 +4645,7 @@ class UserManager WHERE user_id = $user_id AND friend_user_id = $hr_dept_id AND - relation_type = ".USER_RELATION_TYPE_RRHH; + relation_type = ".UserRelUser::USER_RELATION_TYPE_RRHH; $rs = Database::query($sql); if (Database::num_rows($rs) > 0) { $result = true; diff --git a/public/main/social/group_invitation.php b/public/main/social/group_invitation.php index a9da783e67..c4aebb0fb4 100644 --- a/public/main/social/group_invitation.php +++ b/public/main/social/group_invitation.php @@ -142,7 +142,7 @@ if (is_array($Users) && count($Users) > 0) { } } -$social_left_content = SocialManager::show_social_menu('invite_friends', $group_id); +//$social_left_content = SocialManager::show_social_menu('invite_friends', $group_id); $social_right_content = '

    '.Security::remove_XSS($group_info['name'], STUDENT, true).'

    '; if (0 == count($nosessionUsersList)) { diff --git a/public/main/social/group_members.php b/public/main/social/group_members.php index 18a11ba15d..17c847f310 100644 --- a/public/main/social/group_members.php +++ b/public/main/social/group_members.php @@ -115,7 +115,7 @@ $social_avatar_block = SocialManager::show_social_avatar_block( 'member_list', $group_id ); -$social_menu_block = SocialManager::show_social_menu('member_list', $group_id); +//$social_menu_block = SocialManager::show_social_menu('member_list', $group_id); $social_right_content = '

    '.$group_info['name'].'

    '; foreach ($users as $user) { @@ -189,7 +189,7 @@ if (count($new_member_list) > 0) { $tpl = new Template(null); $tpl->setHelp('Groups'); $tpl->assign('social_avatar_block', $social_avatar_block); -$tpl->assign('social_menu_block', $social_menu_block); +$tpl->assign('social_menu_block', ''); $tpl->assign('social_right_content', $social_right_content); $social_layout = $tpl->get_template('social/home.tpl'); diff --git a/public/main/social/promoted_messages.php b/public/main/social/promoted_messages.php index 05eb01d96a..0e9f2b441b 100644 --- a/public/main/social/promoted_messages.php +++ b/public/main/social/promoted_messages.php @@ -29,7 +29,7 @@ $interbreadcrumb[] = [ 'name' => get_lang('PromotedMessages'), ]; $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('List')]; -$menu = SocialManager::show_social_menu('messages'); +//$menu = SocialManager::show_social_menu('messages'); // Right content $social_right_content = ''; @@ -50,7 +50,7 @@ $tpl = new Template(null); // Block Social Avatar SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'messages'); -$tpl->assign('social_menu_block', $menu); +$tpl->assign('social_menu_block', ''); $tpl->assign('social_right_content', $social_right_content); $social_layout = $tpl->get_template('social/inbox.tpl'); $tpl->display($social_layout); diff --git a/public/main/social/search.php b/public/main/social/search.php deleted file mode 100644 index e9fef77e66..0000000000 --- a/public/main/social/search.php +++ /dev/null @@ -1,254 +0,0 @@ - - */ -$cidReset = true; - -require_once __DIR__.'/../inc/global.inc.php'; -$ajax_url = api_get_path(WEB_AJAX_PATH).'message.ajax.php'; -api_block_anonymous_users(); - -if ('true' != api_get_setting('allow_social_tool')) { - api_not_allowed(); -} - -$this_section = SECTION_SOCIAL; -$tool_name = get_lang('Search'); -$interbreadcrumb[] = [ - 'url' => api_get_path(WEB_CODE_PATH).'social/profile.php', - 'name' => get_lang('Social network'), -]; - -$query = isset($_GET['q']) ? Security::remove_XSS($_GET['q']) : null; - -$queryNoFilter = isset($_GET['q']) ? $_GET['q'] : null; -$query_search_type = isset($_GET['search_type']) && in_array($_GET['search_type'], ['0', '1', '2']) ? $_GET['search_type'] : null; -$extra_fields = UserManager::getExtraFilterableFields(); -$query_vars = ['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]) && '0' != $_GET[$field_name]) { - $query_vars[$field_name] = $_GET[$field_name]; - } - } -} - -//Block Social Menu -$social_menu_block = SocialManager::show_social_menu('search'); -$block_search = ''; -$searchForm = UserManager::get_search_form($queryNoFilter); - -$groups = []; -$totalGroups = []; -$users = []; -$totalUsers = []; -$usergroup = new UserGroupModel(); - -// I'm searching something -if ('' != $query || ('1' == $query_vars['search_type'] && count($query_vars) > 2)) { - $itemPerPage = 6; - - if ('0' == $_GET['search_type'] || '1' == $_GET['search_type']) { - $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); - // Get users from tags - $users = UserManager::get_all_user_tags($_GET['q'], 0, $from, $itemPerPage); - } - - if ('0' == $_GET['search_type'] || '2' == $_GET['search_type']) { - $pageGroup = isset($_GET['groups_page_nr']) ? intval($_GET['groups_page_nr']) : 1; - // Groups - $fromGroups = intval(($pageGroup - 1) * $itemPerPage); - $totalGroups = count($usergroup->get_all_group_tags($_GET['q'], 0, $itemPerPage, true)); - - $groups = $usergroup->get_all_group_tags($_GET['q'], $fromGroups); - } - - if (empty($users) && empty($groups)) { - Display::addFlash(Display::return_message(get_lang('Sorry no results'))); - } - - $results = '
    '; - if (is_array($users) && count($users) > 0) { - $buttonClass = 'btn btn-default btn-sm'; - foreach ($users as $user) { - $user_info = api_get_user_info($user['id'], true); - $sendInvitation = ''; - $relation_type = SocialManager::get_relation_between_contacts(api_get_user_id(), $user_info['user_id']); - $url = api_get_path(WEB_PATH).'main/social/profile.php?u='.$user_info['user_id']; - - // Show send invitation icon if they are not friends yet - if (3 != $relation_type && 4 != $relation_type && $user_info['user_id'] != api_get_user_id()) { - $sendInvitation = ' - '.get_lang('Send invitation').''; - } - - $sendMessageUrl = api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?'.http_build_query([ - 'a' => 'get_user_popup', - 'user_id' => $user_info['user_id'], - ]); - - $sendMessage = Display::toolbarButton( - get_lang('Send message'), - $sendMessageUrl, - 'envelope', - 'default', - [ - 'class' => 'ajax btn-sm', - 'data-title' => get_lang('Send message'), - ] - ); - - if (!empty($user_info['user_is_online'])) { - $status_icon = Display::return_icon('online.png', get_lang('Online'), null, ICON_SIZE_TINY); - } else { - $status_icon = Display::return_icon('offline.png', get_lang('Disconnected'), null, ICON_SIZE_TINY); - } - - if (5 == $user_info['status']) { - $user_icon = Display::return_icon('user.png', get_lang('Learner'), null, ICON_SIZE_TINY); - } else { - $user_icon = Display::return_icon('teacher.png', get_lang('Trainer'), null, ICON_SIZE_TINY); - } - - $user_info['complete_name'] = Display::url($user_info['complete_name'], $url); - $invitations = $sendInvitation.$sendMessage; - - $results .= Display::getUserCard( - $user_info, - $status_icon.$user_icon, - $invitations - ); - } - } - $results .= '
    '; - - $visibility = [true, true, true, true, true]; - - if (!empty($users)) { - $results .= Display::return_sortable_grid( - 'users', - null, - null, - ['hide_navigation' => false, 'per_page' => $itemPerPage], - $query_vars, - false, - $visibility, - true, - [], - $totalUsers - ); - $block_search .= Display::panelCollapse( - get_lang('Users'), - $results, - 'search-friends', - null, - 'friends-accordion', - 'friends-collapse' - ); - } - - $grid_groups = []; - $block_groups = '
    '; - if (is_array($groups) && count($groups) > 0) { - $block_groups .= '
    '; - foreach ($groups as $group) { - $group['name'] = Security::remove_XSS($group['name'], STUDENT, true); - $group['description'] = Security::remove_XSS($group['description'], STUDENT, true); - $id = $group['id']; - $url_open = ''; - $url_close = ''; - $name = cut($group['name'], 60, true); - $count_users_group = count($usergroup->get_all_users_by_group($id)); - if (1 == $count_users_group) { - $count_users_group = $count_users_group; - } else { - $count_users_group = $count_users_group; - } - $picture = $usergroup->get_picture_group( - $group['id'], - $group['picture'], - GROUP_IMAGE_SIZE_ORIGINAL - ); - - $tags = null; - $group['picture'] = ''; - - $members = Display::returnFontAwesomeIcon('user').'( '.$count_users_group.' )'; - $item_1 = Display::tag('p', $url_open.$name.$url_close); - - $block_groups .= ' -
    -
    -
    - '.$group['picture'].' -
    - -
    -
    '; - } - $block_groups .= '
    '; - } - $block_groups .= '
    '; - - $visibility = [true, true, true, true, true]; - - if (!empty($groups)) { - $block_groups .= Display::return_sortable_grid( - 'groups', - null, - $grid_groups, - ['hide_navigation' => false, 'per_page' => $itemPerPage], - $query_vars, - false, - $visibility, - true, - [], - $totalGroups - ); - $block_search .= Display:: panelCollapse( - get_lang('Groups'), - $block_groups, - 'search-groups', - null, - 'groups-accordion', - 'groups-collapse' - ); - } -} - -$tpl = new Template($tool_name); -// Block Social Avatar -SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'search'); -$tpl->assign('social_menu_block', $social_menu_block); -$tpl->assign('social_search', $block_search); -$tpl->assign('search_form', $searchForm); - -$formModalTpl = new Template(); -$formModalTpl->assign('invitation_form', MessageManager::generate_invitation_form()); -$template = $formModalTpl->get_template('social/form_modals.tpl'); -$formModals = $formModalTpl->fetch($template); - -$tpl->assign('form_modals', $formModals); - -$social_layout = $tpl->get_template('social/search.tpl'); -$tpl->display($social_layout); diff --git a/public/main/social/terms.php b/public/main/social/terms.php index 276b0c1c54..9a4ea82112 100644 --- a/public/main/social/terms.php +++ b/public/main/social/terms.php @@ -46,7 +46,7 @@ $allowSocial = 'true' === api_get_setting('allow_social_tool'); if ($allowSocial) { // Block Social Menu - $socialMenuBlock = SocialManager::show_social_menu('personal-data'); + //$socialMenuBlock = SocialManager::show_social_menu('personal-data'); } $tpl = new Template(null); diff --git a/public/main/social/view_promoted_message.php b/public/main/social/view_promoted_message.php index cfd1dc34f6..fe2d7195f9 100644 --- a/public/main/social/view_promoted_message.php +++ b/public/main/social/view_promoted_message.php @@ -26,7 +26,7 @@ $logInfo = [ 'action_details' => 'view-message', ]; Event::registerLog($logInfo); -$social_menu_block = SocialManager::show_social_menu('inbox'); +//$social_menu_block = SocialManager::show_social_menu('inbox'); throw new Exception('Fix MessageManager::showMessageBox'); diff --git a/public/main/template/default/admin/user_information.html.twig b/public/main/template/default/admin/user_information.html.twig index cdd484afa7..e62d249c99 100644 --- a/public/main/template/default/admin/user_information.html.twig +++ b/public/main/template/default/admin/user_information.html.twig @@ -15,9 +15,9 @@ {% if social_tool %}
    - {{ display.box_widget('Friends'|get_lang, params.social.friends, 'users') }} - {{ display.box_widget('InvitationSent'|get_lang, params.social.invitation_sent, 'paper-plane') }} - {{ display.box_widget('InvitationReceived'|get_lang, params.social.invitation_received, 'smile-o') }} +{# {{ display.box_widget('Friends'|get_lang, params.social.friends, 'users') }}#} +{# {{ display.box_widget('InvitationSent'|get_lang, params.social.invitation_sent, 'paper-plane') }}#} +{# {{ display.box_widget('InvitationReceived'|get_lang, params.social.invitation_received, 'smile-o') }}#} {{ display.box_widget('WallMessagesPosted'|get_lang, params.social.messages_posted, 'comments') }} {{ display.box_widget('MessagesSent'|get_lang, params.social.messages_sent, 'envelope') }} {{ display.box_widget('MessagesReceived'|get_lang, params.social.messages_received, 'envelope-open-o') }}