search.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. api_block_anonymous_users();
  15. if (api_get_setting('allow_social_tool') !='true') {
  16. api_not_allowed();
  17. }
  18. $this_section = SECTION_SOCIAL;
  19. $tool_name = get_lang('Search');
  20. $interbreadcrumb[]= array ('url' =>'profile.php','name' => get_lang('SocialNetwork'));
  21. $query_vars = array();
  22. $query = isset($_GET['q']) ? $_GET['q'] : null;
  23. $social_left_content = SocialManager::show_social_menu('search');
  24. $social_right_content = '<div class="span9">'.UserManager::get_search_form($query).'</div>';
  25. $usergroup = new UserGroup();
  26. //I'm searching something
  27. if ($query !='') {
  28. //get users from tags
  29. $users = UserManager::get_all_user_tags($_GET['q'], 0, 0, 5);
  30. $groups = $usergroup->get_all_group_tags($_GET['q']);
  31. if (empty($users) && empty($groups)) {
  32. $social_right_content .= get_lang('SorryNoResults');
  33. }
  34. $results = '<div id="online_grid_container"><div class="span9">';
  35. if (is_array($users) && count($users)> 0) {
  36. $results .= Display::page_subheader(get_lang('Users'));
  37. $results .= '<ul class="thumbnails">';
  38. foreach ($users as $user) {
  39. $user_info = api_get_user_info($user['user_id'], true);
  40. $url = api_get_path(WEB_PATH).'main/social/profile.php?u='.$user['user_id'];
  41. if (empty($user['picture_uri'])) {
  42. $picture['file'] = api_get_path(WEB_CODE_PATH).'img/unknown_180_100.jpg';
  43. $img = '<img src="'.$picture['file'].'">';
  44. } else {
  45. $picture = UserManager::get_picture_user($user['user_id'], $user['picture_uri'], 80, USER_IMAGE_SIZE_ORIGINAL );
  46. $img = '<img src="'.$picture['file'].'">';
  47. }
  48. if ($user_info['user_is_online']) {
  49. $status_icon = Display::span('', array('class' => 'online_user_in_text'));
  50. } else {
  51. $status_icon = Display::span('', array('class' => 'offline_user_in_text'));
  52. }
  53. $user['tag'] = isset($user['tag']) ? $user['tag'] : null;
  54. $user_info['complete_name'] = Display::url($status_icon.$user_info['complete_name'], $url).'<br />'.$user['tag'];
  55. $results .= '<li class="span3"><div class="thumbnail">'.$img.'<div class="caption">'.$user_info['complete_name'].$user['tag'].'</div</div></li>';
  56. }
  57. $results .='</ul></div></div>';
  58. $social_right_content .= $results;
  59. }
  60. $grid_groups = array();
  61. if (is_array($groups) && count($groups)>0) {
  62. $social_right_content .= '<div class="span9">';
  63. $social_right_content .= Display::page_subheader(get_lang('Groups'));
  64. foreach($groups as $group) {
  65. $group['name'] = Security::remove_XSS($group['name'], STUDENT, true);
  66. $$group['description'] = Security::remove_XSS($group['description'], STUDENT, true);
  67. $id = $group['id'];
  68. $url_open = '<a href="groups.php?id='.$id.'" >';
  69. $url_close = '</a>';
  70. $name = Text::cut($group['name'],25,true);
  71. $count_users_group = count($usergroup->get_all_users_by_group($id));
  72. if ($count_users_group == 1 ) {
  73. $count_users_group = $count_users_group.' '.get_lang('Member');
  74. } else {
  75. $count_users_group = $count_users_group.' '.get_lang('Members');
  76. }
  77. $picture = $usergroup->get_picture_group($group['id'], $group['picture'],80);
  78. $tags = $usergroup->get_group_tags($group['id']);
  79. $group['picture'] = '<img class="social-groups-image" src="'.$picture['file'].'" hspace="4" height="50" border="2" align="left" width="50" />';
  80. $item_0 = Display::div($group['picture'], array('class'=>'box_description_group_image'));
  81. $members = Display::span($count_users_group, array('class'=>'box_description_group_member'));
  82. $item_1 = Display::div(Display::tag('h3', $url_open.$name.$url_close).$members, array('class'=>'box_description_group_title'));
  83. $item_2 = '';
  84. $item_3 = '';
  85. if ($group['description'] != '') {
  86. $item_3 = '<div class="box_description_group_content" >'.Text::cut($group['description'],100,true).'</div>';
  87. } else {
  88. $item_2 = '<div class="box_description_group_title" ><span class="social-groups-text2"></span></div>';
  89. $item_3 = '<div class="box_description_group_content" ></div>';
  90. }
  91. $item_4 = '<div class="box_description_group_tags" >'.$tags.'</div>';
  92. $item_5 = '<div class="box_description_group_actions" >'.$url_open.get_lang('SeeMore').$url_close.'</div>';
  93. $grid_item_2 = $item_0.$item_1.$item_2.$item_3.$item_4.$item_5;
  94. $grid_groups[]= array('',$grid_item_2);
  95. }
  96. }
  97. $visibility = array(true,true,true,true,true);
  98. $social_right_content .= Display::return_sortable_grid('mygroups', array(), $grid_groups, array('hide_navigation'=>true, 'per_page' => 5), $query_vars, false, $visibility);
  99. }
  100. $app['title'] = $tool_name;
  101. $tpl = $app['template'];
  102. $tpl->assign('social_left_content', $social_left_content);
  103. $tpl->assign('social_right_content', $social_right_content);
  104. $social_layout = $tpl->get_template('layout/social_layout.tpl');
  105. $tpl->display($social_layout);