Merge branch '1.9.x' of ssh://github.com/chamilo/chamilo-lms into chamilo19

1.9.x
Julio Montoya 10 years ago
commit 54a93bead8
  1. 2
      documentation/credits.html
  2. 70
      main/inc/lib/social.lib.php
  3. 6
      main/messages/inbox.php
  4. 6
      main/messages/new_message.php
  5. 6
      main/messages/outbox.php
  6. 6
      main/messages/view_message.php
  7. 6
      main/social/friends.php
  8. 6
      main/social/group_add.php
  9. 6
      main/social/group_edit.php
  10. 496
      main/social/group_invitation.php
  11. 202
      main/social/group_members.php
  12. 136
      main/social/group_topics.php
  13. 7
      main/social/group_waiting_list.php
  14. 744
      main/social/groups.php
  15. 339
      main/social/home.php
  16. 2
      main/social/index.php
  17. 13
      main/social/invitations.php
  18. 227
      main/social/message_for_group_form.inc.php
  19. 97
      main/social/myfiles.php
  20. 6
      main/social/profile.php
  21. 252
      main/social/profile_friends_and_groups.inc.php
  22. 6
      main/social/search.php
  23. 6
      main/template/default/layout/social_layout.tpl

@ -683,7 +683,7 @@ Note that we are infinitely grateful to our translators, having made the spread
<li>Gaëtan Frenoy, for efficient and well-coded updates to Drupal module and the integration with Drupal Ubercart in 1.9.8</li>
<li>Francis Gonzales Tello, for a first draft of the OpenMeetings plugin for 1.9.8</li>
<li>Maxim Solodovnik, for his help in the development of the OpenMeetings plugin for 1.9.8 - see https://issues.apache.org/jira/browse/OPENMEETINGS-802</li>
<li>Hector Lacherre, Alan Garcia, Genesis Lopez and Kenny Rodas, for their work extending Chamilo at USIL and letting us share the advance (notably for exercises tool and the tickets plugin) in 1.8 and 1.9</li>
<li>Hector Lacherre, Alan García, Genesis Lopez and Kenny Rodas, for their work extending Chamilo at USIL and letting us share the advance (notably for exercises tool and the tickets plugin) in 1.8 and 1.9</li>
<li>Adolfo Igualada Martínez, for changes to the glossary to PDF export for subdir installs in 1.9.8 (#6929)</li>
<li>Kevin Levron, for several contributions to Chamilo LMS 1.9.*</li>
<li>Cesar Perales, for several contributions to Chamilo LMS 1.9.*</li>

@ -566,43 +566,22 @@ class SocialManager extends UserManager
}
/**
* Shows the right menu of the Social Network tool
* Shows the avatar block in social pages
*
* @param string highlight link possible values: group_add, home, messages, messages_inbox, messages_compose ,messages_outbox ,invitations, shared_profile, friends, groups search
* @param int group id
* @param int user id
* @param bool show profile or not (show or hide the user image/information)
*
*/
public static function show_social_menu($show = '', $group_id = 0, $user_id = 0, $show_full_profile = false, $show_delete_account_button = false)
public static function show_social_avatar_block($show = '', $group_id = 0, $user_id = 0)
{
if (empty($user_id)) {
$user_id = api_get_user_id();
}
$user_info = api_get_user_info($user_id, true);
$current_user_id = api_get_user_id();
$current_user_info = api_get_user_info($current_user_id, true);
if ($current_user_id == $user_id) {
$user_friend_relation = null;
} else {
$user_friend_relation = SocialManager::get_relation_between_contacts($current_user_id, $user_id);
}
$show_groups = array('groups', 'group_messages', 'messages_list', 'group_add', 'mygroups', 'group_edit', 'member_list', 'invite_friends', 'waiting_list', 'browse_groups');
// get count unread message and total invitations
$count_unread_message = MessageManager::get_number_of_messages(true);
$count_unread_message = !empty($count_unread_message) ? Display::badge($count_unread_message) : null;
$number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id(api_get_user_id());
$group_pending_invitations = GroupPortalManager::get_groups_by_user(api_get_user_id(), GROUP_USER_PERMISSION_PENDING_INVITATION, false);
$group_pending_invitations = count($group_pending_invitations);
$total_invitations = $number_of_new_messages_of_friend + $group_pending_invitations;
$total_invitations = (!empty($total_invitations) ? Display::badge($total_invitations) : '');
$html = '<div class="social-menu">';
$html = '';
if (in_array($show, $show_groups) && !empty($group_id)) {
//--- Group image
$group_info = GroupPortalManager::get_group_data($group_id);
@ -638,6 +617,47 @@ class SocialManager extends UserManager
}
$html .= '</div>';
}
return $html;
}
/**
* Shows the right menu of the Social Network tool
*
* @param string highlight link possible values: group_add, home, messages, messages_inbox, messages_compose ,messages_outbox ,invitations, shared_profile, friends, groups search
* @param int group id
* @param int user id
* @param bool show profile or not (show or hide the user image/information)
*
*/
public static function show_social_menu($show = '', $group_id = 0, $user_id = 0, $show_full_profile = false, $show_delete_account_button = false)
{
if (empty($user_id)) {
$user_id = api_get_user_id();
}
$user_info = api_get_user_info($user_id, true);
$current_user_id = api_get_user_id();
$current_user_info = api_get_user_info($current_user_id, true);
if ($current_user_id == $user_id) {
$user_friend_relation = null;
} else {
$user_friend_relation = SocialManager::get_relation_between_contacts($current_user_id, $user_id);
}
$show_groups = array('groups', 'group_messages', 'messages_list', 'group_add', 'mygroups', 'group_edit', 'member_list', 'invite_friends', 'waiting_list', 'browse_groups');
// get count unread message and total invitations
$count_unread_message = MessageManager::get_number_of_messages(true);
$count_unread_message = !empty($count_unread_message) ? Display::badge($count_unread_message) : null;
$number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id(api_get_user_id());
$group_pending_invitations = GroupPortalManager::get_groups_by_user(api_get_user_id(), GROUP_USER_PERMISSION_PENDING_INVITATION, false);
$group_pending_invitations = count($group_pending_invitations);
$total_invitations = $number_of_new_messages_of_friend + $group_pending_invitations;
$total_invitations = (!empty($total_invitations) ? Display::badge($total_invitations) : '');
$html = '';
if (!in_array($show, array('shared_profile', 'groups', 'group_edit', 'member_list', 'waiting_list', 'invite_friends'))) {
@ -788,7 +808,7 @@ class SocialManager extends UserManager
$html .= Display::url(Display::return_icon('delete.png', get_lang('Unsubscribe'), array(), ICON_SIZE_TINY).get_lang('Unsubscribe'), $url);
$html .= '</li></ul></div>';
}
$html .= '</div>';
$html .= '';
return $html;
}

