search.php 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @package chamilo.social
  5. * @author Julio Montoya <gugli100@gmail.com>
  6. */
  7. /**
  8. * Initialization
  9. */
  10. // name of the language file that needs to be included
  11. $language_file = array('registration','admin','userInfo');
  12. $cidReset = true;
  13. require_once '../inc/global.inc.php';
  14. require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
  15. api_block_anonymous_users();
  16. if (api_get_setting('allow_social_tool') !='true') {
  17. api_not_allowed();
  18. }
  19. $this_section = SECTION_SOCIAL;
  20. $tool_name = get_lang('Search');
  21. $interbreadcrumb[]= array ('url' =>'profile.php','name' => get_lang('Social'));
  22. $query_vars = array();
  23. $query = isset($_GET['q']) ? $_GET['q'] : null;
  24. Display :: display_header($tool_name);
  25. echo '<div id="social-content">';
  26. echo '<div id="social-content-left">';
  27. //show the action menu
  28. SocialManager::show_social_menu('search');
  29. echo '</div>';
  30. echo '<div id="social-content-right">';
  31. echo UserManager::get_search_form($query);
  32. //I'm searching something
  33. if ($query !='') {
  34. //get users from tags
  35. $users = UserManager::get_all_user_tags($_GET['q'], 0, 0, 5);
  36. $groups = GroupPortalManager::get_all_group_tags($_GET['q']);
  37. if (empty($users) && empty($groups)) {
  38. echo get_lang('SorryNoResults');
  39. }
  40. $results = array();
  41. if (is_array($users) && count($users)> 0) {
  42. echo '<h2>'.get_lang('Users').'</h2>';
  43. foreach($users as $user) {
  44. $url = api_get_path(WEB_PATH).'main/social/profile.php?u='.$user['user_id'];
  45. if (empty($user['picture_uri'])) {
  46. $picture['file'] = api_get_path(WEB_CODE_PATH).'img/unknown_180_100.jpg';
  47. $img = Display::url('<img title class="social-home-anonymous-online" src="'.$picture['file'].'">', $url);
  48. } else {
  49. $picture = UserManager::get_picture_user($user['user_id'], $user['picture_uri'], 80, USER_IMAGE_SIZE_ORIGINAL );
  50. $img = '<img src="'.$picture['file'].'">';
  51. $clip = 'clip_vertical';
  52. if ($picture['original_height'] > $picture['original_width']) {
  53. $clip = 'clip_horizontal';
  54. }
  55. $img = Display::url(Display::div(Display::div($img, array('class'=>$clip)), array('class'=>'clip-wrapper')) , $url);
  56. }
  57. $user['firstname'] = Display::url($user['firstname'], $url);
  58. $user['lastname'] = Display::url($user['lastname'], $url);
  59. $user['tag'] = isset($user['tag']) ? $user['tag'] : null;
  60. $results[] = array($img, $user['firstname'], $user['lastname'], $user['tag']);
  61. }
  62. echo '<div id="div_content_table" class="rounded_div">';
  63. Display::display_sortable_grid('online', array(), $results, array('hide_navigation'=>true, 'per_page' => 5), $query_vars, false ,true);
  64. echo '</div>';
  65. }
  66. //Get users from tags
  67. if (is_array($results) && count($results) > 0) {
  68. foreach ($results as $result) {
  69. $id = $result['id'];
  70. $url_open = '<a href="groups.php?id='.$id.'">';
  71. $url_close = '</a>';
  72. $name = api_strtoupper(cut($result['name'],25,true));
  73. if (isset($result['relation_type']) && $result['relation_type'] == GROUP_USER_PERMISSION_ADMIN) {
  74. $name .= Display::return_icon('social_group_admin.png', get_lang('Admin'), array('style'=>'vertical-align:middle'));
  75. } elseif (isset($result['relation_type']) && $result['relation_type'] == GROUP_USER_PERMISSION_MODERATOR) {
  76. $name .= Display::return_icon('social_group_moderator.png', get_lang('Moderator'), array('style'=>'vertical-align:middle'));
  77. }
  78. $count_users_group = count(GroupPortalManager::get_all_users_by_group($id));
  79. if ($count_users_group == 1 ) {
  80. $count_users_group = $count_users_group.' '.get_lang('Member');
  81. } else {
  82. $count_users_group = $count_users_group.' '.get_lang('Members');
  83. }
  84. $picture = GroupPortalManager::get_picture_group($id, $result['picture_uri'],80);
  85. $result['picture_uri'] = '<img class="social-groups-image" src="'.$picture['file'].'" hspace="4" height="50" border="2" align="left" width="50" />';
  86. $grid_item_1 = Display::return_icon('boxmygroups.jpg');
  87. $item_1 = '<div>'.$url_open.$result['picture_uri'].'<strong>'.$name.'<br />('.$count_users_group.')</strong>'.$url_close.'</div>';
  88. if ($result['description'] != '') {
  89. $item_2 = '<div class="box_description_group_title" ><span class="social-groups-text2">'.get_lang('Description').'</span></div>';
  90. $item_3 = '<div class="box_description_group_content" >'.cut($result['description'],100,true).'</div>';
  91. } else {
  92. $item_2 = '<div class="box_description_group_title" ><span class="social-groups-text2"></span></div>';
  93. $item_3 = '<div class="box_description_group_content" ></div>';
  94. }
  95. $item_4 = '<div class="box_description_group_actions" >'.$url_open.get_lang('SeeMore').$url_close.'</div>';
  96. $grid_item_2 = $item_1.$item_2.$item_3.$item_4;
  97. $grid_my_groups[]= array($grid_item_1,$grid_item_2);
  98. }
  99. }
  100. $grid_groups = array();
  101. if (is_array($groups) && count($groups)>0) {
  102. echo '<h2>'.get_lang('Groups').'</h2>';
  103. foreach($groups as $group) {
  104. $id = $group['id'];
  105. $url_open = '<a href="groups.php?id='.$id.'">';
  106. $url_close = '</a>';
  107. $name = cut($group['name'],25,true);
  108. $count_users_group = count(GroupPortalManager::get_all_users_by_group($id));
  109. if ($count_users_group == 1 ) {
  110. $count_users_group = $count_users_group.' '.get_lang('Member');
  111. } else {
  112. $count_users_group = $count_users_group.' '.get_lang('Members');
  113. }
  114. $picture = GroupPortalManager::get_picture_group($group['id'], $group['picture_uri'],80);
  115. $tags = GroupPortalManager::get_group_tags($group['id']);
  116. $group['picture_uri'] = '<img class="social-groups-image" src="'.$picture['file'].'" hspace="4" height="50" border="2" align="left" width="50" />';
  117. $item_0 = Display::div($group['picture_uri'], array('class'=>'box_description_group_image'));
  118. $members = Display::span($count_users_group, array('class'=>'box_description_group_member'));
  119. $item_1 = Display::div(Display::tag('h3', $url_open.$name.$url_close).$members, array('class'=>'box_description_group_title'));
  120. $item_2 = '';
  121. $item_3 = '';
  122. if ($group['description'] != '') {
  123. $item_3 = '<div class="box_description_group_content" >'.cut($group['description'],100,true).'</div>';
  124. } else {
  125. $item_2 = '<div class="box_description_group_title" ><span class="social-groups-text2"></span></div>';
  126. $item_3 = '<div class="box_description_group_content" ></div>';
  127. }
  128. $item_4 = '<div class="box_description_group_tags" >'.$tags.'</div>';
  129. $item_5 = '<div class="box_description_group_actions" >'.$url_open.get_lang('SeeMore').$url_close.'</div>';
  130. $grid_item_2 = $item_0.$item_1.$item_2.$item_3.$item_4.$item_5;
  131. $grid_groups[]= array('',$grid_item_2);
  132. }
  133. }
  134. $visibility = array(true,true,true,true,true);
  135. Display::display_sortable_grid('mygroups', array(), $grid_groups, array('hide_navigation'=>true, 'per_page' => 5), $query_vars, false, $visibility);
  136. }
  137. echo '</div>';
  138. echo '</div>';
  139. Display :: display_footer();