template groups social - refs #2681

pull/2818/head
Alex Aragón 6 years ago
parent 460b7d51fa
commit f92d32ca03
  1. 50
      assets/css/base.css
  2. 4
      main/inc/lib/message.lib.php
  3. 31
      main/inc/lib/social.lib.php
  4. 56
      main/social/group_view.php
  5. 2
      main/social/message_for_group_form.inc.php
  6. 16
      main/template/default/social/avatar_block.html.twig
  7. 66
      main/template/default/social/group_view.html.twig
  8. 12
      main/template/default/social/home.html.twig
  9. 36
      src/ThemeBundle/Resources/views/Social/user_block.html.twig

@ -4385,56 +4385,6 @@ i.size-32.icon-new-work {
top: 30px;
}
#sm-groups .list-group-newest .items {
display: block;
}
#sm-groups .list-group-newest .items .group-image {
vertical-align: top;
padding-left: 10px;
padding-right: 10px;
}
#sm-groups .list-group-newest .items .group-image,
#sm-groups .list-group-newest .items .group-info {
display: inline-block;
}
#sm-groups .list-group-newest .items .group-info {
width: auto;
}
#sm-groups .items {
border-bottom: 1px dotted #B1DDE0;
padding-bottom: 5px;
margin-bottom: 5px;
}
#sm-groups .group-name a {
font-size: 18px;
font-weight: bold;
}
#sm-groups .count-username {
font-size: 12px;
color: #4D4D4D;
}
#sm-groups .description p {
color: #4D4D4D;
padding-top: 5px;
padding-bottom: 0;
line-height: 22px;
}
.sm-groups .social-profile .img-responsive {
display: inline-block;
}
.sm-groups-content .groups-messages {
padding: 20px;
}
.social-post .mediaPost {
padding-top: 10px;
padding-bottom: 5px;

@ -1560,7 +1560,7 @@ class MessageManager
api_get_path(
WEB_CODE_PATH
).'social/group_topics.php?action=delete&id='.$group_id.'&topic_id='.$topic['id'],
['class' => 'btn btn-default']
['class' => 'btn btn-primary']
);
}
@ -1581,7 +1581,7 @@ class MessageManager
$image = $user_sender_info['avatar'];
$user_info = '<div class="author"><img class="img-responsive img-circle" src="'.$image.'" alt="'.$name.'" width="64" height="64" title="'.$name.'" /></div>';
$user_info = '<div class="author"><img class="img-fluid rounded-circle" src="'.$image.'" alt="'.$name.'" width="64" height="64" title="'.$name.'" /></div>';
$user_info .= '<div class="name"><a href="'.api_get_path(
WEB_PATH
).'main/social/profile.php?u='.$topic['user_sender_id'].'">'.$name.'&nbsp;</a></div>';

@ -842,33 +842,27 @@ class SocialManager extends UserManager
if (in_array($show, $show_groups) && !empty($group_id)) {
// Group image
$userGroup = new UserGroup();
$group_info = $userGroup->get($group_id);
$groupInfo = $userGroup->get($group_id);
$userGroupImage = [
'big' => $userGroup->get_picture_group(
$group_id,
$group_info['picture'],
$groupInfo['picture'],
128,
GROUP_IMAGE_SIZE_BIG
),
'normal' => $userGroup->get_picture_group(
$group_id,
$group_info['picture'],
$groupInfo['picture'],
128,
GROUP_IMAGE_SIZE_MEDIUM
)
];
$template->assign('show_group', true);
$template->assign('group_id', $group_id);
$template->assign('group', $groupInfo);
$template->assign('avatar', $userGroupImage);
$template->assign(
'user_is_group_admin',
$userGroup->is_group_admin(
$group_id,
api_get_user_id()
)
);
} else {
$template->assign('show_group', false);
$template->assign('show_user', true);
@ -888,7 +882,7 @@ class SocialManager extends UserManager
);
}
$skillBlock = $template->get_template('social/avatar_block.tpl');
$skillBlock = $template->get_template('social/avatar_block.html.twig');
return $template->fetch($skillBlock);
}
@ -1875,7 +1869,20 @@ class SocialManager extends UserManager
$userInfo = api_get_user_info($userId, true, false, true, true);
$userGroup = new UserGroup();
$groupInfo = $userGroup->get($groupId);
$template->assign(
'user_is_group_admin',
$userGroup->is_group_admin(
$groupId,
api_get_user_id()
)
);
$template->assign('user', $userInfo);
$template->assign('group', $groupInfo);
$template->assign('social_avatar_block', $socialAvatarBlock);
$template->assign('profile_edition_link', $profileEditionLink);
// Added the link to export the vCard to the Template

