friends.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. require_once api_get_path(CONFIGURATION_PATH).'profile.conf.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. $htmlHeadXtra[] = '<script>
  20. function delete_friend (element_div) {
  21. id_image=$(element_div).attr("id");
  22. user_id=id_image.split("_");
  23. if (confirm("'.get_lang('Delete', '').'")) {
  24. $.ajax({
  25. contentType: "application/x-www-form-urlencoded",
  26. type: "POST",
  27. url: "'.api_get_path(WEB_AJAX_PATH).'social.ajax.php?a=delete_friend",
  28. data: "delete_friend_id="+user_id[1],
  29. success: function(datos) {
  30. $("div#"+"div_"+user_id[1]).hide("slow");
  31. $("div#"+"div_"+user_id[1]).html("");
  32. clear_form ();
  33. }
  34. });
  35. }
  36. }
  37. function search_image_social() {
  38. var name_search = $("#id_search_image").attr("value");
  39. $.ajax({
  40. contentType: "application/x-www-form-urlencoded",
  41. type: "POST",
  42. url: "'.api_get_path(WEB_AJAX_PATH).'social.ajax.php?a=show_my_friends",
  43. data: "search_name_q="+name_search,
  44. success: function(data) {
  45. $("#friends").html(data);
  46. }
  47. });
  48. }
  49. function show_icon_delete(element_html) {
  50. elem_id=$(element_html).attr("id");
  51. id_elem=elem_id.split("_");
  52. ident="#img_"+id_elem[1];
  53. $(ident).attr("src","../img/delete.png");
  54. $(ident).attr("alt","'.get_lang('Delete', '').'");
  55. $(ident).attr("title","'.get_lang('Delete', '').'");
  56. }
  57. function hide_icon_delete(element_html) {
  58. elem_id=$(element_html).attr("id");
  59. id_elem=elem_id.split("_");
  60. ident="#img_"+id_elem[1];
  61. $(ident).attr("src","../img/blank.gif");
  62. $(ident).attr("alt","");
  63. $(ident).attr("title","");
  64. }
  65. function clear_form () {
  66. $("input[@type=radio]").attr("checked", false);
  67. $("div#div_qualify_image").html("");
  68. $("div#div_info_user").html("");
  69. }
  70. </script>';
  71. $interbreadcrumb[] = array('url' => 'profile.php', 'name' => get_lang('SocialNetwork'));
  72. $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Friends'));
  73. $social_left_content = SocialManager::show_social_menu('friends');
  74. $user_id = api_get_user_id();
  75. $user_id = api_get_user_id();
  76. $name_search = isset($_POST['search_name_q']) ? $_POST['search_name_q'] : null;
  77. $number_friends = 0;
  78. if (isset($name_search) && $name_search != 'undefined') {
  79. $friends = SocialManager::get_friends($user_id, null, $name_search);
  80. } else {
  81. $friends = SocialManager::get_friends($user_id);
  82. }
  83. $social_right_content = '<div class="span8">';
  84. if (count($friends) == 0) {
  85. $social_right_content .= get_lang('NoFriendsInYourContactList').'<br /><br />';
  86. $social_right_content .= '<a class="btn" href="search.php">'.get_lang('TryAndFindSomeFriends').'</a>';
  87. } else {
  88. $social_right_content .= get_lang('Search').'&nbsp;&nbsp; : &nbsp;&nbsp;';
  89. $social_right_content .= '<input class="social-search-image" type="text" id="id_search_image" name="id_search_image" onkeyup="search_image_social()" />';
  90. $friend_html = '<div id="friends">';
  91. $number_friends = count($friends);
  92. $j = 0;
  93. $friend_html .= '<ul class="thumbnails">';
  94. for ($k = 0; $k < $number_friends; $k++) {
  95. while ($j < $number_friends) {
  96. if (isset($friends[$j])) {
  97. $friend_html .= '<li class="span2">';
  98. $friend = $friends[$j];
  99. $user_name = api_xml_http_response_encode($friend['firstName'].' '.$friend['lastName']);
  100. $friends_profile = SocialManager::get_picture_user($friend['friend_user_id'], $friend['image'], 92);
  101. $friend_html .= '<div class="thumbnail" onMouseover="show_icon_delete(this)" onMouseout="hide_icon_delete(this)" class="image-social-content" id=div_'.$friends[$j]['friend_user_id'].'>';
  102. $friend_html .= '<img src="'.$friends_profile['file'].'" id="imgfriend_'.$friend['friend_user_id'].'" title="'.$user_name.'" /> ';
  103. $friend_html .= '<div class="caption">
  104. <a href="profile.php?u='.$friend['friend_user_id'].'"> <h5>'.$user_name.'</h5></a>';
  105. $friend_html .= '<p><button onclick="delete_friend(this)" id=img_'.$friend['friend_user_id'].' />'.get_lang(
  106. 'Delete'
  107. ).'</button></p>
  108. </div>';
  109. $friend_html .= '</li>';
  110. }
  111. $j++;
  112. }
  113. }
  114. $friend_html .= '</ul>';
  115. $friend_html .= '</div>';
  116. $social_right_content .= $friend_html;
  117. }
  118. $social_right_content .= '</div>';
  119. $tpl = new Template(get_lang('Social'));
  120. $tpl->assign('social_left_content', $social_left_content);
  121. $tpl->assign('social_right_content', $social_right_content);
  122. $social_layout = $tpl->get_template('layout/social_layout.tpl');
  123. $tpl->display($social_layout);