profile_friends_and_groups.inc.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. $language_file = array('registration','messages','userInfo','admin');
  4. $cidReset=true;
  5. require_once '../inc/global.inc.php';
  6. api_block_anonymous_users();
  7. if (api_get_setting('allow_social_tool') !='true') {
  8. api_not_allowed();
  9. }
  10. require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
  11. require_once api_get_path(LIBRARY_PATH).'message.lib.php';
  12. require_once api_get_path(LIBRARY_PATH).'social.lib.php';
  13. require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
  14. $views = array('friends','mygroups');
  15. $user_id = intval($_GET['user_id']);
  16. if (isset($_GET['view']) && in_array($_GET['view'], $views)) {
  17. // show all friends by user_id
  18. if ($_GET['view']=='friends') {
  19. echo '<div style="margin-top:20px;">';
  20. $list_path_friends= $list_path_normal_friends = $list_path_parents = array();
  21. //SOCIALGOODFRIEND , USER_RELATION_TYPE_FRIEND, SOCIALPARENT
  22. $friends = SocialManager::get_friends($user_id, USER_RELATION_TYPE_FRIEND);
  23. $number_friends = count($friends);
  24. $friend_html = '';
  25. $friend_html .= '<div><h3>'.get_lang('SocialFriend').'</h3></div>';
  26. $friend_html .= '<div id="friend-container" class="social-friend-container">';
  27. $friend_html .= '<div id="friend-header" >';
  28. if ($number_friends == 1) {
  29. $friend_html.= '<div style="float:left;width:80%">'.$number_friends.' '.get_lang('Friend').'</div>';
  30. } else {
  31. $friend_html.= '<div style="float:left;width:80%">'.$number_friends.' '.get_lang('Friends').'</div>';
  32. }
  33. $friend_html.= '</div>'; // close div friend-header
  34. for ($k=0;$k<$number_friends;$k++) {
  35. if (isset($friends[$k])) {
  36. $friend = $friends[$k];
  37. $name_user = api_get_person_name($friend['firstName'], $friend['lastName']);
  38. $friend_html.='<div id=div_'.$friend['friend_user_id'].' class="image_friend_network" ><span><center>';
  39. // the height = 92 must be the sqme in the image_friend_network span style in default.css
  40. $friends_profile = SocialManager::get_picture_user($friend['friend_user_id'], $friend['image'], 92, USER_IMAGE_SIZE_MEDIUM , 'width="85" height="90" ');
  41. $friend_html.='<a href="profile.php?u='.$friend['friend_user_id'].'&amp;'.$link_shared.'">';
  42. $friend_html.='<img src="'.$friends_profile['file'].'" '.$friends_profile['style'].' id="imgfriend_'.$friend['friend_user_id'].'" title="'.$name_user.'" />';
  43. $friend_html.= '</center></span>';
  44. $friend_html.= '<center class="friend">'.$name_user.'</a></center>';
  45. $friend_html.= '</div>';
  46. }
  47. }
  48. echo $friend_html;
  49. echo '</div>';
  50. } else {
  51. // show all groups by user_id
  52. // MY GROUPS
  53. $results = GroupPortalManager::get_groups_by_user($user_id, 0);
  54. $grid_my_groups = array();
  55. if (is_array($results) && count($results) > 0) {
  56. $i = 1;
  57. foreach ($results as $result) {
  58. $id = $result['id'];
  59. $url_open = '<a href="groups.php?id='.$id.'">';
  60. $url_close = '</a>';
  61. $icon = '';
  62. $name = cut($result['name'],20,true);
  63. if ($result['relation_type'] == GROUP_USER_PERMISSION_ADMIN) {
  64. $icon = Display::return_icon('social_group_admin.png', get_lang('Admin'), array('style'=>'vertical-align:middle;width:16px;height:16px;'));
  65. } elseif ($result['relation_type'] == GROUP_USER_PERMISSION_MODERATOR) {
  66. $icon = Display::return_icon('social_group_moderator.png', get_lang('Moderator'), array('style'=>'vertical-align:middle;width:16px;height:16px;'));
  67. }
  68. $count_users_group = count(GroupPortalManager::get_all_users_by_group($id));
  69. if ($count_users_group == 1 ) {
  70. $count_users_group = $count_users_group.' '.get_lang('Member');
  71. } else {
  72. $count_users_group = $count_users_group.' '.get_lang('Members');
  73. }
  74. $picture = GroupPortalManager::get_picture_group($result['id'], $result['picture_uri'],80);
  75. $item_name = '<div class="box_shared_profile_group_title">'.$url_open.api_xml_http_response_encode($name). $icon.$url_close.'</div>';
  76. $item_description = '';
  77. if (!empty($result['description'])) {
  78. $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>';
  79. }
  80. $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>';
  81. $item_actions = '';
  82. if (api_get_user_id() == $user_id) {
  83. $item_actions = '<div class="box_shared_profile_group_actions"><a href="groups.php?id='.$id.'">'.get_lang('SeeMore').$url_close.'</div>';
  84. }
  85. $grid_my_groups[]= array($item_name,$url_open.$result['picture_uri'].$url_close, $item_description.$item_actions);
  86. $i++;
  87. }
  88. }
  89. if (count($grid_my_groups) > 0) {
  90. echo '<div style="margin-top:20px">';
  91. echo '<div><h3>'.get_lang('MyGroups').'</h3></div>';
  92. $count_groups = 0;
  93. if (count($results) == 1 ) {
  94. $count_groups = count($results).' '.get_lang('Group');
  95. } else {
  96. $count_groups = count($results).' '.get_lang('Groups');
  97. }
  98. echo '<div>'.$count_groups.'</div>';
  99. 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));
  100. echo '</div>';
  101. }
  102. }
  103. }