friends.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. $language_file = array('userInfo');
  11. $cidReset = true;
  12. //require_once '../inc/global.inc.php';
  13. api_block_anonymous_users();
  14. if (api_get_setting('allow_social_tool') != 'true') {
  15. api_not_allowed();
  16. }
  17. $this_section = SECTION_SOCIAL;
  18. $htmlHeadXtra[] = '<script>
  19. function delete_friend (element_div) {
  20. id_image=$(element_div).attr("id");
  21. user_id=id_image.split("_");
  22. if (confirm("'.get_lang('Delete', '').'")) {
  23. $.ajax({
  24. contentType: "application/x-www-form-urlencoded",
  25. type: "POST",
  26. url: "'.api_get_path(WEB_AJAX_PATH).'social.ajax.php?a=delete_friend",
  27. data: "delete_friend_id="+user_id[1],
  28. success: function(datos) {
  29. $("div#"+"div_"+user_id[1]).hide("slow");
  30. $("div#"+"div_"+user_id[1]).html("");
  31. clear_form ();
  32. }
  33. });
  34. }
  35. }
  36. function search_image_social() {
  37. var name_search = $("#id_search_image").attr("value");
  38. $.ajax({
  39. contentType: "application/x-www-form-urlencoded",
  40. type: "POST",
  41. url: "'.api_get_path(WEB_AJAX_PATH).'social.ajax.php?a=show_my_friends",
  42. data: "search_name_q="+name_search,
  43. success: function(data) {
  44. $("#friends").html(data);
  45. }
  46. });
  47. }
  48. function clear_form() {
  49. $("input[@type=radio]").attr("checked", false);
  50. $("div#div_qualify_image").html("");
  51. $("div#div_info_user").html("");
  52. }
  53. </script>';
  54. $interbreadcrumb[] = array('url' => 'profile.php', 'name' => get_lang('SocialNetwork'));
  55. $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Friends'));
  56. $social_left_content = SocialManager::show_social_menu('friends');
  57. $user_id = api_get_user_id();
  58. $user_id = api_get_user_id();
  59. $name_search = isset($_POST['search_name_q']) ? $_POST['search_name_q'] : null;
  60. $number_friends = 0;
  61. if (isset($name_search) && $name_search != 'undefined') {
  62. $friends = SocialManager::get_friends($user_id, null, $name_search);
  63. } else {
  64. $friends = SocialManager::get_friends($user_id);
  65. }
  66. $social_right_content = '<div class="span8">';
  67. if (count($friends) == 0) {
  68. $social_right_content .= get_lang('NoFriendsInYourContactList').'<br /><br />';
  69. $social_right_content .= '<a class="btn" href="search.php">'.get_lang('TryAndFindSomeFriends').'</a>';
  70. } else {
  71. $social_right_content .= get_lang('Search').'&nbsp;&nbsp; : &nbsp;&nbsp;';
  72. $social_right_content .= '<input class="social-search-image" type="text" id="id_search_image" name="id_search_image" onkeyup="search_image_social()" />';
  73. $friend_html = '<div id="friends">';
  74. $number_friends = count($friends);
  75. $j = 0;
  76. $friend_html .= '<ul class="thumbnails">';
  77. for ($k = 0; $k < $number_friends; $k++) {
  78. while ($j < $number_friends) {
  79. if (isset($friends[$j])) {
  80. $friend_html .= '<li class="span2">';
  81. $userInfo = $friends[$j]['user_info'];
  82. $friend = $friends[$j];
  83. $user_name = api_xml_http_response_encode($friend['firstName'].' '.$friend['lastName']);
  84. $friends_profile = SocialManager::get_picture_user($friend['friend_user_id'], $friend['image'], 92);
  85. $friend_html .= '<div class="thumbnail" class="image-social-content" id=div_'.$friends[$j]['friend_user_id'].'>';
  86. $friend_html .= '<img src="'.$friends_profile['file'].'" id="imgfriend_'.$friend['friend_user_id'].'" title="'.$user_name.'" /> ';
  87. $friend_html .= '<div class="caption">
  88. <a href="'.$userInfo['profile_url'].'"><h5>'.$user_name.'</h5></a>';
  89. $friend_html .= '<p><button onclick="delete_friend(this)" id=img_'.$friend['friend_user_id'].' />'.get_lang(
  90. 'Delete'
  91. ).'</button></p>
  92. </div>';
  93. $friend_html .= '</li>';
  94. }
  95. $j++;
  96. }
  97. }
  98. $friend_html .= '</ul>';
  99. $friend_html .= '</div>';
  100. $social_right_content .= $friend_html;
  101. }
  102. $social_right_content .= '</div>';
  103. $app['title'] = get_lang('Social');
  104. $tpl = $app['template'];
  105. $tpl->assign('social_left_content', $social_left_content);
  106. $tpl->assign('social_right_content', $social_right_content);
  107. $social_layout = $tpl->getTemplate('layout/social_layout.tpl');
  108. $tpl->display($social_layout);