Actualización

This commit is contained in:
Xes
2025-04-10 12:49:05 +02:00
parent 4aff98e77b
commit 1cdd00920f
9151 changed files with 1800913 additions and 0 deletions

68
main/social/download.php Normal file
View File

@@ -0,0 +1,68 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file is responsible for passing requested file attachments from messages
* Html files are parsed to fix a few problems with URLs,
* but this code will hopefully be replaced soon by an Apache URL
* rewrite mechanism.
*
* @package chamilo.messages
*/
session_cache_limiter('public');
require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users();
// IMPORTANT to avoid caching of documents
header('Expires: Wed, 01 Jan 1990 00:00:00 GMT');
header('Cache-Control: public');
header('Pragma: no-cache');
$messageId = isset($_GET['message_id']) ? $_GET['message_id'] : 0;
$attachmentId = isset($_GET['attachment_id']) ? $_GET['attachment_id'] : 0;
$messageInfo = MessageManager::get_message_by_id($messageId);
$attachmentInfo = MessageManager::getAttachment($attachmentId);
if (empty($messageInfo) || empty($attachmentInfo)) {
api_not_allowed();
}
// Attachment belongs to the message?
if ($messageInfo['id'] != $attachmentInfo['message_id']) {
api_not_allowed();
}
// Do not process group items
if (!empty($messageInfo['group_id'])) {
api_not_allowed();
}
// Only process wall messages
if (!in_array($messageInfo['msg_status'], [MESSAGE_STATUS_WALL, MESSAGE_STATUS_WALL_POST, MESSAGE_STATUS_PROMOTED])) {
api_not_allowed();
}
$dir = UserManager::getUserPathById($messageInfo['user_sender_id'], 'system');
if (empty($dir)) {
api_not_allowed();
}
$file = $dir.'message_attachments/'.$attachmentInfo['path'];
$title = api_replace_dangerous_char($attachmentInfo['filename']);
if (Security::check_abs_path($file, $dir.'message_attachments/')) {
// launch event
Event::event_download($file);
$result = DocumentManager::file_send_for_download(
$file,
false,
$title
);
if ($result === false) {
api_not_allowed(true);
}
}
exit;

View File

@@ -0,0 +1,30 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';
$userId = isset($_GET['user_id']) ? (int) $_GET['user_id'] : 0;
$file = isset($_GET['file']) ? $_GET['file'] : '';
if (empty($userId) || empty($file)) {
exit;
}
$dir = UserManager::getUserPathById($userId, 'system');
if (empty($dir)) {
exit;
}
$file = $dir.'/my_files/'.$file;
$config = api_get_configuration_value('block_my_files_access');
if ($config) {
api_block_anonymous_users();
}
if (Security::check_abs_path($file, $dir.'my_files/')) {
$result = DocumentManager::file_send_for_download($file);
if ($result === false) {
exit;
}
}

144
main/social/friends.php Normal file
View File

@@ -0,0 +1,144 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.social
*
* @author Julio Montoya <gugli100@gmail.com>
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users();
if (api_get_setting('allow_social_tool') != 'true') {
api_not_allowed();
}
$this_section = SECTION_SOCIAL;
$htmlHeadXtra[] = '<script>
function delete_friend (element_div) {
id_image = $(element_div).attr("id");
user_id = id_image.split("_");
if (confirm("'.get_lang('Delete', '').'")) {
$.ajax({
contentType: "application/x-www-form-urlencoded",
type: "POST",
url: "'.api_get_path(WEB_AJAX_PATH).'social.ajax.php?a=delete_friend",
data: "delete_friend_id="+user_id[1],
success: function(datos) {
$("#user_card_"+user_id[1]).hide("slow");
}
});
}
}
function search_image_social() {
var name_search = $("#id_search_image").val();
$.ajax({
contentType: "application/x-www-form-urlencoded",
type: "POST",
url: "'.api_get_path(WEB_AJAX_PATH).'social.ajax.php?a=show_my_friends",
data: "search_name_q="+name_search,
success: function(data) {
$("#friends").html(data);
}
});
}
function show_icon_delete(element_html) {
elem_id=$(element_html).attr("id");
id_elem=elem_id.split("_");
ident="#img_"+id_elem[1];
$(ident).attr("src","'.Display::returnIconPath('delete.png').'");
$(ident).attr("alt","'.get_lang('Delete', '').'");
$(ident).attr("title","'.get_lang('Delete', '').'");
}
function hide_icon_delete(element_html) {
elem_id=$(element_html).attr("id");
id_elem=elem_id.split("_");
ident="#img_"+id_elem[1];
$(ident).attr("src","'.Display::returnIconPath('blank.gif').'");
$(ident).attr("alt","");
$(ident).attr("title","");
}
</script>';
$interbreadcrumb[] = ['url' => 'profile.php', 'name' => get_lang('SocialNetwork')];
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Friends')];
//Block Social Menu
$social_menu_block = SocialManager::show_social_menu('friends');
$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, USER_RELATION_TYPE_FRIEND, $name_search);
} else {
$friends = SocialManager::get_friends($user_id, USER_RELATION_TYPE_FRIEND);
}
$social_right_content = '<div class="col-md-12">';
if (count($friends) == 0) {
$social_right_content .= Display::return_message(
Display::tag('p', get_lang('NoFriendsInYourContactList')),
'warning',
false
);
$social_right_content .= Display::toolbarButton(
get_lang('TryAndFindSomeFriends'),
'search.php',
'search',
'success'
);
} else {
$filterForm = new FormValidator('filter');
$filterForm->addText(
'id_search_image',
get_lang('Search'),
false,
[
'onkeyup' => 'search_image_social()',
'id' => 'id_search_image',
]
);
$social_right_content .= $filterForm->returnForm();
$friend_html = '<div id="whoisonline">';
$friend_html .= '<div class="row">';
$number_friends = count($friends);
$j = 0;
for ($k = 0; $k < $number_friends; $k++) {
while ($j < $number_friends) {
if (isset($friends[$j])) {
$friend = $friends[$j];
$toolBar = '<button class="btn btn-danger" onclick="delete_friend(this)" id=img_'.$friend['friend_user_id'].'>
'.get_lang('Delete').'
</button>';
$url = api_get_path(WEB_PATH).'main/social/profile.php?u='.$friend['friend_user_id'];
$friend['user_info']['complete_name'] = Display::url($friend['user_info']['complete_name'], $url);
$friend_html .= Display::getUserCard($friend['user_info'], '', $toolBar);
}
$j++;
}
}
$friend_html .= '</div>';
$friend_html .= '</div>';
$social_right_content .= $friend_html;
}
$social_right_content .= '</div>';
$tpl = new Template(get_lang('Social'));
SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'friends');
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->assign('social_right_content', $social_right_content);
$social_layout = $tpl->get_template('social/friends.tpl');
$tpl->display($social_layout);

56
main/social/group_add.php Normal file
View File

@@ -0,0 +1,56 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.social
*
* @author Julio Montoya <gugli100@gmail.com>
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users();
if (api_get_setting('allow_social_tool') !== 'true') {
api_not_allowed(true);
}
if (api_get_setting('allow_students_to_create_groups_in_social') === 'false' && !api_is_allowed_to_edit()) {
api_not_allowed(true);
}
$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', []);
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[] = ['url' => 'home.php', 'name' => get_lang('Social')];
$interbreadcrumb[] = ['url' => 'groups.php', 'name' => get_lang('Groups')];
$interbreadcrumb[] = ['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, api_get_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);

View File

@@ -0,0 +1,69 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.social
*
* @author Julio Montoya <gugli100@gmail.com>
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users();
if (api_get_setting('allow_social_tool') !== 'true') {
api_not_allowed();
}
$this_section = SECTION_SOCIAL;
$group_id = isset($_GET['id']) ? intval($_GET['id']) : intval($_POST['id']);
$tool_name = get_lang('GroupEdit');
$usergroup = new UserGroup();
$group_data = $usergroup->get($group_id);
if (empty($group_data)) {
header('Location: group_view.php?id='.$group_id);
exit;
}
$interbreadcrumb[] = ['url' => 'groups.php', 'name' => get_lang('Groups')];
$interbreadcrumb[] = ['url' => 'group_view.php?id='.$group_id, 'name' => $group_data['name']];
// only group admins can edit the group
if (!$usergroup->is_group_admin($group_id)) {
api_not_allowed();
}
// Create the form
$form = new FormValidator('group_edit', 'post', '', '');
$form->addElement('hidden', 'id', $group_id);
$usergroup->setGroupType($usergroup::SOCIAL_CLASS);
$usergroup->setForm($form, 'edit', $group_data);
// Set default values
$form->setDefaults($group_data);
// Validate form
if ($form->validate()) {
$group = $form->exportValues();
$group['id'] = $group_id;
$group['group_type'] = $usergroup::SOCIAL_CLASS;
$usergroup->update($group);
Display::addFlash(Display::return_message(get_lang('GroupUpdated')));
header('Location: group_view.php?id='.$group_id);
exit();
}
$social_left_content = SocialManager::show_social_menu('group_edit', $group_id);
$social_right_content = $form->returnForm();
$tpl = new Template(get_lang('Edit'));
SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'groups', $group_id);
$tpl->setHelp('Groups');
$tpl->assign('social_menu_block', $social_left_content);
$tpl->assign('social_right_content', $social_right_content);
$social_layout = $tpl->get_template('social/add_groups.tpl');
$tpl->display($social_layout);

View File

@@ -0,0 +1,209 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.social
*
* @author Julio Montoya <gugli100@gmail.com>
*/
// resetting the course id
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users();
// setting breadcrumbs
$this_section = SECTION_SOCIAL;
// Database Table Definitions
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_group_rel_user = Database::get_main_table(TABLE_USERGROUP_REL_USER);
// setting the name of the tool
$tool_name = get_lang('SubscribeUsersToGroup');
$group_id = intval($_REQUEST['id']);
$usergroup = new UserGroup();
// todo @this validation could be in a function in group_portal_manager
if (empty($group_id)) {
api_not_allowed();
} else {
$group_info = $usergroup->get($group_id);
if (empty($group_info)) {
api_not_allowed();
}
//only admin or moderator can do that
if (!$usergroup->is_group_member($group_id)) {
api_not_allowed();
}
}
$interbreadcrumb[] = ['url' => 'groups.php', 'name' => get_lang('Groups')];
$interbreadcrumb[] = ['url' => 'group_view.php?id='.$group_id, 'name' => $group_info['name']];
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('SubscribeUsersToGroup')];
$form_sent = 0;
$errorMsg = $firstLetterUser = $firstLetterSession = '';
$UserList = $SessionList = [];
$users = $sessions = [];
$content = null;
if (isset($_POST['form_sent']) && $_POST['form_sent']) {
$form_sent = $_POST['form_sent'];
$user_list = isset($_POST['invitation']) ? $_POST['invitation'] : null;
$group_id = intval($_POST['id']);
if (!is_array($user_list)) {
$user_list = [];
}
if ($form_sent == 1) {
// invite this users
$result = $usergroup->add_users_to_groups(
$user_list,
[$group_id],
GROUP_USER_PERMISSION_PENDING_INVITATION
);
$title = get_lang('YouAreInvitedToGroup').' '.$group_info['name'];
$content = get_lang('YouAreInvitedToGroupContent').' '.$group_info['name'].' <br />';
$content .= get_lang('ToSubscribeClickInTheLinkBelow').' <br />';
$content .= '<a href="'.api_get_path(WEB_CODE_PATH).'social/invitations.php?accept='.$group_id.'">'.
get_lang('Subscribe').'</a>';
if (is_array($user_list) && count($user_list) > 0) {
//send invitation message
foreach ($user_list as $user_id) {
$result = MessageManager::send_message(
$user_id,
$title,
$content
);
}
Display::addFlash(Display::return_message(get_lang('InvitationSent')));
}
header('Location: '.api_get_self().'?id='.$group_id);
exit;
}
}
$nosessionUsersList = $sessionUsersList = [];
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
$friends = SocialManager::get_friends(api_get_user_id());
$suggest_friends = false;
$Users = [];
if (!$friends) {
$suggest_friends = true;
} else {
foreach ($friends as $friend) {
$group_friend_list = $usergroup->get_groups_by_user($friend['friend_user_id'], 0);
if (!empty($group_friend_list)) {
$friend_group_id = '';
if (isset($group_friend_list[$group_id]) &&
$group_friend_list[$group_id]['id'] == $group_id
) {
$friend_group_id = $group_id;
}
if (!isset($group_friend_list[$group_id]) ||
isset($group_friend_list[$group_id]) &&
$group_friend_list[$group_id]['relation_type'] == '') {
$Users[$friend['friend_user_id']] = [
'user_id' => $friend['friend_user_id'],
'firstname' => $friend['firstName'],
'lastname' => $friend['lastName'],
'username' => $friend['username'],
'group_id' => $friend_group_id,
];
}
} else {
$Users[$friend['friend_user_id']] = [
'user_id' => $friend['friend_user_id'],
'firstname' => $friend['firstName'],
'lastname' => $friend['lastName'],
'username' => $friend['username'],
'group_id' => null,
];
}
}
}
if (is_array($Users) && count($Users) > 0) {
foreach ($Users as $user) {
if ($user['group_id'] != $group_id) {
$nosessionUsersList[$user['user_id']] = api_get_person_name(
$user['firstname'],
$user['lastname']
);
}
}
}
$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 (count($nosessionUsersList) == 0) {
$friends = SocialManager::get_friends(api_get_user_id());
if ($friends == 0) {
$social_right_content .= Display::return_message(get_lang('YouNeedToHaveFriendsInYourSocialNetwork'), 'warning');
} else {
$social_right_content .= Display::return_message(get_lang('YouAlreadyInviteAllYourContacts'), 'info');
}
$social_right_content .= '<div>';
$social_right_content .= '<a href="search.php" class="btn btn-default btn-sm">'.Display::returnFontAwesomeIcon('search').' '.get_lang('TryAndFindSomeFriends').'</a>';
$social_right_content .= '</div>';
$social_right_content .= '<br />';
}
$form = new FormValidator('frm_invitation', 'post', api_get_self().'?id='.$group_id);
$form->addHidden('form_sent', 1);
$form->addHidden('id', $group_id);
$group_members_element = $form->addElement(
'advmultiselect',
'invitation',
get_lang('Friends'),
$nosessionUsersList
);
$form->addButtonSave(get_lang('InviteUsersToGroup'));
$social_right_content .= $form->returnForm();
// Current group members
$members = $usergroup->get_users_by_group(
$group_id,
false,
[GROUP_USER_PERMISSION_PENDING_INVITATION]
);
if (is_array($members) && count($members) > 0) {
foreach ($members as &$member) {
$image = UserManager::getUserPicture($member['id']);
$member['image'] = '<img class="img-circle" src="'.$image.'" width="50px" height="50px" />';
}
$userList = Display::return_sortable_grid(
'invitation_profile',
[],
$members,
['hide_navigation' => true, 'per_page' => 100],
[],
false,
[true, false, true, false]
);
$social_right_content .= Display::panel($userList, get_lang('UsersAlreadyInvited'));
}
$tpl = new Template(null);
SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'groups', $group_id);
$social_menu_block = SocialManager::show_social_menu('member_list', $group_id);
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->setHelp('Groups');
$tpl->assign('social_right_content', $social_right_content);
$social_layout = $tpl->get_template('social/add_groups.tpl');
$tpl->display($social_layout);

View File

