friends.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <?php
  2. /* For licensing terms, see /chamilo_license.txt */
  3. /**
  4. * @package dokeos.social
  5. * @author Julio Montoya <gugli100@gmail.com>
  6. */
  7. $language_file = array('userInfo');
  8. $cidReset=true;
  9. require '../inc/global.inc.php';
  10. require_once api_get_path(CONFIGURATION_PATH).'profile.conf.php';
  11. require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
  12. require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
  13. require_once api_get_path(LIBRARY_PATH).'image.lib.php';
  14. require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
  15. require_once api_get_path(LIBRARY_PATH).'social.lib.php';
  16. api_block_anonymous_users();
  17. $this_section = SECTION_SOCIAL;
  18. $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
  19. $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/thickbox.js" type="text/javascript" language="javascript"></script>';
  20. $htmlHeadXtra[] = '<script type="text/javascript">
  21. function delete_friend (element_div) {
  22. id_image=$(element_div).attr("id");
  23. user_id=id_image.split("_");
  24. if (confirm("'.get_lang('Delete', '').'")) {
  25. $.ajax({
  26. contentType: "application/x-www-form-urlencoded",
  27. type: "POST",
  28. url: "'.api_get_path(WEB_AJAX_PATH).'social.ajax.php?a=delete_friend",
  29. data: "delete_friend_id="+user_id[1],
  30. success: function(datos) {
  31. $("div#"+"div_"+user_id[1]).hide("slow");
  32. $("div#"+"div_"+user_id[1]).html("");
  33. clear_form ();
  34. }
  35. });
  36. }
  37. }
  38. function search_image_social(element_html) {
  39. name_search=$(element_html).attr("value");
  40. $.ajax({
  41. contentType: "application/x-www-form-urlencoded",
  42. type: "POST",
  43. url: "'.api_get_path(WEB_AJAX_PATH).'social.ajax.php?a=show_my_friends",
  44. data: "search_name_q="+name_search,
  45. success: function(datos) {
  46. $("div#div_content_table").html(datos);
  47. }
  48. });
  49. }
  50. function show_icon_delete(element_html) {
  51. elem_id=$(element_html).attr("id");
  52. id_elem=elem_id.split("_");
  53. ident="#img_"+id_elem[1];
  54. $(ident).attr("src","../img/delete.gif");
  55. $(ident).attr("alt","'.get_lang('Delete', '').'");
  56. $(ident).attr("title","'.get_lang('Delete', '').'");
  57. }
  58. function hide_icon_delete(element_html) {
  59. elem_id=$(element_html).attr("id");
  60. id_elem=elem_id.split("_");
  61. ident="#img_"+id_elem[1];
  62. $(ident).attr("src","../img/blank.gif");
  63. $(ident).attr("alt","");
  64. $(ident).attr("title","");
  65. }
  66. function clear_form () {
  67. $("input[@type=radio]").attr("checked", false);
  68. $("div#div_qualify_image").html("");
  69. $("div#div_info_user").html("");
  70. }
  71. </script>';
  72. $interbreadcrumb[]= array ('url' =>'profile.php','name' => get_lang('Social'));
  73. $interbreadcrumb[]= array ('url' =>'#','name' => get_lang('Friends'));
  74. Display :: display_header($tool_name, 'Groups');
  75. echo '<div id="social-content">';
  76. echo '<div id="social-content-left">';
  77. //this include the social menu div
  78. SocialManager::show_social_menu('friends');
  79. echo '</div>';
  80. echo '<div id="social-content-right">';
  81. $language_variable = api_xml_http_response_encode(get_lang('Contacts'));
  82. $user_id = api_get_user_id();
  83. ?>
  84. <div align="center" >
  85. <table width="100%" border="0" cellpadding="0" cellspacing="0" >
  86. <tr>
  87. <td height="25" valign="top">
  88. <table width="100%" border="0" cellpadding="0" cellspacing="0" >
  89. <tr>
  90. <td width="100%" valign="top" class="social-align-box">&nbsp;&nbsp;<?php echo get_lang('Search') .'&nbsp;&nbsp; : &nbsp;&nbsp;'; ?>
  91. <input class="social-search-image" type="text" id="id_search_image" name="id_search_image" value="" onkeyup="search_image_social(this)" />
  92. </td>
  93. </tr>
  94. </table></td>
  95. </tr>
  96. <tr>
  97. <td height="175" valign="top">
  98. <table width="100%" border="0" cellpadding="0" cellspacing="0" >
  99. <tr>
  100. <td height="153" valign="top">
  101. <?php
  102. echo '<div class="social-box-container2">';
  103. echo '<div>'.Display::return_icon('content-post-group1.jpg').'</div>';
  104. echo '<div id="div_content_table" class="social-box-content2">';
  105. $list_path_friends = array();
  106. $user_id = api_get_user_id();
  107. $name_search= Security::remove_XSS($_POST['search_name_q']);
  108. $number_friends = 0;
  109. if (isset($name_search) && $name_search!='undefined') {
  110. $friends = SocialManager::get_friends($user_id,null,$name_search);
  111. } else {
  112. $friends = SocialManager::get_friends($user_id);
  113. }
  114. $friend_html = '';
  115. $number_of_images = 8;
  116. $number_friends = count($friends);
  117. if ($number_friends != 0) {
  118. $number_loop = ($number_friends/$number_of_images);
  119. $loop_friends = ceil($number_loop);
  120. $j=0;
  121. $friend_html.= '<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="" >';
  122. for ($k=0;$k<$loop_friends;$k++) {
  123. $friend_html.='<tr><td valign="top">';
  124. if ($j==$number_of_images) {
  125. $number_of_images=$number_of_images*2;
  126. }
  127. while ($j<$number_of_images) {
  128. if (isset($friends[$j])) {
  129. $friend = $friends[$j];
  130. $user_name = api_xml_http_response_encode($friend['firstName'].' '.$friend['lastName']);
  131. $friends_profile = SocialManager::get_picture_user($friend['friend_user_id'], $friend['image'], 92);
  132. $friend_html.='<div onMouseover="show_icon_delete(this)" onMouseout="hide_icon_delete(this)" class="image-social-content" id=div_'.$friends[$j]['friend_user_id'].'>';
  133. $friend_html.='<span><a href="profile.php?u='.$friend['friend_user_id'].'"><center><img src="'.$friends_profile['file'].'" style="width:60px;height:60px;border:3pt solid #eee" id="imgfriend_'.$friend['friend_user_id'].'" title="'.$user_name.'" /></center></a></span>';
  134. $friend_html.='<img onclick="delete_friend (this)" id=img_'.$friend['friend_user_id'].' src="../img/blank.gif" alt="" title="" class="image-delete" /> <center class="friend">'.$user_name.'</center></div>';
  135. }
  136. $j++;
  137. }
  138. $friend_html.='</td></tr>';
  139. }
  140. $friend_html.='<br/></table>';
  141. }
  142. echo $friend_html;
  143. echo '</div>';
  144. echo '</div>';
  145. ?>
  146. </td>
  147. </tr>
  148. </table></td>
  149. </tr>
  150. </table>
  151. </div>
  152. <?php
  153. echo '</div>';
  154. echo '</div>';
  155. Display :: display_footer();
  156. ?>