@ -129,7 +129,8 @@ if (isset($_GET['f']) && $_GET['f'] == 'social' || api_get_setting('allow_social
//LEFT CONTENT
if (api_get_setting('allow_social_tool') == 'true') {
$social_left_content = SocialManager::show_social_menu('messages');
$social_avatar_block = SocialManager::show_social_avatar_block('messages');
$social_menu_block = SocialManager::show_social_menu('messages');
}
//Right content
@ -165,7 +166,8 @@ if (api_get_setting('allow_social_tool') == 'true') {
$tpl = new Template(null);
if (api_get_setting('allow_social_tool') == 'true') {
$tpl->assign('social_left_content', $social_left_content);
$tpl->assign('social_avatar_block', $social_avatar_block);
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->assign('social_right_content', $social_right_content);
$social_layout = $tpl->get_template('layout/social_layout.tpl');
$tpl->display($social_layout);

@ -305,7 +305,8 @@ if ($group_id != 0) {
// LEFT COLUMN
$social_left_content = null;
if (api_get_setting('allow_social_tool') == 'true') {
$social_left_content = SocialManager::show_social_menu('messages');
$social_avatar_block = SocialManager::show_social_avatar_block('messages');
$social_menu_block = SocialManager::show_social_menu('messages');
$social_right_content .= '<div class="span9">';
$social_right_content .= '<div class="actions">';
$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php?f=social">'.Display::return_icon('back.png', get_lang('Back'), array(), 32).'</a>';
@ -362,7 +363,8 @@ if (api_get_setting('allow_social_tool') == 'true') {
$tpl = new Template(get_lang('ComposeMessage'));
if (api_get_setting('allow_social_tool') == 'true') {
$tpl->assign('social_left_content', $social_left_content);
$tpl->assign('social_avatar_block', $social_avatar_block);
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->assign('social_right_content', $social_right_content);
$social_layout = $tpl->get_template('layout/social_layout.tpl');
$tpl->display($social_layout);

@ -108,7 +108,8 @@ if (isset($_REQUEST['action'])) {
$social_right_content = '';
if (api_get_setting('allow_social_tool') == 'true') {
$social_left_content = SocialManager::show_social_menu('messages');
$social_avatar_block = SocialManager::show_social_avatar_block('messages');
$social_menu_block = SocialManager::show_social_menu('messages');
$social_right_content .= '<div class="span9">';
$social_right_content .= '<div class="actions">';
$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php?f=social">'.Display::return_icon('back.png', get_lang('Back'), array(), 32).'</a>';
@ -147,7 +148,8 @@ if (api_get_setting('allow_social_tool') == 'true') {
$tpl = new Template(get_lang('ComposeMessage'));
if (api_get_setting('allow_social_tool') == 'true') {
$tpl->assign('social_left_content', $social_left_content);
$tpl->assign('social_avatar_block', $social_avatar_block);
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->assign('social_right_content', $social_right_content);
$social_layout = $tpl->get_template('layout/social_layout.tpl');
$tpl->display($social_layout);

@ -54,7 +54,8 @@ $message = '';
//LEFT COLUMN
if (api_get_setting('allow_social_tool') == 'true') {
$social_left_content = SocialManager::show_social_menu($show_menu);
$social_avatar_block = SocialManager::show_social_avatar_block($show_menu);
$social_menu_block = SocialManager::show_social_menu($show_menu);
$message .='<div class="span9">';
}
//MAIN CONTENT
@ -71,7 +72,8 @@ if (!empty($message)) {
}
$tpl = new Template(get_lang('View'));
if (api_get_setting('allow_social_tool') == 'true') {
$tpl->assign('social_left_content', $social_left_content);
$tpl->assign('social_avatar_block', $social_avatar_block);
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->assign('social_right_content', $social_right_content);
$social_layout = $tpl->get_template('layout/social_layout.tpl');
$tpl->display($social_layout);

@ -86,7 +86,8 @@ function clear_form () {
$interbreadcrumb[] = array('url' => 'profile.php', 'name' => get_lang('SocialNetwork'));
$interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Friends'));
$social_left_content = SocialManager::show_social_menu('friends');
$social_avatar_block = SocialManager::show_social_avatar_block('friends');
$social_menu_block = SocialManager::show_social_menu('friends');
$user_id = api_get_user_id();
@ -142,7 +143,8 @@ $social_right_content .= '</div>';
$tpl = new Template(get_lang('Social'));
$tpl->assign('social_left_content', $social_left_content);
$tpl->assign('social_avatar_block', $social_avatar_block);
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->assign('social_right_content', $social_right_content);
$social_layout = $tpl->get_template('layout/social_layout.tpl');

@ -71,13 +71,15 @@ $interbreadcrumb[]= array ('url' =>'home.php','name' => get_lang('Social'));
$interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups'));
$interbreadcrumb[]= array ('url' =>'#','name' => $nameTools);
$social_left_content = SocialManager::show_social_menu('group_add');
$social_avatar_block = SocialManager::show_social_avatar_block('group_add');
$social_menu_block = SocialManager::show_social_menu('group_add');
$social_right_content = $form->return_form();
$tpl = new Template();
$tpl->set_help('Groups');
$tpl->assign('social_left_content', $social_left_content);
$tpl->assign('social_avatar_block', $social_avatar_block);
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->assign('social_right_content', $social_right_content);
//$tpl->assign('actions', $actions);
//$tpl->assign('message', $show_message);

@ -102,12 +102,14 @@ $big_image_width = $big_image_size['width'];
$big_image_height = $big_image_size['height'];
$url_big_image = $big_image.'?rnd='.time();
$social_left_content = SocialManager::show_social_menu('group_edit', $group_id);
$social_avatar_block = SocialManager::show_social_avatar_block('group_edit', $group_id);
$social_menu_block = SocialManager::show_social_menu('group_edit', $group_id);
$social_right_content = $form->return_form();
$tpl = new Template($tool_name);
$tpl->set_help('Groups');
$tpl->assign('social_left_content', $social_left_content);
$tpl->assign('social_avatar_block', $social_avatar_block);
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->assign('social_right_content', $social_right_content);
$social_layout = $tpl->get_template('layout/social_layout.tpl');
$tpl->display($social_layout);

@ -21,7 +21,7 @@ api_block_anonymous_users();
$xajax = new xajax();
$xajax->registerFunction ('search_users');
$xajax->registerFunction('search_users');
$add = isset($_GET['add']) ? Security::remove_XSS($_GET['add']) : null;
@ -31,25 +31,25 @@ $this_section = SECTION_PLATFORM_ADMIN;
// setting breadcrumbs
$this_section = SECTION_SOCIAL;
$interbreadcrumb[]= array ('url' =>'home.php','name' => get_lang('Social'));
$interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups'));
$interbreadcrumb[] = array('url' => 'home.php', 'name' => get_lang('Social'));
$interbreadcrumb[] = array('url' => 'groups.php', 'name' => get_lang('Groups'));
// Database Table Definitions
$tbl_group = Database::get_main_table(TABLE_MAIN_GROUP);
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP);
$tbl_group = Database::get_main_table(TABLE_MAIN_GROUP);
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP);
// setting the name of the tool
$tool_name = get_lang('SubscribeUsersToGroup');
$group_id = intval($_REQUEST['id']);
$add_type = 'multiple';
if (isset($_REQUEST['add_type']) && $_REQUEST['add_type']!='') {
if (isset($_REQUEST['add_type']) && $_REQUEST['add_type'] != '') {
$add_type = Security::remove_XSS($_REQUEST['add_type']);
}
//checking for extra field with filter on
require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
require_once api_get_path(LIBRARY_PATH) . 'group_portal_manager.lib.php';
//todo @this validation could be in a function in group_portal_manager
if (empty($group_id)) {
@ -65,8 +65,9 @@ if (empty($group_id)) {
}
}
function search_users($needle, $type) {
global $tbl_user,$tbl_group_rel_user,$group_id;
function search_users($needle, $type)
{
global $tbl_user, $tbl_group_rel_user, $group_id;
$xajax_response = new XajaxResponse();
$return = '';
@ -76,14 +77,15 @@ function search_users($needle, $type) {
$charset = api_get_system_encoding();
$needle = Database::escape_string($needle);
$needle = api_convert_encoding($needle, $charset, 'utf-8');
$user_anonymous=api_get_anonymous_id();
$user_anonymous = api_get_anonymous_id();
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
$order_clause = api_sort_by_first_name(
) ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
$cond_user_id = '';
if (!empty($id_session)) {
$group_id = Database::escape_string($group_id);
// check id_user from session_rel_user table
$sql = 'SELECT id_user FROM '.$tbl_group_rel_user.' WHERE group_id ="'.(int)$group_id.'"';
$sql = 'SELECT id_user FROM ' . $tbl_group_rel_user . ' WHERE group_id ="' . (int)$group_id . '"';
$res = Database::query($sql);
$user_ids = array();
if (Database::num_rows($res) > 0) {
@ -92,69 +94,90 @@ function search_users($needle, $type) {
}
}
if (count($user_ids) > 0) {
$cond_user_id = ' AND user_id NOT IN('.implode(",",$user_ids).')';
$cond_user_id = ' AND user_id NOT IN(' . implode(
",",
$user_ids
) . ')';
}
}
}
if ($type == 'single') {
// search users where username or firstname or lastname begins likes $needle
$sql = 'SELECT user_id, username, lastname, firstname FROM '.$tbl_user.' user
WHERE (username LIKE "'.$needle.'%"
OR firstname LIKE "'.$needle.'%"
OR lastname LIKE "'.$needle.'%") AND user_id<>"'.$user_anonymous.'"'.
$order_clause.
$sql = 'SELECT user_id, username, lastname, firstname FROM ' . $tbl_user . ' user
WHERE (username LIKE "' . $needle . '%"
OR firstname LIKE "' . $needle . '%"
OR lastname LIKE "' . $needle . '%") AND user_id<>"' . $user_anonymous . '"' .
$order_clause .
' LIMIT 11';
} else {
$sql = 'SELECT user_id, username, lastname, firstname FROM '.$tbl_user.' user
WHERE '.(api_sort_by_first_name() ? 'firstname' : 'lastname').' LIKE "'.$needle.'%" AND user_id<>"'.$user_anonymous.'"'.$cond_user_id.
$order_clause;
$sql = 'SELECT user_id, username, lastname, firstname FROM ' . $tbl_user . ' user
WHERE ' . (api_sort_by_first_name(
) ? 'firstname' : 'lastname') . ' LIKE "' . $needle . '%" AND user_id<>"' . $user_anonymous . '"' . $cond_user_id .
$order_clause;
}
if (api_is_multiple_url_enabled()) {
$tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
if (api_is_multiple_url_enabled()) {
$tbl_user_rel_access_url = Database::get_main_table(
TABLE_MAIN_ACCESS_URL_REL_USER
);
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) {
if ($type == 'single') {
$sql = 'SELECT user.user_id, username, lastname, firstname FROM '.$tbl_user.' user
INNER JOIN '.$tbl_user_rel_access_url.' url_user ON (url_user.user_id=user.user_id)
WHERE access_url_id = '.$access_url_id.' AND (username LIKE "'.$needle.'%"
OR firstname LIKE "'.$needle.'%"
OR lastname LIKE "'.$needle.'%") AND user.user_id<>"'.$user_anonymous.'"'.
$order_clause.
' LIMIT 11';
$sql = 'SELECT user.user_id, username, lastname, firstname FROM ' . $tbl_user . ' user
INNER JOIN ' . $tbl_user_rel_access_url . ' url_user ON (url_user.user_id=user.user_id)
WHERE access_url_id = ' . $access_url_id . ' AND (username LIKE "' . $needle . '%"
OR firstname LIKE "' . $needle . '%"
OR lastname LIKE "' . $needle . '%") AND user.user_id<>"' . $user_anonymous . '"' .
$order_clause .
' LIMIT 11';
} else {
$sql = 'SELECT user.user_id, username, lastname, firstname FROM '.$tbl_user.' user
INNER JOIN '.$tbl_user_rel_access_url.' url_user ON (url_user.user_id=user.user_id)
WHERE access_url_id = '.$access_url_id.'
AND '.(api_sort_by_first_name() ? 'firstname' : 'lastname').' LIKE "'.$needle.'%" AND user.user_id<>"'.$user_anonymous.'"'.$cond_user_id.
$order_clause;
$sql = 'SELECT user.user_id, username, lastname, firstname FROM ' . $tbl_user . ' user
INNER JOIN ' . $tbl_user_rel_access_url . ' url_user ON (url_user.user_id=user.user_id)
WHERE access_url_id = ' . $access_url_id . '
AND ' . (api_sort_by_first_name(
) ? 'firstname' : 'lastname') . ' LIKE "' . $needle . '%" AND user.user_id<>"' . $user_anonymous . '"' . $cond_user_id .
$order_clause;
}
}
}
$rs = Database::query($sql);
$i = 0;
if ($type=='single') {
if ($type == 'single') {
while ($user = Database :: fetch_array($rs)) {
$i++;
if ($i<=10) {
$person_name = api_get_person_name($user['firstname'], $user['lastname']);
$return .= '<a href="javascript: void(0);" onclick="javascript: add_user(\''.$user['user_id'].'\',\''.$person_name.' ('.$user['username'].')'.'\')">'.$person_name.' ('.$user['username'].')</a><br />';
if ($i <= 10) {
$person_name = api_get_person_name(
$user['firstname'],
$user['lastname']
);
$return .= '<a href="javascript: void(0);" onclick="javascript: add_user(\'' . $user['user_id'] . '\',\'' . $person_name . ' (' . $user['username'] . ')' . '\')">' . $person_name . ' (' . $user['username'] . ')</a><br />';
} else {
$return .= '...<br />';
}
}
$xajax_response -> addAssign('ajax_list_users_single','innerHTML',api_utf8_encode($return));
$xajax_response->addAssign(
'ajax_list_users_single',
'innerHTML',
api_utf8_encode($return)
);
} else {
$return .= '<select id="origin_users" name="nosessionUsersList[]" multiple="multiple" size="15" style="width:360px;">';
while ($user = Database :: fetch_array($rs)) {
$person_name = api_get_person_name($user['firstname'], $user['lastname']);
$return .= '<option value="'.$user['user_id'].'">'.$person_name.' ('.$user['username'].')</option>';
$person_name = api_get_person_name(
$user['firstname'],
$user['lastname']
);
$return .= '<option value="' . $user['user_id'] . '">' . $person_name . ' (' . $user['username'] . ')</option>';
}
$return .= '</select>';
$xajax_response -> addAssign('ajax_list_users_multiple','innerHTML',api_utf8_encode($return));
$xajax_response->addAssign(
'ajax_list_users_multiple',
'innerHTML',
api_utf8_encode($return)
);
}
}
return $xajax_response;
}
return $xajax_response;
}
$xajax->processRequests();
@ -162,45 +185,44 @@ $xajax->processRequests();
$htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/');
$htmlHeadXtra[] = '<script>
function add_user (code, content) {
// document.getElementById("user_to_add").value = "";
//document.getElementById("ajax_list_users_single").innerHTML = "";
destination = document.getElementById("destination_users");
for (i=0;i<destination.length;i++) {
if(destination.options[i].text == content) {
return false;
}
}
destination.options[destination.length] = new Option(content,code);
destination.selectedIndex = -1;
sortOptions(destination.options);
// document.getElementById("user_to_add").value = "";
//document.getElementById("ajax_list_users_single").innerHTML = "";
destination = document.getElementById("destination_users");
for (i=0;i<destination.length;i++) {
if(destination.options[i].text == content) {
return false;
}
}
destination.options[destination.length] = new Option(content,code);
destination.selectedIndex = -1;
sortOptions(destination.options);
}
function remove_item(origin) {
for(var i = 0 ; i<origin.options.length ; i++) {
if(origin.options[i].selected) {
origin.options[i]=null;
i = i-1;
}
}
for(var i = 0 ; i<origin.options.length ; i++) {
if(origin.options[i].selected) {
origin.options[i]=null;
i = i-1;
}
}
}
function validate_filter() {
document.formulaire.add_type.value = \''.$add_type.'\';
document.formulaire.form_sent.value=0;
document.formulaire.submit();
document.formulaire.add_type.value = \'' . $add_type . '\';
document.formulaire.form_sent.value=0;
document.formulaire.submit();
}
</script>';
$form_sent=0;
$errorMsg = $firstLetterUser = $firstLetterSession='';
$form_sent = 0;
$errorMsg = $firstLetterUser = $firstLetterSession = '';
$UserList = array();
$SessionList = array();
$sessions = array();
$Users = array();
if (isset($_POST['form_sent']) && $_POST['form_sent']) {
$form_sent = $_POST['form_sent'];
$user_list = $_POST['sessionUsersList'];
$group_id = intval($_POST['id']);
$form_sent = $_POST['form_sent'];
$user_list = $_POST['sessionUsersList'];
$group_id = intval($_POST['id']);
if (!is_array($user_list)) {
$user_list = array();
@ -212,15 +234,21 @@ if (isset($_POST['form_sent']) && $_POST['form_sent']) {
array($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>';
$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);
$result = MessageManager::send_message(
$user_id,
$title,
$content
);
}
}
}
@ -228,33 +256,36 @@ if (isset($_POST['form_sent']) && $_POST['form_sent']) {
$nosessionUsersList = $sessionUsersList = array();
$ajax_search = $add_type == 'unique' ? true : false;
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
$order_clause = api_sort_by_first_name(
) ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
if ($ajax_search) {
$sql= "SELECT u.user_id, lastname, firstname, username, group_id
$sql = "SELECT u.user_id, lastname, firstname, username, group_id
FROM $tbl_user u
LEFT JOIN $tbl_group_rel_user gu
ON (gu.user_id = u.user_id)
WHERE gu.group_id = $group_id $order_clause";
if (api_is_multiple_url_enabled()) {
$tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
if (api_is_multiple_url_enabled()) {
$tbl_user_rel_access_url = Database::get_main_table(
TABLE_MAIN_ACCESS_URL_REL_USER
);
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) {
$sql = "SELECT u.user_id, lastname, firstname, username, id_session
FROM $tbl_user u
INNER JOIN $tbl_session_rel_user
ON $tbl_session_rel_user.id_user = u.user_id
AND $tbl_session_rel_user.id_session = ".intval($id_session)."
AND $tbl_session_rel_user.id_session = " . intval($id_session) . "
INNER JOIN $tbl_user_rel_access_url url_user ON (url_user.user_id=u.user_id)
WHERE access_url_id = $access_url_id
$order_clause";
}
}
}
$result = Database::query($sql);
$Users = Database::store_result($result);
foreach ($Users as $user) {
$sessionUsersList[$user['user_id']] = $user ;
$sessionUsersList[$user['user_id']] = $user;
}
} else {
$friends = SocialManager::get_friends(api_get_user_id());
@ -264,7 +295,10 @@ if ($ajax_search) {
$suggest_friends = true;
} else {
foreach ($friends as $friend) {
$group_friend_list = GroupPortalManager::get_groups_by_user($friend['friend_user_id'], 0);
$group_friend_list = GroupPortalManager::get_groups_by_user(
$friend['friend_user_id'],
0
);
$friend_group_id = '';
if (isset($group_friend_list[$group_id]) && $group_friend_list[$group_id]['id'] == $group_id) {
$friend_group_id = $group_id;
@ -274,8 +308,8 @@ if ($ajax_search) {
'user_id' => $friend['friend_user_id'],
'firstname' => $friend['firstName'],
'lastname' => $friend['lastName'],
'username' =>$friend['username'],
'group_id'=> $friend_group_id
'username' => $friend['username'],
'group_id' => $friend_group_id
);
}
}
@ -291,7 +325,7 @@ if ($ajax_search) {
// Deleting anonymous users
$user_anonymous = api_get_anonymous_id();
foreach ($nosessionUsersList as $key_user_list =>$value_user_list) {
foreach ($nosessionUsersList as $key_user_list => $value_user_list) {
if ($nosessionUsersList[$key_user_list]['user_id'] == $user_anonymous) {
unset($nosessionUsersList[$key_user_list]);
}
@ -299,26 +333,51 @@ if ($ajax_search) {
}
if ($add_type == 'multiple') {
$link_add_type_unique = '<a href="'.api_get_self().'?id='.$group_id.'&add='.$add.'&add_type=unique">'.Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').'</a>';
$link_add_type_multiple = Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple');
$link_add_type_unique = '<a href="' . api_get_self(
) . '?id=' . $group_id . '&add=' . $add . '&add_type=unique">' . Display::return_icon(
'single.gif'
) . get_lang('SessionAddTypeUnique') . '</a>';
$link_add_type_multiple = Display::return_icon('multiple.gif') . get_lang(
'SessionAddTypeMultiple'
);
} else {
$link_add_type_unique = Display::return_icon('single.gif').get_lang('SessionAddTypeUnique');
$link_add_type_multiple = '<a href="'.api_get_self().'?id='.$group_id.'&add='.$add.'&add_type=multiple">'.Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').'</a>';
$link_add_type_unique = Display::return_icon('single.gif') . get_lang(
'SessionAddTypeUnique'
);
$link_add_type_multiple = '<a href="' . api_get_self(
) . '?id=' . $group_id . '&add=' . $add . '&add_type=multiple">' . Display::return_icon(
'multiple.gif'
) . get_lang('SessionAddTypeMultiple') . '</a>';
}
$social_left_content = SocialManager::show_social_menu('invite_friends',$group_id);
$social_right_content = '<h2>'.Security::remove_XSS($group_info['name'], STUDENT, true).'</h2>';
$social_avatar_block = SocialManager::show_social_avatar_block(
'invite_friends',
$group_id
);
$social_menu_block = SocialManager::show_social_menu(
'invite_friends',
$group_id
);
$social_right_content = '<h2>' . Security::remove_XSS(
$group_info['name'],
STUDENT,
true
) . '</h2>';
if (count($nosessionUsersList) == 0) {
$friends = SocialManager::get_friends(api_get_user_id());
if ($friends == 0) {
$social_right_content .= get_lang('YouNeedToHaveFriendsInYourSocialNetwork');
$social_right_content .= get_lang(
'YouNeedToHaveFriendsInYourSocialNetwork'
);
} else {
$social_right_content .= get_lang('YouAlreadyInviteAllYourContacts');
$social_right_content .= get_lang('YouAlreadyInviteAllYourContacts');
}
$social_right_content .= '<div>';
$social_right_content .= '<a href="search.php">'.get_lang('TryAndFindSomeFriends').'</a>';
$social_right_content .= '</div>';
$social_right_content .= '<div>';
$social_right_content .= '<a href="search.php">' . get_lang(
'TryAndFindSomeFriends'
) . '</a>';
$social_right_content .= '</div>';
}
$add_true = null;
@ -330,57 +389,31 @@ if ($ajax_search) {
$ajax = 'onsubmit="valide();"';
}
$form = '<form name="formulaire" method="post" action="'.api_get_self().'?id='.$group_id.$add_true.'" style="margin:0px;" '.$ajax.'>';
/*$extra_field_list = UserManager::get_extra_fields();
if ($add_type == 'multiple') {
if (is_array($extra_field_list)) {
if (is_array($new_field_list) && count($new_field_list)>0 ) {
$form .= '<h3>'.get_lang('FilterUsers').'</h3>';
foreach ($new_field_list as $new_field) {
$form .= $new_field['name'];
$varname = 'field_'.$new_field['variable'];
$form .= '&nbsp;<select name="'.$varname.'">';
$form .= '<option value="0">--'.get_lang('Select').'--</option>';
foreach ($new_field['data'] as $option) {
$checked='';
if (isset($_POST[$varname])) {
if ($_POST[$varname]==$option[1]) {
$checked = 'selected="true"';
}
}
$form .= '<option value="'.$option[1].'" '.$checked.'>'.$option[1].'</option>';
}
$form .= '</select>';
$form .= '&nbsp;&nbsp;';
}
$form .= '<input type="button" value="'.get_lang('Filter').'" onclick="validate_filter()" />';
$form .= '<br /><br />';
}
}
}*/
$form .= '<input type="hidden" name="form_sent" value="1" />';
$form .= '<input type="hidden" name="id" value="'.$group_id.'">';
$form .= '<input type="hidden" name="add_type" />';
$form = '<form name="formulaire" method="post" action="' . api_get_self().
'?id=' . $group_id . $add_true . '" style="margin:0px;" ' . $ajax . '>';
$form .= '<input type="hidden" name="form_sent" value="1" />';
$form .= '<input type="hidden" name="id" value="' . $group_id . '">';
$form .= '<input type="hidden" name="add_type" />';
if (!empty($errorMsg)) {
$form .= Display::return_message($errorMsg,'error'); //main API
$form .= Display::return_message($errorMsg, 'error'); //main API
}
$form .= '<table border="0" cellpadding="5" cellspacing="0" width="100%">
<tr>
<td align="center"><b>'.get_lang('Friends').' :</b>
<td align="center"><b>' . get_lang('Friends') . ' :</b>
</td>
<td></td>
<td align="center"><b>'.get_lang('SendInvitationTo').':</b></td></tr>';
<td align="center"><b>' . get_lang('SendInvitationTo') . ':</b></td></tr>';
if ($add_type=='no') {
$form .='
if ($add_type == 'no') {
$form .= '
<tr>
<td align="center">'.get_lang('FirstLetterUser').' :
<td align="center">' . get_lang('FirstLetterUser') . ' :
<select name="firstLetterUser" onchange = "xajax_search_users(this.value,\'multiple\')" >
<option value = "%">--</option>
'.Display :: get_alphabet_options().'
' . Display :: get_alphabet_options() . '
</select>
</td>
<td align="center">&nbsp;</td>
@ -392,16 +425,24 @@ $form .= '
<td align="center">
<div id="content_source">';
if (!($add_type=='multiple')) {
$form .='<input type="text" id="user_to_add" onkeyup="xajax_search_users(this.value,\'single\')" /><div id="ajax_list_users_single"></div>';
if (!($add_type == 'multiple')) {
$form .= '<input type="text" id="user_to_add" onkeyup="xajax_search_users(this.value,\'single\')" /><div id="ajax_list_users_single"></div>';
} else {
$form .= '<div id="ajax_list_users_multiple">
<select id="origin_users" name="nosessionUsersList[]" multiple="multiple" size="15" style="width:290px;">';
foreach ($nosessionUsersList as $enreg) {
$selected = '';
if(in_array($enreg['user_id'],$UserList)) $selected = 'selected="selected"';
$form .= '<option value="'.$enreg['user_id'].'" '.$selected.'>'.api_get_person_name($enreg['firstname'], $enreg['lastname']).' ('.$enreg['username'].') </option>';
if (in_array(
$enreg['user_id'],
$UserList
)
) {
$selected = 'selected="selected"';
}
$form .= '<option value="' . $enreg['user_id'] . '" ' . $selected . '>' .
api_get_person_name($enreg['firstname'], $enreg['lastname']).
' (' . $enreg['username'] . ') </option>';
}
$form .= '</select>';
$form .= '</div>';
@ -411,7 +452,7 @@ $form .= '</div>';
$form .= '</td><td width="10%" valign="middle" align="center">';
if ($ajax_search) {
$form .= '<button class="arrowl" type="button" onclick="remove_item(document.getElementById(\'destination_users\'))" ></button>';
$form .= '<button class="arrowl" type="button" onclick="remove_item(document.getElementById(\'destination_users\'))" ></button>';
} else {
$form .= '<button class="arrowr" type="button" onclick="moveItem(document.getElementById(\'origin_users\'), document.getElementById(\'destination_users\'))" ></button>
<br /><br />
@ -419,20 +460,25 @@ if ($ajax_search) {
<br /><br />';
}
$form .= ' <br /><br /><br /><br /><br />
$form .= ' <br /><br /><br /><br /><br />
</td>
<td align="center">
<select id="destination_users" name="sessionUsersList[]" multiple="multiple" size="15" style="width:290px;">';
foreach ($sessionUsersList as $enreg) {
$form .= ' <option value="'.$enreg['user_id'].'">'.api_get_person_name($enreg['firstname'], $enreg['lastname']).' ('.$enreg['username'].')</option>';
$form .= ' <option value="' . $enreg['user_id'] . '">' . api_get_person_name(
$enreg['firstname'],
$enreg['lastname']
) . ' (' . $enreg['username'] . ')</option>';
}
$form .= '</select></td>
</tr>
<tr>
<td colspan="3" align="center">
<br />
<button class="save" type="button" value="" onclick="valide()" >'.get_lang('InviteUsersToGroup').'</button>
<button class="save" type="button" value="" onclick="valide()" >' . get_lang(
'InviteUsersToGroup'
) . '</button>
</td>
</tr>
</table>
@ -441,15 +487,28 @@ $form .= '</select></td>
$social_right_content .= $form;
// Current group members
$members = GroupPortalManager::get_users_by_group($group_id, false, array(GROUP_USER_PERMISSION_PENDING_INVITATION));
if (is_array($members) && count($members)>0) {
foreach ($members as &$member) {
$image_path = UserManager::get_user_picture_path_by_id($member['user_id'], 'web', false, true);
$picture = UserManager::get_picture_user($member['user_id'], $image_path['file'],80);
$member['image'] = '<img src="'.$picture['file'].'" width="50px" height="50px" />';
}
$social_right_content .= '<h3>'.get_lang('UsersAlreadyInvited').'</h3>';
$social_right_content .= Display::return_sortable_grid(
$members = GroupPortalManager::get_users_by_group(
$group_id,
false,
array(GROUP_USER_PERMISSION_PENDING_INVITATION)
);
if (is_array($members) && count($members) > 0) {
foreach ($members as &$member) {
$image_path = UserManager::get_user_picture_path_by_id(
$member['user_id'],
'web',
false,
true
);
$picture = UserManager::get_picture_user(
$member['user_id'],
$image_path['file'],
80
);
$member['image'] = '<img src="' . $picture['file'] . '" width="50px" height="50px" />';
}
$social_right_content .= '<h3>' . get_lang('UsersAlreadyInvited') . '</h3>';
$social_right_content .= Display::return_sortable_grid(
'invitation_profile',
array(),
$members,
@ -462,90 +521,89 @@ if (is_array($members) && count($members)>0) {
$htmlHeadXtra[] = '<script>
function moveItem(origin , destination) {
for(var i = 0 ; i<origin.options.length ; i++) {
if(origin.options[i].selected) {
destination.options[destination.length] = new Option(origin.options[i].text,origin.options[i].value);
origin.options[i]=null;
i = i-1;
}
}
destination.selectedIndex = -1;
sortOptions(destination.options);
for(var i = 0 ; i<origin.options.length ; i++) {
if(origin.options[i].selected) {
destination.options[destination.length] = new Option(origin.options[i].text,origin.options[i].value);
origin.options[i]=null;
i = i-1;
}
}
destination.selectedIndex = -1;
sortOptions(destination.options);
}
function sortOptions(options) {
newOptions = new Array();
for (i = 0 ; i<options.length ; i++)
newOptions[i] = options[i];
newOptions = newOptions.sort(mysort);
options.length = 0;
for(i = 0 ; i < newOptions.length ; i++)
options[i] = newOptions[i];
newOptions = new Array();
for (i = 0 ; i<options.length ; i++)
newOptions[i] = options[i];
newOptions = newOptions.sort(mysort);
options.length = 0;
for(i = 0 ; i < newOptions.length ; i++)
options[i] = newOptions[i];
}
function mysort(a, b){
if(a.text.toLowerCase() > b.text.toLowerCase()){
return 1;
}
if(a.text.toLowerCase() < b.text.toLowerCase()){
return -1;
}
return 0;
if(a.text.toLowerCase() > b.text.toLowerCase()){
return 1;
}
if(a.text.toLowerCase() < b.text.toLowerCase()){
return -1;
}
return 0;
}
function valide(){
var options = document.getElementById(\'destination_users\').options;
for (i = 0 ; i<options.length ; i++)
options[i].selected = true;
document.forms.formulaire.submit();
var options = document.getElementById(\'destination_users\').options;
for (i = 0 ; i<options.length ; i++)
options[i].selected = true;
document.forms.formulaire.submit();
}
function loadUsersInSelect(select) {
var xhr_object = null;
if(window.XMLHttpRequest) // Firefox
xhr_object = new XMLHttpRequest();
else if(window.ActiveXObject) // Internet Explorer
xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
else // XMLHttpRequest non supporté par le navigateur
alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
xhr_object.open("POST", "loadUsersInSelect.ajax.php");
xhr_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
nosessionUsers = makepost(document.getElementById("origin_users"));
sessionUsers = makepost(document.getElementById("destination_users"));
nosessionClasses = makepost(document.getElementById("origin_classes"));
sessionClasses = makepost(document.getElementById("destination_classes"));
xhr_object.send("nosessionusers="+nosessionUsers+"&sessionusers="+sessionUsers+"&nosessionclasses="+nosessionClasses+"&sessionclasses="+sessionClasses);
xhr_object.onreadystatechange = function() {
if(xhr_object.readyState == 4) {
document.getElementById("content_source").innerHTML = result = xhr_object.responseText;
}
}
var xhr_object = null;
if(window.XMLHttpRequest) // Firefox
xhr_object = new XMLHttpRequest();
else if(window.ActiveXObject) // Internet Explorer
xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
else // XMLHttpRequest non supporté par le navigateur
alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
xhr_object.open("POST", "loadUsersInSelect.ajax.php");
xhr_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
nosessionUsers = makepost(document.getElementById("origin_users"));
sessionUsers = makepost(document.getElementById("destination_users"));
nosessionClasses = makepost(document.getElementById("origin_classes"));
sessionClasses = makepost(document.getElementById("destination_classes"));
xhr_object.send("nosessionusers="+nosessionUsers+"&sessionusers="+sessionUsers+"&nosessionclasses="+nosessionClasses+"&sessionclasses="+sessionClasses);
xhr_object.onreadystatechange = function() {
if(xhr_object.readyState == 4) {
document.getElementById("content_source").innerHTML = result = xhr_object.responseText;
}
}
}
function makepost(select) {
var options = select.options;
var ret = "";
for (i = 0 ; i<options.length ; i++)
ret = ret + options[i].value +\'::\'+options[i].text+";;";
return ret;
var options = select.options;
var ret = "";
for (i = 0 ; i<options.length ; i++)
ret = ret + options[i].value +\'::\'+options[i].text+";;";
return ret;
}
</script>';
$social_right_content = Display::div($social_right_content, array('class' => 'span9'));
$social_right_content = Display::div(
$social_right_content,
array('class' => 'span9')
);
$tpl = new Template($tool_name);
$tpl->set_help('Groups');
$tpl->assign('social_left_content', $social_left_content);
//$tpl->assign('social_left_menu', $social_left_menu);
$tpl->assign('social_avatar_block', $social_avatar_block);
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->assign('social_right_content', $social_right_content);
//$tpl->assign('actions', $actions);
//$tpl->assign('content', $content);
$social_layout = $tpl->get_template('layout/social_layout.tpl');
$tpl->display($social_layout);

@ -12,114 +12,177 @@ $cidReset = true;
require_once '../inc/global.inc.php';
api_block_anonymous_users();
if (api_get_setting('allow_social_tool') !='true') {
if (api_get_setting('allow_social_tool') != 'true') {
api_not_allowed();
}
require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
require_once api_get_path(LIBRARY_PATH) . 'group_portal_manager.lib.php';
$this_section = SECTION_SOCIAL;
$interbreadcrumb[]= array ('url' =>'home.php','name' => get_lang('Social'));
$interbreadcrumb[] = array('url' => 'groups.php','name' => get_lang('Groups'));
$interbreadcrumb[] = array('url' => '#','name' => get_lang('MemberList'));
$interbreadcrumb[] = array('url' => 'home.php', 'name' => get_lang('Social'));
$interbreadcrumb[] = array('url' => 'groups.php', 'name' => get_lang('Groups'));
$interbreadcrumb[] = array('url' => '#', 'name' => get_lang('MemberList'));
$group_id = intval($_GET['id']);
$group_id = intval($_GET['id']);
//todo @this validation could be in a function in group_portal_manager
if (empty($group_id)) {
api_not_allowed();
api_not_allowed();
} else {
$group_info = GroupPortalManager::get_group_data($group_id);
if (empty($group_info)) {
api_not_allowed();
}
$user_role = GroupPortalManager::get_user_group_role(api_get_user_id(), $group_id);
if (!in_array($user_role, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_MODERATOR, GROUP_USER_PERMISSION_READER))) {
api_not_allowed();
}
$group_info = GroupPortalManager::get_group_data($group_id);
if (empty($group_info)) {
api_not_allowed();
}
$user_role = GroupPortalManager::get_user_group_role(
api_get_user_id(),
$group_id
);
if (!in_array(
$user_role,
array(
GROUP_USER_PERMISSION_ADMIN,
GROUP_USER_PERMISSION_MODERATOR,
GROUP_USER_PERMISSION_READER
)
)
) {
api_not_allowed();
}
}
$show_message = '';
$show_message = '';
//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 (GroupPortalManager::is_group_moderator($group_id)) {
GroupPortalManager::update_user_role($user_join, $group_id);
$show_message = get_lang('UserAdded');
}
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 (GroupPortalManager::is_group_moderator($group_id)) {
GroupPortalManager::update_user_role($user_join, $group_id);
$show_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 (GroupPortalManager::is_group_moderator($group_id)) {
GroupPortalManager::delete_user_rel_group($user_join, $group_id);
$show_message = Display::return_message(get_lang('UserDeleted'));
}
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 (GroupPortalManager::is_group_moderator($group_id)) {
GroupPortalManager::delete_user_rel_group($user_join, $group_id);
$show_message = 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 (GroupPortalManager::is_group_admin($group_id)) {
GroupPortalManager::update_user_role($user_moderator, $group_id, GROUP_USER_PERMISSION_MODERATOR);
$show_message = Display::return_message(get_lang('UserChangeToModerator'));
}
if (isset($_GET['action']) && $_GET['action'] == 'set_moderator') {
// we add a user only if is a open group
$user_moderator = intval($_GET['u']);
//if i'm the admin
if (GroupPortalManager::is_group_admin($group_id)) {
GroupPortalManager::update_user_role(
$user_moderator,
$group_id,
GROUP_USER_PERMISSION_MODERATOR
);
$show_message = 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 (GroupPortalManager::is_group_admin($group_id)) {
GroupPortalManager::update_user_role($user_moderator, $group_id, GROUP_USER_PERMISSION_READER);
$show_message = Display::return_message(get_lang('UserChangeToReader'));
}
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 (GroupPortalManager::is_group_admin($group_id)) {
GroupPortalManager::update_user_role(
$user_moderator,
$group_id,
GROUP_USER_PERMISSION_READER
);
$show_message = Display::return_message(get_lang('UserChangeToReader'));
}
}
$users = GroupPortalManager::get_users_by_group(
$users = GroupPortalManager::get_users_by_group(
$group_id,
false,
array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_READER, GROUP_USER_PERMISSION_MODERATOR),
array(
GROUP_USER_PERMISSION_ADMIN,
GROUP_USER_PERMISSION_READER,
GROUP_USER_PERMISSION_MODERATOR
),
0,
1000
);
$new_member_list = array();
$social_left_content = SocialManager::show_social_menu('member_list',$group_id);
$social_right_content = '<h2>'.$group_info['name'].'</h2>';
$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>';
$social_right_content .= '<div style="width:90%">';
foreach($users as $user) {
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;
$user['link'] = Display::return_icon(
'social_group_admin.png',
get_lang('Admin')
);
break;
case GROUP_USER_PERMISSION_READER:
if (in_array($user_role, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_MODERATOR))) {
$user['link'] = '<a href="group_members.php?id='.$group_id.'&u='.$user['user_id'].'&action=delete">'.Display::return_icon('delete.png', get_lang('DeleteFromGroup')).'</a>'.
'<a href="group_members.php?id='.$group_id.'&u='.$user['user_id'].'&action=set_moderator">'.Display::return_icon('social_moderator_add.png', get_lang('AddModerator')).'</a>';
if (in_array(
$user_role,
array(
GROUP_USER_PERMISSION_ADMIN,
GROUP_USER_PERMISSION_MODERATOR
)
)
) {
$user['link'] = '<a href="group_members.php?id=' . $group_id . '&u=' . $user['user_id'] . '&action=delete">' . Display::return_icon(
'delete.png',
get_lang('DeleteFromGroup')
) . '</a>' .
'<a href="group_members.php?id=' . $group_id . '&u=' . $user['user_id'] . '&action=set_moderator">' . Display::return_icon(
'social_moderator_add.png',
get_lang('AddModerator')
) . '</a>';
}
break;
break;
case GROUP_USER_PERMISSION_PENDING_INVITATION:
$user['link'] = '<a href="group_members.php?id='.$group_id.'&u='.$user['user_id'].'&action=add">'.Display::return_icon('pending_invitation.png', get_lang('PendingInvitation')).'</a>';
break;
$user['link'] = '<a href="group_members.php?id=' . $group_id . '&u=' . $user['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'));
$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['user_id'].'&action=delete_moderator">'.Display::return_icon('social_moderator_delete.png', get_lang('DeleteModerator')).'</a>';
$user['link'] .= '<a href="group_members.php?id=' . $group_id . '&u=' . $user['user_id'] . '&action=delete_moderator">' . Display::return_icon(
'social_moderator_delete.png',
get_lang('DeleteModerator')
) . '</a>';
}
break;
break;
}
$image_path = UserManager::get_user_picture_path_by_id($user['user_id'], 'web', false, true);
$picture = UserManager::get_picture_user($user['user_id'], $image_path['file'],80);
$user['image'] = '<img src="'.$picture['file'].'" width="50px" height="50px" />';
$image_path = UserManager::get_user_picture_path_by_id(
$user['user_id'],
'web',
false,
true
);
$picture = UserManager::get_picture_user(
$user['user_id'],
$image_path['file'],
80
);
$user['image'] = '<img src="' . $picture['file'] . '" width="50px" height="50px" />';
$new_member_list[] = $user;
}
@ -128,7 +191,7 @@ if (count($new_member_list) > 0) {
'list_members',
array(),
$new_member_list,
array('hide_navigation'=>true, 'per_page' => 100),
array('hide_navigation' => true, 'per_page' => 100),
array(),
false,
array(true, false, true, true, false, true, true)
@ -138,7 +201,8 @@ $social_right_content .= '</div>';
$tpl = new Template($tool_name);
$tpl->set_help('Groups');
$tpl->assign('social_left_content', $social_left_content);
$tpl->assign('social_avatar_block', $social_avatar_block);
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->assign('social_right_content', $social_right_content);
$social_layout = $tpl->get_template('layout/social_layout.tpl');

@ -10,14 +10,14 @@ $cidReset = true;
require_once '../inc/global.inc.php';
api_block_anonymous_users();
if (api_get_setting('allow_social_tool') !='true') {
if (api_get_setting('allow_social_tool') != 'true') {
api_not_allowed();
}
require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
require_once api_get_path(LIBRARY_PATH) . 'group_portal_manager.lib.php';
$group_id = intval($_GET['id']);
$topic_id = intval($_GET['topic_id']);
$group_id = intval($_GET['id']);
$topic_id = intval($_GET['topic_id']);
$message_id = intval($_GET['msg_id']);
//todo @this validation could be in a function in group_portal_manager
@ -35,11 +35,20 @@ if (empty($group_id)) {
}
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') {
$group_role = GroupPortalManager::get_user_group_role(api_get_user_id(), $group_id);
if (api_is_platform_admin() || in_array($group_role, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_MODERATOR))) {
$group_role = GroupPortalManager::get_user_group_role(
api_get_user_id(),
$group_id
);
if (api_is_platform_admin() || in_array(
$group_role,
array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_MODERATOR)
)
) {
GroupPortalManager::delete_topic($group_id, $topic_id);
header("Location: groups.php?id=$group_id&action=show_message&msg=topic_deleted");
header(
"Location: groups.php?id=$group_id&action=show_message&msg=topic_deleted"
);
}
}
@ -47,34 +56,58 @@ if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') {
if (isset($_POST['token']) && $_POST['token'] === $_SESSION['sec_token']) {
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']);
$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);
$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();
}
$res = MessageManager::send_message(0, $title, $content, $_FILES, '', $group_id, $parent_id, 0, $topic_id);
$res = MessageManager::send_message(
0,
$title,
$content,
$_FILES,
'',
$group_id,
$parent_id,
0,
$topic_id
);
}
// display error messages
if (!$res) {
$social_right_content .= Display::return_message(get_lang('Error'),'error');
}
$topic_id = intval($_GET['topic_id']);
if ($_POST['action'] == 'add_message_group') {
$topic_id = $res;
}
$message_id = $res;
}
// display error messages
if (!$res) {
$social_right_content .= Display::return_message(
get_lang('Error'),
'error'
);
}
$topic_id = intval($_GET['topic_id']);
if ($_POST['action'] == 'add_message_group') {
$topic_id = $res;
}
$message_id = $res;
}
}
$htmlHeadXtra[] = '<script type="text/javascript">
@ -88,7 +121,9 @@ function remove_image_form(id_elem1) {
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>\';
link_attach.innerHTML=\'<a href="javascript://" onclick="return add_image_form()">' . get_lang(
'AddOneMoreFile'
) . '</a>\';
}
}
}
@ -106,7 +141,9 @@ function add_image_form() {
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=\"'.api_get_path(WEB_CODE_PATH).'img/delete.gif\"></a>";
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=\"' . api_get_path(
WEB_CODE_PATH
) . 'img/delete.gif\"></a>";
if (filepaths.childNodes.length == 3) {
var link_attach = document.getElementById("link-more-attach");
@ -136,9 +173,9 @@ function validate_text_empty(str,msg) {
$(document).ready(function() {
if ( $("#msg_'.$message_id.'").length) {
if ( $("#msg_' . $message_id . '").length) {
$("html,body").animate({
scrollTop: $("#msg_'.$message_id.'").offset().top
scrollTop: $("#msg_' . $message_id . '").offset().top
})
}
@ -168,29 +205,48 @@ $(document).ready(function() {
</script>';
$this_section = SECTION_SOCIAL;
$interbreadcrumb[] = array ('url' =>'home.php', 'name' => get_lang('Social'));
$interbreadcrumb[] = array('url' => 'groups.php', 'name' => get_lang('Groups'));
$interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Thread'));
$interbreadcrumb[] = array('url' => 'home.php', 'name' => get_lang('Social'));
$interbreadcrumb[] = array('url' => 'groups.php', 'name' => get_lang('Groups'));
$interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Thread'));
$social_right_content = '<div class="breadcrumb">
<a href="groups.php?id='.$group_id.'">'.Security::remove_XSS($group_info['name'], STUDENT, true).'</a>
<a href="groups.php?id=' . $group_id . '">' . Security::remove_XSS(
$group_info['name'],
STUDENT,
true
) . '</a>
<span class="divider">/</span>
<a href="groups.php?id='.$group_id.'#tabs_2">'.get_lang('Discussions').'</a>
<a href="groups.php?id=' . $group_id . '#tabs_2">' . get_lang(
'Discussions'
) . '</a>
</div> ';
$social_left_content .= SocialManager::show_social_menu('member_list', $group_id);
$social_avatar_block = SocialManager::show_social_avatar_block(
'member_list',
$group_id
);
$social_menu_block = SocialManager::show_social_menu('member_list', $group_id);
if (!empty($show_message)) {
$social_right_content .= Display::return_message($show_message, 'confirmation');
$social_right_content .= Display::return_message(
$show_message,
'confirmation'
);
}
$social_right_content .= MessageManager::display_message_for_group($group_id, $topic_id, $is_member, $message_id);
$social_right_content .= MessageManager::display_message_for_group(
$group_id,
$topic_id,
$is_member,
$message_id
);
$social_right_content = '<div class="span9">'.$social_right_content.'</div>';
$social_right_content = '<div class="span9">' . $social_right_content . '</div>';
$tpl = new Template($tool_name);
$tpl->set_help('Groups');
$tpl->assign('social_left_content', $social_left_content);
$tpl->assign('social_left_menu', $social_left_menu);
$tpl->assign('social_avatar_block', $social_avatar_block);
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->assign('social_right_content', $social_right_content);
$tpl->assign('actions', $actions);
$tpl->assign('message', $show_message);

@ -79,7 +79,8 @@ if (isset($_GET['action']) && $_GET['action']=='set_moderator') {
$users = GroupPortalManager::get_users_by_group($group_id, true, array(GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER), 0, 1000);
$new_member_list = array();
$social_left_content = SocialManager::show_social_menu('waiting_list',$group_id);
$social_avatar_block = SocialManager::show_social_avatar_block('waiting_list', $group_id);
$social_menu_block = SocialManager::show_social_menu('waiting_list', $group_id);
if (!empty($show_message)){
$social_right_content .= Display :: return_message($show_message);
@ -104,8 +105,8 @@ if (count($new_member_list) > 0) {
$tpl = new Template($tool_name);
$tpl->set_help('Groups');
$tpl->assign('social_left_content', $social_left_content);
$tpl->assign('social_left_menu', $social_left_menu);
$tpl->assign('social_avatar_block', $social_avatar_block);
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->assign('social_right_content', $social_right_content);
$tpl->assign('actions', $actions);

@ -10,12 +10,12 @@ $language_file = array('userInfo');
require_once '../inc/global.inc.php';
api_block_anonymous_users();
if (api_get_setting('allow_social_tool') !='true') {
if (api_get_setting('allow_social_tool') != 'true') {
api_not_allowed();
}
require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
require_once api_get_path(LIBRARY_PATH) . 'group_portal_manager.lib.php';
require_once api_get_path(LIBRARY_PATH) . 'mail.lib.inc.php';
$this_section = SECTION_SOCIAL;
@ -32,7 +32,7 @@ if (isset($_GET['anchor_topic'])) {
}
}
if (isset($match[1])) {
$anchor = 'topic_'.$match[1];
$anchor = 'topic_' . $match[1];
}
}
@ -47,7 +47,9 @@ function remove_image_form(id_elem1) {
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>\';
link_attach.innerHTML=\'<a href="javascript://" onclick="return add_image_form()">' . get_lang(
'AddOneMoreFile'
) . '</a>\';
}
}
}
@ -65,7 +67,9 @@ function add_image_form() {
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=\"'.api_get_path(WEB_CODE_PATH).'img/delete.gif\"></a>";
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=\"' . api_get_path(
WEB_CODE_PATH
) . 'img/delete.gif\"></a>";
if (filepaths.childNodes.length == 3) {
var link_attach = document.getElementById("link-more-attach");
@ -91,7 +95,7 @@ jQuery(document).ready(function() {
$("#tabs").tabs();
$("#tab_browse").tabs();
var valor = "'.$anchor.'";
var valor = "' . $anchor . '";
$(".head").click(function() {
$(this).next().next().slideToggle("fast");
@ -119,25 +123,54 @@ jQuery(document).ready(function() {
});
</script>';
$allowed_views = array('mygroups','newest','pop');
$interbreadcrumb[]= array ('url' =>'home.php','name' => get_lang('SocialNetwork'));
$allowed_views = array('mygroups', 'newest', 'pop');
$interbreadcrumb[] = array(
'url' => 'home.php',
'name' => get_lang('SocialNetwork')
);
$content = null;
if (isset($_GET['view']) && in_array($_GET['view'], $allowed_views)) {
if ($_GET['view'] == 'mygroups') {
$interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups'));
$interbreadcrumb[]= array ('url' =>'#','name' => get_lang('MyGroups'));
} else if ($_GET['view'] == 'newest') {
$interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups'));
$interbreadcrumb[]= array ('url' =>'#','name' => get_lang('Newest'));
} else {
$interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups'));
$interbreadcrumb[]= array ('url' =>'#','name' => get_lang('Popular'));
$interbreadcrumb[] = array(
'url' => 'groups.php',
'name' => get_lang('Groups')
);
$interbreadcrumb[] = array(
'url' => '#',
'name' => get_lang('MyGroups')
);
} else {
if ($_GET['view'] == 'newest') {
$interbreadcrumb[] = array(
'url' => 'groups.php',
'name' => get_lang('Groups')
);
$interbreadcrumb[] = array(
'url' => '#',
'name' => get_lang('Newest')
);
} else {
$interbreadcrumb[] = array(
'url' => 'groups.php',
'name' => get_lang('Groups')
);
$interbreadcrumb[] = array(
'url' => '#',
'name' => get_lang('Popular')
);
}
}
} else {
$interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups'));
$interbreadcrumb[] = array(
'url' => 'groups.php',
'name' => get_lang('Groups')
);
if (!isset($_GET['id'])) {
$interbreadcrumb[]= array ('url' =>'#','name' => get_lang('GroupList'));
$interbreadcrumb[] = array(
'url' => '#',
'name' => get_lang('GroupList')
);
} else {
//$interbreadcrumb[]= array ('url' =>'#','name' => get_lang('Group'));
}
@ -156,22 +189,25 @@ if ($group_id != 0) {
$group_info = GroupPortalManager::get_group_data($group_id);
if (!empty($group_id)) {
$interbreadcrumb[]= array ('url' =>'#','name' => $group_info['name']);
$interbreadcrumb[] = array('url' => '#', 'name' => $group_info['name']);
}
if (isset($_GET['action']) && $_GET['action']=='leave') {
if (isset($_GET['action']) && $_GET['action'] == 'leave') {
$user_leaved = intval($_GET['u']);
if (GroupPortalManager::canLeave($group_info)) {
// I can "leave me myself"
if (api_get_user_id() == $user_leaved) {
GroupPortalManager::delete_user_rel_group($user_leaved, $group_id);
GroupPortalManager::delete_user_rel_group(
$user_leaved,
$group_id
);
$user_leave_message = true;
}
}
}
// add a user to a group if its open
if (isset($_GET['action']) && $_GET['action']=='join') {
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)) {
@ -179,7 +215,11 @@ if ($group_id != 0) {
GroupPortalManager::add_user_to_group($user_join, $group_id);
$user_added_group_message = true;
} else {
GroupPortalManager::add_user_to_group($user_join, $group_id, GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER);
GroupPortalManager::add_user_to_group(
$user_join,
$group_id,
GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER
);
$user_invitation_sent = true;
}
}
@ -187,137 +227,244 @@ if ($group_id != 0) {
}
$create_thread_link = '';
if ($group_id != 0 ) {
$social_left_content = SocialManager::show_social_menu('groups',$group_id);
if ($group_id != 0) {
$social_avatar_block = SocialManager::show_social_avatar_block(
'groups',
$group_id
);
$social_menu_block = SocialManager::show_social_menu('groups', $group_id);
} else {
$show_menu = 'browse_groups';
if (isset($_GET['view']) && $_GET['view'] == 'mygroups') {
$show_menu = $_GET['view'];
}
$social_left_content = SocialManager::show_social_menu($show_menu);
$social_avatar_block = SocialManager::show_social_avatar_block(
$show_menu,
$group_id
);
$social_menu_block = SocialManager::show_social_menu($show_menu, $group_id);
}
$social_right_content = null;
if ($group_id != 0 ) {
if ($group_id != 0) {
$group_info = GroupPortalManager::get_group_data($group_id);
//Loading group information
if (isset($_GET['status']) && $_GET['status']=='sent') {
$social_right_content .= Display::return_message(get_lang('MessageHasBeenSent'), 'confirmation', false);
if (isset($_GET['status']) && $_GET['status'] == 'sent') {
$social_right_content .= Display::return_message(
get_lang('MessageHasBeenSent'),
'confirmation',
false
);
}
if ($user_leave_message) {
$social_right_content .= Display::return_message(get_lang('UserIsNotSubscribedToThisGroup'), 'confirmation', false);
$social_right_content .= Display::return_message(
get_lang('UserIsNotSubscribedToThisGroup'),
'confirmation',
false
);
}
if ($user_added_group_message) {
$social_right_content .= Display::return_message(get_lang('UserIsSubscribedToThisGroup'), 'confirmation', false);
$social_right_content .= Display::return_message(
get_lang('UserIsSubscribedToThisGroup'),
'confirmation',
false
);
}
if ($user_invitation_sent) {
$social_right_content .= Display::return_message(get_lang('InvitationSent'), 'confirmation', false);
$social_right_content .= Display::return_message(
get_lang('InvitationSent'),
'confirmation',
false
);
}
$is_group_member = GroupPortalManager::is_group_member($group_id);
// details about the current group
$social_right_content = '<div class="span9">';
$social_right_content .= '<div id="social-group-details">';
// details about the current group
$social_right_content = '<div class="span9">';
$social_right_content .= '<div id="social-group-details">';
//Group's title
$social_right_content .= Display::tag('h2', Security::remove_XSS($group_info['name'], STUDENT, true));
$social_right_content .= Display::tag(
'h2',
Security::remove_XSS($group_info['name'], STUDENT, true)
);
//Privacy
if (!$is_group_member) {
$social_right_content .= '<div class="social-group-details-info">';
$social_right_content .= '<span>'.get_lang('Privacy').' : </span>';
if ($group_info['visibility']== GROUP_PERMISSION_OPEN) {
$social_right_content .= get_lang('ThisIsAnOpenGroup');
} elseif ($group_info['visibility']== GROUP_PERMISSION_CLOSED) {
$social_right_content .= get_lang('ThisIsACloseGroup');
$social_right_content .= '<div class="social-group-details-info">';
$social_right_content .= '<span>' . get_lang('Privacy') . ' : </span>';
if ($group_info['visibility'] == GROUP_PERMISSION_OPEN) {
$social_right_content .= get_lang('ThisIsAnOpenGroup');
} elseif ($group_info['visibility'] == GROUP_PERMISSION_CLOSED) {
$social_right_content .= get_lang('ThisIsACloseGroup');
}
$social_right_content .= '</div>';
$social_right_content .= '</div>';
}
if (!$is_group_member && $group_info['visibility'] == GROUP_PERMISSION_CLOSED) {
$role = GroupPortalManager::get_user_group_role(api_get_user_id(), $group_id);
$role = GroupPortalManager::get_user_group_role(
api_get_user_id(),
$group_id
);
if ($role == GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER) {
$social_right_content .= Display::return_message(get_lang('YouAlreadySentAnInvitation'));
$social_right_content .= Display::return_message(
get_lang('YouAlreadySentAnInvitation')
);
}
}
// Group's tags
if (!empty($tags)) {
$social_right_content .= '<div id="social-group-details-info"><span>'.get_lang('Tags').' : </span>'.$tags.'</div>';
$social_right_content .= '<div id="social-group-details-info"><span>' . get_lang(
'Tags'
) . ' : </span>' . $tags . '</div>';
}
$social_right_content .= '</div>';
$social_right_content .= '</div>';
//-- Show message groups
$social_right_content .= '<div class="span9">';
if ($is_group_member || $group_info['visibility'] == GROUP_PERMISSION_OPEN) {
if (!$is_group_member) {
if (!in_array($my_group_role, array(GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER, GROUP_USER_PERMISSION_PENDING_INVITATION))) {
$social_right_content .= '<a class="btn" href="groups.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.get_lang('JoinGroup').'</a>';
} elseif ($my_group_role == GROUP_USER_PERMISSION_PENDING_INVITATION) {
$social_right_content .= '<a class="btn" href="groups.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.get_lang('YouHaveBeenInvitedJoinNow').'</a>';
$social_right_content .= '</div>';
$social_right_content .= '</div>';
//-- Show message groups
$social_right_content .= '<div class="span9">';
if ($is_group_member || $group_info['visibility'] == GROUP_PERMISSION_OPEN) {
if (!$is_group_member) {
if (!in_array(
$my_group_role,
array(
GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER,
GROUP_USER_PERMISSION_PENDING_INVITATION
)
)
) {
$social_right_content .= '<a class="btn" href="groups.php?id=' . $group_id . '&action=join&u=' . api_get_user_id(
) . '">' . get_lang('JoinGroup') . '</a>';
} elseif ($my_group_role == GROUP_USER_PERMISSION_PENDING_INVITATION) {
$social_right_content .= '<a class="btn" href="groups.php?id=' . $group_id . '&action=join&u=' . api_get_user_id(
) . '">' . get_lang('YouHaveBeenInvitedJoinNow') . '</a>';
}
$social_right_content .= '<br /><br />';
}
$content = MessageManager::display_messages_for_group($group_id);
if ($is_group_member) {
if (empty($content)) {
$create_thread_link = '<a href="' . api_get_path(
WEB_CODE_PATH
) . 'social/message_for_group_form.inc.php?view_panel=1&height=400&width=610&&user_friend=' . api_get_user_id(
) . '&group_id=' . $group_id . '&action=add_message_group" class="ajax btn" title="' . get_lang(
'ComposeMessage'
) . '">' . get_lang('YouShouldCreateATopic') . '</a></li>';
} else {
$create_thread_link = '<a href="' . api_get_path(
WEB_CODE_PATH
) . 'social/message_for_group_form.inc.php?view_panel=1&height=400&width=610&&user_friend=' . api_get_user_id(
) . '&group_id=' . $group_id . '&action=add_message_group" class="ajax btn" title="' . get_lang(
'ComposeMessage'
) . '">' . get_lang('NewTopic') . '</a>';
}
}
$members = GroupPortalManager::get_users_by_group($group_id);
$member_content = '';
//Members
if (count($members) > 0) {
if ($my_group_role == GROUP_USER_PERMISSION_ADMIN) {
$member_content .= Display::url(
Display::return_icon(
'edit.gif',
get_lang('EditMembersList')
) . ' ' . get_lang('EditMembersList'),
'group_members.php?id=' . $group_id
);
}
foreach ($members as $member) {
// if is a member
if (in_array(
$member['relation_type'],
array(
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 = '';
}
$image_path = UserManager::get_user_picture_path_by_id(
$member['user_id'],
'web',
false,
true
);
$picture = UserManager::get_picture_user(
$member['user_id'],
$image_path['file'],
60,
USER_IMAGE_SIZE_MEDIUM
);
$member_content .= '<div class="">';
$member_name = Display::url(
api_get_person_name(
cut($member['firstname'], 15),
cut($member['lastname'], 15)
) . '&nbsp;' . $icon,
'profile.php?u=' . $member['user_id']
);
$member_content .= Display::div(
'<img height="44" border="2" align="middle" vspace="10" class="social-groups-image" src="' . $picture['file'] . '"/>&nbsp' . $member_name
);
$member_content .= '</div>';
}
$social_right_content .= '<br /><br />';
}
$content = MessageManager::display_messages_for_group($group_id);
if ($is_group_member) {
if (empty($content)) {
$create_thread_link = '<a href="'.api_get_path(WEB_CODE_PATH).'social/message_for_group_form.inc.php?view_panel=1&height=400&width=610&&user_friend='.api_get_user_id().'&group_id='.$group_id.'&action=add_message_group" class="ajax btn" title="'.get_lang('ComposeMessage').'">'.get_lang('YouShouldCreateATopic').'</a></li>';
} else {
$create_thread_link = '<a href="'.api_get_path(WEB_CODE_PATH).'social/message_for_group_form.inc.php?view_panel=1&height=400&width=610&&user_friend='.api_get_user_id().'&group_id='.$group_id.'&action=add_message_group" class="ajax btn" title="'.get_lang('ComposeMessage').'">'.get_lang('NewTopic').'</a>';
}
}
$members = GroupPortalManager::get_users_by_group($group_id);
$member_content = '';
//Members
if (count($members) > 0) {
if ($my_group_role == GROUP_USER_PERMISSION_ADMIN) {
$member_content .= Display::url(Display::return_icon('edit.gif', get_lang('EditMembersList')).' '.get_lang('EditMembersList'), 'group_members.php?id='.$group_id);
}
foreach($members as $member) {
// if is a member
if (in_array($member['relation_type'] , array(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= '';
}
$image_path = UserManager::get_user_picture_path_by_id($member['user_id'], 'web', false, true);
$picture = UserManager::get_picture_user($member['user_id'], $image_path['file'], 60, USER_IMAGE_SIZE_MEDIUM);
$member_content .= '<div class="">';
$member_name = Display::url(api_get_person_name(cut($member['firstname'],15),cut($member['lastname'],15)).'&nbsp;'.$icon, 'profile.php?u='.$member['user_id']);
$member_content .= Display::div('<img height="44" border="2" align="middle" vspace="10" class="social-groups-image" src="'.$picture['file'].'"/>&nbsp'.$member_name);
$member_content .= '</div>';
}
}
}
if (!empty($create_thread_link)) {
$create_thread_link = Display::div($create_thread_link, array('style'=>'padding-top:2px;height:40px'));
}
$headers = array(get_lang('Discussions'), get_lang('Members'));
$social_right_content .= Display::tabs($headers, array($create_thread_link.$content, $member_content),'tabs');
} else {
// if I already sent an invitation message
if (!in_array($my_group_role, array(GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER, GROUP_USER_PERMISSION_PENDING_INVITATION))) {
$social_right_content .= '<a class="btn" href="groups.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.get_lang('JoinGroup').'</a>';
} elseif ($my_group_role == GROUP_USER_PERMISSION_PENDING_INVITATION) {
$social_right_content .= '<a class="btn" href="groups.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.get_lang('YouHaveBeenInvitedJoinNow').'</a>';
}
}
$social_right_content .= '</div>'; // end layout messages
}
}
if (!empty($create_thread_link)) {
$create_thread_link = Display::div(
$create_thread_link,
array('style' => 'padding-top:2px;height:40px')
);
}
$headers = array(get_lang('Discussions'), get_lang('Members'));
$social_right_content .= Display::tabs(
$headers,
array($create_thread_link . $content, $member_content),
'tabs'
);
} else {
// if I already sent an invitation message
if (!in_array(
$my_group_role,
array(
GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER,
GROUP_USER_PERMISSION_PENDING_INVITATION
)
)
) {
$social_right_content .= '<a class="btn" href="groups.php?id=' . $group_id . '&action=join&u=' . api_get_user_id(
) . '">' . get_lang('JoinGroup') . '</a>';
} elseif ($my_group_role == GROUP_USER_PERMISSION_PENDING_INVITATION) {
$social_right_content .= '<a class="btn" href="groups.php?id=' . $group_id . '&action=join&u=' . api_get_user_id(
) . '">' . get_lang('YouHaveBeenInvitedJoinNow') . '</a>';
}
}
$social_right_content .= '</div>'; // end layout messages
} else {
// My groups -----
@ -327,129 +474,254 @@ if ($group_id != 0 ) {
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);
$result['name'] = Security::remove_XSS(
$result['name'],
STUDENT,
true
);
$result['description'] = Security::remove_XSS(
$result['description'],
STUDENT,
true
);
$my_group_list[] = $id;
$url_open = '<a href="groups.php?id='.$id.'">';
$url_open = '<a href="groups.php?id=' . $id . '">';
$url_close = '</a>';
$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'), array('style'=>'vertical-align:middle'));
$name .= ' ' . Display::return_icon(
'social_group_admin.png',
get_lang('Admin'),
array('style' => 'vertical-align:middle')
);
} elseif ($result['relation_type'] == GROUP_USER_PERMISSION_MODERATOR) {
$name .= ' '.Display::return_icon('social_group_moderator.png', get_lang('Moderator'), array('style'=>'vertical-align:middle'));
$name .= ' ' . Display::return_icon(
'social_group_moderator.png',
get_lang('Moderator'),
array('style' => 'vertical-align:middle')
);
}
$count_users_group = count(GroupPortalManager::get_users_by_group($id, false, array(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');
$count_users_group = count(
GroupPortalManager::get_users_by_group(
$id,
false,
array(
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');
$count_users_group = $count_users_group . ' ' . get_lang(
'Members'
);
}
$picture = GroupPortalManager::get_picture_group($result['id'], $result['picture_uri'],80);
$result['picture_uri'] = '<img class="social-groups-image" src="'.$picture['file'].'" hspace="4" height="50" border="2" align="left" width="50" />';
$item_0 = Display::div($result['picture_uri'], array('class'=>'box_description_group_image'));
$members = Display::span($count_users_group, array('class'=>'box_description_group_member'));
$item_1 = Display::div(Display::tag('h3', $url_open.$name.$url_close).$members, array('class'=>'box_description_group_title'));
$picture = GroupPortalManager::get_picture_group(
$result['id'],
$result['picture_uri'],
80
);
$result['picture_uri'] = '<img class="social-groups-image" src="' . $picture['file'] . '" hspace="4" height="50" border="2" align="left" width="50" />';
$item_0 = Display::div(
$result['picture_uri'],
array('class' => 'box_description_group_image')
);
$members = Display::span(
$count_users_group,
array('class' => 'box_description_group_member')
);
$item_1 = Display::div(
Display::tag('h3', $url_open . $name . $url_close) . $members,
array('class' => 'box_description_group_title')
);
$item_2 = '';
$item_3 = '';
if ($result['description'] != '') {
$item_3 = '<div class="box_description_group_content" >'.cut($result['description'],100,true).'</div>';
$item_3 = '<div class="box_description_group_content" >' . cut(
$result['description'],
100,
true
) . '</div>';
} else {
$item_2 = '<div class="box_description_group_title" ><span class="social-groups-text2"></span></div>';
$item_3 = '<div class="box_description_group_content" ></div>';
}
$grid_item_2 = $item_0.$item_1.$item_2.$item_3;
$grid_my_groups[]= array($grid_item_2);
$grid_item_2 = $item_0 . $item_1 . $item_2 . $item_3;
$grid_my_groups[] = array($grid_item_2);
}
}
// Newest groups
$results = GroupPortalManager::get_groups_by_age(4,false);
$results = GroupPortalManager::get_groups_by_age(4, false);
$grid_newest_groups = array();
foreach ($results as $result) {
$result['name'] = Security::remove_XSS($result['name'], STUDENT, true);
$result['description'] = Security::remove_XSS($result['description'], STUDENT, true);
$result['description'] = Security::remove_XSS(
$result['description'],
STUDENT,
true
);
$id = $result['id'];
$url_open = '<a href="groups.php?id='.$id.'">';
$url_open = '<a href="groups.php?id=' . $id . '">';
$url_close = '</a>';
$count_users_group = count(GroupPortalManager::get_users_by_group($id, false, array(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');
$count_users_group = count(
GroupPortalManager::get_users_by_group(
$id,
false,
array(
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');
$count_users_group = $count_users_group . ' ' . get_lang('Members');
}
$name = cut($result['name'],GROUP_TITLE_LENGTH,true);
$picture = GroupPortalManager::get_picture_group($result['id'], $result['picture_uri'],80);
$result['picture_uri'] = '<img class="social-groups-image" src="'.$picture['file'].'" hspace="4" height="50" border="2" align="left" width="50" />';
$item_0 = Display::div($result['picture_uri'], array('class'=>'box_description_group_image'));
$members = Display::span($count_users_group, array('class'=>'box_description_group_member'));
$item_1 = Display::div(Display::tag('h3', $url_open.$name.$url_close).$members, array('class'=>'box_description_group_title'));
$name = cut($result['name'], GROUP_TITLE_LENGTH, true);
$picture = GroupPortalManager::get_picture_group(
$result['id'],
$result['picture_uri'],
80
);
$result['picture_uri'] = '<img class="social-groups-image" src="' . $picture['file'] . '" hspace="4" height="50" border="2" align="left" width="50" />';
$item_0 = Display::div(
$result['picture_uri'],
array('class' => 'box_description_group_image')
);
$members = Display::span(
$count_users_group,
array('class' => 'box_description_group_member')
);
$item_1 = Display::div(
Display::tag('h3', $url_open . $name . $url_close) . $members,
array('class' => 'box_description_group_title')
);
if ($result['description'] != '') {
$item_3 = '<div class="box_description_group_content" >'.cut($result['description'],100,true).'</div>';
$item_3 = '<div class="box_description_group_content" >' . cut(
$result['description'],
100,
true
) . '</div>';
} else {
$item_2 = '<div class="box_description_group_title" ><span class="social-groups-text2"></span></div>';
$item_3 = '<div class="box_description_group_content" ></div>';
}
//Avoiding my groups
$join_url = '';
if (!in_array($id,$my_group_list)) {
$join_url = '<a class="btn" href="groups.php?id='.$id.'&action=join&u='.api_get_user_id().'">'.get_lang('JoinGroup').'</a> ';
if (!in_array($id, $my_group_list)) {
$join_url = '<a class="btn" href="groups.php?id=' . $id . '&action=join&u=' . api_get_user_id(
) . '">' . get_lang('JoinGroup') . '</a> ';
}
$item_4 = '<div class="box_description_group_actions" >'.$join_url.'</div>';
$grid_item_2 = $item_0.$item_1.$item_2.$item_3.$item_4;
$item_4 = '<div class="box_description_group_actions" >' . $join_url . '</div>';
$grid_item_2 = $item_0 . $item_1 . $item_2 . $item_3 . $item_4;
$grid_newest_groups[]= array($grid_item_2);
$grid_newest_groups[] = array($grid_item_2);
}
// Pop groups
$results = GroupPortalManager::get_groups_by_popularity(4,false);
$results = GroupPortalManager::get_groups_by_popularity(4, false);
$grid_pop_groups = array();
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);
$result['name'] = Security::remove_XSS(
$result['name'],
STUDENT,
true
);
$result['description'] = Security::remove_XSS(
$result['description'],
STUDENT,
true
);
$id = $result['id'];
$url_open = '<a href="groups.php?id='.$id.'">';
$url_open = '<a href="groups.php?id=' . $id . '">';
$url_close = '</a>';
$count_users_group = count(GroupPortalManager::get_users_by_group($id, false, array(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');
$count_users_group = count(
GroupPortalManager::get_users_by_group(
$id,
false,
array(
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');
$count_users_group = $count_users_group . ' ' . get_lang(
'Members'
);
}
$name = cut($result['name'],GROUP_TITLE_LENGTH,true);
$picture = GroupPortalManager::get_picture_group($result['id'], $result['picture_uri'],80);
$result['picture_uri'] = '<img class="social-groups-image" src="'.$picture['file'].'" hspace="4" height="50" border="2" align="left" width="50" />';
$item_0 = Display::div($result['picture_uri'], array('class'=>'box_description_group_image'));
$members = Display::span($count_users_group, array('class'=>'box_description_group_member'));
$item_1 = Display::div(Display::tag('h3', $url_open.$name.$url_close).$members, array('class'=>'box_description_group_title'));
$name = cut($result['name'], GROUP_TITLE_LENGTH, true);
$picture = GroupPortalManager::get_picture_group(
$result['id'],
$result['picture_uri'],
80
);
$result['picture_uri'] = '<img class="social-groups-image" src="' . $picture['file'] . '" hspace="4" height="50" border="2" align="left" width="50" />';
$item_0 = Display::div(
$result['picture_uri'],
array('class' => 'box_description_group_image')
);
$members = Display::span(
$count_users_group,
array('class' => 'box_description_group_member')
);
$item_1 = Display::div(
Display::tag('h3', $url_open . $name . $url_close) . $members,
array('class' => 'box_description_group_title')
);
if ($result['description'] != '') {
$item_3 = '<div class="box_description_group_content" >'.cut($result['description'],100,true).'</div>';
$item_3 = '<div class="box_description_group_content" >' . cut(
$result['description'],
100,
true
) . '</div>';
} else {
$item_2 = '<div class="box_description_group_title" ><span class="social-groups-text2"></span></div>';
$item_3 = '<div class="box_description_group_content" ></div>';
}
$join_url = '';
if (!in_array($id,$my_group_list)) {
$join_url = '<a class="btn" href="groups.php?id='.$id.'&action=join&u='.api_get_user_id().'">'.get_lang('JoinGroup').'</a> ';
if (!in_array($id, $my_group_list)) {
$join_url = '<a class="btn" href="groups.php?id=' . $id . '&action=join&u=' . api_get_user_id(
) . '">' . get_lang('JoinGroup') . '</a> ';
}
$item_4 = '<div class="box_description_group_actions" >'.$join_url.'</div>';
$item_4 = '<div class="box_description_group_actions" >' . $join_url . '</div>';
$grid_item_2 = $item_0.$item_1.$item_2.$item_3.$item_4;
$grid_pop_groups[]= array($grid_item_2);
$grid_item_2 = $item_0 . $item_1 . $item_2 . $item_3 . $item_4;
$grid_pop_groups[] = array($grid_item_2);
}
}
@ -458,28 +730,58 @@ if ($group_id != 0 ) {
$newest_content = $popular_content = $my_group_content = null;
if (isset($_GET['view']) && in_array($_GET['view'],$allowed_views)) {
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', array(), $grid_my_groups, array('hide_navigation'=>true, 'per_page' => 2), $query_vars, false, array(true, true, true,false));
$my_group_content = Display::return_sortable_grid(
'mygroups',
array(),
$grid_my_groups,
array('hide_navigation' => true, 'per_page' => 2),
$query_vars,
false,
array(true, true, true, false)
);
}
if (api_get_setting('allow_students_to_create_groups_in_social') == 'true') {
$create_group_item = '<a class="btn" href="'.api_get_path(WEB_PATH).'main/social/group_add.php">'.get_lang('CreateASocialGroup').'</a>';
if (api_get_setting(
'allow_students_to_create_groups_in_social'
) == 'true'
) {
$create_group_item = '<a class="btn" href="' . api_get_path(
WEB_PATH
) . 'main/social/group_add.php">' . get_lang(
'CreateASocialGroup'
) . '</a>';
//$my_group_content = $create_group_item. $my_group_content;
} else {
if (api_is_allowed_to_edit(null,true)) {
$create_group_item = '<a class="btn" href="'.api_get_path(WEB_PATH).'main/social/group_add.php">'.get_lang('CreateASocialGroup').'</a>';
if (api_is_allowed_to_edit(null, true)) {
$create_group_item = '<a class="btn" 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', array(), $grid_newest_groups, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, true, true,false));
$newest_content = Display::return_sortable_grid(
'newest',
array(),
$grid_newest_groups,
array('hide_navigation' => true, 'per_page' => 100),
$query_vars,
false,
array(true, true, true, false)
);
}
if (api_is_platform_admin() || api_get_setting('allow_students_to_create_groups_in_social') == 'true') {
if (api_is_platform_admin() || api_get_setting(
'allow_students_to_create_groups_in_social'
) == 'true'
) {
if (empty($grid_newest_groups)) {
//echo '<a href="group_add.php">'.get_lang('YouShouldCreateAGroup').'</a>';
}
@ -487,9 +789,20 @@ if ($group_id != 0 ) {
break;
default :
if (count($grid_pop_groups) > 0) {
$popular_content = Display::return_sortable_grid('popular', array(), $grid_pop_groups, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, true, true,true,true));
$popular_content = Display::return_sortable_grid(
'popular',
array(),
$grid_pop_groups,
array('hide_navigation' => true, 'per_page' => 100),
$query_vars,
false,
array(true, true, true, true, true)
);
}
if (api_is_platform_admin() || api_get_setting('allow_students_to_create_groups_in_social') == 'true') {
if (api_is_platform_admin() || api_get_setting(
'allow_students_to_create_groups_in_social'
) == 'true'
) {
if (empty($grid_pop_groups)) {
//echo '<a href="group_add.php">'.get_lang('YouShouldCreateAGroup').'</a>';
}
@ -499,29 +812,75 @@ if ($group_id != 0 ) {
} else {
$my_group_content = null;
if (count($grid_my_groups) > 0) {
$my_group_content = Display::return_sortable_grid('mygroups', array(), $grid_my_groups, array('hide_navigation'=>true, 'per_page' => 2), $query_vars, false, array(true, true, true,false));
$my_group_content = Display::return_sortable_grid(
'mygroups',
array(),
$grid_my_groups,
array('hide_navigation' => true, 'per_page' => 2),
$query_vars,
false,
array(true, true, true, false)
);
}
if (api_get_setting('allow_students_to_create_groups_in_social') == 'true') {
$create_group_item = '<a class="btn" href="'.api_get_path(WEB_PATH).'main/social/group_add.php">'.get_lang('CreateASocialGroup').'</a>';
if (api_get_setting(
'allow_students_to_create_groups_in_social'
) == 'true'
) {
$create_group_item = '<a class="btn" href="' . api_get_path(
WEB_PATH
) . 'main/social/group_add.php">' . get_lang(
'CreateASocialGroup'
) . '</a>';
//$my_group_content = $create_group_item. $my_group_content;
} else {
if (api_is_allowed_to_edit(null,true)) {
$create_group_item = '<a class="btn" href="'.api_get_path(WEB_PATH).'main/social/group_add.php">'.get_lang('CreateASocialGroup').'</a>';
if (api_is_allowed_to_edit(null, true)) {
$create_group_item = '<a class="btn" 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', array(), $grid_newest_groups, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, true, true,false));
$newest_content = Display::return_sortable_grid(
'mygroups',
array(),
$grid_newest_groups,
array('hide_navigation' => true, 'per_page' => 100),
$query_vars,
false,
array(true, true, true, false)
);
}
if (count($grid_pop_groups) > 0) {
$popular_content = Display::return_sortable_grid('mygroups', array(), $grid_pop_groups, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, true, true,true,true));
$popular_content = Display::return_sortable_grid(
'mygroups',
array(),
$grid_pop_groups,
array('hide_navigation' => true, 'per_page' => 100),
$query_vars,
false,
array(true, true, true, true, true)
);
}
}
if (!empty($create_group_item)) {
$social_right_content .= Display::div($create_group_item, array('class'=>'span9'));
$social_right_content .= Display::div(
$create_group_item,
array('class' => 'span9')
);
}
$headers = array(get_lang('Newest'), get_lang('Popular'), get_lang('MyGroups'));
$social_right_content .= '<div class="span9">'.Display::tabs($headers, array($newest_content, $popular_content, $my_group_content),'tab_browse').'</div>';
$headers = array(
get_lang('Newest'),
get_lang('Popular'),
get_lang('MyGroups')
);
$social_right_content .= '<div class="span9">' . Display::tabs(
$headers,
array($newest_content, $popular_content, $my_group_content),
'tab_browse'
) . '</div>';
}
$show_message = null;
@ -531,7 +890,8 @@ if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'show_message' && $_REQ
$tpl = new Template();
$tpl->set_help('Groups');
$tpl->assign('social_left_content', $social_left_content);
$tpl->assign('social_avatar_block', $social_avatar_block);
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->assign('social_right_content', $social_right_content);
$tpl->assign('message', $show_message);

@ -11,159 +11,268 @@ $language_file = array('userInfo');
$cidReset = true;
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
require_once api_get_path(LIBRARY_PATH).'skill.lib.php';
require_once api_get_path(LIBRARY_PATH) . 'group_portal_manager.lib.php';
require_once api_get_path(LIBRARY_PATH) . 'skill.lib.php';
$user_id = api_get_user_id();
$show_full_profile = true;
//social tab
$this_section = SECTION_SOCIAL;
unset($_SESSION['this_section']);//for hmtl editor repository
unset($_SESSION['this_section']); //for hmtl editor repository
api_block_anonymous_users();
if (api_get_setting('allow_social_tool') !='true' ) {
$url = api_get_path(WEB_CODE_PATH).'auth/profile.php';
header('Location: '.$url);
if (api_get_setting('allow_social_tool') != 'true') {
$url = api_get_path(WEB_CODE_PATH) . 'auth/profile.php';
header('Location: ' . $url);
exit;
api_not_allowed();
}
//fast upload image
if (api_get_setting('profile', 'picture') == 'true') {
$form = new FormValidator('profile', 'post', 'home.php', null, array());
// PICTURE
$form->addElement('file', 'picture', get_lang('AddImage'));
$form->add_progress_bar();
if (!empty($user_data['picture_uri'])) {
$form->addElement('checkbox', 'remove_picture', null, get_lang('DelImage'));
}
$allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif');
$form->addRule('picture', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types);
$form->addElement('style_submit_button', 'apply_change', get_lang('SaveSettings'), 'class="save"');
if ($form->validate()) {
$user_data = $form->getSubmitValues();
// 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 = ".api_get_user_id();
$result = Database::query($sql);
}
}
}
$form = new FormValidator('profile', 'post', 'home.php', null, array());
// PICTURE
$form->addElement('file', 'picture', get_lang('AddImage'));
$form->add_progress_bar();
if (!empty($user_data['picture_uri'])) {
$form->addElement(
'checkbox',
'remove_picture',
null,
get_lang('DelImage')
);
}
$allowed_picture_types = array('jpg', 'jpeg', 'png', 'gif');
$form->addRule(
'picture',
get_lang('OnlyImagesAllowed') . ' (' . implode(
',',
$allowed_picture_types
) . ')',
'filetype',
$allowed_picture_types
);
$form->addElement(
'style_submit_button',
'apply_change',
get_lang('SaveSettings'),
'class="save"'
);
if ($form->validate()) {
$user_data = $form->getSubmitValues();
// 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 = " . api_get_user_id(
);
$result = Database::query($sql);
}
}
}
}
$user_info = UserManager :: get_user_info_by_id(api_get_user_id());
$social_left_content = SocialManager::show_social_menu('home');
$social_avatar_block = SocialManager::show_social_avatar_block('home');
$social_menu_block = SocialManager::show_social_menu('home');
$social_right_content = '<div class="span5">';
$social_right_content .= '<div class="well_border">';
$social_right_content .= '<h3>'.get_lang('ContactInformation').'</h3>';
$social_right_content .= '<h3>' . get_lang('ContactInformation') . '</h3>';
$list = array(
array('title' => get_lang('Name'), 'content' => api_get_person_name($user_info['firstname'], $user_info['lastname'])),
array('title' => get_lang('Email'), 'content' => $user_info['email']),
);
array(
'title' => get_lang('Name'),
'content' => api_get_person_name(
$user_info['firstname'],
$user_info['lastname']
)
),
array('title' => get_lang('Email'), 'content' => $user_info['email']),
);
// information current user
$social_right_content .= '<div>'.Display::description($list).'</div>';
$social_right_content .= '<div>' . Display::description($list) . '</div>';
$social_right_content .= '
<div class="form-actions">
<a class="btn" href="'.api_get_path(WEB_PATH).'main/auth/profile.php">
'.get_lang('EditProfile').'
<a class="btn" href="' . api_get_path(WEB_PATH) . 'main/auth/profile.php">
' . get_lang('EditProfile') . '
</a>
</div></div>';
if (api_get_setting('allow_skills_tool') == 'true') {
$social_right_content .= '<div class="well_border">';
$skill = new Skill();
$ranking = $skill->get_user_skill_ranking(api_get_user_id());
$url = api_get_path(WEB_CODE_PATH).'social/skills_ranking.php';
$ranking_url = Display::url(sprintf(get_lang('YourSkillRankingX'), $ranking), $url, array('class' => 'btn'));
if (api_get_setting('allow_skills_tool') == 'true') {
$social_right_content .= '<div class="well_border">';
$skill = new Skill();
$ranking = $skill->get_user_skill_ranking(api_get_user_id());
$url = api_get_path(WEB_CODE_PATH) . 'social/skills_ranking.php';
$ranking_url = Display::url(
sprintf(get_lang('YourSkillRankingX'), $ranking),
$url,
array('class' => 'btn')
);
$skills = $skill->get_user_skills(api_get_user_id(), true);
$skills = $skill->get_user_skills(api_get_user_id(), true);
$social_right_content .= '<h3>'.get_lang('Skills').'</h3>';
$lis = '';
if (!empty($skills)) {
foreach($skills as $skill) {
$lis .= Display::tag('li', Display::span($skill['name'], array('class'=>'label_tag skill')));
}
$social_right_content .= Display::tag('ul', $lis);
$social_right_content .= '<h3>' . get_lang('Skills') . '</h3>';
$lis = '';
if (!empty($skills)) {
foreach ($skills as $skill) {
$lis .= Display::tag(
'li',
Display::span(
$skill['name'],
array('class' => 'label_tag skill')
)
);
}
$url = api_get_path(WEB_CODE_PATH).'social/skills_wheel.php';
$skill_wheel_url = Display::url(get_lang('ViewSkillsWheel'), $url, array('class' => 'btn'));
$social_right_content .= '<div class="btn-group">'.$skill_wheel_url.$ranking_url.'</div>';
$social_right_content .= '</div>';
$social_right_content .= Display::tag('ul', $lis);
}
$url = api_get_path(WEB_CODE_PATH) . 'social/skills_wheel.php';
$skill_wheel_url = Display::url(
get_lang('ViewSkillsWheel'),
$url,
array('class' => 'btn')
);
$social_right_content .= '<div class="btn-group">' . $skill_wheel_url . $ranking_url . '</div>';
$social_right_content .= '</div>';
}
$social_right_content .= '</div>';
//Search box
$social_right_content .= '<div class="span4">';
$social_right_content .= UserManager::get_search_form('');
$social_right_content .= '<br />';
//Search box
$social_right_content .= '<div class="span4">';
$social_right_content .= UserManager::get_search_form('');
$social_right_content .= '<br />';
//Group box by age
$results = GroupPortalManager::get_groups_by_age(1,false);
$groups_newest = array();
if (!empty($results)) {
foreach ($results as $result) {
$id = $result['id'];
$result['description'] = Security::remove_XSS($result['description'], STUDENT, true);
$result['name'] = Security::remove_XSS($result['name'], STUDENT, true);
if ($result['count'] == 1 ) {
$result['count'] = '1 '.get_lang('Member');
} else {
$result['count'] = $result['count'].' '.get_lang('Members');
}
$group_url = "groups.php?id=$id";
$result['name'] = Display::url(api_ucwords(cut($result['name'],40,true)), $group_url).Display::span('<br />'.$result['count'],array('class'=>'box_description_group_member'));
$picture = GroupPortalManager::get_picture_group($id, $result['picture_uri'],80);
$result['picture_uri'] = '<img class="social-groups-image" src="'.$picture['file'].'" hspace="10" height="44" border="2" align="left" width="44" />';
$group_actions = '<div class="box_description_group_actions"><a href="groups.php?#tab_browse-2">'.get_lang('SeeMore').'</a></div>';
$groups_newest[]= array(Display::url($result['picture_uri'], $group_url), $result['name'], cut($result['description'],120,true).$group_actions);
}
}
$results = GroupPortalManager::get_groups_by_popularity(1,false);
$groups_pop = array();
foreach ($results as $result) {
$result['description'] = Security::remove_XSS($result['description'], STUDENT, true);
$result['name'] = Security::remove_XSS($result['name'], STUDENT, true);
$id = $result['id'];
$group_url = "groups.php?id=$id";
if ($result['count'] == 1 ) {
$result['count'] = '1 '.get_lang('Member');
} else {
$result['count'] = $result['count'].' '.get_lang('Members');
}
$result['name'] = Display::url(api_ucwords(cut($result['name'],40,true)), $group_url).Display::span('<br />'.$result['count'],array('class'=>'box_description_group_member'));
$picture = GroupPortalManager::get_picture_group($id, $result['picture_uri'],80);
$result['picture_uri'] = '<img class="social-groups-image" src="'.$picture['file'].'" hspace="10" height="44" border="2" align="left" width="44" />';
$group_actions = '<div class="box_description_group_actions" ><a href="groups.php?#tab_browse-3">'.get_lang('SeeMore').'</a></div>';
$groups_pop[]= array(Display::url($result['picture_uri'], $group_url) , $result['name'], cut($result['description'],120,true).$group_actions);
}
if (count($groups_newest) > 0) {
$social_right_content .= '<div class="social-groups-home-title">'.get_lang('Newest').'</div>';
$social_right_content .= Display::return_sortable_grid('home_group', array(), $groups_newest, array('hide_navigation'=>true, 'per_page' => 100), array(), false, array(true, true, true,false));
}
if (count($groups_pop) > 0) {
$social_right_content .= '<div class="social-groups-home-title">'.get_lang('Popular').'</div>';
$social_right_content .= Display::return_sortable_grid('home_group', array(), $groups_pop, array('hide_navigation'=>true, 'per_page' => 100), array(), false, array(true, true, true,true,true));
}
//Group box by age
$results = GroupPortalManager::get_groups_by_age(1, false);
$groups_newest = array();
if (!empty($results)) {
foreach ($results as $result) {
$id = $result['id'];
$result['description'] = Security::remove_XSS(
$result['description'],
STUDENT,
true
);
$result['name'] = Security::remove_XSS($result['name'], STUDENT, true);
if ($result['count'] == 1) {
$result['count'] = '1 ' . get_lang('Member');
} else {
$result['count'] = $result['count'] . ' ' . get_lang('Members');
}
$group_url = "groups.php?id=$id";
$result['name'] = Display::url(
api_ucwords(cut($result['name'], 40, true)),
$group_url
) . Display::span(
'<br />' . $result['count'],
array('class' => 'box_description_group_member')
);
$picture = GroupPortalManager::get_picture_group(
$id,
$result['picture_uri'],
80
);
$result['picture_uri'] = '<img class="social-groups-image" src="' . $picture['file'] . '" hspace="10" height="44" border="2" align="left" width="44" />';
$group_actions = '<div class="box_description_group_actions"><a href="groups.php?#tab_browse-2">' . get_lang(
'SeeMore'
) . '</a></div>';
$groups_newest[] = array(
Display::url(
$result['picture_uri'],
$group_url
),
$result['name'],
cut($result['description'], 120, true) . $group_actions
);
}
}
$results = GroupPortalManager::get_groups_by_popularity(1, false);
$groups_pop = array();
foreach ($results as $result) {
$result['description'] = Security::remove_XSS(
$result['description'],
STUDENT,
true
);
$result['name'] = Security::remove_XSS($result['name'], STUDENT, true);
$id = $result['id'];
$group_url = "groups.php?id=$id";
if ($result['count'] == 1) {
$result['count'] = '1 ' . get_lang('Member');
} else {
$result['count'] = $result['count'] . ' ' . get_lang('Members');
}
$result['name'] = Display::url(
api_ucwords(cut($result['name'], 40, true)),
$group_url
) . Display::span(
'<br />' . $result['count'],
array('class' => 'box_description_group_member')
);
$picture = GroupPortalManager::get_picture_group(
$id,
$result['picture_uri'],
80
);
$result['picture_uri'] = '<img class="social-groups-image" src="' . $picture['file'] . '" hspace="10" height="44" border="2" align="left" width="44" />';
$group_actions = '<div class="box_description_group_actions" ><a href="groups.php?#tab_browse-3">' . get_lang(
'SeeMore'
) . '</a></div>';
$groups_pop[] = array(
Display::url($result['picture_uri'], $group_url),
$result['name'],
cut($result['description'], 120, true) . $group_actions
);
}
if (count($groups_newest) > 0) {
$social_right_content .= '<div class="social-groups-home-title">' . get_lang(
'Newest'
) . '</div>';
$social_right_content .= Display::return_sortable_grid(
'home_group',
array(),
$groups_newest,
array('hide_navigation' => true, 'per_page' => 100),
array(),
false,
array(true, true, true, false)
);
}
if (count($groups_pop) > 0) {
$social_right_content .= '<div class="social-groups-home-title">' . get_lang(
'Popular'
) . '</div>';
$social_right_content .= Display::return_sortable_grid(
'home_group',
array(),
$groups_pop,
array('hide_navigation' => true, 'per_page' => 100),
array(),
false,
array(true, true, true, true, true)
);
}
$social_right_content .= '</div>';
$tpl = new Template(get_lang('SocialNetwork'));
$tpl->assign('social_left_content', $social_left_content);
$tpl->assign('social_avatar_block', $social_avatar_block);
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->assign('social_right_content', $social_right_content);
$social_layout = $tpl->get_template('layout/social_layout.tpl');
$tpl->display($social_layout);

@ -8,4 +8,4 @@
* Redirect
*/
header('Location: profile.php');
exit();
exit();

@ -91,7 +91,9 @@ if (is_array($_GET) && count($_GET)>0) {
}
}
}
$social_left_content = SocialManager::show_social_menu('invitations');
$social_avatar_block = SocialManager::show_social_avatar_block('invitations');
$social_menu_block = SocialManager::show_social_menu('invitations');
$social_right_content = '<div id="id_response" align="center"></div>';
$user_id = api_get_user_id();
@ -152,9 +154,9 @@ if (count($list_get_invitation_sent) > 0) {
$friends_profile = SocialManager::get_picture_user($sender_user_id, $picture['file'], 92);
$user_info = api_get_user_info($sender_user_id);
$title = Security::remove_XSS($invitation['title'], STUDENT, true);
$content = Security::remove_XSS($invitation['content'], STUDENT, true);
$date = api_convert_and_format_date($invitation['send_date'], DATE_TIME_FORMAT_LONG);
$title = Security::remove_XSS($invitation['title'], STUDENT, true);
$content = Security::remove_XSS($invitation['content'], STUDENT, true);
$date = api_convert_and_format_date($invitation['send_date'], DATE_TIME_FORMAT_LONG);
$social_right_content .= '
<div class="span2">
<a class="thumbnail" href="profile.php?u='.$sender_user_id.'">
@ -200,7 +202,8 @@ if (count($pending_invitations) > 0) {
}
$tpl = new Template(null);
$tpl->assign('social_left_content', $social_left_content);
$tpl->assign('social_avatar_block', $social_avatar_block);
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->assign('social_right_content', $social_right_content);
$tpl->assign('message', $show_message);

@ -7,122 +7,179 @@
/**
* Initialization
*/
$language_file = array('registration','messages','userInfo','admin');
$cidReset=true;
$language_file = array('registration', 'messages', 'userInfo', 'admin');
$cidReset = true;
require_once '../inc/global.inc.php';
api_block_anonymous_users();
if (api_get_setting('allow_social_tool') !='true') {
if (api_get_setting('allow_social_tool') != 'true') {
api_not_allowed();
}
require_once api_get_path(LIBRARY_PATH).'fckeditor/fckeditor.php';
require_once api_get_path(LIBRARY_PATH).'fileDisplay.lib.php';
require_once api_get_path(LIBRARY_PATH) . 'fckeditor/fckeditor.php';
require_once api_get_path(LIBRARY_PATH) . 'fileDisplay.lib.php';
$tok = Security::get_token();
if (isset($_REQUEST['user_friend'])) {
$userfriend_id = intval($_REQUEST['user_friend']);
// panel=1 send message
// panel=2 send invitation
$panel = Security::remove_XSS($_REQUEST['view_panel']);
$info_user_friend = api_get_user_info($userfriend_id);
$info_path_friend = UserManager::get_user_picture_path_by_id($userfriend_id,'web',false,true);
$userfriend_id = intval($_REQUEST['user_friend']);
// panel=1 send message
// panel=2 send invitation
$panel = Security::remove_XSS($_REQUEST['view_panel']);
$info_user_friend = api_get_user_info($userfriend_id);
$info_path_friend = UserManager::get_user_picture_path_by_id(
$userfriend_id,
'web',
false,
true
);
}
$group_id = intval($_GET['group_id']);
$message_id = intval($_GET['message_id']);
$actions = array('add_message_group', 'edit_message_group', 'reply_message_group');
$actions = array(
'add_message_group',
'edit_message_group',
'reply_message_group'
);
$allowed_action = (isset($_GET['action']) && in_array($_GET['action'],$actions))?Security::remove_XSS($_GET['action']):'';
$allowed_action = (isset($_GET['action']) && in_array(
$_GET['action'],
$actions
)) ? Security::remove_XSS($_GET['action']) : '';
$to_group = '';
$subject = '';
$message = '';
if (!empty($group_id) && $allowed_action) {
$group_info = GroupPortalManager::get_group_data($group_id);
$is_member = GroupPortalManager::is_group_member($group_id);
$group_info = GroupPortalManager::get_group_data($group_id);
$is_member = GroupPortalManager::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']);
//$message = api_xml_http_response_encode($message_info['content']);
} else {
$subject = api_xml_http_response_encode($message_info['title']);
$message = api_xml_http_response_encode($message_info['content']);
}
}
$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']
);
//$message = api_xml_http_response_encode($message_info['content']);
} 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)):'';
$param_item_page .= '&topic_id='.intval($_GET['topic_id']);
$page_topic = !empty($_GET['topics_page_nr'])?intval($_GET['topics_page_nr']):1;
$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)) : '';
$param_item_page .= '&topic_id=' . intval($_GET['topic_id']);
$page_topic = !empty($_GET['topics_page_nr']) ? intval(
$_GET['topics_page_nr']
) : 1;
?>
<form name="form" action="group_topics.php?id=<?php echo $group_id ?>&anchor_topic=<?php echo Security::remove_XSS($_GET['anchor_topic']) ?>&topics_page_nr=<?php echo $page_topic.$param_item_page ?>" method="POST" enctype="multipart/form-data">
<input type="hidden" name="action" value="<?php echo $allowed_action ?>" />
<input type="hidden" name="group_id" value="<?php echo $group_id ?>" />
<input type="hidden" name="parent_id" value="<?php echo $message_id ?>" />
<input type="hidden" name="message_id" value="<?php echo $message_id ?>" />
<input type="hidden" name="token" value="<?php echo $tok ?>" />
<table width="500px" border="0" height="220px">
<tr height="180">
<td align="left">
<div id="id_content_panel_init">
<dl>
<?php
if (api_get_setting('allow_message_tool')=='true') {
//normal message
$user_info = api_get_user_info($userfriend_id);
//echo api_xml_http_response_encode(get_lang('To')).":&nbsp;&nbsp;".api_xml_http_response_encode($to_group);
$height = 180;
if ($allowed_action == 'add_message_group') {
$height = 140;
echo '<span style="color:red">*</span> '.api_xml_http_response_encode(get_lang('Title')).' :<br />';
echo '<input id="txt_subject_id" name="title" type="text" style="width:450px;" value="'.$subject.'"><br /><br />';
}
//echo api_xml_http_response_encode(get_lang('Description')).' :<br />';
<form name="form"
action="group_topics.php?id=<?php echo $group_id ?>&anchor_topic=<?php echo Security::remove_XSS(
$_GET['anchor_topic']
) ?>&topics_page_nr=<?php echo $page_topic . $param_item_page ?>"
method="POST" enctype="multipart/form-data">
<input type="hidden" name="action" value="<?php echo $allowed_action ?>"/>
<input type="hidden" name="group_id" value="<?php echo $group_id ?>"/>
<input type="hidden" name="parent_id" value="<?php echo $message_id ?>"/>
<input type="hidden" name="message_id" value="<?php echo $message_id ?>"/>
<input type="hidden" name="token" value="<?php echo $tok ?>"/>
<table width="500px" border="0" height="220px">
<tr height="180">
<td align="left">
<div id="id_content_panel_init">
<dl>
<?php
if (api_get_setting('allow_message_tool') == 'true') {
//normal message
$user_info = api_get_user_info($userfriend_id);
//echo api_xml_http_response_encode(get_lang('To')).":&nbsp;&nbsp;".api_xml_http_response_encode($to_group);
$height = 180;
if ($allowed_action == 'add_message_group') {
$height = 140;
echo '<span style="color:red">*</span> ' . api_xml_http_response_encode(
get_lang('Title')
) . ' :<br />';
echo '<input id="txt_subject_id" name="title" type="text" style="width:450px;" value="' . $subject . '"><br /><br />';
}
//echo api_xml_http_response_encode(get_lang('Description')).' :<br />';
$oFCKeditor = new FCKeditor('content') ;
$oFCKeditor->ToolbarSet = 'messages';
$oFCKeditor->Width = '95%';
$oFCKeditor->Height = $height;
$oFCKeditor->Value = $message;
$oFCKeditor = new FCKeditor('content');
$oFCKeditor->ToolbarSet = 'messages';
$oFCKeditor->Width = '95%';
$oFCKeditor->Height = $height;
$oFCKeditor->Value = $message;
$return = $oFCKeditor->CreateHtml();
echo $return;
if ($allowed_action == 'add_message_group') {
echo '<div><span style="color:red"> * </span>'.get_lang('FieldRequired').'</div>';
}
?>
<br /><br />
<?php echo api_xml_http_response_encode(get_lang('AttachmentFiles')); ?> :<br />
<span id="filepaths"><div id="filepath_1"><input type="file" name="attach_1" size="20" /></div></span>
<div id="link-more-attach">
<a href="javascript://" onclick="return add_image_form()">
<?php echo get_lang('AddOneMoreFile') ?></a>
</div>
(<?php echo api_xml_http_response_encode(sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message_max_upload_filesize')))) ?>)
<br />
<br />
$return = $oFCKeditor->CreateHtml();
echo $return;
if ($allowed_action == 'add_message_group') {
echo '<div><span style="color:red"> * </span>' . get_lang(
'FieldRequired'
) . '</div>';
}
?>
<br/><br/>
<?php echo api_xml_http_response_encode(
get_lang('AttachmentFiles')
); ?> :<br/>
<span id="filepaths"><div id="filepath_1"><input
type="file" name="attach_1" size="20"/>
</div></span>
<div id="link-more-attach">
<a href="javascript://"
onclick="return add_image_form()">
<?php echo get_lang('AddOneMoreFile') ?></a>
</div>
(<?php echo api_xml_http_response_encode(
sprintf(
get_lang('MaximunFileSizeX'),
format_file_size(
api_get_setting(
'message_max_upload_filesize'
)
)
)
) ?>)
<br/>
<br/>
<?php if ($allowed_action == 'add_message_group') { ?>
<button class="btn save" onclick="if(validate_text_empty(this.form.title.value,'<?php echo get_lang('YouShouldWriteASubject')?>')){return false;}" type="submit" value="<?php echo api_xml_http_response_encode(get_lang('SendMessage')); ?>"><?php echo api_xml_http_response_encode(get_lang('SendMessage')) ?></button>
<?php } else { ?>
<button class="btn save" type="submit" value="<?php echo api_xml_http_response_encode(get_lang('SendMessage')); ?>"><?php echo api_xml_http_response_encode(get_lang('SendMessage')) ?></button>
<?php } ?>
<?php } ?>
</dl>
</td>
</tr>
</div>
</table>
<?php if ($allowed_action == 'add_message_group') { ?>
<button class="btn save"
onclick="if(validate_text_empty(this.form.title.value,'<?php echo get_lang(
'YouShouldWriteASubject'
) ?>')){return false;}" type="submit"
value="<?php echo api_xml_http_response_encode(
get_lang('SendMessage')
); ?>"><?php echo api_xml_http_response_encode(
get_lang('SendMessage')
) ?></button>
<?php } else { ?>
<button class="btn save" type="submit"
value="<?php echo api_xml_http_response_encode(
get_lang('SendMessage')
); ?>"><?php echo api_xml_http_response_encode(
get_lang('SendMessage')
) ?></button>
<?php } ?>
<?php } ?>
</dl>
</td>
</tr>
</div>
</table>
</form>

@ -7,23 +7,26 @@
/**
* Initialization
*/
$language_file = array('messages','userInfo');
$language_file = array('messages', 'userInfo');
$cidReset = true;
require_once '../inc/global.inc.php';
api_block_anonymous_users();
if (api_get_setting('allow_social_tool') !='true') {
if (api_get_setting('allow_social_tool') != 'true') {
api_not_allowed();
}
require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
require_once api_get_path(LIBRARY_PATH) . 'group_portal_manager.lib.php';
$this_section = SECTION_SOCIAL;
$_SESSION['this_section']=$this_section;
$_SESSION['this_section'] = $this_section;
$interbreadcrumb[]= array ('url' =>'profile.php','name' => get_lang('SocialNetwork'));
$interbreadcrumb[]= array ('url' =>'#','name' => get_lang('MyFiles'));
$interbreadcrumb[] = array(
'url' => 'profile.php',
'name' => get_lang('SocialNetwork')
);
$interbreadcrumb[] = array('url' => '#', 'name' => get_lang('MyFiles'));
$htmlHeadXtra[] = '
<script>
@ -38,7 +41,7 @@ function denied_friend (element_input) {
beforeSend: function(objeto) {
$("#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",
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");
@ -47,7 +50,7 @@ function denied_friend (element_input) {
});
}
function register_friend(element_input) {
if(confirm("'.get_lang('AddToFriends').'")) {
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("_");
@ -57,7 +60,7 @@ function register_friend(element_input) {
beforeSend: function(objeto) {
$("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",
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()
@ -71,41 +74,87 @@ function register_friend(element_input) {
$show_message = null;
// easy links
if (is_array($_GET) && count($_GET)>0) {
foreach ($_GET as $key => $value) {
if (is_array($_GET) && count($_GET) > 0) {
foreach ($_GET as $key => $value) {
switch ($key) {
case 'accept':
$user_role = GroupPortalManager::get_user_group_role(api_get_user_id(), $value);
if (in_array($user_role , array(GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER, GROUP_USER_PERMISSION_PENDING_INVITATION))) {
GroupPortalManager::update_user_role(api_get_user_id(), $value, GROUP_USER_PERMISSION_READER);
$user_role = GroupPortalManager::get_user_group_role(
api_get_user_id(),
$value
);
if (in_array(
$user_role,
array(
GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER,
GROUP_USER_PERMISSION_PENDING_INVITATION
)
)
) {
GroupPortalManager::update_user_role(
api_get_user_id(),
$value,
GROUP_USER_PERMISSION_READER
);
$show_message = get_lang('UserIsSubscribedToThisGroup');
} elseif (in_array($user_role , array(GROUP_USER_PERMISSION_READER, GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_MODERATOR))) {
$show_message = get_lang('UserIsAlreadySubscribedToThisGroup');
} elseif (in_array(
$user_role,
array(
GROUP_USER_PERMISSION_READER,
GROUP_USER_PERMISSION_ADMIN,
GROUP_USER_PERMISSION_MODERATOR
)
)
) {
$show_message = get_lang(
'UserIsAlreadySubscribedToThisGroup'
);
} else {
$show_message = get_lang('UserIsNotSubscribedToThisGroup');
}
break 2;
case 'deny':
// delete invitation
GroupPortalManager::delete_user_rel_group(api_get_user_id(), $value);
GroupPortalManager::delete_user_rel_group(
api_get_user_id(),
$value
);
$show_message = get_lang('GroupInvitationWasDeny');
break 2;
}
}
}
}
}
$social_left_content = SocialManager::show_social_menu('myfiles');
$social_avatar_block = SocialManager::show_social_avatar_block('myfiles');
$social_menu_block = SocialManager::show_social_menu('myfiles');
$actions = null;
if (isset($_GET['cidReq'])) {
$actions = '<a href="'.api_get_path(WEB_CODE_PATH).'document/document.php?cidReq='.Security::remove_XSS($_GET['cidReq']).'&amp;id_session='.Security::remove_XSS($_GET['id_session']).'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;id='.Security::remove_XSS($_GET['parent_id']).'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('Documents').' ('.get_lang('Course').')').'</a>';
$actions = '<a href="' . api_get_path(
WEB_CODE_PATH
) . 'document/document.php?cidReq=' . Security::remove_XSS(
$_GET['cidReq']
) . '&amp;id_session=' . Security::remove_XSS(
$_GET['id_session']
) . '&amp;gidReq=' . Security::remove_XSS(
$_GET['gidReq']
) . '&amp;id=' . Security::remove_XSS(
$_GET['parent_id']
) . '">' . Display::return_icon(
'back.png',
get_lang('BackTo') . ' ' . get_lang('Documents') . ' (' . get_lang(
'Course'
) . ')'
) . '</a>';
}
$social_right_content = '<div class="span9">';
$social_right_content .= '<iframe name="fileManager" id="fileManager" src="'.api_get_path(WEB_PATH).'main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajaxfilemanager.php?editor=stand_alone" scrolling="no" noresize="noresize" frameborder="no" style="height:480px; width:100%; float:left"></iframe>';
$social_right_content = '<div class="span9">';
$social_right_content .= '<iframe name="fileManager" id="fileManager" src="' . api_get_path(
WEB_PATH
) . 'main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajaxfilemanager.php?editor=stand_alone" scrolling="no" noresize="noresize" frameborder="no" style="height:480px; width:100%; float:left"></iframe>';
$social_right_content .= '</div>';
$tpl = new Template();
$tpl->assign('social_left_content', $social_left_content);
$tpl->assign('social_avatar_block', $social_avatar_block);
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->assign('social_right_content', $social_right_content);
$tpl->assign('actions', $actions);

@ -302,7 +302,8 @@ if (is_array($personal_course_list)) {
$course_list_code = array_unique_dimensional($course_list_code);
}
$social_left_content = SocialManager::show_social_menu('shared_profile', null, $user_id, $show_full_profile);
$social_avatar_block = SocialManager::show_social_avatar_block('shared_profile', null, $user_id);
$social_menu_block = SocialManager::show_social_menu('shared_profile', null, $user_id, $show_full_profile);
$personal_info = null;
if (!empty($user_info['firstname']) || !empty($user_info['lastname'])) {
@ -763,7 +764,8 @@ $social_right_content .= MessageManager::generate_invitation_form('send_invitati
$tpl = new Template(get_lang('Social'));
$tpl->assign('social_left_content', $social_left_content);
$tpl->assign('social_avatar_block', $social_avatar_block);
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->assign('social_right_content', $social_right_content);
$social_layout = $tpl->get_template('layout/social_layout.tpl');

@ -8,111 +8,169 @@
/**
* Initialization
*/
$language_file = array('registration','messages','userInfo','admin');
$cidReset=true;
$language_file = array('registration', 'messages', 'userInfo', 'admin');
$cidReset = true;
require_once '../inc/global.inc.php';
api_block_anonymous_users();
if (api_get_setting('allow_social_tool') !='true') {
if (api_get_setting('allow_social_tool') != 'true') {
api_not_allowed();
}
require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
require_once api_get_path(LIBRARY_PATH) . 'group_portal_manager.lib.php';
$views = array('friends','mygroups');
$views = array('friends', 'mygroups');
$user_id = intval($_GET['user_id']);
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 = array();
//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>';
// the height = 92 must be the sqme in the image_friend_network span style in default.css
$friends_profile = SocialManager::get_picture_user($friend['friend_user_id'], $friend['image'], 92, USER_IMAGE_SIZE_MEDIUM , 'width="85" height="90" ');
$friend_html.='<a href="profile.php?u='.$friend['friend_user_id'].'&amp;'.$link_shared.'">';
$friend_html.='<img src="'.$friends_profile['file'].'" '.$friends_profile['style'].' 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 = GroupPortalManager::get_groups_by_user($user_id, 0);
$grid_my_groups = array();
if (is_array($results) && count($results) > 0) {
$i = 1;
foreach ($results as $result) {
$id = $result['id'];
$url_open = '<a href="groups.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'), array('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'), array('style'=>'vertical-align:middle;width:16px;height:16px;'));
}
$count_users_group = count(GroupPortalManager::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 = GroupPortalManager::get_picture_group($result['id'], $result['picture_uri'],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'].'" hspace="4" height="50" border="2" align="left" width="50" /></div>';
$item_actions = '';
if (api_get_user_id() == $user_id) {
$item_actions = '<div class="box_shared_profile_group_actions"><a href="groups.php?id='.$id.'">'.get_lang('SeeMore').$url_close.'</div>';
}
$grid_my_groups[]= array($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>';
Display::display_sortable_grid('shared_profile_mygroups', array(), $grid_my_groups, array('hide_navigation'=>true, 'per_page' => 2), $query_vars, false, array(true, true, true,false));
echo '</div>';
}
}
// 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 = array();
//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>';
// the height = 92 must be the sqme in the image_friend_network span style in default.css
$friends_profile = SocialManager::get_picture_user(
$friend['friend_user_id'],
$friend['image'],
92,
USER_IMAGE_SIZE_MEDIUM,
'width="85" height="90" '
);
$friend_html .= '<a href="profile.php?u=' . $friend['friend_user_id'] . '&amp;' . $link_shared . '">';
$friend_html .= '<img src="' . $friends_profile['file'] . '" ' . $friends_profile['style'] . ' 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 = GroupPortalManager::get_groups_by_user($user_id, 0);
$grid_my_groups = array();
if (is_array($results) && count($results) > 0) {
$i = 1;
foreach ($results as $result) {
$id = $result['id'];
$url_open = '<a href="groups.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'),
array('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'),
array('style' => 'vertical-align:middle;width:16px;height:16px;')
);
}
$count_users_group = count(
GroupPortalManager::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 = GroupPortalManager::get_picture_group(
$result['id'],
$result['picture_uri'],
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'] . '" hspace="4" height="50" border="2" align="left" width="50" /></div>';
$item_actions = '';
if (api_get_user_id() == $user_id) {
$item_actions = '<div class="box_shared_profile_group_actions"><a href="groups.php?id=' . $id . '">' . get_lang(
'SeeMore'
) . $url_close . '</div>';
}
$grid_my_groups[] = array(
$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>';
Display::display_sortable_grid(
'shared_profile_mygroups',
array(),
$grid_my_groups,
array('hide_navigation' => true, 'per_page' => 2),
$query_vars,
false,
array(true, true, true, false)
);
echo '</div>';
}
}
}

@ -139,7 +139,8 @@ $interbreadcrumb[] = array('url' => 'profile.php', 'name' => get_lang('SocialNet
$query = isset($_GET['q']) ? $_GET['q'] : null;
$query_vars = array('q' => $query);
$social_left_content = SocialManager::show_social_menu('search');
$social_avatar_block = SocialManager::show_social_avatar_block('search');
$social_menu_block = SocialManager::show_social_menu('search');
$social_right_content = '<div class="span9">'.UserManager::get_search_form($query).'</div>';
@ -314,7 +315,8 @@ $social_right_content .= MessageManager::generate_message_form('send_message');
$social_right_content .= MessageManager::generate_invitation_form('send_invitation');
$tpl = new Template($tool_name);
$tpl->assign('social_left_content', $social_left_content);
$tpl->assign('social_avatar_block', $social_avatar_block);
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->assign('social_right_content', $social_right_content);
$social_layout = $tpl->get_template('layout/social_layout.tpl');

@ -3,8 +3,10 @@
{% block content %}
<div class="row">
<div class="span3">
{{ social_left_content }}
{{ social_left_menu }}
<div class="social-menu">
{{ social_avatar_block }}
{{ social_menu_block }}
</div>
</div>
<div class="span9">
<div class="row">

Loading…
Cancel
Save