@@ -0,0 +1,197 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.social
*
* @author Julio Montoya <gugli100@gmail.com>
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users();
if (api_get_setting('allow_social_tool') != 'true') {
api_not_allowed(true);
}
$this_section = SECTION_SOCIAL;
$group_id = intval($_GET['id']);
$userGroup = new UserGroup();
$user_role = '';
//todo @this validation could be in a function in group_portal_manager
if (empty($group_id)) {
api_not_allowed(true);
} else {
$group_info = $userGroup->get($group_id);
if (empty($group_info)) {
api_not_allowed(true);
}
$user_role = $userGroup->get_user_group_role(
api_get_user_id(),
$group_id
);
if (!in_array(
$user_role,
[
GROUP_USER_PERMISSION_ADMIN,
GROUP_USER_PERMISSION_MODERATOR,
GROUP_USER_PERMISSION_READER,
]
)
) {
api_not_allowed(true);
}
}
$interbreadcrumb[] = ['url' => 'home.php', 'name' => get_lang('Social')];
$interbreadcrumb[] = ['url' => 'groups.php', 'name' => get_lang('Groups')];
$interbreadcrumb[] = ['url' => 'group_view.php?id='.$group_id, 'name' => $group_info['name']];
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('MemberList')];
//if i'm a moderator
if (isset($_GET['action']) && $_GET['action'] == 'add') {
// we add a user only if is a open group
$user_join = intval($_GET['u']);
//if i'm a moderator
if ($userGroup->isGroupModerator($group_id)) {
$userGroup->update_user_role($user_join, $group_id);
Display::addFlash(Display::return_message(get_lang('UserAdded')));
}
}
if (isset($_GET['action']) && $_GET['action'] == 'delete') {
// we add a user only if is a open group
$user_join = intval($_GET['u']);
//if i'm a moderator
if ($userGroup->isGroupModerator($group_id)) {
$userGroup->delete_user_rel_group($user_join, $group_id);
Display::addFlash(Display::return_message(get_lang('UserDeleted')));
}
}
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 ($userGroup->is_group_admin($group_id)) {
$userGroup->update_user_role(
$user_moderator,
$group_id,
GROUP_USER_PERMISSION_MODERATOR
);
Display::addFlash(Display::return_message(get_lang('UserChangeToModerator')));
}
}
if (isset($_GET['action']) && $_GET['action'] == 'delete_moderator') {
// we add a user only if is a open group
$user_moderator = intval($_GET['u']);
//only group admins can do that
if ($userGroup->is_group_admin($group_id)) {
$userGroup->update_user_role(
$user_moderator,
$group_id,
GROUP_USER_PERMISSION_READER
);
Display::addFlash(Display::return_message(get_lang('UserChangeToReader')));
}
}
$users = $userGroup->get_users_by_group(
$group_id,
false,
[
GROUP_USER_PERMISSION_ADMIN,
GROUP_USER_PERMISSION_READER,
GROUP_USER_PERMISSION_MODERATOR,
],
0,
1000
);
$new_member_list = [];
$social_avatar_block = SocialManager::show_social_avatar_block(
'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) {
switch ($user['relation_type']) {
case GROUP_USER_PERMISSION_ADMIN:
$user['link'] = Display::return_icon(
'social_group_admin.png',
get_lang('Admin')
);
break;
case GROUP_USER_PERMISSION_READER:
if (in_array(
$user_role,
[
GROUP_USER_PERMISSION_ADMIN,
GROUP_USER_PERMISSION_MODERATOR,
]
)
) {
$user['link'] = '<a href="group_members.php?id='.$group_id.'&u='.$user['id'].'&action=delete">'.
Display::return_icon(
'delete.png',
get_lang('DeleteFromGroup')
).'</a>'.
'<a href="group_members.php?id='.$group_id.'&u='.$user['id'].'&action=set_moderator">'.
Display::return_icon(
'social_moderator_add.png',
get_lang('AddModerator')
).'</a>';
}
break;
case GROUP_USER_PERMISSION_PENDING_INVITATION:
$user['link'] = '<a href="group_members.php?id='.$group_id.'&u='.$user['id'].'&action=add">'.
Display::return_icon(
'pending_invitation.png',
get_lang('PendingInvitation')
).'</a>';
break;
case GROUP_USER_PERMISSION_MODERATOR:
$user['link'] = Display::return_icon(
'social_group_moderator.png',
get_lang('Moderator')
);
//only group admin can manage moderators
if ($user_role == GROUP_USER_PERMISSION_ADMIN) {
$user['link'] .= '<a href="group_members.php?id='.$group_id.'&u='.$user['id'].'&action=delete_moderator">'.
Display::return_icon(
'social_moderator_delete.png',
get_lang('DeleteModerator')
).'</a>';
}
break;
}
$userPicture = UserManager::getUserPicture($user['id']);
$user['image'] = '<img src="'.$userPicture.'" width="50px" height="50px" />';
$new_member_list[] = $user;
}
if (count($new_member_list) > 0) {
$social_right_content .= Display::return_sortable_grid(
'list_members',
[],
$new_member_list,
['hide_navigation' => true, 'per_page' => 100],
[],
false,
[true, false, true, false, false, true, true]
);
}
$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_right_content', $social_right_content);
$social_layout = $tpl->get_template('social/home.tpl');
$tpl->display($social_layout);

View File

@@ -0,0 +1,211 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.social
*
* @author Julio Montoya <gugli100@gmail.com>
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users();
if (api_get_setting('allow_social_tool') != 'true') {
api_not_allowed(true);
}
$group_id = intval($_GET['id']);
$topic_id = isset($_GET['topic_id']) ? intval($_GET['topic_id']) : null;
$message_id = isset($_GET['msg_id']) ? intval($_GET['msg_id']) : null;
$usergroup = new UserGroup();
$is_member = false;
//todo @this validation could be in a function in group_portal_manager
if (empty($group_id)) {
api_not_allowed(true);
} else {
$group_info = $usergroup->get($group_id);
if (empty($group_info)) {
api_not_allowed(true);
}
$is_member = $usergroup->is_group_member($group_id);
if ($group_info['visibility'] == GROUP_PERMISSION_CLOSED && !$is_member) {
api_not_allowed(true);
}
}
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') {
$group_role = $usergroup->get_user_group_role(api_get_user_id(), $group_id);
if (api_is_platform_admin() ||
in_array($group_role, [GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_MODERATOR])
) {
$usergroup->delete_topic($group_id, $topic_id);
Display::addFlash(Display::return_message(get_lang('Deleted')));
header("Location: group_view.php?id=$group_id");
exit;
}
}
// My friends
$friend_html = SocialManager::listMyFriendsBlock(
$user_id
);
$content = null;
$social_right_content = '';
if (isset($_POST['action'])) {
$title = isset($_POST['title']) ? $_POST['title'] : null;
$content = $_POST['content'];
$group_id = intval($_POST['group_id']);
$parent_id = intval($_POST['parent_id']);
if ($_POST['action'] == 'reply_message_group') {
$title = cut($content, 50);
}
if ($_POST['action'] == 'edit_message_group') {
$edit_message_id = intval($_POST['message_id']);
$res = MessageManager::send_message(
0,
$title,
$content,
$_FILES,
[],
$group_id,
$parent_id,
$edit_message_id,
0,
$topic_id
);
} else {
if ($_POST['action'] == 'add_message_group' && !$is_member) {
api_not_allowed(true);
}
$res = MessageManager::send_message(
0,
$title,
$content,
$_FILES,
[],
$group_id,
$parent_id,
0,
$topic_id
);
}
// display error messages
if (!$res) {
Display::addFlash(Display::return_message(get_lang('Error'), 'error'));
}
$topic_id = isset($_GET['topic_id']) ? intval($_GET['topic_id']) : null;
if ($_POST['action'] == 'add_message_group') {
$topic_id = $res;
}
$message_id = $res;
}
$htmlHeadXtra[] = '<script>
var counter_image = 1;
function remove_image_form(id_elem1) {
var elem1 = document.getElementById(id_elem1);
elem1.parentNode.removeChild(elem1);
counter_image--;
var filepaths = document.getElementById("filepaths");
if (filepaths.childNodes.length < 3) {
var link_attach = document.getElementById("link-more-attach");
if (link_attach) {
link_attach.innerHTML=\'<a href="javascript://" onclick="return add_image_form()">'.get_lang('AddOneMoreFile').'</a>\';
}
}
}
function add_image_form() {
// Multiple filepaths for image form
var filepaths = document.getElementById("filepaths");
if (document.getElementById("filepath_"+counter_image)) {
counter_image = counter_image + 1;
} else {
counter_image = counter_image;
}
var elem1 = document.createElement("div");
elem1.setAttribute("id","filepath_"+counter_image);
filepaths.appendChild(elem1);
id_elem1 = "filepath_"+counter_image;
id_elem1 = "\'"+id_elem1+"\'";
document.getElementById("filepath_"+counter_image).innerHTML = "<input type=\"file\" name=\"attach_"+counter_image+"\" size=\"20\" />&nbsp;<a href=\"javascript:remove_image_form("+id_elem1+")\"><img src=\"'.Display::returnIconPath('delete.png').'\"></a>";
if (filepaths.childNodes.length == 3) {
var link_attach = document.getElementById("link-more-attach");
if (link_attach) {
link_attach.innerHTML="";
}
}
}
$(function() {
if ($("#msg_'.$message_id.'").length) {
$("html,body").animate({
scrollTop: $("#msg_'.$message_id.'").offset().top
})
}
$(\'.group_message_popup\').on(\'click\', function() {
var url = this.href;
var dialog = $("#dialog");
if ($("#dialog").length == 0) {
dialog = $(\'<div id="dialog" style="display:hidden"></div>\').appendTo(\'body\');
}
// load remote content
dialog.load(
url,
{},
function(responseText, textStatus, XMLHttpRequest) {
dialog.dialog({
modal : true,
width : 520,
height : 400,
});
});
//prevent the browser to follow the link
return false;
});
});
</script>';
$this_section = SECTION_SOCIAL;
$interbreadcrumb[] = ['url' => 'groups.php', 'name' => get_lang('Groups')];
$interbreadcrumb[] = ['url' => 'group_view.php?id='.$group_id, 'name' => Security::remove_XSS($group_info['name'])];
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Discussions')];
$social_left_content = SocialManager::show_social_menu('member_list', $group_id);
$show_message = null;
if (!empty($show_message)) {
$social_right_content .= Display::return_message($show_message, 'confirmation');
}
$group_message = MessageManager::display_message_for_group(
$group_id,
$topic_id,
$is_member,
$message_id
);
$social_menu_block = SocialManager::show_social_menu('member_list', $group_id);
$tpl = new Template(null);
$tpl->setHelp('Groups');
// Block Social Avatar
SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'groups', $group_id);
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->assign('social_friend_block', $friend_html);
$tpl->assign('group_message', $group_message);
$tpl->assign('social_right_content', $social_right_content);
$social_layout = $tpl->get_template('social/groups_topics.tpl');
$tpl->display($social_layout);

347
main/social/group_view.php Normal file
View File

@@ -0,0 +1,347 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.social
*
* @author Julio Montoya <gugli100@gmail.com>
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users();
if (api_get_setting('allow_social_tool') !== 'true') {
api_not_allowed();
}
$this_section = SECTION_SOCIAL;
// prepare anchor for message group topic
$anchor = '';
if (isset($_GET['anchor_topic'])) {
$anchor = Security::remove_XSS($_GET['anchor_topic']);
} else {
$match = 0;
$param_names = array_keys($_GET);
foreach ($param_names as $param) {
if (preg_match('/^items_(\d)_page_nr$/', $param, $match)) {
break;
}
}
if (isset($match[1])) {
$anchor = 'topic_'.$match[1];
}
}
$htmlHeadXtra[] = '<script>
var counter_image = 1;
function remove_image_form(id_elem1) {
var elem1 = document.getElementById(id_elem1);
elem1.parentNode.removeChild(elem1);
counter_image--;
var filepaths = document.getElementById("filepaths");
if (filepaths.childNodes.length < 3) {
var link_attach = document.getElementById("link-more-attach");
if (link_attach) {
link_attach.innerHTML=\'<a href="javascript://" class="btn btn-default" onclick="return add_image_form()">'.get_lang('AddOneMoreFile').'</a>\';
}
}
}
function add_image_form() {
// Multiple filepaths for image form
var filepaths = document.getElementById("filepaths");
if (document.getElementById("filepath_"+counter_image)) {
counter_image = counter_image + 1;
} else {
counter_image = counter_image;
}
var elem1 = document.createElement("div");
elem1.setAttribute("id","filepath_"+counter_image);
filepaths.appendChild(elem1);
id_elem1 = "filepath_"+counter_image;
id_elem1 = "\'"+id_elem1+"\'";
document.getElementById("filepath_"+counter_image).innerHTML = "\n\
<input type=\"file\" name=\"attach_"+counter_image+"\" size=\"20\" />\n\
<a href=\"javascript:remove_image_form("+id_elem1+")\">\n\
<img src=\"'.Display::returnIconPath('delete.gif').'\">\n\
</a>\n\
";
if (filepaths.childNodes.length == 3) {
var link_attach = document.getElementById("link-more-attach");
if (link_attach) {
link_attach.innerHTML="";
}
}
}
$.fn.modal.Constructor.prototype.enforceFocus = function() {
modal_this = this
$(document).on("focusin.modal", function (e) {
if (modal_this.$element[0] !== e.target && !modal_this.$element.has(e.target).length
&& !$(e.target.parentNode).hasClass("cke_dialog_ui_input_select")
&& !$(e.target.parentNode).hasClass("cke_dialog_ui_input_text")) {
modal_this.$element.focus()
}
})
};
</script>';
$allowed_views = ['mygroups', 'newest', 'pop'];
$content = null;
if (isset($_GET['view']) && in_array($_GET['view'], $allowed_views)) {
if ($_GET['view'] == 'mygroups') {
$interbreadcrumb[] = ['url' => 'groups.php', 'name' => get_lang('Groups')];
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('MyGroups')];
} elseif ($_GET['view'] == 'newest') {
$interbreadcrumb[] = ['url' => 'groups.php', 'name' => get_lang('Groups')];
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Newest')];
} else {
$interbreadcrumb[] = ['url' => 'groups.php', 'name' => get_lang('Groups')];
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Popular')];
}
} else {
$interbreadcrumb[] = ['url' => 'groups.php', 'name' => get_lang('Groups')];
if (!isset($_GET['id'])) {
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('GroupList')];
} else {
//$interbreadcrumb[]= array ('url' =>'#','name' => get_lang('Group'));
}
}
// getting group information
$group_id = isset($_GET['id']) ? intval($_GET['id']) : null;
$relation_group_title = '';
$role = 0;
$usergroup = new UserGroup();
if ($group_id != 0) {
$groupInfo = $usergroup->get($group_id);
$groupInfo['name'] = Security::remove_XSS($groupInfo['name']);
$groupInfo['description'] = Security::remove_XSS($groupInfo['description']);
$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($groupInfo)) {
$usergroup->delete_user_rel_group($user_leaved, $group_id);
Display::addFlash(
Display::return_message(get_lang('UserIsNotSubscribedToThisGroup'), 'confirmation', false)
);
}
}
}
// add a user to a group if its open
if (isset($_GET['action']) && $_GET['action'] == 'join') {
// 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 ($groupInfo['visibility'] == GROUP_PERMISSION_OPEN) {
$usergroup->add_user_to_group($user_join, $group_id);
Display::addFlash(
Display::return_message(get_lang('UserIsSubscribedToThisGroup'), 'confirmation', false)
);
} else {
$usergroup->add_user_to_group(
$user_join,
$group_id,
GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER
);
Display::addFlash(
Display::return_message(get_lang('InvitationSent'), 'confirmation', false)
);
}
}
}
}
$create_thread_link = '';
$social_right_content = null;
$socialForum = '';
$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') {
$social_right_content .= Display::return_message(get_lang('MessageHasBeenSent'), 'confirmation', false);
}
$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 && $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 || $groupInfo['visibility'] == GROUP_PERMISSION_OPEN) {
if (!$is_group_member) {
if (!in_array(
$role,
[GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER, GROUP_USER_PERMISSION_PENDING_INVITATION]
)) {
$social_right_content .= '<div class="group-tool">';
$social_right_content .= '<div class="pull-right">';
$social_right_content .= '<a class="btn btn-default btn-sm" href="group_view.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.
get_lang('JoinGroup').'</a>';
$social_right_content .= '</div>';
$social_right_content .= '</div>';
} elseif ($role == GROUP_USER_PERMISSION_PENDING_INVITATION) {
$social_right_content .= '<div class="group-tool">';
$social_right_content .= '<div class="pull-right">';
$social_right_content .= '<a class="btn btn-default btn-sm" href="group_view.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.
Display::returnFontAwesomeIcon('envelope').' '.
get_lang('YouHaveBeenInvitedJoinNow').'</a>';
}
$social_right_content .= '</div>';
$social_right_content .= '</div>';
}
$content = MessageManager::display_messages_for_group($group_id);
if ($is_group_member) {
if (empty($content)) {
$createThreadUrl = api_get_path(WEB_CODE_PATH)
.'social/message_for_group_form.inc.php?'
.http_build_query([
'view_panel' => 1,
'user_friend' => api_get_user_id(),
'group_id' => $group_id,
'action' => 'add_message_group',
]);
$create_thread_link = Display::url(
Display::returnFontAwesomeIcon('commenting').' '.
get_lang('YouShouldCreateATopic'),
$createThreadUrl,
[
'class' => 'ajax btn btn-primary',
'title' => get_lang('ComposeMessage'),
'data-title' => get_lang('ComposeMessage'),
'data-size' => 'lg',
]
);
} else {
$createThreadUrl = api_get_path(WEB_CODE_PATH)
.'social/message_for_group_form.inc.php?'
.http_build_query([
'view_panel' => 1,
'user_friend' => api_get_user_id(),
'group_id' => $group_id,
'action' => 'add_message_group',
]);
$create_thread_link = Display::url(
Display::returnFontAwesomeIcon('commenting').' '.
get_lang('NewTopic'),
$createThreadUrl,
[
'class' => 'ajax btn btn-default',
'title' => get_lang('ComposeMessage'),
'data-title' => get_lang('ComposeMessage'),
'data-size' => 'lg',
]
);
}
}
$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) {
$member_content .= '<div class="group-tool">';
$member_content .= '<div class="pull-right">';
$member_content .= Display::url(
Display::returnFontAwesomeIcon('pencil').' '.get_lang('EditMembersList'),
'group_members.php?id='.$group_id,
['class' => 'btn btn-default btn-sm', 'title' => get_lang('EditMembersList')]
);
$member_content .= '</div>';
$member_content .= '</div>';
}
$member_content .= '<div class="user-list">';
$member_content .= '<div class="row">';
foreach ($members as $member) {
// if is a member
if (in_array(
$member['relation_type'],
[GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_READER, GROUP_USER_PERMISSION_MODERATOR]
)) {
//add icons
if ($member['relation_type'] == GROUP_USER_PERMISSION_ADMIN) {
$icon = Display::return_icon('social_group_admin.png', get_lang('Admin'));
} elseif ($member['relation_type'] == GROUP_USER_PERMISSION_MODERATOR) {
$icon = Display::return_icon('social_group_moderator.png', get_lang('Moderator'));
} else {
$icon = '';
}
$userPicture = UserManager::getUserPicture($member['id']);
$member_content .= '<div class="col-md-3">';
$member_content .= '<div class="items-user">';
$member_name = Display::url(
api_get_person_name(
cut($member['user_info']['firstname'], 15),
cut($member['user_info']['lastname'], 15)
).'&nbsp;'.$icon,
$member['user_info']['profile_url']
);
$member_content .= Display::div('<img class="img-circle" src="'.$userPicture.'"/>', ['class' => 'avatar']);
$member_content .= Display::div($member_name, ['class' => 'name']);
$member_content .= '</div>';
$member_content .= '</div>';
}
}
$member_content .= '</div>';
$member_content .= '</div>';
}
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');
} else {
// if I already sent an invitation message
if (!in_array(
$role,
[
GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER,
GROUP_USER_PERMISSION_PENDING_INVITATION,
]
)) {
$social_right_content .= '<a class="btn" href="group_view.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.get_lang('JoinGroup').'</a>';
} elseif ($role == GROUP_USER_PERMISSION_PENDING_INVITATION) {
$social_right_content .= '<a class="btn" href="group_view.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.get_lang('YouHaveBeenInvitedJoinNow').'</a>';
}
}
$tpl = new Template(null);
// Block Social Avatar
SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'groups', $group_id);
$social_menu_block = SocialManager::show_social_menu('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', $groupInfo);
$tpl->assign('social_friend_block', $friend_html);
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->assign('social_forum', $socialForum);
$tpl->assign('social_right_content', $social_right_content);
$social_layout = $tpl->get_template('social/group_view.tpl');
$tpl->display($social_layout);

