profile_friends_and_groups.inc.php 5.5 KB

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