home.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use ChamiloSession as Session;
  4. /**
  5. * @package chamilo.social
  6. *
  7. * @author Julio Montoya <gugli100@gmail.com>
  8. * @autor Alex Aragon <alex.aragon@beeznest.com> CSS Design and Template
  9. */
  10. $cidReset = true;
  11. require_once __DIR__.'/../inc/global.inc.php';
  12. api_block_anonymous_users();
  13. $user_id = api_get_user_id();
  14. $show_full_profile = true;
  15. // social tab
  16. Session::erase('this_section');
  17. $this_section = SECTION_SOCIAL;
  18. if (api_get_setting('allow_social_tool') !== 'true') {
  19. $url = api_get_path(WEB_CODE_PATH).'auth/profile.php';
  20. header('Location: '.$url);
  21. exit;
  22. }
  23. $userGroup = new UserGroup();
  24. SocialManager::handlePosts(api_get_self());
  25. $threadList = SocialManager::getThreadList($user_id);
  26. $threadIdList = [];
  27. if (!empty($threadList)) {
  28. $threadIdList = array_column($threadList, 'id');
  29. }
  30. $posts = SocialManager::getMyWallMessages($user_id, 0, 10, $threadIdList);
  31. $countPost = $posts['count'];
  32. $posts = $posts['posts'];
  33. SocialManager::getScrollJs($countPost, $htmlHeadXtra);
  34. // Block Menu
  35. $menu = SocialManager::show_social_menu('home');
  36. $social_search_block = Display::panel(
  37. UserManager::get_search_form(''),
  38. get_lang('Search users')
  39. );
  40. $social_group_block = SocialManager::getGroupBlock($user_id);
  41. // My friends
  42. $friend_html = SocialManager::listMyFriendsBlock($user_id);
  43. // Block Social Sessions
  44. $social_session_block = null;
  45. //$user_info = api_get_user_info($user_id);
  46. //$sessionList = SessionManager::getSessionsFollowedByUser($user_id, $user_info['status']);
  47. $sessionList = [];
  48. if (count($sessionList) > 0) {
  49. $social_session_block = $sessionList;
  50. }
  51. $wallSocialAddPost = SocialManager::getWallForm(api_get_self());
  52. $socialAutoExtendLink = SocialManager::getAutoExtendLink($user_id, $countPost);
  53. $formSearch = new FormValidator(
  54. 'find_friends_form',
  55. 'get',
  56. api_get_path(WEB_CODE_PATH).'social/search.php?search_type=1',
  57. null,
  58. null,
  59. FormValidator::LAYOUT_BOX_NO_LABEL
  60. );
  61. $formSearch->addHidden('search_type', 1);
  62. $formSearch->addText(
  63. 'q',
  64. get_lang('Search'),
  65. false,
  66. [
  67. 'aria-label' => get_lang('Search users'),
  68. 'custom' => true,
  69. 'placeholder' => get_lang('Search usersByName'),
  70. ]
  71. );
  72. // Added a Jquery Function to return the Preview of OpenGraph URL Content
  73. $htmlHeadXtra[] = SocialManager::getScriptToGetOpenGraph();
  74. $tpl = new Template(get_lang('Social network'));
  75. SocialManager::setSocialUserBlock($tpl, $user_id, 'home');
  76. $tpl->assign('add_post_form', $wallSocialAddPost);
  77. $tpl->assign('posts', $posts);
  78. $tpl->assign('social_menu_block', $menu);
  79. $tpl->assign('social_auto_extend_link', $socialAutoExtendLink);
  80. $tpl->assign('search_friends_form', $formSearch->returnForm());
  81. $tpl->assign('social_friend_block', $friend_html);
  82. $tpl->assign('social_search_block', $social_search_block);
  83. $tpl->assign('social_skill_block', SocialManager::getSkillBlock($user_id, 'vertical'));
  84. $tpl->assign('social_group_block', $social_group_block);
  85. $tpl->assign('session_list', $social_session_block);
  86. $social_layout = $tpl->get_template('social/home.tpl');
  87. $tpl->display($social_layout);