View File

@@ -0,0 +1,122 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.social
*
* @author Julio Montoya <gugli100@gmail.com>
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users();
if (api_get_setting('allow_social_tool') != 'true') {
api_not_allowed();
}
$this_section = SECTION_SOCIAL;
$group_id = intval($_GET['id']);
$usergroup = new UserGroup();
//todo @this validation could be in a function in group_portal_manager
if (empty($group_id)) {
api_not_allowed();
} else {
$group_info = $usergroup->get($group_id);
if (empty($group_info)) {
api_not_allowed();
}
//only admin or moderator can do that
$user_role = $usergroup->get_user_group_role(api_get_user_id(), $group_id);
if (!in_array($user_role, [GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_MODERATOR])) {
api_not_allowed();
}
}
$interbreadcrumb[] = ['url' => 'groups.php', 'name' => get_lang('Groups')];
$interbreadcrumb[] = ['url' => 'group_view.php?id='.$group_id, 'name' => $group_info['name']];
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('WaitingList')];
// Group information
$admins = $usergroup->get_users_by_group(
$group_id,
true,
[GROUP_USER_PERMISSION_ADMIN],
0,
1000
);
$show_message = '';
if (isset($_GET['action']) && $_GET['action'] == 'accept') {
// we add a user only if is a open group
$user_join = intval($_GET['u']);
//if i'm a moderator
if ($usergroup->isGroupModerator($group_id)) {
$usergroup->update_user_role($user_join, $group_id);
Display::addFlash(Display::return_message(get_lang('UserAdded')));
}
}
if (isset($_GET['action']) && $_GET['action'] == 'deny') {
// we add a user only if is a open group
$user_join = intval($_GET['u']);
//if i'm a moderator
if ($usergroup->isGroupModerator($group_id)) {
$usergroup->delete_user_rel_group($user_join, $group_id);
Display::addFlash(Display::return_message(get_lang('UserDeleted')));
}
}
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 ($usergroup->is_group_admin($group_id)) {
$usergroup->update_user_role($user_moderator, $group_id, GROUP_USER_PERMISSION_MODERATOR);
Display::addFlash(Display::return_message(get_lang('UserChangeToModerator')));
}
}
$users = $usergroup->get_users_by_group(
$group_id,
true,
[GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER],
0,
1000
);
$new_member_list = [];
$social_left_content = SocialManager::show_social_menu('waiting_list', $group_id);
// Display form
foreach ($users as $user) {
$userId = $user['user_info']['user_id'];
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='.$userId.'&action=accept">'.
Display::return_icon('invitation_friend.png', get_lang('AddNormalUser')).'</a>';
$user['link'] .= '<a href="group_waiting_list.php?id='.$group_id.'&u='.$userId.'&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='.$userId.'&action=deny">'.
Display::return_icon('user_delete.png', get_lang('DenyEntry')).'</a>';
break;
}
$new_member_list[] = $user;
}
$social_right_content = '';
if (empty($new_member_list) > 0) {
$social_right_content = Display::return_message(get_lang('ThereAreNotUsersInTheWaitingList'));
}
$tpl = new Template(null);
SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'groups', $group_id);
$social_menu_block = SocialManager::show_social_menu('member_list', $group_id);
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->setHelp('Groups');
$tpl->assign('members', $new_member_list);
$tpl->assign('social_right_content', $social_right_content);
$social_layout = $tpl->get_template('social/group_waiting_list.tpl');
$tpl->display($social_layout);

388
main/social/groups.php Normal file
View File

@@ -0,0 +1,388 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.social
*
* @author Julio Montoya <gugli100@gmail.com>
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users();
if (api_get_setting('allow_social_tool') !== 'true') {
api_not_allowed();
}
$join_url = '';
$this_section = SECTION_SOCIAL;
$allowed_views = ['mygroups', 'newest', 'pop'];
$content = null;
if (isset($_GET['view']) && in_array($_GET['view'], $allowed_views)) {
if ($_GET['view'] === 'mygroups') {
$interbreadcrumb[] = ['url' => 'groups.php', 'name' => get_lang('Groups')];
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('MyGroups')];
} elseif ($_GET['view'] === 'newest') {
$interbreadcrumb[] = ['url' => 'groups.php', 'name' => get_lang('Groups')];
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Newest')];
} else {
$interbreadcrumb[] = ['url' => 'groups.php', 'name' => get_lang('Groups')];
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Popular')];
}
} else {
$interbreadcrumb[] = ['url' => 'groups.php', 'name' => get_lang('Groups')];
if (!isset($_GET['id'])) {
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('GroupList')];
}
}
// getting group information
$relation_group_title = '';
$my_group_role = 0;
$usergroup = new UserGroup();
$create_thread_link = '';
$show_menu = 'browse_groups';
if (isset($_GET['view']) && $_GET['view'] == 'mygroups') {
$show_menu = $_GET['view'];
}
$social_right_content = null;
// My groups
$results = $usergroup->get_groups_by_user(api_get_user_id(), 0);
$grid_my_groups = [];
$my_group_list = [];
if (is_array($results) && count($results) > 0) {
foreach ($results as $result) {
$id = $result['id'];
$result['name'] = Security::remove_XSS($result['name'], STUDENT, true);
$result['description'] = Security::remove_XSS($result['description'], STUDENT, true);
$my_group_list[] = $id;
$name = cut($result['name'], GROUP_TITLE_LENGTH, true);
if ($result['relation_type'] == GROUP_USER_PERMISSION_ADMIN) {
$name .= ' '.Display::return_icon(
'social_group_admin.png',
get_lang('Admin'),
['style' => 'vertical-align:middle']
);
} elseif ($result['relation_type'] == GROUP_USER_PERMISSION_MODERATOR) {
$name .= ' '.Display::return_icon(
'social_group_moderator.png',
get_lang('Moderator'),
['style' => 'vertical-align:middle']
);
}
$url = '<a href="group_view.php?id='.$id.'">'.$name.'</a>';
$count_users_group = count(
$usergroup->get_users_by_group(
$id,
false,
[
GROUP_USER_PERMISSION_ADMIN,
GROUP_USER_PERMISSION_READER,
GROUP_USER_PERMISSION_MODERATOR,
],
0,
1000
)
);
if ($count_users_group == 1) {
$count_users_group = $count_users_group.' '.get_lang('Member');
} else {
$count_users_group = $count_users_group.' '.get_lang('Members');
}
$picture = $usergroup->get_picture_group(
$result['id'],
$result['picture'],
80
);
$result['picture'] = '<img class="social-groups-image" src="'.$picture['file'].'" />';
$members = Display::returnFontAwesomeIcon('user').$count_users_group;
$html = '<div class="row">';
$html .= '<div class="col-md-2">';
$html .= $result['picture'];
$html .= '</div>';
$html .= '<div class="col-md-10">';
$html .= '<div class="title-groups">';
$html .= Display::tag('h5', $url);
$html .= '</div>';
$html .= '<div class="members-groups">'.$members.'</div>';
if ($result['description'] != '') {
$html .= '<div class="description-groups">'.cut($result['description'], 100, true).'</div>';
} else {
$html .= '';
}
$html .= '</div>';
$html .= '</div>';
$grid_item_2 = $html;
$grid_my_groups[] = [$grid_item_2];
}
}
// Newest groups
$results = $usergroup->get_groups_by_age(4, false);
$grid_newest_groups = [];
foreach ($results as $result) {
$result['name'] = Security::remove_XSS($result['name'], STUDENT, true);
$result['description'] = Security::remove_XSS($result['description'], STUDENT, true);
$id = $result['id'];
$name = cut($result['name'], GROUP_TITLE_LENGTH, true);
$count_users_group = count(
$usergroup->get_users_by_group(
$id,
false,
[GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_READER, GROUP_USER_PERMISSION_MODERATOR],
0,
1000
)
);
if ($count_users_group == 1) {
$count_users_group = $count_users_group.' '.get_lang('Member');
} else {
$count_users_group = $count_users_group.' '.get_lang('Members');
}
$url = '<a href="group_view.php?id='.$id.'">'.$name.'</a>';
$picture = $usergroup->get_picture_group($result['id'], $result['picture'], 80);
$result['picture'] = '<img class="social-groups-image" src="'.$picture['file'].'" />';
$members = Display::returnFontAwesomeIcon('user').$count_users_group;
$html = '<div class="row">';
$html .= '<div class="col-md-2">';
$html .= $result['picture'];
$html .= '</div>';
$html .= '<div class="col-md-10">';
$html .= '<div class="title-groups">';
$html .= Display::tag('h5', $url);
$html .= '</div>';
$html .= '<div class="members-groups">'.$members.'</div>';
if ($result['description'] != '') {
$html .= '<div class="description-groups">'.cut($result['description'], 100, true).'</div>';
}
// Avoiding my groups
if (!in_array($id, $my_group_list)) {
$html .= '<a class="btn btn-primary" href="group_view.php?id='.$id.'&action=join&u='.api_get_user_id().'">'.
get_lang('JoinGroup').'</a> ';
}
$html .= '<div class="group-actions" >'.$join_url.'</div>';
$html .= '</div>';
$html .= '</div>';
$grid_item_2 = $html;
$grid_newest_groups[] = [$grid_item_2];
}
// Pop groups
$results = $usergroup->get_groups_by_popularity(4, false);
$grid_pop_groups = [];
if (is_array($results) && count($results) > 0) {
foreach ($results as $result) {
$result['name'] = Security::remove_XSS($result['name'], STUDENT, true);
$result['description'] = Security::remove_XSS($result['description'], STUDENT, true);
$id = $result['id'];
$name = cut($result['name'], GROUP_TITLE_LENGTH, true);
$count_users_group = count(
$usergroup->get_users_by_group(
$id,
false,
[
GROUP_USER_PERMISSION_ADMIN,
GROUP_USER_PERMISSION_READER,
GROUP_USER_PERMISSION_MODERATOR,
],
0,
1000
)
);
if ($count_users_group == 1) {
$count_users_group = $count_users_group.' '.get_lang('Member');
} else {
$count_users_group = $count_users_group.' '.get_lang('Members');
}
$url = '<a href="group_view.php?id='.$id.'">'.$name.'</a>';
$picture = $usergroup->get_picture_group($result['id'], $result['picture'], 80);
$result['picture'] = '<img class="social-groups-image" src="'.$picture['file'].'" />';
$html = '<div class="row">';
$html .= '<div class="col-md-2">';
$html .= $result['picture'];
$html .= '</div>';
$html .= '<div class="col-md-10">';
$html .= '<div class="title-groups">';
$html .= Display::tag('h5', $url);
$html .= '</div>';
$html .= '<div class="members-groups">'.$members.'</div>';
if ($result['description'] != '') {
$html .= '<div class="description-groups">'.cut($result['description'], 100, true).'</div>';
} else {
$html .= '';
}
// Avoiding my groups
if (!in_array($id, $my_group_list)) {
$html .= '<a class="btn btn-primary" href="group_view.php?id='.$id.'&action=join&u='.api_get_user_id().'">'.
get_lang('JoinGroup').'</a> ';
}
$html .= '<div class="group-actions" >'.$join_url.'</div>';
$html .= '</div>';
$html .= '</div>';
$grid_item_2 = $html;
$grid_pop_groups[] = [$grid_item_2];
}
}
// Display groups (newest, mygroups, pop)
$query_vars = [];
$newest_content = $popular_content = $my_group_content = null;
if (isset($_GET['view']) && in_array($_GET['view'], $allowed_views)) {
$view_group = $_GET['view'];
switch ($view_group) {
case 'mygroups':
if (count($grid_my_groups) > 0) {
$my_group_content = Display::return_sortable_grid(
'mygroups',
[],
$grid_my_groups,
['hide_navigation' => true, 'per_page' => 2],
$query_vars,
false,
[true, true, true, false]
);
}
if (api_get_setting('allow_students_to_create_groups_in_social') == 'true') {
$create_group_item =
'<a class="btn btn-default" href="'.api_get_path(WEB_PATH).'main/social/group_add.php">'.
get_lang('CreateASocialGroup').'</a>';
} else {
if (api_is_allowed_to_edit(null, true)) {
$create_group_item =
'<a class="btn btn-default" href="'.api_get_path(WEB_PATH).'main/social/group_add.php">'.
get_lang('CreateASocialGroup').'</a>';
}
}
break;
case 'newest':
if (count($grid_newest_groups) > 0) {
$newest_content = Display::return_sortable_grid(
'newest',
[],
$grid_newest_groups,
['hide_navigation' => true, 'per_page' => 100],
$query_vars,
false,
[true, true, true, false]
);
}
break;
default:
if (count($grid_pop_groups) > 0) {
$popular_content = Display::return_sortable_grid(
'popular',
[],
$grid_pop_groups,
['hide_navigation' => true, 'per_page' => 100],
$query_vars,
false,
[true, true, true, true, true]
);
}
break;
}
} else {
$my_group_content = null;
if (count($grid_my_groups) > 0) {
$my_group_content = Display::return_sortable_grid(
'mygroups',
[],
$grid_my_groups,
['hide_navigation' => true, 'per_page' => 2],
$query_vars,
false,
[true, true, true, false]
);
} else {
$my_group_content = '<span class="muted">'.get_lang('GroupNone').'</span>';
}
if (api_get_setting('allow_students_to_create_groups_in_social') == 'true') {
$create_group_item =
'<a class="btn btn-default" href="'.api_get_path(WEB_PATH).'main/social/group_add.php">'.
get_lang('CreateASocialGroup').'</a>';
} else {
if (api_is_allowed_to_edit(null, true)) {
$create_group_item =
'<a class="btn btn-default" href="'.api_get_path(WEB_PATH).'main/social/group_add.php">'.
get_lang('CreateASocialGroup').'</a>';
}
}
if (count($grid_newest_groups) > 0) {
$newest_content = Display::return_sortable_grid(
'mygroups',
[],
$grid_newest_groups,
['hide_navigation' => true, 'per_page' => 100],
$query_vars,
false,
[true, true, true, false]
);
} else {
$newest_content = '<div class="muted">'.get_lang('GroupNone').'</div>';
}
if (count($grid_pop_groups) > 0) {
$popular_content = Display::return_sortable_grid(
'mygroups',
[],
$grid_pop_groups,
['hide_navigation' => true, 'per_page' => 100],
$query_vars,
false,
[true, true, true, true, true]
);
} else {
$popular_content = '<div class="muted">'.get_lang('GroupNone').'</div>';
}
}
if (!empty($create_group_item)) {
$social_right_content .= Display::page_subheader($create_group_item);
}
$headers = [get_lang('Newest'), get_lang('Popular'), get_lang('MyGroups')];
$social_right_content .= Display::tabs(
$headers,
[$newest_content, $popular_content, $my_group_content],
'tab_browse'
);
$tpl = new Template(null);
// Block Social Avatar
SocialManager::setSocialUserBlock($tpl, api_get_user_id(), $show_menu);
$show_menu = 'browse_groups';
if (isset($_GET['view']) && $_GET['view'] == 'mygroups') {
$show_menu = $_GET['view'];
}
$social_menu_block = SocialManager::show_social_menu($show_menu);
$templateName = 'social/groups.tpl';
$tpl->setHelp('Groups');
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->assign('social_right_content', $social_right_content);
$social_layout = $tpl->get_template($templateName);
$tpl->display($social_layout);

141
main/social/home.php Normal file
View File

