Remove unused code

pull/3924/head
Julio Montoya 4 years ago
parent b974e3797f
commit 18afd677b9
  1. 20
      public/main/admin/user_information.php
  2. 20
      public/main/admin/user_linking_requests.php
  3. 10
      public/main/auth/justification.php
  4. 42
      public/main/inc/ajax/social.ajax.php
  5. 2
      public/main/inc/lib/api.lib.php
  6. 2
      public/main/inc/lib/database.constants.inc.php
  7. 474
      public/main/inc/lib/social.lib.php
  8. 72
      public/main/inc/lib/usermanager.lib.php
  9. 2
      public/main/social/group_invitation.php
  10. 4
      public/main/social/group_members.php
  11. 4
      public/main/social/promoted_messages.php
  12. 254
      public/main/social/search.php
  13. 2
      public/main/social/terms.php
  14. 2
      public/main/social/view_promoted_message.php
  15. 6
      public/main/template/default/admin/user_information.html.twig

@ -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,

@ -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) {

@ -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');

@ -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 '';

@ -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);

@ -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');

@ -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 = '<ul class="nav-bar">';
$active = 'home' === $show ? 'active' : null;
$links .= '
<li class="home-icon '.$active.'">
<a href="'.api_get_path(WEB_CODE_PATH).'social/home.php">
'.$homeIcon.' '.get_lang('Home').'
</a>
</li>';
$active = 'messages' === $show ? 'active' : null;
$links .= '
<li class="messages-icon '.$active.'">
<a href="'.api_get_path(WEB_CODE_PATH).'messages/inbox.php">
'.$messagesIcon.' '.get_lang('Messages').$count_unread_message.'
</a>
</li>';
// Invitations
$active = 'invitations' === $show ? 'active' : null;
$links .= '
<li class="invitations-icon '.$active.'">
<a href="'.api_get_path(WEB_CODE_PATH).'social/invitations.php">
'.$invitationsIcon.' '.get_lang('Invitations').$total_invitations.'
</a>
</li>';
// Shared profile and groups
$active = 'shared_profile' === $show ? 'active' : null;
$links .= '
<li class="shared-profile-icon'.$active.'">
<a href="'.api_get_path(WEB_CODE_PATH).'social/profile.php">
'.$sharedProfileIcon.' '.get_lang('My shared profile').'
</a>
</li>';
$active = 'friends' === $show ? 'active' : null;
$links .= '
<li class="friends-icon '.$active.'">
<a href="'.api_get_path(WEB_CODE_PATH).'social/friends.php">
'.$friendsIcon.' '.get_lang('Friends').'
</a>
</li>';
$active = 'browse_groups' === $show ? 'active' : null;
$links .= '
<li class="browse-groups-icon '.$active.'">
<a href="'.$groupUrl.'">
'.$groupsIcon.' '.get_lang('Social groups').'
</a>
</li>';
// Search users
$active = 'search' === $show ? 'active' : null;
$links .= '
<li class="search-icon '.$active.'">
<a href="'.api_get_path(WEB_CODE_PATH).'social/search.php">
'.$searchIcon.' '.get_lang('Search').'
</a>
</li>';
// My files
$active = 'myfiles' === $show ? 'active' : null;
/*$myFiles = '
<li class="myfiles-icon '.$active.'">
<a href="'.api_get_path(WEB_CODE_PATH).'social/myfiles.php">
'.$filesIcon.' '.get_lang('My files').'
</a>
</li>';
if ('false' === api_get_setting('allow_my_files')) {
$myFiles = '';
}
$links .= $myFiles;*/
if (api_get_configuration_value('allow_portfolio_tool')) {
$links .= '
<li class="portoflio-icon '.('portfolio' === $show ? 'active' : '').'">
<a href="'.api_get_path(WEB_CODE_PATH).'portfolio/index.php">
'.$portfolioIcon.' '.get_lang('Portfolio').'
</a>
</li>
';
}
if (!api_get_configuration_value('disable_gdpr')) {
$active = 'personal-data' === $show ? 'active' : null;
$personalData = '
<li class="personal-data-icon '.$active.'">
<a href="'.api_get_path(WEB_CODE_PATH).'social/personal_data.php">
'.$personalDataIcon.' '.get_lang('Personal data').'
</a>
</li>';
$links .= $personalData;
}
if (api_is_platform_admin()) {
$active = 'promoted_messages' === $show ? 'active' : null;
$personalData = '
<li class="personal-data-icon '.$active.'">
<a href="'.api_get_path(WEB_CODE_PATH).'social/promoted_messages.php">
'.$messageSocialIcon.' '.get_lang('PromotedMessages').'
</a>
</li>';
$links .= $personalData;
}
$links .= '</ul>';
$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 = '<ul class="nav-bar">';
// My own profile
if ($show_full_profile && $user_id == api_get_user_id()) {
$links .= '
<li class="home-icon '.$active.'">
<a href="'.api_get_path(WEB_CODE_PATH).'social/home.php">
'.$homeIcon.' '.get_lang('Home').'
</a>
</li>
<li class="messages-icon '.$active.'">
<a href="'.api_get_path(WEB_CODE_PATH).'messages/inbox.php">
'.$messagesIcon.' '.get_lang('Messages').$count_unread_message.'
</a>
</li>';
$active = 'invitations' === $show ? 'active' : null;
$links .= '
<li class="invitations-icon'.$active.'">
<a href="'.api_get_path(WEB_CODE_PATH).'social/invitations.php">
'.$invitationsIcon.' '.get_lang('Invitations').$total_invitations.'
</a>
</li>';
$links .= '
<li class="shared-profile-icon active">
<a href="'.api_get_path(WEB_CODE_PATH).'social/profile.php">
'.$sharedProfileIcon.' '.get_lang('My shared profile').'
</a>
</li>
<li class="friends-icon">
<a href="'.api_get_path(WEB_CODE_PATH).'social/friends.php">
'.$friendsIcon.' '.get_lang('Friends').'
</a>
</li>';
$links .= '<li class="browse-groups-icon">
<a href="'.$groupUrl.'">
'.$groupsIcon.' '.get_lang('Social groups').'
</a>
</li>';
$active = 'search' == $show ? 'active' : null;
$links .= '
<li class="search-icon '.$active.'">
<a href="'.api_get_path(WEB_CODE_PATH).'social/search.php">
'.$searchIcon.' '.get_lang('Search').'
</a>
</li>';
$active = 'myfiles' == $show ? 'active' : null;
$myFiles = '
<li class="myfiles-icon '.$active.'">
<a href="'.api_get_path(WEB_CODE_PATH).'social/myfiles.php">
'.$filesIcon.' '.get_lang('My files').'
</a>
</li>';
if ('false' === api_get_setting('allow_my_files')) {
$myFiles = '';
}
$links .= $myFiles;
if (api_get_configuration_value('allow_portfolio_tool')) {
$links .= '
<li class="portoflio-icon '.('portfolio' == $show ? 'active' : '').'">
<a href="'.api_get_path(WEB_CODE_PATH).'portfolio/index.php">
'.$portfolioIcon.' '.get_lang('Portfolio').'
</a>
</li>
';
}
if (!api_get_configuration_value('disable_gdpr')) {
$active = 'personal-data' == $show ? 'active' : null;
$personalData = '
<li class="personal-data-icon '.$active.'">
<a href="'.api_get_path(WEB_CODE_PATH).'social/personal_data.php">
'.$personalDataIcon.' '.get_lang('Personal data').'
</a>
</li>';
$links .= $personalData;
$links .= '</ul>';
}
}
// 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 .= '<li>';
$links .= Display::url(
"$sendMessageIcon $sendMessageText",
$sendMessageUrl,
[
'class' => 'ajax',
'title' => $sendMessageText,
'data-title' => $sendMessageText,
]
);
$links .= '</li>';
if (api_get_configuration_value('allow_portfolio_tool')) {
$links .= '
<li class="portoflio-icon '.('portfolio' == $show ? 'active' : '').'">
<a href="'.api_get_path(WEB_CODE_PATH).'portfolio/index.php?user='.$user_id.'">
'.$portfolioIcon.' '.get_lang('Portfolio').'
</a>
</li>
';
}
}
// 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 .= '<li><a href="'.api_get_path(WEB_CODE_PATH).'social/invitations.php">'.
Display::return_icon('invitation.png', get_lang('You already sent an invitation'))
.'&nbsp;&nbsp;'.get_lang('You already sent an invitation').'</a></li>';
} else {
if (!$show_full_profile) {
$links .= '<li>
<a class="btn-to-send-invitation" href="#" data-send-to="'.$user_id.'" title="'.get_lang('Send invitation').'">'.
Display::return_icon('invitation.png', get_lang('Invite to join my group of friends')).'&nbsp;'.get_lang('Send invitation').
'</a></li>';
}
}
$links .= '</ul>';
$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 .= '<div class="social_menu_items">';
$html .= '<ul>';
foreach ($announcements as $announcement) {
$html .= $announcement;
}
$html .= '</ul>';
$html .= '</div>';
}
}
}
if ($show_delete_account_button) {
$html .= '<div class="panel panel-default"><div class="panel-body">';
$html .= '<ul class="nav-bar"><li>';
$url = api_get_path(WEB_CODE_PATH).'auth/unsubscribe_account.php';
$html .= Display::url(
Display::return_icon(
'delete.png',
get_lang('Unsubscribe'),
[],
ICON_SIZE_TINY
).get_lang('Unsubscribe'),
$url
);
$html .= '</li></ul>';
$html .= '</div></div>';
}
$html .= '';
return $html;
}
/**
* Displays a sortable table with the list of online users.
*

@ -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;

@ -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 = '<h3 class="group-title">'.Security::remove_XSS($group_info['name'], STUDENT, true).'</h3>';
if (0 == count($nosessionUsersList)) {

@ -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 = '<h2>'.$group_info['name'].'</h2>';
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');

@ -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);

@ -1,254 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @author Julio Montoya <gugli100@gmail.com>
*/
$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 = '<div id="whoisonline">';
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 = '<button class="'.$buttonClass.' disabled ">
<em class="fa fa-user"></em> '.get_lang('Send invitation').'</button>';
$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 = '<a href="#" class="'.$buttonClass.' btn-to-send-invitation" data-send-to="'.$user_info['user_id'].'">
<em class="fa fa-user"></em> '.get_lang('Send invitation').'</a>';
}
$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 .= '</div>';
$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 = '<div id="whoisonline">';
if (is_array($groups) && count($groups) > 0) {
$block_groups .= '<div class="row">';
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 = '<a href="group_view.php?id='.$id.'">';
$url_close = '</a>';
$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'] = '<img class="img-responsive img-circle" src="'.$picture['file'].'" />';
$members = Display::returnFontAwesomeIcon('user').'( '.$count_users_group.' )';
$item_1 = Display::tag('p', $url_open.$name.$url_close);
$block_groups .= '
<div class="col-md-4">
<div class="items-user">
<div class="items-user-avatar">
'.$group['picture'].'
</div>
<div class="user-info">
'.$item_1.'
<p>'.$members.'</p>
<p>'.$group['description'].'</p>
<p>'.$tags.'</p>
<p>'.$url_open.get_lang('See more').$url_close.'</p>
</div>
</div>
</div>';
}
$block_groups .= '</div>';
}
$block_groups .= '</div>';
$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);

@ -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);

@ -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');

@ -15,9 +15,9 @@
</div>
{% if social_tool %}
<div class="list-box-widget">
{{ 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') }}

Loading…
Cancel
Save