@ -109,17 +109,17 @@ $role = 0;
$usergroup = new UserGroup();
if ($group_id != 0) {
$group_info = $usergroup->get($group_id);
$group_info['name'] = Security::remove_XSS($group_info['name']);
$group_info['description'] = Security::remove_XSS($group_info['description']);
$groupInfo = $usergroup->get($group_id);
$groupInfo['name'] = Security::remove_XSS($groupInfo['name']);
$groupInfo['description'] = Security::remove_XSS($groupInfo['description']);
$interbreadcrumb[] = ['url' => '#', 'name' => $group_info['name']];
$interbreadcrumb[] = ['url' => '#', 'name' => $groupInfo['name']];
if (isset($_GET['action']) && $_GET['action'] == 'leave') {
$user_leaved = intval($_GET['u']);
// I can "leave me myself"
if (api_get_user_id() == $user_leaved) {
if (UserGroup::canLeave($group_info)) {
if (UserGroup::canLeave($groupInfo)) {
$usergroup->delete_user_rel_group($user_leaved, $group_id);
Display::addFlash(
Display::return_message(get_lang('UserIsNotSubscribedToThisGroup'), 'confirmation', false)
@ -133,7 +133,7 @@ if ($group_id != 0) {
// we add a user only if is a open group
$user_join = intval($_GET['u']);
if (api_get_user_id() == $user_join && !empty($group_id)) {
if ($group_info['visibility'] == GROUP_PERMISSION_OPEN) {
if ($groupInfo['visibility'] == GROUP_PERMISSION_OPEN) {
$usergroup->add_user_to_group($user_join, $group_id);
Display::addFlash(
Display::return_message(get_lang('UserIsSubscribedToThisGroup'), 'confirmation', false)
@ -155,9 +155,9 @@ $create_thread_link = '';
$social_right_content = null;
$socialForum = '';
$group_info = $usergroup->get($group_id);
$group_info['name'] = Security::remove_XSS($group_info['name']);
$group_info['description'] = Security::remove_XSS($group_info['description']);
$groupInfo = $usergroup->get($group_id);
$groupInfo['name'] = Security::remove_XSS($groupInfo['name']);
$groupInfo['description'] = Security::remove_XSS($groupInfo['description']);
//Loading group information
if (isset($_GET['status']) && $_GET['status'] == 'sent') {
@ -167,13 +167,13 @@ if (isset($_GET['status']) && $_GET['status'] == 'sent') {
$is_group_member = $usergroup->is_group_member($group_id);
$role = $usergroup->get_user_group_role(api_get_user_id(), $group_id);
if (!$is_group_member && $group_info['visibility'] == GROUP_PERMISSION_CLOSED) {
if (!$is_group_member && $groupInfo['visibility'] == GROUP_PERMISSION_CLOSED) {
if ($role == GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER) {
$social_right_content .= Display::return_message(get_lang('YouAlreadySentAnInvitation'));
}
}
if ($is_group_member || $group_info['visibility'] == GROUP_PERMISSION_OPEN) {
if ($is_group_member || $groupInfo['visibility'] == GROUP_PERMISSION_OPEN) {
if (!$is_group_member) {
if (!in_array(
$role,
@ -211,7 +211,7 @@ if ($is_group_member || $group_info['visibility'] == GROUP_PERMISSION_OPEN) {
get_lang('YouShouldCreateATopic'),
$createThreadUrl,
[
'class' => 'ajax btn btn-primary',
'class' => 'btn btn-primary',
'title' => get_lang('ComposeMessage'),
'data-title' => get_lang('ComposeMessage'),
'data-size' => 'lg',
@ -231,7 +231,7 @@ if ($is_group_member || $group_info['visibility'] == GROUP_PERMISSION_OPEN) {
get_lang('NewTopic'),
$createThreadUrl,
[
'class' => 'ajax btn btn-default',
'class' => 'btn btn-primary',
'title' => get_lang('ComposeMessage'),
'data-title' => get_lang('ComposeMessage'),
'data-size' => 'lg',
@ -242,13 +242,6 @@ if ($is_group_member || $group_info['visibility'] == GROUP_PERMISSION_OPEN) {
$members = $usergroup->get_users_by_group($group_id, true);
$member_content = '';
// My friends
$friend_html = SocialManager::listMyFriendsBlock(
api_get_user_id(),
'',
''
);
// Members
if (count($members) > 0) {
if ($role == GROUP_USER_PERMISSION_ADMIN) {
@ -302,8 +295,10 @@ if ($is_group_member || $group_info['visibility'] == GROUP_PERMISSION_OPEN) {
if (!empty($create_thread_link)) {
$create_thread_link = Display::div($create_thread_link, ['class' => 'pull-right']);
}
$headers = [get_lang('Discussions'), get_lang('Members')];
$socialForum = Display::tabs($headers, [$content, $member_content], 'tabs');
$listTopic = $content;
$listMembers = $member_content;
} else {
// if I already sent an invitation message
if (!in_array(
@ -323,15 +318,16 @@ $tpl = new Template(null);
// Block Social Avatar
SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'groups', $group_id);
//Block Social Menu
$social_menu_block = SocialManager::getMenuSocial('groups', $group_id);
$tpl->setHelp('Groups');
$tpl->assign('create_link', $create_thread_link);
$tpl->assign('is_group_member', $is_group_member);
$tpl->assign('group_info', $group_info);
$tpl->assign('social_friend_block', $friend_html);
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->assign('social_forum', $socialForum);
$tpl->assign('list_members', $listMembers);
$tpl->assign('list_topic', $listTopic);
$tpl->assign('social_right_content', $social_right_content);
$social_layout = $tpl->get_template('social/group_view.tpl');
$tpl->display($social_layout);
$social_layout = $tpl->get_template('social/group_view.html.twig');
$content = $tpl->fetch($social_layout);
$tpl->assign('content', $content);
$tpl->display_one_col_template();

@ -114,4 +114,4 @@ if (api_get_setting('allow_message_tool') === 'true') {
$tpl->assign('content', $form->returnForm());
}
$tpl->displayBlankTemplateNoHeader();
$tpl->display_one_col_template();

@ -9,19 +9,9 @@
<a href="{{ avatar.big }}" class="expand-image">
<img src="{{ avatar.normal }}" class="img-fluid rounded-circle">
</a>
<div class="caption">
<h4 class="group-title">
<a href="{{ _p.web_main ~ 'social/group_view.php?id=' ~ group_id }}">{{ user_group.name }}</a>
</h4>
<p class="group-description">{{ user_group.description }}</p>
{% if user_is_group_admin %}
<div id="edit_image" class="buttom-subscribed">
<a class="btn btn-default" href="{{ _p.web_main ~ 'social/group_edit.php?id=' ~ group_id }}">
{{ 'EditGroup'|get_lang }}
</a>
</div>
<br />
{% endif %}
<div class="user-panel-info mb-10">
<p class="text-black">{{ group.name }}</p>
<small class="text-secondary">{{ 'Created'|trans }}: {{ group.created_at }} </small>
</div>
{% elseif show_user %}
<a href="{{ avatar.big }}" class="expand-image">

@ -1,44 +1,68 @@
{% extends "@ChamiloTheme/Layout/layout_one_col.html.twig" %}
{% import '@ChamiloTheme/Macros/box.html.twig' as macro %}
{% block content %}
{% autoescape false %}
<div class="row" xmlns="http://www.w3.org/1999/html">
<div class="col-md-3">
<div class="sm-groups">
<div class="col-md-4">
{% set avatar %}
{% include '@ChamiloTheme/Social/user_block.html.twig' %}
{{ social_menu_block }}
{{ macro.panel("SocialFriend" | get_lang, social_friend_block) }}
</div>
{% endset %}
{{ macro.panel('', avatar ) }}
</div>
<div class="col-md-9">
<div class="col-md-8">
<div class="sm-groups-content">
{{ create_link }}
{% if is_group_member == false %}
<div class="social-group-details-info">
{{ 'Privacy' | get_lang }}
{{ create_link }}
{% if group_info.visibility == 1 %}
{{ 'ThisIsAnOpenGroup' | get_lang }}
{% else %}
{{ 'ThisIsACloseGroup' | get_lang }}
{% endif %}
</div>
{% endif %}
{% if is_group_member == false %}
<div class="social-group-details-info">
{{ 'Privacy' | get_lang }}
{% if group_info.visibility == 1 %}
{{ 'ThisIsAnOpenGroup' | get_lang }}
{% else %}
{{ 'ThisIsACloseGroup' | get_lang }}
{% endif %}
</div>
{% endif %}
<div class="group-info">
<h2 class="title">{{ group_info.name }}</h2>
<p class="description">{{ group_info.description }}</p>
</div>
<div class="group-list">
{{ social_forum }}
<ul class="nav nav-tabs" id="topics" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="discussions-tab" data-toggle="tab" href="#discussions" role="tab" aria-controls="discussions" aria-selected="true">
{{ 'Discussions' | get_lang }}
</a>
</li>
<li class="nav-item">
<a class="nav-link" id="members-tab" data-toggle="tab" href="#members" role="tab" aria-controls="members" aria-selected="false">
{{ 'Members' | get_lang }}
</a>
</li>
</ul>
<div class="tab-content" id="topics-content">
<div class="tab-pane fade show active" id="discussions" role="tabpanel" aria-labelledby="discussions-tab">
{{ list_topic }}
</div>
<div class="tab-pane fade" id="members" role="tabpanel" aria-labelledby="members-tab">
{{ list_members }}
</div>
</div>
</div>
{{ social_right_content }}
<div id="display_response_id" class="col-md-5"></div>
<div id="display_response_id" class="col-md-12"></div>
{{ social_auto_extend_link }}
</div>
</div>
</div>
{% endautoescape %}

@ -5,11 +5,13 @@
{% autoescape false %}
<div class="row">
<div class="col-md-4">
<div class="card">
<div class="card-body">
{% include '@ChamiloTheme/Social/user_block.html.twig' %}
</div>
</div>
{% set avatar %}
{% include '@ChamiloTheme/Social/user_block.html.twig' %}
{% endset %}
{{ macro.panel('', avatar ) }}
{{ macro.panel("Search Users" | trans, social_search ) }}
{{ macro.panel("SocialFriend" | get_lang, social_friend_block ) }}

@ -2,20 +2,38 @@
{% autoescape false %}
<div class="profile">
{{ social_avatar_block }}
<div class="btn-toolbar justify-content-center">
<a href="{{ _p.web }}main/messages/new_message.php" title="{{ "Message" | trans }}" class="btn btn-primary btn-sm">
<i class="fas fa-envelope"></i>
</a>
<a href="{{ vcard_user_link }}" title="{{ "BusinessCard" | trans }}" class="btn btn-success btn-sm">
<i class="fas fa-address-card"></i>
</a>
{% if is_granted('ROLE_ADMIN') %}
<a href="{{ _p.web }}main/admin/user_edit.php?user_id={{ user.id }}" title="{{ "Edit" | trans }}" class="btn btn-light btn-sm">
<i class="fas fa-pencil-alt"></i>
{% if group is empty %}
<a href="{{ _p.web }}main/messages/new_message.php" title="{{ "Message" | trans }}" class="btn btn-primary btn-sm">
<i class="fas fa-envelope"></i>
</a>
<a href="{{ vcard_user_link }}" title="{{ "BusinessCard" | trans }}" class="btn btn-success btn-sm">
<i class="fas fa-address-card"></i>
</a>
{% if is_granted('ROLE_ADMIN') %}
<a href="{{ _p.web }}main/admin/user_edit.php?user_id={{ user.id }}" title="{{ "Edit" | trans }}" class="btn btn-light btn-sm">
<i class="fas fa-pencil-alt"></i>
</a>
{% endif %}
{% endif %}
{% if user_is_group_admin %}
<a class="btn btn-light btn-sm" title="{{ 'EditGroup'|get_lang }}" href="{{ _p.web_main ~ 'social/group_edit.php?id=' ~ group.id }}">
<i class="fas fa-pencil-alt"></i>
</a>
{% endif %}
</div>
<hr>
<div class="group-info">
{{ group.description }}
</div>
<ul class="list-user-data">
{% if show_full_profile %}
{% set skype_account = '' %}

Loading…
Cancel
Save