@@ -0,0 +1,141 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* @author Julio Montoya <gugli100@gmail.com>
* @autor Alex Aragon <alex.aragon@beeznest.com> CSS Design and Template
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users();
$user_id = api_get_user_id();
$show_full_profile = true;
// social tab
Session::erase('this_section');
$this_section = SECTION_SOCIAL;
if (api_get_setting('allow_social_tool') !== 'true') {
$url = api_get_path(WEB_CODE_PATH).'auth/profile.php';
header('Location: '.$url);
exit;
}
//fast upload image
if (api_get_setting('profile', 'picture') == 'true') {
$form = new FormValidator('profile', 'post', 'home.php', null, []);
// PICTURE
$form->addElement('file', 'picture', get_lang('AddImage'));
$form->addProgress();
if (!empty($user_data['picture_uri'])) {
$form->addElement(
'checkbox',
'remove_picture',
null,
get_lang('DelImage')
);
}
$allowed_picture_types = api_get_supported_image_extensions();
$form->addRule(
'picture',
get_lang('OnlyImagesAllowed').' ('.implode(
',',
$allowed_picture_types
).')',
'filetype',
$allowed_picture_types
);
$form->addButtonSave(get_lang('SaveSettings'), 'apply_change');
if ($form->validate()) {
// upload picture if a new one is provided
if ($_FILES['picture']['size']) {
if ($new_picture = UserManager::update_user_picture(
api_get_user_id(),
$_FILES['picture']['name'],
$_FILES['picture']['tmp_name']
)) {
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$sql = "UPDATE $table_user
SET
picture_uri = '$new_picture'
WHERE user_id = ".$user_id;
Database::query($sql);
}
}
}
}
SocialManager::handlePosts(api_get_self());
$threadList = SocialManager::getThreadList($user_id);
$threadIdList = [];
if (!empty($threadList)) {
$threadIdList = array_column($threadList, 'id');
}
$posts = SocialManager::getMyWallMessages($user_id, 0, 10, $threadIdList);
$countPost = $posts['count'];
$posts = $posts['posts'];
SocialManager::getScrollJs($countPost, $htmlHeadXtra);
// Block Menu
$menu = SocialManager::show_social_menu('home');
$social_search_block = Display::panel(
UserManager::get_search_form(''),
get_lang('SearchUsers')
);
$social_group_block = SocialManager::getGroupBlock($user_id);
// My friends
$friend_html = SocialManager::listMyFriendsBlock($user_id);
// Block Social Sessions
$wallSocialAddPost = SocialManager::displayWallForm(api_get_self());
$socialAutoExtendLink = SocialManager::getAutoExtendLink($user_id, $countPost);
$formSearch = new FormValidator(
'find_friends_form',
'get',
api_get_path(WEB_CODE_PATH).'social/search.php?search_type=1',
null,
null,
FormValidator::LAYOUT_BOX_NO_LABEL
);
$formSearch->addHidden('search_type', 1);
$formSearch->addText(
'q',
get_lang('Search'),
false,
[
'aria-label' => get_lang('SearchUsers'),
'custom' => true,
'placeholder' => get_lang('SearchUsersByName'),
]
);
// Added a Jquery Function to return the Preview of OpenGraph URL Content
$htmlHeadXtra[] = SocialManager::getScriptToGetOpenGraph();
$tpl = new Template(get_lang('SocialNetwork'));
SocialManager::setSocialUserBlock($tpl, $user_id, 'home');
$tpl->assign('add_post_form', $wallSocialAddPost);
$tpl->assign('posts', $posts);
$tpl->assign('social_menu_block', $menu);
$tpl->assign('social_auto_extend_link', $socialAutoExtendLink);
$tpl->assign('search_friends_form', $formSearch->returnForm());
$tpl->assign('social_friend_block', $friend_html);
$tpl->assign('social_search_block', $social_search_block);
$tpl->assign('social_skill_block', SocialManager::getSkillBlock($user_id, 'vertical'));
$tpl->assign('social_group_block', $social_group_block);
$tpl->assign('session_list', null);
$social_layout = $tpl->get_template('social/home.tpl');
$tpl->display($social_layout);

9
main/social/index.php Normal file
View File

@@ -0,0 +1,9 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Redirect file for social network default page.
*
* @package chamilo.social
*/
header('Location: profile.php');
exit();

242
main/social/invitations.php Normal file
View File

@@ -0,0 +1,242 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.social
*
* @author Julio Montoya <gugli100@gmail.com>
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users();
if (api_get_setting('allow_social_tool') !== 'true') {
api_not_allowed(true);
}
$this_section = SECTION_SOCIAL;
$interbreadcrumb[] = ['url' => 'profile.php', 'name' => get_lang('SocialNetwork')];
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Invitations')];
$userGroupModel = new UserGroup();
if (is_array($_GET) && count($_GET) > 0) {
foreach ($_GET as $key => $value) {
switch ($key) {
case 'accept':
$useRole = $userGroupModel->get_user_group_role(api_get_user_id(), $value);
if (in_array(
$useRole,
[
GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER,
GROUP_USER_PERMISSION_PENDING_INVITATION,
]
)) {
$userGroupModel->update_user_role(api_get_user_id(), $value, GROUP_USER_PERMISSION_READER);
Display::addFlash(
Display::return_message(get_lang('UserIsSubscribedToThisGroup'), 'success')
);
header('Location: '.api_get_path(WEB_CODE_PATH).'social/invitations.php');
exit;
}
if (in_array(
$useRole,
[
GROUP_USER_PERMISSION_READER,
GROUP_USER_PERMISSION_ADMIN,
GROUP_USER_PERMISSION_MODERATOR,
]
)) {
Display::addFlash(
Display::return_message(get_lang('UserIsAlreadySubscribedToThisGroup'), 'warning')
);
header('Location: '.api_get_path(WEB_CODE_PATH).'social/invitations.php');
exit;
}
Display::addFlash(
Display::return_message(get_lang('UserIsNotSubscribedToThisGroup'), 'warning')
);
header('Location: '.api_get_path(WEB_CODE_PATH).'social/invitations.php');
exit;
break;
case 'deny':
$userGroupModel->delete_user_rel_group(api_get_user_id(), $value);
Display::addFlash(
Display::return_message(get_lang('GroupInvitationWasDeny'))
);
header('Location: '.api_get_path(WEB_CODE_PATH).'social/invitations.php');
exit;
}
}
}
$content = null;
// Block Menu Social
$social_menu_block = SocialManager::show_social_menu('invitations');
// Block Invitations
$socialInvitationsBlock = '<div id="id_response" align="center"></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 = $userGroupModel->get_groups_by_user(
$user_id,
GROUP_USER_PERMISSION_PENDING_INVITATION
);
$numberLoop = count($list_get_invitation);
$total_invitations = $numberLoop + count($list_get_invitation_sent) + count($pending_invitations);
if (count($_GET) <= 0) {
$socialInvitationsBlock .= '<div class="row">
<div class="col-md-12">
<a class="btn btn-success" href="search.php"><em class="fa fa-search"></em> '.
get_lang('TryAndFindSomeFriends').'
</a>
</div>
</div><br />';
}
if ($numberLoop != 0) {
$invitationHtml = '';
foreach ($list_get_invitation as $invitation) {
$sender_user_id = $invitation['user_sender_id'];
$user_info = api_get_user_info($sender_user_id);
$userPicture = $user_info['avatar'];
$invitationHtml .= '<div id="id_'.$sender_user_id.'" class="block-invitation">';
$title = Security::remove_XSS($invitation['title'], STUDENT, true);
$content = Security::remove_XSS($invitation['content'], STUDENT, true);
$date = Display::dateToStringAgoAndLongDate($invitation['send_date']);
$invitationHtml .= '<div class="row">';
$invitationHtml .= '<div class="col-md-2">';
$invitationHtml .= '<a href="profile.php?u='.$sender_user_id.'">';
$invitationHtml .= '<img class="img-responsive img-rounded" src="'.$userPicture.'"/></a>';
$invitationHtml .= '</div>';
$invitationHtml .= '<div class="col-md-10">';
$invitationHtml .= '<div class="pull-right">';
$invitationHtml .= '<div class="btn-group btn-group-sm" role="group">';
$invitationHtml .= Display::toolbarButton(
null,
api_get_path(WEB_AJAX_PATH).'social.ajax.php?'.http_build_query([
'a' => 'add_friend',
'friend_id' => $sender_user_id,
'is_my_friend' => 'friend',
]),
'check',
'primary',
['id' => 'btn-accept-'.$sender_user_id]
);
$invitationHtml .= Display::toolbarButton(
null,
api_get_path(WEB_AJAX_PATH).'social.ajax.php?'.http_build_query([
'a' => 'deny_friend',
'denied_friend_id' => $sender_user_id,
]),
'times',
'danger',
['id' => 'btn-deny-'.$sender_user_id]
);
$invitationHtml .= '</div>';
$invitationHtml .= '</div>';
$invitationHtml .= '<h5 class="title-profile"><a href="profile.php?u='.$sender_user_id.'">
'.$user_info['complete_name'].'</a>:
</h5>';
$invitationHtml .= '<div class="content-invitation">'.$content.'</div>';
$invitationHtml .= '<div class="date-invitation">'.get_lang('Sent').' : '.$date.'</div>';
$invitationHtml .= '</div>';
$invitationHtml .= '</div></div>';
}
$socialInvitationsBlock .= Display::panel($invitationHtml, get_lang('InvitationReceived'));
}
if (count($list_get_invitation_sent) > 0) {
$invitationSentHtml = '';
foreach ($list_get_invitation_sent as $invitation) {
$sender_user_id = $invitation['user_receiver_id'];
$user_info = api_get_user_info($sender_user_id);
$invitationSentHtml .= '<div id="id_'.$sender_user_id.'" class="well">';
$title = Security::remove_XSS($invitation['title'], STUDENT, true);
$content = Security::remove_XSS($invitation['content'], STUDENT, true);
$invitationSentHtml .= '<div class="row">';
$invitationSentHtml .= '<div class="col-md-3">';
$invitationSentHtml .= '<a href="profile.php?u='.$sender_user_id.'">';
$invitationSentHtml .= '<img class="img-responsive img-rounded" src="'.$user_info['avatar'].'" /></a>';
$invitationSentHtml .= '</div>';
$invitationSentHtml .= '<div class="col-md-9">';
$invitationSentHtml .= '<h4 class="title-profile">
<a class="profile_link" href="profile.php?u='.$sender_user_id.'">'.$user_info['complete_name'].'</a></h4>';
$invitationSentHtml .= '<div class="content-invitation">'.$title.' : '.$content.'</div>';
$invitationSentHtml .= '<div class="date-invitation">'.
get_lang('Sent').' : '.Display::dateToStringAgoAndLongDate($invitation['send_date']).'</div>';
$invitationSentHtml .= '</div>';
$invitationSentHtml .= '</div></div>';
}
$socialInvitationsBlock .= Display::panel($invitationSentHtml, get_lang('InvitationSent'));
}
if (count($pending_invitations) > 0) {
$new_invitation = [];
$waitingInvitation = '';
foreach ($pending_invitations as $invitation) {
$picture = $userGroupModel->get_picture_group(
$invitation['id'],
$invitation['picture'],
null,
GROUP_IMAGE_SIZE_BIG
);
$img = '<img class="img-responsive" src="'.$picture['file'].'" />';
$invitation['picture_uri'] = '<a href="group_view.php?id='.$invitation['id'].'">'.$img.'</a>';
$invitation['name'] = '<a href="group_view.php?id='.$invitation['id'].'">'.
cut($invitation['name'], 120, true).'</a>';
$invitation['description'] = cut($invitation['description'], 220, true);
$new_invitation[] = $invitation;
$waitingInvitation .= '<div class="panel-invitations"><div class="row">';
$waitingInvitation .= '<div class="col-md-3">'.$invitation['picture_uri'].'</div>';
$waitingInvitation .= '<div class="col-md-9">';
$waitingInvitation .= '<h4 class="tittle-profile">'.$invitation['name'].'</h4>';
$waitingInvitation .= '<div class="description-group">'.$invitation['description'].'</div>';
$waitingInvitation .= '<div class="btn-group" role="group">';
$waitingInvitation .= Display::toolbarButton(
get_lang('AcceptInvitation'),
api_get_path(WEB_CODE_PATH).'social/invitations.php?'.http_build_query(['accept' => $invitation['id']]),
'check',
'success',
['id' => 'accept-invitation-'.$invitation['id']]
);
$waitingInvitation .= Display::toolbarButton(
get_lang('DenyInvitation'),
api_get_path(WEB_CODE_PATH).'social/invitations.php?'.http_build_query(['deny' => $invitation['id']]),
'times',
'danger',
['id' => 'deny-invitation-'.$invitation['id']]
);
$waitingInvitation .= '</div>';
$waitingInvitation .= '</div></div>';
}
$socialInvitationsBlock .= Display::panel($waitingInvitation, get_lang('GroupsWaitingApproval'));
}
$tpl = new Template(null);
SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'invitations');
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->assign('social_invitations_block', $socialInvitationsBlock);
$tpl->assign('content', $content);
$social_layout = $tpl->get_template('social/invitations.tpl');
$tpl->display($social_layout);

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

151
main/social/map.php Normal file
View File

@@ -0,0 +1,151 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.social
*
* @author Julio Montoya <gugli100@gmail.com>
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users();
$fields = api_get_configuration_value('allow_social_map_fields');
if (!$fields) {
api_not_allowed(true);
}
$fields = isset($fields['fields']) ? $fields['fields'] : '';
if (empty($fields)) {
api_not_allowed(true);
}
$extraField = new ExtraField('user');
$infoStage = $extraField->get_handler_field_info_by_field_variable($fields['0']);
$infoVille = $extraField->get_handler_field_info_by_field_variable($fields['1']);
if (empty($infoStage) || empty($infoVille)) {
api_not_allowed(true);
}
$gMapsPlugin = GoogleMapsPlugin::create();
$localization = $gMapsPlugin->get('enable_api') === 'true';
if ($localization) {
$apiKey = $gMapsPlugin->get('api_key');
if (empty($apiKey)) {
api_not_allowed(true);
}
} else {
api_not_allowed(true);
}
$tableUser = Database::get_main_table(TABLE_MAIN_USER);
$sql = "SELECT u.id, firstname, lastname, ev.value ville, ev2.value stage
FROM $tableUser u
INNER JOIN extra_field_values ev
ON ev.item_id = u.id
INNER JOIN extra_field_values ev2
ON ev2.item_id = u.id
WHERE
ev.field_id = ".$infoStage['id']." AND
ev2.field_id = ".$infoVille['id']." AND
u.status = ".STUDENT." AND
u.active = 1 AND
(ev.value <> '' OR ev2.value <> '') AND
(ev.value LIKE '%::%' OR ev2.value LIKE '%::%')
";
$cacheDriver = new \Doctrine\Common\Cache\ApcuCache();
$keyDate = 'map_cache_date';
$keyData = 'map_cache_data';
$now = time();
// Refresh cache every day
//$tomorrow = strtotime('+1 day', $now);
$tomorrow = strtotime('+5 minute', $now);
$loadFromDatabase = true;
if ($cacheDriver->contains($keyData) && $cacheDriver->contains($keyDate)) {
$savedDate = $cacheDriver->fetch($keyDate);
$loadFromDatabase = false;
if ($savedDate < $now) {
$loadFromDatabase = true;
}
}
$loadFromDatabase = true;
if ($loadFromDatabase) {
$result = Database::query($sql);
$data = Database::store_result($result, 'ASSOC');
$cacheDriver->save($keyData, $data);
$cacheDriver->save($keyDate, $tomorrow);
} else {
$data = $cacheDriver->fetch($keyData);
}
foreach ($data as &$result) {
// Clean process is made in twig with escape('js')
$result['complete_name'] = $result['firstname'].' '.$result['lastname'];
$result['lastname'] = '';
$result['firstname'] = '';
$parts = explode('::', $result['ville']);
if (isset($parts[1]) && !empty($parts[1])) {
$parts2 = explode(',', $parts[1]);
$result['ville_lat'] = $parts2[0];
$result['ville_long'] = $parts2[1];
unset($result['ville']);
}
$parts = explode('::', $result['stage']);
if (isset($parts[1]) && !empty($parts[1])) {
$parts2 = explode(',', $parts[1]);
$result['stage_lat'] = $parts2[0];
$result['stage_long'] = $parts2[1];
unset($result['stage']);
}
}
$htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_LIBRARY_JS_PATH).'map/markerclusterer.js"></script>';
$htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_LIBRARY_JS_PATH).'map/oms.min.js"></script>';
$tpl = new Template(null);
$tpl->assign('url', api_get_path(WEB_CODE_PATH).'social/profile.php');
$tpl->assign(
'image_city',
Display::return_icon(
'red-dot.png',
'',
[],
ICON_SIZE_SMALL,
false,
true
)
);
$tpl->assign(
'image_stage',
Display::return_icon(
'blue-dot.png',
'',
[],
ICON_SIZE_SMALL,
false,
true
)
);
$tpl->assign('places', json_encode($data));
$tpl->assign('api_key', $apiKey);
$tpl->assign('field_1', $infoStage['display_text']);
$tpl->assign('field_2', $infoVille['display_text']);
$layout = $tpl->get_template('social/map.tpl');
$tpl->display($layout);

View File

@@ -0,0 +1,117 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Form for group message.
*
* @package chamilo.social
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users();
if (api_get_setting('allow_social_tool') != 'true') {
api_not_allowed();
}
$tok = Security::get_token();
if (isset($_REQUEST['user_friend'])) {
$info_user_friend = [];
$info_path_friend = [];
$userfriend_id = intval($_REQUEST['user_friend']);
$info_user_friend = api_get_user_info($userfriend_id);
$info_path_friend = UserManager::get_user_picture_path_by_id($userfriend_id, 'web');
}
$group_id = isset($_GET['group_id']) ? intval($_GET['group_id']) : null;
$message_id = isset($_GET['message_id']) ? intval($_GET['message_id']) : null;
$actions = ['add_message_group', 'edit_message_group', 'reply_message_group'];
$allowed_action = isset($_GET['action']) && in_array($_GET['action'], $actions) ? Security::remove_XSS($_GET['action']) : '';
$to_group = '';
$subject = '';
$message = '';
$usergroup = new UserGroup();
if (!empty($group_id) && $allowed_action) {
$group_info = $usergroup->get($group_id);
$is_member = $usergroup->is_group_member($group_id);
if ($group_info['visibility'] == GROUP_PERMISSION_CLOSED && !$is_member) {
api_not_allowed(true);
}
$to_group = $group_info['name'];
if (!empty($message_id)) {
$message_info = MessageManager::get_message_by_id($message_id);
if ($allowed_action == 'reply_message_group') {
$subject = get_lang('Reply').': '.api_xml_http_response_encode($message_info['title']);
} else {
$subject = api_xml_http_response_encode($message_info['title']);
$message = api_xml_http_response_encode($message_info['content']);
}
}
}
$page_item = !empty($_GET['topics_page_nr']) ? intval($_GET['topics_page_nr']) : 1;
$param_item_page = isset($_GET['items_page_nr']) && isset($_GET['topic_id']) ? ('&items_'.intval($_GET['topic_id']).'_page_nr='.(!empty($_GET['topics_page_nr']) ? intval($_GET['topics_page_nr']) : 1)) : '';
if (isset($_GET['topic_id'])) {
$param_item_page .= '&topic_id='.intval($_GET['topic_id']);
}
$page_topic = isset($_GET['topics_page_nr']) ? intval($_GET['topics_page_nr']) : 1;
$anchor_topic = isset($_GET['anchor_topic']) ? Security::remove_XSS($_GET['anchor_topic']) : null;
$url = api_get_path(WEB_CODE_PATH).'social/group_topics.php?id='.$group_id.'&anchor_topic='.$anchor_topic.'&topics_page_nr='.$page_topic.$param_item_page;
$form = new FormValidator(
'form',
'post',
$url,
null,
['enctype' => 'multipart/form-data']
);
$form->addHidden('action', $allowed_action);
$form->addHidden('group_id', $group_id);
$form->addHidden('parent_id', $message_id);
$form->addHidden('message_id', $message_id);
$form->addHidden('token', $tok);
$tpl = new Template(get_lang('Groups'));
if (api_get_setting('allow_message_tool') === 'true') {
// Normal message
$user_info = api_get_user_info($userfriend_id);
$height = 180;
if ($allowed_action === 'add_message_group') {
$form->addElement('text', 'title', get_lang('Title'));
$height = 140;
}
$config = ['ToolbarSet' => 'Messages'];
$form->addHtmlEditor('content', get_lang('Message'), true, false, $config);
$form->addElement(
'label',
get_lang('AttachmentFiles'),
'<div id="link-more-attach">
<a class="btn btn-default" href="javascript://" onclick="return add_image_form()">
'.get_lang('AddOneMoreFile').'
</a>
</div>'
);
$form->addElement('label', null, '<div id="filepaths"></div>');
$form->addElement(
'file',
'attach_1',
sprintf(
get_lang('MaximunFileSizeX'),
format_file_size(api_get_setting('message_max_upload_filesize'))
)
);
$form->addButtonSend(get_lang('SendMessage'));
$form->setDefaults(['content' => $message, 'title' => $subject]);
$tpl->assign('content', $form->returnForm());
}
$tpl->displayBlankTemplateNoHeader();

View File

@@ -0,0 +1,223 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Show the skills report.
*
* @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com>
*
* @package chamilo.social.skill
*/
require_once __DIR__.'/../inc/global.inc.php';
$userId = api_get_user_id();
Skill::isAllowed($userId);
$isStudent = api_is_student();
$isStudentBoss = api_is_student_boss();
$isDRH = api_is_drh();
if (!$isStudent && !$isStudentBoss && !$isDRH) {
header('Location: '.api_get_path(WEB_CODE_PATH).'social/skills_wheel.php');
exit;
}
$action = isset($_GET['a']) ? $_GET['a'] : '';
switch ($action) {
case 'generate_custom_skill':
$certificate = new Certificate(0, api_get_user_id(), false, false);
$certificate->generatePdfFromCustomCertificate();
break;
case 'generate':
$certificate = Certificate::generateUserSkills(api_get_user_id());
Display::addFlash(Display::return_message(get_lang('Updated')));
header('Location: '.api_get_self());
exit;
break;
}
$skillTable = Database::get_main_table(TABLE_MAIN_SKILL);
$skillRelUserTable = Database::get_main_table(TABLE_MAIN_SKILL_REL_USER);
$courseTable = Database::get_main_table(TABLE_MAIN_COURSE);
$tableRows = [];
$objSkill = new Skill();
$tpl = new Template(get_lang('Skills'));
$tplPath = null;
$tpl->assign('allow_skill_tool', api_get_setting('allow_skills_tool') === 'true');
$tpl->assign('allow_drh_skills_management', api_get_setting('allow_hr_skills_management') === 'true');
if ($isStudent) {
$result = $objSkill->getUserSkillsTable($userId);
$tableRows = $result['skills'];
$tpl->assign('skill_table', $result['table']);
$tplPath = 'skill/student_report.tpl';
} elseif ($isStudentBoss) {
$tableRows = [];
$followedStudents = UserManager::getUsersFollowedByStudentBoss($userId);
$frmStudents = new FormValidator('students', 'get');
$slcStudent = $frmStudents->addSelect(
'student',
get_lang('Student'),
['0' => get_lang('Select')]
);
$frmStudents->addButtonSearch(get_lang('Search'));
foreach ($followedStudents as &$student) {
$student['completeName'] = api_get_person_name($student['firstname'], $student['lastname']);
$slcStudent->addOption($student['completeName'], $student['user_id']);
}
if ($frmStudents->validate()) {
$selectedStudent = (int) $frmStudents->exportValue('student');
$sql = "SELECT s.name, sru.acquired_skill_at, c.title, c.directory
FROM $skillTable s
INNER JOIN $skillRelUserTable sru
ON s.id = sru.skill_id
LEFT JOIN $courseTable c
ON sru.course_id = c.id
WHERE sru.user_id = $selectedStudent
";
$result = Database::query($sql);
while ($resultData = Database::fetch_assoc($result)) {
$tableRow = [
'complete_name' => $followedStudents[$selectedStudent]['completeName'],
'skill_name' => Skill::translateName($resultData['name']),
'achieved_at' => api_format_date($resultData['acquired_skill_at'], DATE_FORMAT_NUMBER),
'course_image' => Display::return_icon(
'course.png',
null,
null,
ICON_SIZE_MEDIUM,
null,
true
),
'course_name' => $resultData['title'],
];
$imageSysPath = sprintf('%s%s/course-pic.png', api_get_path(SYS_COURSE_PATH), $resultData['directory']);
if (file_exists($imageSysPath)) {
$thumbSysPath = sprintf(
"%s%s/course-pic32.png",
api_get_path(SYS_COURSE_PATH),
$resultData['directory']
);
$thumbWebPath = sprintf(
"%s%s/course-pic32.png",
api_get_path(WEB_COURSE_PATH),
$resultData['directory']
);
if (!file_exists($thumbSysPath)) {
$courseImageThumb = new Image($imageSysPath);
$courseImageThumb->resize(32);
$courseImageThumb->send_image($thumbSysPath);
}
$tableRow['courseImage'] = $thumbWebPath;
}
$tableRows[] = $tableRow;
}
}
$tplPath = 'skill/student_boss_report.tpl';
$tpl->assign('form', $frmStudents->returnForm());
} elseif ($isDRH) {
$selectedCourse = isset($_REQUEST['course']) ? intval($_REQUEST['course']) : null;
$selectedSkill = isset($_REQUEST['skill']) ? intval($_REQUEST['skill']) : 0;
$action = null;
if (!empty($selectedCourse)) {
$action = 'filterByCourse';
} elseif (!empty($selectedSkill)) {
$action = 'filterBySkill';
}
$courses = CourseManager::getCoursesFollowedByUser($userId, DRH);
$tableRows = [];
$reportTitle = null;
$skills = $objSkill->get_all();
switch ($action) {
case 'filterByCourse':
$course = api_get_course_info_by_id($selectedCourse);
$reportTitle = sprintf(get_lang('AchievedSkillInCourseX'), $course['name']);
$tableRows = $objSkill->listAchievedByCourse($selectedCourse);
break;
case 'filterBySkill':
$skill = $objSkill->get($selectedSkill);
$reportTitle = sprintf(get_lang('StudentsWhoAchievedTheSkillX'), $skill['name']);
$students = UserManager::getUsersFollowedByUser(
$userId,
STUDENT,
false,
false,
false,
null,
null,
null,
null,
null,
null,
DRH
);
$coursesFilter = [];
foreach ($courses as $course) {
$coursesFilter[] = $course['id'];
}
$tableRows = $objSkill->listUsersWhoAchieved($selectedSkill, $coursesFilter);
break;
}
foreach ($tableRows as &$row) {
$row['complete_name'] = api_get_person_name($row['firstname'], $row['lastname']);
$row['achieved_at'] = api_format_date($row['acquired_skill_at'], DATE_FORMAT_NUMBER);
$row['course_image'] = Display::return_icon(
'course.png',
null,
null,
ICON_SIZE_MEDIUM,
null,
true
);
$imageSysPath = sprintf("%s%s/course-pic.png", api_get_path(SYS_COURSE_PATH), $row['c_directory']);
if (file_exists($imageSysPath)) {
$thumbSysPath = sprintf("%s%s/course-pic32.png", api_get_path(SYS_COURSE_PATH), $row['c_directory']);
$thumbWebPath = sprintf("%s%s/course-pic32.png", api_get_path(WEB_COURSE_PATH), $row['c_directory']);
if (!file_exists($thumbSysPath)) {
$courseImageThumb = new Image($imageSysPath);
$courseImageThumb->resize(32);
$courseImageThumb->send_image($thumbSysPath);
}
$row['course_image'] = $thumbWebPath;
}
}
$tplPath = 'skill/drh_report.tpl';
$tpl->assign('action', $action);
$tpl->assign('courses', $courses);
$tpl->assign('skills', $skills);
$tpl->assign('selected_course', $selectedCourse);
$tpl->assign('selected_skill', $selectedSkill);
$tpl->assign('report_title', $reportTitle);
}
if (empty($tableRows)) {
Display::addFlash(Display::return_message(get_lang('NoResults')));
}
$tpl->assign('rows', $tableRows);
$templateName = $tpl->get_template($tplPath);
$contentTemplate = $tpl->fetch($templateName);
$tpl->assign('content', $contentTemplate);
$tpl->display_one_col_template();

126
main/social/myfiles.php Normal file
View File

@@ -0,0 +1,126 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* @author Juan Carlos Trabado herodoto@telefonica.net
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users();
if (api_get_setting('allow_my_files') === 'false') {
api_not_allowed(true);
}
$this_section = SECTION_SOCIAL;
$htmlHeadXtra[] = '
<script>
function denied_friend (element_input) {
name_button=$(element_input).attr("id");
name_div_id="id_"+name_button.substring(13);
user_id=name_div_id.split("_");
friend_user_id=user_id[1];
$.ajax({
contentType: "application/x-www-form-urlencoded",
beforeSend: function(myObject) {
$("#id_response").html("<img src=\'../inc/lib/javascript/indicator.gif\' />"); },
type: "POST",
url: "'.api_get_path(WEB_AJAX_PATH).'social.ajax.php?a=deny_friend",
data: "denied_friend_id="+friend_user_id,
success: function(datos) {
$("div#"+name_div_id).hide("slow");
$("#id_response").html(datos);
}
});
}
function register_friend(element_input) {
if(confirm("'.get_lang('AddToFriends').'")) {
name_button=$(element_input).attr("id");
name_div_id="id_"+name_button.substring(13);
user_id=name_div_id.split("_");
user_friend_id=user_id[1];
$.ajax({
contentType: "application/x-www-form-urlencoded",
beforeSend: function(myObject) {
$("div#dpending_"+user_friend_id).html("<img src=\'../inc/lib/javascript/indicator.gif\' />"); },
type: "POST",
url: "'.api_get_path(WEB_AJAX_PATH).'social.ajax.php?a=add_friend",
data: "friend_id="+user_friend_id+"&is_my_friend="+"friend",
success: function(datos) { $("div#"+name_div_id).hide("slow");
$("form").submit()
}
});
}
}
$(function() {
$("#el-finder")
.elfinder({
url: "'.api_get_path(WEB_LIBRARY_PATH).'elfinder/php/connector.php",
lang: "'.api_get_language_isocode().'",
height: 600,
resizable: false,
rememberLastDir: false,
})
.elfinder("instance");
});
</script>';
// Social Menu Block
$social_menu_block = SocialManager::show_social_menu('myfiles');
$actions = null;
if (isset($_GET['cidReq'])) {
$actions = Display::url(
Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('Documents').' ('.get_lang('Course').')'),
api_get_self().'?'.api_get_cidreq().'&id='.(int) $_GET['parent_id']
);
}
if (api_get_setting('allow_social_tool') === 'true') {
Session::write('this_section', SECTION_SOCIAL);
$interbreadcrumb[] = [
'url' => 'profile.php',
'name' => get_lang('SocialNetwork'),
];
} else {
Session::write('this_section', SECTION_COURSES);
$interbreadcrumb[] = [
'url' => api_get_path(WEB_PATH).'user_portal.php',
'name' => get_lang('MyCourses'),
];
}
$tpl = new Template(get_lang('MyFiles'));
SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'myfiles');
$editor = new \Chamilo\CoreBundle\Component\Editor\Editor();
$template = $tpl->get_template($editor->getEditorStandAloneTemplate());
$editor = $tpl->fetch($template);
$tpl->assign('show_media_element', 0);
if (api_get_setting('allow_social_tool') == 'true') {
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->assign('social_right_content', $editor);
$social_layout = $tpl->get_template('social/myfiles.tpl');
$tpl->display($social_layout);
} else {
$controller = new IndexManager(get_lang('MyCourses'));
$tpl->assign(
'actions',
Display::toolbarAction('toolbar', [$actions])
);
$tpl->assign('content', $editor);
$tpl->assign('profile_block', $controller->return_profile_block());
$tpl->assign('user_image_block', $controller->return_user_image_block());
$tpl->assign('course_block', $controller->return_course_block());
$tpl->display_two_col_template();
}

View File

@@ -0,0 +1,261 @@
<?php
/* For licensing terms, see /license.txt */
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_protect_admin_script();
if (api_get_setting('allow_social_tool') !== 'true') {
api_not_allowed(true);
}
$logInfo = [
'tool' => 'Messages',
'action' => 'add_new_promoted_message',
];
Event::registerLog($logInfo);
$allowSocial = api_get_setting('allow_social_tool') === 'true';
$nameTools = api_xml_http_response_encode(get_lang('Messages'));
$htmlHeadXtra[] = '<script>
var counter_image = 1;
function add_image_form() {
// Multiple filepaths for image form
var filepaths = document.getElementById("file_uploads");
if (document.getElementById("filepath_"+counter_image)) {
counter_image = counter_image + 1;
} else {
counter_image = counter_image;
}
var elem1 = document.createElement("div");
elem1.setAttribute("id","filepath_"+counter_image);
filepaths.appendChild(elem1);
id_elem1 = "filepath_"+counter_image;
id_elem1 = "\'"+id_elem1+"\'";
document.getElementById("filepath_"+counter_image).innerHTML = "<div class=\"form-group\" ><label class=\"col-sm-4\">'.get_lang('FilesAttachment').'</label><input class=\"col-sm-8\" type=\"file\" name=\"attach_"+counter_image+"\" /></div><div class=\"form-group\" ><label class=\"col-sm-4\">'.get_lang('Description').'</label><div class=\"col-sm-8\"><input style=\"width:100%\" type=\"text\" name=\"legend[]\" /></div></div>";
if (filepaths.childNodes.length == 6) {
var link_attach = document.getElementById("link-more-attach");
if (link_attach) {
link_attach.innerHTML="";
}
}
}
</script>';
$nameTools = get_lang('ComposeMessage');
$tpl = new Template(get_lang('ComposeMessage'));
/**
* Shows the compose area + a list of users to select from.
*/
function show_compose_to_any($tpl)
{
$default['user_list'] = 0;
$html = manageForm($default, null, null, $tpl);
return $html;
}
function show_compose_reply_to_message($message_id, $receiver_id, $tpl)
{
$table = Database::get_main_table(TABLE_MESSAGE);
$receiver_id = (int) $receiver_id;
$message_id = (int) $message_id;
$query = "SELECT user_sender_id
FROM $table
WHERE user_receiver_id = ".$receiver_id." AND id = ".$message_id;
$result = Database::query($query);
$row = Database::fetch_array($result, 'ASSOC');
$userInfo = api_get_user_info($row['user_sender_id']);
if (empty($row['user_sender_id']) || empty($userInfo)) {
$html = get_lang('InvalidMessageId');
return $html;
}
$default['users'] = [$row['user_sender_id']];
$html = manageForm($default, null, $userInfo['complete_name_with_username'], $tpl);
return $html;
}
function show_compose_to_user($receiver_id, $tpl)
{
$userInfo = api_get_user_info($receiver_id);
$html = get_lang('To').':&nbsp;<strong>'.$userInfo['complete_name'].'</strong>';
$default['title'] = api_xml_http_response_encode(get_lang('EnterTitle'));
$default['users'] = [$receiver_id];
$html .= manageForm($default, null, '', $tpl);
return $html;
}
/**
* @param $default
* @param null $select_from_user_list
* @param string $sent_to
* @param Template $tpl
*
* @return string
*/
function manageForm($default, $select_from_user_list = null, $sent_to = '', $tpl = null)
{
$form = new FormValidator(
'compose_message',
null,
api_get_self(),
null,
['enctype' => 'multipart/form-data']
);
$form->addText('title', get_lang('Subject'));
$form->addHtmlEditor(
'content',
get_lang('Message'),
false,
false,
['ToolbarSet' => 'Messages', 'Width' => '100%', 'Height' => '250', 'style' => true]
);
$form->addLabel(
'',
'<div id="file_uploads"><div id="filepath_1">
<div id="filepaths" class="form-horizontal">
<div id="paths-file" class="form-group">
<label class="col-sm-4">'.get_lang('FilesAttachment').'</label>
<input class="col-sm-8" type="file" name="attach_1"/>
</div>
</div>
<div id="paths-description" class="form-group">
<label class="col-sm-4">'.get_lang('Description').'</label>
<div class="col-sm-8">
<input id="file-descrtiption" class="form-control" type="text" name="legend[]" />
</div>
</div>
</div>
</div>'
);
$form->addLabel(
'',
'<span id="link-more-attach"><a class="btn btn-default" href="javascript://" onclick="return add_image_form()">'.
get_lang('AddOneMoreFile').'</a></span>&nbsp;('.
sprintf(
get_lang('MaximunFileSizeX'),
format_file_size(api_get_setting('message_max_upload_filesize'))
).')'
);
$form->addButtonSend(get_lang('SendMessage'), 'compose');
$form->setRequiredNote('<span class="form_required">*</span> <small>'.get_lang('ThisFieldIsRequired').'</small>');
$form->setDefaults($default);
$html = '';
if ($form->validate()) {
$check = true;
if ($check) {
$file_comments = $_POST['legend'];
$title = $default['title'];
$content = $default['content'];
$res = MessageManager::send_message(
api_get_user_id(),
$title,
$content,
$_FILES,
$file_comments,
0,
0,
0,
0,
null,
false,
0,
[],
true,
null,
MESSAGE_STATUS_PROMOTED
);
if ($res) {
Display::addFlash(Display::return_message(
get_lang('MessageSent'),
'confirmation',
false
));
}
MessageManager::cleanAudioMessage();
}
Security::clear_token();
header('Location: '.api_get_path(WEB_PATH).'main/social/promoted_messages.php');
exit;
} else {
$token = Security::get_token();
$form->addElement('hidden', 'sec_token');
$form->setConstants(['sec_token' => $token]);
$html .= $form->returnForm();
}
return $html;
}
$this_section = SECTION_SOCIAL;
$interbreadcrumb[] = [
'url' => api_get_path(WEB_PATH).'main/social/home.php',
'name' => get_lang('SocialNetwork'),
];
$interbreadcrumb[] = [
'url' => api_get_path(WEB_PATH).'main/messages/inbox.php',
'name' => get_lang('Messages'),
];
$social_right_content = null;
// LEFT COLUMN
$social_left_content = '';
// Block Social Menu
$social_menu_block = SocialManager::show_social_menu('messages');
$social_right_content .= '<div class="row">';
$social_right_content .= '<div class="col-md-12">';
$social_right_content .= '<div class="actions">';
$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
Display::return_icon('back.png', get_lang('Back'), [], 32).'</a>';
$social_right_content .= '</div>';
$social_right_content .= '</div>';
$social_right_content .= '<div class="col-md-12">';
// 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(),
$tpl
);
} elseif (isset($_GET['send_to_user'])) {
$social_right_content .= show_compose_to_user($_GET['send_to_user'], $tpl);
} else {
$social_right_content .= show_compose_to_any($tpl);
}
} else {
$default['title'] = $_POST['title'];
$default['content'] = $_POST['content'];
$social_right_content .= manageForm($default, null, null, $tpl);
}
$social_right_content .= '</div>';
$social_right_content .= '</div>';
// Block Social Avatar
SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'messages');
MessageManager::cleanAudioMessage();
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->assign('social_right_content', $social_right_content);
$social_layout = $tpl->get_template('social/inbox.tpl');
$tpl->display($social_layout);

View File

@@ -0,0 +1,434 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Repository\LegalRepository;
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_set_more_memory_and_time_limits();
api_block_anonymous_users();
if (api_get_configuration_value('disable_gdpr')) {
api_not_allowed(true);
}
$userId = api_get_user_id();
$userInfo = api_get_user_info($userId);
if (empty($userInfo)) {
api_not_allowed(true);
}
$substitutionTerms = [
'password' => get_lang('EncryptedData'),
'salt' => get_lang('RandomData'),
'empty' => get_lang('NoData'),
];
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
$formToString = '';
if (api_get_setting('allow_terms_conditions') === 'true') {
$form = new FormValidator('delete_term', 'post', api_get_self().'?action=delete_legal&user_id='.$userId);
$form->addHtml(Display::return_message(get_lang('WhyYouWantToDeleteYourLegalAgreement'), 'normal', false));
$form->addTextarea('explanation', [get_lang('DeleteLegal'), get_lang('ExplanationDeleteLegal')], [], true);
$form->addHidden('action', 'delete_legal');
$form->addButtonSave(get_lang('DeleteLegal'));
$formToString = $form->returnForm();
$formDelete = new FormValidator('delete_account', 'post', api_get_self().'?action=delete_account&user_id='.$userId);
$formDelete->addTextarea(
'explanation',
[get_lang('DeleteAccount'), get_lang('ExplanationDeleteAccount')],
[],
true
);
$formDelete->addHidden('action', 'delete_account');
$formDelete->addButtonDelete(get_lang('DeleteAccount'));
$formToString .= $formDelete->returnForm();
}
switch ($action) {
case 'send_legal':
$language = api_get_interface_language();
$language = api_get_language_id($language);
$terms = LegalManager::get_last_condition($language);
if (!$terms) {
//look for the default language
$language = api_get_setting('platformLanguage');
$language = api_get_language_id($language);
$terms = LegalManager::get_last_condition($language);
}
$legalAcceptType = $terms['version'].':'.$terms['language_id'].':'.time();
Event::addEvent(
LOG_TERM_CONDITION_ACCEPTED,
LOG_USER_OBJECT,
api_get_user_info($userId),
api_get_utc_datetime()
);
LegalManager::sendEmailToUserBoss($userId, $legalAcceptType);
Display::addFlash(Display::return_message(get_lang('Saved')));
header('Location: '.api_get_self());
exit;
break;
case 'delete_account':
if ($formDelete->validate()) {
$explanation = $formDelete->getSubmitValue('explanation');
UserManager::createDataPrivacyExtraFields();
UserManager::update_extra_field_value(
$userId,
'request_for_delete_account',
1
);
UserManager::update_extra_field_value(
$userId,
'request_for_delete_account_justification',
$explanation
);
Display::addFlash(Display::return_message(get_lang('Saved')));
Event::addEvent(
LOG_USER_DELETE_ACCOUNT_REQUEST,
LOG_USER_OBJECT,
$userInfo
);
$url = api_get_path(WEB_CODE_PATH).'admin/user_list_consent.php';
$link = Display::url($url, $url);
$subject = get_lang('RequestForAccountDeletion');
$content = sprintf(
get_lang('TheUserXAskedForAccountDeletionWithJustificationXGoHereX'),
$userInfo['complete_name'],
$explanation,
$link
);
$email = api_get_configuration_value('data_protection_officer_email');
if (!empty($email)) {
api_mail_html('', $email, $subject, $content);
} else {
MessageManager::sendMessageToAllAdminUsers(api_get_user_id(), $subject, $content);
}
header('Location: '.api_get_self());
exit;
}
break;
case 'delete_legal':
if ($form->validate()) {
$explanation = $form->getSubmitValue('explanation');
UserManager::createDataPrivacyExtraFields();
UserManager::update_extra_field_value(
$userId,
'request_for_legal_agreement_consent_removal',
1
);
UserManager::update_extra_field_value(
$userId,
'request_for_legal_agreement_consent_removal_justification',
$explanation
);
Display::addFlash(Display::return_message(get_lang('Sent')));
Event::addEvent(
LOG_USER_REMOVED_LEGAL_ACCEPT,
LOG_USER_OBJECT,
$userInfo
);
$url = api_get_path(WEB_CODE_PATH).'admin/user_list_consent.php';
$link = Display::url($url, $url);
$subject = get_lang('RequestForLegalConsentWithdrawal');
$content = sprintf(
get_lang('TheUserXAskedLegalConsentWithdrawalWithJustificationXGoHereX'),
$userInfo['complete_name'],
$explanation,
$link
);
$email = api_get_configuration_value('data_protection_officer_email');
if (!empty($email)) {
api_mail_html('', $email, $subject, $content);
} else {
MessageManager::sendMessageToAllAdminUsers(api_get_user_id(), $subject, $content);
}
header('Location: '.api_get_self());
exit;
}
break;
}
$propertiesToJson = UserManager::getRepository()->getPersonalDataToJson($userId, $substitutionTerms);
if (!empty($_GET['export'])) {
$filename = md5(mt_rand(0, 1000000)).'.json';
$path = api_get_path(SYS_ARCHIVE_PATH).$filename;
$writeResult = file_put_contents($path, $propertiesToJson);
if ($writeResult !== false) {
DocumentManager::file_send_for_download($path, true, $filename);
exit;
}
}
$allowSocial = api_get_setting('allow_social_tool') === 'true';
$nameTools = get_lang('PersonalDataReport');
$show_message = null;
if ($allowSocial) {
$this_section = SECTION_SOCIAL;
$interbreadcrumb[] = [
'url' => api_get_path(WEB_PATH).'main/social/home.php',
'name' => get_lang('SocialNetwork'),
];
} else {
$this_section = SECTION_MYPROFILE;
$interbreadcrumb[] = [
'url' => api_get_path(WEB_PATH).'main/auth/profile.php',
'name' => get_lang('Profile'),
];
}
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('PersonalDataReport')];
// LEFT CONTENT
$socialMenuBlock = '';
if ($allowSocial) {
// Block Social Menu
$socialMenuBlock = SocialManager::show_social_menu('personal-data');
}
// MAIN CONTENT
$personalDataContent = '<ul>';
$properties = json_decode($propertiesToJson);
$webCoursePath = api_get_path(WEB_COURSE_PATH);
$showWarningMessage = false;
foreach ($properties as $key => $value) {
if (is_array($value) || is_object($value)) {
switch ($key) {
case 'classes':
foreach ($value as $category => $subValue) {
$categoryName = 'Social group';
if ($category == 0) {
$categoryName = 'Class';
}
$personalDataContent .= '<li class="advanced_options" id="personal-data-list-'.$category.'">';
$personalDataContent .= '<u>'.$categoryName.'</u> &gt;</li>';
$personalDataContent .= '<ul id="personal-data-list-'.$category.'_options" style="display:none;">';
if (empty($subValue)) {
$personalDataContent .= '<li>'.get_lang('NoData').'</li>';
} else {
foreach ($subValue as $subSubValue) {
$personalDataContent .= '<li>'.Security::remove_XSS($subSubValue).'</li>';
}
}
$personalDataContent .= '</ul>';
}
break;
case 'extraFields':
$personalDataContent .= '<li>'.$key.': </li><ul>';
if (empty($value)) {
$personalDataContent .= '<li>'.get_lang('NoData').'</li>';
} else {
foreach ($value as $subValue) {
if (is_array($subValue->value)) {
// tags fields can be stored as arrays
$val = json_encode(Security::remove_XSS($subValue->value));
} else {
$val = Security::remove_XSS($subValue->value);
}
$personalDataContent .= '<li>'.$subValue->variable.': '.$val.'</li>';
}
}
$personalDataContent .= '</ul>';
break;
case 'dropBoxSentFiles':
foreach ($value as $category => $subValue) {
$personalDataContent .= '<li class="advanced_options" id="personal-data-list-'.$category.'">';
$personalDataContent .= '<u>'.get_lang($category).'</u> &gt;</li>';
$personalDataContent .= '<ul id="personal-data-list-'.$category.'_options" style="display:none;">';
if (empty($subValue)) {
$personalDataContent .= '<li>'.get_lang('NoData').'</li>';
} else {
if (count($subValue) === 1000) {
$showWarningMessage = true;
}
foreach ($subValue as $subSubValue) {
if ($category === 'DocumentsAdded') {
$documentLink = Display::url(
$subSubValue->code_path,
$webCoursePath.$subSubValue->directory.'/document'.$subSubValue->path
);
$personalDataContent .= '<li>'.$documentLink.'</li>';
} else {
$personalDataContent .= '<li>'.Security::remove_XSS($subSubValue).'</li>';
}
}
}
$personalDataContent .= '</ul>';
}
break;
case 'portals':
case 'roles':
case 'achievedSkills':
case 'sessionAsGeneralCoach':
case 'courses':
case 'groupNames':
case 'groups':
$personalDataContent .= '<li>'.$key.': </li><ul>';
if (empty($subValue)) {
$personalDataContent .= '<li>'.get_lang('NoData').'</li>';
} else {
foreach ($value as $subValue) {
$personalDataContent .= '<li>'.Security::remove_XSS($subValue).'</li>';
}
}
$personalDataContent .= '</ul>';
break;
case 'sessionCourseSubscriptions':
$personalDataContent .= '<li>'.$key.': </li><ul>';
foreach ($value as $session => $courseList) {
$personalDataContent .= '<li>'.$session.'<ul>';
if (empty($courseList)) {
$personalDataContent .= '<li>'.get_lang('NoData').'</li>';
} else {
foreach ($courseList as $course) {
$personalDataContent .= '<li>'.$course.'</li>';
}
}
$personalDataContent .= '</ul>';
}
$personalDataContent .= '</ul>';
break;
default:
//var_dump($key);
break;
}
/*foreach ($value as $subValue) {
foreach ($subValue as $subSubValue) {
var_dump($subSubValue);
//$personalDataContent .= '<li>'.$subSubValue.'</li>';
}
}*/
//skip in some cases
/*sif (!empty($value['date'])) {
$personalDataContent .= '<li>'.$key.': '.$value['date'].'</li>';
} else {
$personalDataContent .= '<li>'.$key.': '.get_lang('ComplexDataNotShown').'</li>';
}*/
} else {
$personalDataContent .= '<li>'.$key.': '.Security::remove_XSS($value).'</li>';
}
}
$personalDataContent .= '</ul>';
// Check terms acceptation
$permissionBlock = '';
if (api_get_setting('allow_terms_conditions') === 'true') {
$extraFieldValue = new ExtraFieldValue('user');
$value = $extraFieldValue->get_values_by_handler_and_field_variable(
$userId,
'legal_accept'
);
$permissionBlock .= Display::return_icon('accept_na.png', get_lang('NotAccepted'));
if (isset($value['value']) && !empty($value['value'])) {
list($legalId, $legalLanguageId, $legalTime) = explode(':', $value['value']);
$permissionBlock = '<h4>'.get_lang('CurrentStatus').'</h4>'.
get_lang('LegalAgreementAccepted').' '.Display::return_icon('accept.png', get_lang('LegalAgreementAccepted'), [], ICON_SIZE_TINY).
'<br />';
$permissionBlock .= get_lang('Date').': '.api_get_local_time($legalTime).'<br /><br />';
$permissionBlock .= $formToString;
/*$permissionBlock .= Display::url(
get_lang('DeleteLegal'),
api_get_self().'?action=delete_legal&user_id='.$userId,
['class' => 'btn btn-danger btn-xs']
);*/
} else {
// @TODO add action handling for button
$permissionBlock .= Display::url(
get_lang('SendLegal'),
api_get_self().'?action=send_legal&user_id='.$userId,
['class' => 'btn btn-primary btn-xs']
);
}
} else {
$permissionBlock .= get_lang('NoTermsAndConditionsAvailable');
}
//Build the final array to pass to template
$personalData = [];
$personalData['data'] = $personalDataContent;
//$personalData['responsible'] = api_get_setting('personal_data_responsible_org');
$em = Database::getManager();
/** @var LegalRepository $legalTermsRepo */
$legalTermsRepo = $em->getRepository('ChamiloCoreBundle:Legal');
// Get data about the treatment of data
$treatmentTypes = LegalManager::getTreatmentTypeList();
/*foreach ($treatmentTypes as $id => $item) {
$personalData['treatment'][$item]['title'] = get_lang('PersonalData'.ucfirst($item).'Title');
$legalTerm = $legalTermsRepo->findOneByTypeAndLanguage($id, api_get_language_id($user_language));
$legalTermContent = '';
if (!empty($legalTerm[0]) && is_array($legalTerm[0])) {
$legalTermContent = $legalTerm[0]['content'];
}
$personalData['treatment'][$item]['content'] = $legalTermContent;
}*/
$officerName = api_get_configuration_value('data_protection_officer_name');
$officerRole = api_get_configuration_value('data_protection_officer_role');
$officerEmail = api_get_configuration_value('data_protection_officer_email');
if (!empty($officerName)) {
$personalData['officer_name'] = $officerName;
$personalData['officer_role'] = $officerRole;
$personalData['officer_email'] = $officerEmail;
}
$tpl = new Template(null);
$actions = Display::url(
Display::return_icon('excel.png', get_lang('Export'), [], ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'social/personal_data.php?export=1'
);
$tpl->assign('actions', Display::toolbarAction('toolbar', [$actions]));
$termLink = '';
if (api_get_setting('allow_terms_conditions') === 'true') {
$url = api_get_path(WEB_CODE_PATH).'social/terms.php';
$termLink = Display::url(get_lang('ReadTermsAndConditions'), $url);
}
if ($showWarningMessage) {
Display::addFlash(
Display::return_message(get_lang('MoreDataAvailableInTheDatabaseButTrunkedForEfficiencyReasons'))
);
}
// Block Social Avatar
SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'messages');
if (api_get_setting('allow_social_tool') === 'true') {
$tpl->assign('social_menu_block', $socialMenuBlock);
} else {
$tpl->assign('social_menu_block', '');
$tpl->assign('personal_data_block', $personalDataContent);
}
$tpl->assign('personal_data', $personalData);
$tpl->assign('permission', $permissionBlock);
$tpl->assign('term_link', $termLink);
$socialLayout = $tpl->get_template('social/personal_data.tpl');
$tpl->display($socialLayout);

314
main/social/profile.php Normal file
View File

@@ -0,0 +1,314 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* This is the profile social main page.
*
* @author Julio Montoya <gugli100@gmail.com>
* @author Isaac Flores Paz <florespaz_isaac@hotmail.com>
*
* @todo use Display::panel()
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
if (api_get_setting('allow_social_tool') !== 'true') {
$url = api_get_path(WEB_PATH).'whoisonline.php?id='.intval($_GET['u']);
header('Location: '.$url);
exit;
}
$portfolioRequest = isset($_GET['p']) ? true : false;
$productionString = '';
$bossId = isset($_REQUEST['sup']) ? (int) $_REQUEST['sup'] : 0;
$user_id = api_get_user_id();
$redirectToBossId = 0;
if (!empty($bossId)) {
$bossList = UserManager::getStudentBossList($user_id);
if (!empty($bossList)) {
foreach ($bossList as $boss) {
$bossId = $boss['boss_id'];
$bossInfo = api_get_user_info($bossId);
if (!empty($bossInfo)) {
$redirectToBossId = $bossId;
break;
}
}
}
}
if (!empty($redirectToBossId)) {
header('Location: '.api_get_self().'?u='.$redirectToBossId);
exit;
}
$friendId = isset($_GET['u']) ? (int) $_GET['u'] : api_get_user_id();
$show_full_profile = true;
//social tab
$this_section = SECTION_SOCIAL;
// Initialize blocks
$social_course_block = null;
$social_group_info_block = null;
$social_rss_block = null;
$social_session_block = null;
SocialManager::handlePosts(api_get_self().'?u='.$friendId);
if (isset($_GET['u'])) {
//I'm your friend? I can see your profile?
$user_id = (int) $_GET['u'];
if (api_is_anonymous($user_id, true)) {
api_not_allowed(true);
}
// It's me!
if (api_get_user_id() != $user_id) {
$user_info = api_get_user_info($user_id);
$show_full_profile = false;
if (!$user_info) {
// user does no exist !!
api_not_allowed(true);
} else {
//checking the relationship between me and my friend
$my_status = SocialManager::get_relation_between_contacts(
api_get_user_id(),
$user_id
);
if (in_array($my_status, [
USER_RELATION_TYPE_PARENT,
USER_RELATION_TYPE_FRIEND,
USER_RELATION_TYPE_GOODFRIEND,
])
) {
$show_full_profile = true;
}
//checking the relationship between my friend and me
$my_friend_status = SocialManager::get_relation_between_contacts(
$user_id,
api_get_user_id()
);
if (in_array($my_friend_status, [
USER_RELATION_TYPE_PARENT,
USER_RELATION_TYPE_FRIEND,
USER_RELATION_TYPE_GOODFRIEND,
])
) {
$show_full_profile = true;
} else {
// im probably not a good friend
$show_full_profile = false;
}
}
}
}
api_block_anonymous_users();
$countPost = SocialManager::getCountWallMessagesByUser($friendId);
SocialManager::getScrollJs($countPost, $htmlHeadXtra);
$link_shared = '';
if (isset($_GET['shared'])) {
$link_shared = 'shared='.Security::remove_XSS($_GET['shared']);
}
$interbreadcrumb[] = [
'url' => 'home.php',
'name' => get_lang('SocialNetwork'),
];
if (isset($_GET['u']) && is_numeric($_GET['u']) && $_GET['u'] != api_get_user_id()) {
$info_user = api_get_user_info($_GET['u']);
$interbreadcrumb[] = [
'url' => '#',
'name' => $info_user['complete_name'],
];
}
Session::write('social_user_id', $user_id);
// Social Block Menu
$menu = SocialManager::show_social_menu(
'shared_profile',
null,
$user_id,
$show_full_profile
);
//Setting some session info
$user_info = api_get_user_info($friendId);
$sessionList = [];
// My friends
$friend_html = SocialManager::listMyFriendsBlock($user_id, $link_shared);
$addPostForm = SocialManager::displayWallForm(api_get_self());
$addPostFormPortfolio = SocialManager::getWallFormPortfolio(api_get_self());
$posts = SocialManager::getWallMessagesByUser($friendId);
$socialAutoExtendLink = SocialManager::getAutoExtendLink($user_id, $countPost);
// Added a Jquery Function to return the Preview of OpenGraph URL Content
$htmlHeadXtra[] = SocialManager::getScriptToGetOpenGraph();
$socialRightInformation = '';
$listInvitations = '';
$more_info = '';
if ($show_full_profile) {
$social_group_info_block = SocialManager::getGroupBlock($friendId);
// Block Social Sessions
if (count($sessionList) > 0) {
$social_session_block = $sessionList;
}
// Block Social User Feeds
$user_feeds = SocialManager::getUserRssFeed($user_id);
if (!empty($user_feeds)) {
$social_rss_block = Display::panel($user_feeds, get_lang('RSSFeeds'));
}
// Productions
$production_list = UserManager::build_production_list($user_id);
// Images uploaded by course
$file_list = '';
$count_pending_invitations = 0;
if (!isset($_GET['u']) ||
(isset($_GET['u']) && $_GET['u'] == api_get_user_id())
) {
$pending_invitations = SocialManager::get_list_invitation_of_friends_by_user_id(api_get_user_id());
$list_get_path_web = SocialManager::get_list_web_path_user_invitation_by_user_id(api_get_user_id());
$count_pending_invitations = count($pending_invitations);
}
if (!empty($production_list) || !empty($file_list) || $count_pending_invitations > 0) {
// Pending invitations
if (!isset($_GET['u']) || (isset($_GET['u']) && $_GET['u'] == api_get_user_id())) {
if ($count_pending_invitations > 0) {
$invitations = '<ul class="list-group">';
for ($i = 0; $i < $count_pending_invitations; $i++) {
$user_invitation_id = $pending_invitations[$i]['user_sender_id'];
$invitations .= '<li id="dpending_'.$user_invitation_id.'" class="list-group-item">';
$invitations .= '<img class="img-rounded" '
.' src="'.$list_get_path_web[$i]['dir'].'/'.$list_get_path_web[$i]['file'].'"'
.' width="40px">';
$userInfo = api_get_user_info($user_invitation_id);
$invitations .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php?u='.$user_invitation_id.'">'
.api_get_person_name($userInfo['firstname'], $userInfo['lastname']).'</a>';
$invitations .= '<div class="pull-right">';
$invitations .= Display::toolbarButton(
get_lang('SocialAddToFriends'),
api_get_path(WEB_AJAX_PATH).'social.ajax.php?'.http_build_query([
'a' => 'add_friend',
'friend_id' => $user_invitation_id,
'is_my_friend' => 'friend',
]),
'plus',
'default',
['class' => 'btn-sm'],
false
);
$invitations .= '</div>';
$invitations .= '<div id="id_response"></div>';
$invitations .= '</li>';
}
$invitations .= '</ul>';
$listInvitations = Display::panelCollapse(
get_lang('PendingInvitations'),
$invitations,
'invitations',
null,
'invitations-acordion',
'invitations-collapse'
);
}
}
// MY PRODUCTIONS
// Productions
$production_list = UserManager::build_production_list($user_id);
$product_content = '';
if (!empty($production_list)) {
$product_content .= '<div><h3>'.get_lang('MyProductions').'</h3></div>';
$product_content .= $production_list;
// $socialRightInformation .= SocialManager::social_wrapper_div($product_content, 4);
$more_info_1 = '<div class="social-actions-message"><strong>'.get_lang('MyProductions').'</strong></div>';
$more_info_1 .= '<div class="social-profile-extended">'.$production_list.'</div>';
$more_info_1 .= '<br />';
$productionString .= $more_info_1;
}
$images_uploaded = null;
}
if (!empty($user_info['competences']) || !empty($user_info['diplomas'])
|| !empty($user_info['openarea']) || !empty($user_info['teach'])) {
$more_info .= '<div><h3>'.get_lang('MoreInformation').'</h3></div>';
// MY PERSONAL OPEN AREA
if (!empty($user_info['openarea'])) {
$more_info .= '<div class="social-actions-message"><strong>'.get_lang('MyPersonalOpenArea').'</strong></div>';
$more_info .= '<div class="social-profile-extended">'.$user_info['openarea'].'</div>';
$more_info .= '<br />';
}
// MY COMPETENCES
if (!empty($user_info['competences'])) {
$more_info .= '<div class="social-actions-message"><strong>'.get_lang('MyCompetences').'</strong></div>';
$more_info .= '<div class="social-profile-extended">'.$user_info['competences'].'</div>';
$more_info .= '<br />';
}
// MY DIPLOMAS
if (!empty($user_info['diplomas'])) {
$more_info .= '<div class="social-actions-message"><strong>'.get_lang('MyDiplomas').'</strong></div>';
$more_info .= '<div class="social-profile-extended">'.$user_info['diplomas'].'</div>';
$more_info .= '<br />';
}
// MY PRODUCTIONS
$more_info .= $productionString;
// WHAT I AM ABLE TO TEACH
if (!empty($user_info['teach'])) {
$more_info .= '<div class="social-actions-message"><strong>'.get_lang('MyTeach').'</strong></div>';
$more_info .= '<div class="social-profile-extended">'.$user_info['teach'].'</div>';
$more_info .= '<br />';
}
$socialRightInformation .= SocialManager::social_wrapper_div($more_info, 4);
}
}
$tpl = new Template(get_lang('Social'));
// Block Avatar Social
SocialManager::setSocialUserBlock(
$tpl,
$friendId,
'shared_profile',
0,
$show_full_profile
);
$tpl->assign('social_friend_block', $friend_html);
$tpl->assign('social_menu_block', $menu);
if ($portfolioRequest == true && api_get_setting('extended_profile') == true) {
$tpl->assign('add_post_form', $addPostFormPortfolio);
$socialRightInformation = null;
} else {
$tpl->assign('add_post_form', $addPostForm);
}
$tpl->assign('posts', $posts);
$tpl->assign('social_course_block', $social_course_block);
$tpl->assign('social_group_info_block', $social_group_info_block);
$tpl->assign('social_rss_block', $social_rss_block);
$tpl->assign('social_skill_block', SocialManager::getSkillBlock($friendId, 'vertical'));
$tpl->assign('session_list', $social_session_block);
$tpl->assign('invitations', $listInvitations);
$tpl->assign('social_right_information', $socialRightInformation);
$tpl->assign('social_auto_extend_link', $socialAutoExtendLink);
$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);
$tpl->display($tpl->get_template('social/profile.tpl'));

View File

@@ -0,0 +1,146 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Helper file for friends and groups profiles.
*
* @package chamilo.social
*
* @author Julio Montoya <gugli100@gmail.com>
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users();
if (api_get_setting('allow_social_tool') != 'true') {
api_not_allowed();
}
$views = ['friends', 'mygroups'];
$user_id = (int) $_GET['user_id'];
$userGroup = new UserGroup();
if (isset($_GET['view']) && in_array($_GET['view'], $views)) {
// show all friends by user_id
if ($_GET['view'] == 'friends') {
echo '<div style="margin-top:20px;">';
$list_path_friends = $list_path_normal_friends = $list_path_parents = [];
//SOCIALGOODFRIEND , USER_RELATION_TYPE_FRIEND, SOCIALPARENT
$friends = SocialManager::get_friends(
$user_id,
USER_RELATION_TYPE_FRIEND
);
$number_friends = count($friends);
$friend_html = '';
$friend_html .= '<div><h3>'.get_lang('SocialFriend').'</h3></div>';
$friend_html .= '<div id="friend-container" class="social-friend-container">';
$friend_html .= '<div id="friend-header" >';
if ($number_friends == 1) {
$friend_html .= '<div style="float:left;width:80%">'.$number_friends.' '.get_lang('Friend').'</div>';
} else {
$friend_html .= '<div style="float:left;width:80%">'.$number_friends.' '.get_lang('Friends').'</div>';
}
$friend_html .= '</div>'; // close div friend-header
for ($k = 0; $k < $number_friends; $k++) {
if (isset($friends[$k])) {
$friend = $friends[$k];
$name_user = api_get_person_name(
$friend['firstName'],
$friend['lastName']
);
$friend_html .= '<div id=div_'.$friend['friend_user_id'].' class="image_friend_network" ><span><center>';
$userPicture = UserManager::getUserPicture($friend['friend_user_id']);
$friend_html .= '<a href="profile.php?u='.$friend['friend_user_id'].'">';
$friend_html .= '<img src="'.$userPicture.'" id="imgfriend_'.$friend['friend_user_id'].'" title="'.$name_user.'" />';
$friend_html .= '</center></span>';
$friend_html .= '<center class="friend">'.$name_user.'</a></center>';
$friend_html .= '</div>';
}
}
echo $friend_html;
echo '</div>';
} else {
// show all groups by user_id
// MY GROUPS
$results = $userGroup->get_groups_by_user($user_id, 0);
$grid_my_groups = [];
if (is_array($results) && count($results) > 0) {
$i = 1;
foreach ($results as $result) {
$id = $result['id'];
$url_open = '<a href="group_view.php?id='.$id.'">';
$url_close = '</a>';
$icon = '';
$name = cut($result['name'], 20, true);
if ($result['relation_type'] == GROUP_USER_PERMISSION_ADMIN) {
$icon = Display::return_icon(
'social_group_admin.png',
get_lang('Admin'),
['style' => 'vertical-align:middle;width:16px;height:16px;']
);
} elseif ($result['relation_type'] == GROUP_USER_PERMISSION_MODERATOR) {
$icon = Display::return_icon(
'social_group_moderator.png',
get_lang('Moderator'),
['style' => 'vertical-align:middle;width:16px;height:16px;']
);
}
$count_users_group = count(
$userGroup->get_all_users_by_group($id)
);
if ($count_users_group == 1) {
$count_users_group = $count_users_group.' '.get_lang('Member');
} else {
$count_users_group = $count_users_group.' '.get_lang('Members');
}
$picture = $userGroup->get_picture_group(
$result['id'],
$result['picture'],
80
);
$item_name = '<div class="box_shared_profile_group_title">'.$url_open.api_xml_http_response_encode($name).$icon.$url_close.'</div>';
$item_description = '';
if (!empty($result['description'])) {
$item_description = '<div class="box_shared_profile_group_description">
<span class="social-groups-text2">'.
api_xml_http_response_encode(get_lang('Description')).'</span><p class="social-groups-text4">'.
cut(api_xml_http_response_encode($result['description']), 120, true).'</p></div>';
}
$result['picture_uri'] = '<div class="box_shared_profile_group_image">
<img class="social-groups-image" src="'.$picture['file'].'" /></div>';
$item_actions = '';
if (api_get_user_id() == $user_id) {
$item_actions = '<div class="box_shared_profile_group_actions"><a href="group_view.php?id='.$id.'">'.
get_lang('SeeMore').$url_close.'</div>';
}
$grid_my_groups[] = [
$item_name,
$url_open.$result['picture_uri'].$url_close,
$item_description.$item_actions,
];
$i++;
}
}
if (count($grid_my_groups) > 0) {
echo '<div style="margin-top:20px">';
echo '<div><h3>'.get_lang('MyGroups').'</h3></div>';
$count_groups = 0;
if (count($results) == 1) {
$count_groups = count($results).' '.get_lang('Group');
} else {
$count_groups = count($results).' '.get_lang('Groups');
}
echo '<div>'.$count_groups.'</div>';
foreach ($grid_my_groups as $group) {
echo Display::panel($group[0], $group[1]);
}
echo '</div>';
}
}
}

View File

@@ -0,0 +1,55 @@
<?php
/* For licensing terms, see /license.txt */
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_protect_admin_script();
if (api_get_setting('allow_social_tool') !== 'true') {
api_not_allowed(true);
}
$logInfo = [
'tool' => 'Messages',
'action' => 'promoted_messages_list',
];
Event::registerLog($logInfo);
$this_section = SECTION_SOCIAL;
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'social/home.php',
'name' => get_lang('SocialNetwork'),
];
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'social/promoted_messages.php',
'name' => get_lang('PromotedMessages'),
];
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('List')];
$menu = SocialManager::show_social_menu('messages');
// Right content
$social_right_content = '';
$keyword = '';
$actionsLeft = '<a href="'.api_get_path(WEB_CODE_PATH).'social/new_promoted_message.php">'.
Display::return_icon('new-message.png', get_lang('ComposeMessage'), [], 32).'</a>';
$form = MessageManager::getSearchForm(api_get_self());
if ($form->validate()) {
$values = $form->getSubmitValues();
$keyword = $values['keyword'];
}
$actionsRight = $form->returnForm();
$social_right_content .= Display::toolbarAction('toolbar', [$actionsLeft, $actionsRight]);
$social_right_content .= MessageManager::getPromotedMessagesGrid($keyword);
$tpl = new Template(null);
// Block Social Avatar
SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'messages');
$tpl->assign('social_menu_block', $menu);
$tpl->assign('social_right_content', $social_right_content);
$social_layout = $tpl->get_template('social/inbox.tpl');
$tpl->display($social_layout);

View File

@@ -0,0 +1,116 @@
<?php
/* For licensing terms, see /license.txt */
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
$isAllowed = api_get_configuration_value('show_link_request_hrm_user') && api_is_drh();
if (!$isAllowed) {
api_not_allowed(true);
}
$hrm = api_get_user_entity(api_get_user_id());
$usersRequested = UserManager::getUsersFollowedByUser(
$hrm->getId(),
null,
null,
false,
false,
null,
null,
null,
null,
null,
null,
HRM_REQUEST
);
$requestOptions = [];
foreach ($usersRequested as $userRequested) {
$userInfo = api_get_user_info($userRequested['user_id']);
if (!$userInfo) {
continue;
}
$requestOptions[$userInfo['user_id']] = $userInfo['complete_name'];
}
$form = new FormValidator('require_user_linking');
$form->addUserAvatar('hrm', get_lang('DRH'), 'medium');
$form->addSelectAjax(
'users',
[get_lang('LinkMeToStudent'), get_lang('LinkMeToStudentComment')],
$requestOptions,
[
'multiple' => 'multiple',
'url' => api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?a=get_user_like',
]
);
$form->addButtonSave(get_lang('RequestLinkToStudent'));
$form->setDefaults([
'hrm' => $hrm,
'users' => array_keys($requestOptions),
]);
if ($form->validate()) {
$values = $form->exportValues();
//Avoid self-subscribe as request
$usersId = array_filter($values['users'], function ($userId) use ($hrm) {
return (int) $userId != $hrm->getId();
});
UserManager::clearHrmRequestsForUser($hrm, $usersId);
UserManager::requestUsersToHRManager($hrm->getId(), $usersId, false);
Display::addFlash(
Display::return_message(get_lang('LinkingRequestsAdded'), 'success')
);
header('Location: '.api_get_self());
exit;
}
$usersAssigned = UserManager::get_users_followed_by_drh($hrm->getId());
$content = $form->returnForm();
$content .= Display::page_subheader(get_lang('AssignedUsersListToHumanResourcesManager'));
$content .= '<div class="row">';
foreach ($usersAssigned as $userAssigned) {
$userAssigned = api_get_user_info($userAssigned['user_id']);
$userPicture = isset($userAssigned["avatar_medium"]) ? $userAssigned["avatar_medium"] : $userAssigned["avatar"];
$studentLink = api_get_path(WEB_CODE_PATH).'mySpace/myStudents.php?student='.$userAssigned['user_id'];
$content .= '
<div class="col-sm-4 col-md-3">
<div class="media">
<div class="media-left">
';
$content .= '<a href="'.$studentLink.'">';
$content .= Display::img($userPicture, $userAssigned['complete_name'], ['class' => 'media-object'], false);
$content .= '</a>';
$content .= '
</div>
<div class="media-body">
<h4 class="media-heading"><a href="'.$studentLink.'">'.$userAssigned['complete_name'].'</a></h4>
'.$userAssigned['username'].'
</div>
</div>
</div>
';
}
$content .= '</div>';
$toolName = get_lang('RequestLinkingToUser');
$view = new Template($toolName);
$view->assign('header', $toolName);
$view->assign('content', $content);
$view->display_one_col_template();

258
main/social/search.php Normal file
View File

@@ -0,0 +1,258 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.social
*
* @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 (api_get_setting('allow_social_tool') != 'true') {
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('SocialNetwork'),
];
$query = isset($_GET['q']) ? htmlentities($_GET['q']) : null;
$queryNoTags = isset($_GET['q']) ? strip_tags($_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]) && $_GET[$field_name] != '0') {
$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($queryNoTags);
$groups = [];
$totalGroups = [];
$users = [];
$totalUsers = [];
$usergroup = new UserGroup();
// I'm searching something
if ($query != '' || ($query_vars['search_type'] == '1' && count($query_vars) > 2)) {
$itemPerPage = 6;
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);
// Get users from tags
$users = UserManager::get_all_user_tags($_GET['q'], 0, $from, $itemPerPage);
}
if ($_GET['search_type'] == '0' || $_GET['search_type'] == '2') {
$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('SorryNoResults')));
}
$results = '<div id="whoisonline">';
if (is_array($users) && count($users) > 0) {
$results .= '<div class="row">';
$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('SendInvitation').'</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 ($relation_type != 3 && $relation_type != 4 && $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('SendInvitation').'</a>';
}
$userIdHash = UserManager::generateUserHash($user_info['user_id']);
$sendMessageUrl = api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?'.http_build_query([
'a' => 'get_user_popup',
'hash' => $userIdHash,
]);
$sendMessage = Display::toolbarButton(
get_lang('SendMessage'),
$sendMessageUrl,
'envelope',
'default',
[
'class' => 'ajax btn-sm',
'data-title' => get_lang('SendMessage'),
]
);
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 ($user_info['status'] == 5) {
$user_icon = Display::return_icon('user.png', get_lang('Student'), null, ICON_SIZE_TINY);
} else {
$user_icon = Display::return_icon('teacher.png', get_lang('Teacher'), 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>';
}
$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 ($count_users_group == 1) {
$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('SeeMore').$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);

View File

@@ -0,0 +1,104 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.social
*
* @author Julio Montoya <gugli100@gmail.com>
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users();
Skill::isAllowed(api_get_user_id());
//Add the JS needed to use the jqgrid
$htmlHeadXtra[] = api_get_jqgrid_js();
$interbreadcrumb[] = ["url" => "index.php", "name" => get_lang('Skills')];
//jqgrid will use this URL to do the selects
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_user_skill_ranking';
//The order is important you need to check the the $column variable in the model.ajax.php file
$columns = [
get_lang('Photo'),
get_lang('FirstName'),
get_lang('LastName'),
get_lang('SkillsAcquired'),
get_lang('CurrentlyLearning'),
get_lang('Rank'),
];
$column_model = [
[
'name' => 'photo',
'index' => 'photo',
'width' => '10',
'align' => 'center',
'sortable' => 'false',
],
[
'name' => 'firstname',
'index' => 'firstname',
'width' => '70',
'align' => 'center',
'sortable' => 'false',
],
[
'name' => 'lastname',
'index' => 'lastname',
'width' => '70',
'align' => 'center',
'sortable' => 'false',
],
[
'name' => 'skills_acquired',
'index' => 'skills_acquired',
'width' => '30 ',
'align' => 'center',
'sortable' => 'false',
],
[
'name' => 'currently_learning',
'index' => 'currently_learning',
'width' => '30',
'align' => 'center',
'sortable' => 'false',
],
[
'name' => 'rank',
'index' => 'rank',
'width' => '30',
'align' => 'center',
'sortable' => 'false',
],
];
//Autowidth
$extra_params['autowidth'] = 'true';
//height auto
$extra_params['height'] = 'auto';
//$extra_params['excel'] = 'excel';
//$extra_params['rowList'] = array(10, 20 ,30);
$jqgrid = Display::grid_js(
'skill_ranking',
$url,
$columns,
$column_model,
$extra_params,
[],
null,
true
);
$content = Display::grid_html('skill_ranking');
$tpl = new Template(get_lang('Ranking'));
$tpl->assign('jqgrid_html', $jqgrid);
$template = $tpl->get_template('skill/skill_ranking.tpl');
$content .= $tpl->fetch($template);
$tpl->assign('content', $content);
$tpl->display_one_col_template();

View File

@@ -0,0 +1,34 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.admin
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_MYPROFILE;
api_block_anonymous_users();
Skill::isAllowed(api_get_user_id());
//Adds the JS needed to use the jqgrid
$htmlHeadXtra[] = api_get_jqgrid_js();
$htmlHeadXtra[] = api_get_js('jqueryui-touch-punch/jquery.ui.touch-punch.min.js');
$htmlHeadXtra[] = api_get_js('jquery.jsPlumb.all.js');
$htmlHeadXtra[] = api_get_js('skills.js');
$skill = new Skill();
$type = 'read'; //edit
$tree = $skill->getSkillsTree(api_get_user_id(), null, true);
$skill_visualizer = new SkillVisualizer($tree, $type);
$url = api_get_path(WEB_AJAX_PATH).'skill.ajax.php?1=1';
$tpl = new Template(null, false, false);
$tpl->assign('url', $url);
$tpl->assign('skill_visualizer', $skill_visualizer);
$template = $tpl->get_template('skill/skill_tree_student.tpl');
$content = $tpl->fetch($template);
$tpl->assign('content', $content);
$tpl->display_no_layout_template();

View File

@@ -0,0 +1,80 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.admin
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_SOCIAL;
api_block_anonymous_users();
Skill::isAllowed(api_get_user_id());
//Adds the JS needed to use the jqgrid
$htmlHeadXtra[] = api_get_js('d3/d3.v3.5.4.min.js');
$htmlHeadXtra[] = api_get_js('d3/colorbrewer.js');
$htmlHeadXtra[] = api_get_js('d3/jquery.xcolor.js');
$htmlHeadXtra[] = api_get_js('jquery.jsPlumb.all.js');
$htmlHeadXtra[] = api_get_js('jqueryui-touch-punch/jquery.ui.touch-punch.min.js');
$htmlHeadXtra[] = api_get_js('skills.js');
$tpl = new Template(null, false, false);
$userId = api_get_user_id();
$userInfo = api_get_user_info();
$skill = new Skill();
$ranking = $skill->getUserSkillRanking($userId);
$skills = $skill->getUserSkills($userId, true);
$dialogForm = new FormValidator('form', 'post', null, null, ['id' => 'add_item']);
$dialogForm->addLabel(
get_lang('Name'),
Display::tag('p', null, ['id' => 'name', 'class' => 'form-control-static'])
);
$dialogForm->addLabel(
get_lang('ShortCode'),
Display::tag('p', null, ['id' => 'short_code', 'class' => 'form-control-static'])
);
$dialogForm->addLabel(
get_lang('Parent'),
Display::tag('p', null, ['id' => 'parent', 'class' => 'form-control-static'])
);
$dialogForm->addLabel(
[
get_lang('Gradebook'),
get_lang('WithCertificate'),
],
Display::tag(
'ul',
null,
['id' => 'gradebook', 'class' => 'form-control-static list-unstyled']
)
);
$dialogForm->addLabel(
get_lang('Description'),
Display::tag('p', null, ['id' => 'description', 'class' => 'form-control-static'])
);
$type = 'read';
$tree = $skill->getSkillsTree($userId, null, true);
$skill_visualizer = new SkillVisualizer($tree, $type);
$tpl->assign('skill_visualizer', $skill_visualizer);
$tpl->assign('dialogForm', $dialogForm->returnForm());
$url = api_get_path(WEB_AJAX_PATH)."skill.ajax.php?a=get_skills_tree_json&load_user=$userId";
$tpl->assign('wheel_url', $url);
$url = api_get_path(WEB_AJAX_PATH).'skill.ajax.php?1=1';
$tpl->assign('url', $url);
$tpl->assign('user_info', $userInfo);
$tpl->assign('ranking', $ranking);
$tpl->assign('skills', $skills);
$template = $tpl->get_template('skill/skill_wheel_student.tpl');
$content = $tpl->fetch($template);
$tpl->assign('content', $content);
$tpl->display_no_layout_template();

70
main/social/terms.php Normal file
View File

@@ -0,0 +1,70 @@
<?php
/* For licensing terms, see /license.txt */
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
if (api_get_setting('allow_terms_conditions') !== 'true') {
api_not_allowed(true);
}
api_block_anonymous_users();
$language = api_get_interface_language();
$language = api_get_language_id($language);
$term = LegalManager::get_last_condition($language);
if (!$term) {
// look for the default language
$language = api_get_setting('platformLanguage');
$language = api_get_language_id($language);
$term = LegalManager::get_last_condition($language);
}
$termExtraFields = new ExtraFieldValue('terms_and_condition');
$values = $termExtraFields->getAllValuesByItem($term['id']);
foreach ($values as $value) {
if (!empty($value['value'])) {
$term['content'] .= '<h3>'.get_lang($value['display_text']).'</h3><br />'.$value['value'].'<br />';
}
}
$term['date_text'] = get_lang('PublicationDate').': '.
api_get_local_time(
$term['date'],
null,
null,
false,
true,
true
);
$socialMenuBlock = '';
$allowSocial = api_get_setting('allow_social_tool') === 'true';
if ($allowSocial) {
// Block Social Menu
$socialMenuBlock = SocialManager::show_social_menu('personal-data');
}
$tpl = new Template(null);
$actions = Display::url(
Display::return_icon('back.png', get_lang('Back'), [], ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'social/personal_data.php'
);
$tpl->assign('actions', Display::toolbarAction('toolbar', [$actions]));
// Block Social Avatar
SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'messages');
if (api_get_setting('allow_social_tool') === 'true') {
$tpl->assign('social_menu_block', $socialMenuBlock);
} else {
$tpl->assign('social_menu_block', '');
}
$tpl->assign('term', $term);
$socialLayout = $tpl->get_template('social/terms.tpl');
$tpl->display($socialLayout);

View File

@@ -0,0 +1,60 @@
<?php
/* For licensing terms, see /license.txt */
use JeroenDesloovere\VCard\VCard;
/**
* VCard Generator.
*
* @package chamilo.social
*
* @author José Loguercio Silva <jose.loguercio@beeznest.com>
*/
require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users();
if (isset($_REQUEST['userId'])) {
$userId = intval($_REQUEST['userId']);
} else {
api_not_allowed(true);
}
// Return User Info to vCard Export
$userInfo = api_get_user_info($userId, true, false, true);
/* Get the relationship between current user and vCard user */
$currentUserId = api_get_user_id();
$hasRelation = SocialManager::get_relation_between_contacts(
$currentUserId,
$userId,
true
);
if ($userId !== $currentUserId && $hasRelation == 0) {
/* if not the same user && has no relationship, bypass only if admin */
api_protect_admin_script();
}
if (empty($userInfo)) {
api_not_allowed(true);
}
if (api_get_user_id() != $userId && !SocialManager::get_relation_between_contacts(api_get_user_id(), $userId)) {
api_not_allowed(true);
}
// Pre-Loaded User Info
$language = get_lang('Language').': '.$userInfo['language'];
// Instance the vCard Class
$vcard = new VCard();
// Adding the User Info to the vCard
$vcard->addName($userInfo['firstname'], $userInfo['lastname']);
if (api_get_setting('show_email_addresses') == 'true') {
$vcard->addEmail($userInfo['email']);
}
$vcard->addPhoneNumber($userInfo['phone'], 'CELL');
$vcard->addNote($language);
// Generate the vCard
return $vcard->download();

View File

@@ -0,0 +1,41 @@
<?php
/* For licensing terms, see /license.txt */
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users();
if (api_get_setting('allow_social_tool') != 'true') {
api_not_allowed(true);
}
$this_section = SECTION_SOCIAL;
$interbreadcrumb[] = ['url' => api_get_path(WEB_PATH).'main/social/home.php', 'name' => get_lang('SocialNetwork')];
$interbreadcrumb[] = ['url' => 'promoted_messages.php', 'name' => get_lang('PromotedMessages')];
$social_right_content = '';
$messageId = $_GET['id'];
$message = '';
$logInfo = [
'tool' => 'Messages',
'action' => 'promoted_messages',
'action_details' => 'view-message',
];
Event::registerLog($logInfo);
$social_menu_block = SocialManager::show_social_menu('inbox');
$message .= MessageManager::showMessageBox($messageId, MessageManager::MESSAGE_TYPE_PROMOTED);
if (!empty($message)) {
$social_right_content .= $message;
} else {
api_not_allowed(true);
}
$tpl = new Template(get_lang('View'));
// Block Social Avatar
SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'promoted_messages');
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->assign('social_right_content', $social_right_content);
$social_layout = $tpl->get_template('social/inbox.tpl');
$tpl->display($social_layout);