friends.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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. //jquery thickbox already called from main/inc/header.inc.php
  19. $htmlHeadXtra[] = '<script type="text/javascript">
  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(element_html) {
  38. name_search=$(element_html).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(datos) {
  45. $("div#div_content_table").html(datos);
  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.gif");
  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. function show_icon_edit(element_html) {
  71. ident="#edit_image";
  72. $(ident).show();
  73. }
  74. function hide_icon_edit(element_html) {
  75. ident="#edit_image";
  76. $(ident).hide();
  77. }
  78. </script>';
  79. $interbreadcrumb[]= array ('url' =>'profile.php','name' => get_lang('Social'));
  80. $interbreadcrumb[]= array ('url' =>'#','name' => get_lang('Friends'));
  81. Display :: display_header($tool_name, 'Groups');
  82. echo '<div id="social-content">';
  83. echo '<div id="social-content-left">';
  84. //this include the social menu div
  85. SocialManager::show_social_menu('friends');
  86. echo '</div>';
  87. echo '<div id="social-content-right">';
  88. $language_variable = api_xml_http_response_encode(get_lang('Contacts'));
  89. $user_id = api_get_user_id();
  90. $list_path_friends = array();
  91. $user_id = api_get_user_id();
  92. $name_search= Security::remove_XSS($_POST['search_name_q']);
  93. $number_friends = 0;
  94. if (isset($name_search) && $name_search!='undefined') {
  95. $friends = SocialManager::get_friends($user_id,null,$name_search);
  96. } else {
  97. $friends = SocialManager::get_friends($user_id);
  98. }
  99. if (count($friends) == 0 ) {
  100. echo get_lang('NoFriendsInYourContactList').'<br /><br />';
  101. echo '<a href="search.php">'.get_lang('TryAndFindSomeFriends').'</a>';
  102. } else {
  103. ?>
  104. <div align="center" >
  105. <table width="100%" border="0" cellpadding="0" cellspacing="0" >
  106. <tr>
  107. <td height="25" valign="top">
  108. <table width="100%" border="0" cellpadding="0" cellspacing="0" >
  109. <tr>
  110. <td width="100%" valign="top" class="social-align-box">&nbsp;&nbsp;<?php echo get_lang('Search') .'&nbsp;&nbsp; : &nbsp;&nbsp;'; ?>
  111. <input class="social-search-image" type="text" id="id_search_image" name="id_search_image" value="" onkeyup="search_image_social(this)" />
  112. </td>
  113. </tr>
  114. </table></td>
  115. </tr>
  116. <tr>
  117. <td height="175" valign="top">
  118. <table width="100%" border="0" cellpadding="0" cellspacing="0" >
  119. <tr>
  120. <td height="153" valign="top">
  121. <?php
  122. echo '<div class="social-box-container2">';
  123. echo '<div>'.Display::return_icon('content-post-group1.jpg',get_lang('Friends')).'</div>';
  124. echo '<div id="div_content_table" class="social-box-content2">';
  125. $friend_html = '';
  126. $number_of_images = 8;
  127. $number_friends = count($friends);
  128. $j=0;
  129. echo '<div id ="social-content-right">';
  130. $friend_html.= '<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="" >';
  131. for ($k=0;$k<$number_friends;$k++) {
  132. $friend_html.='<tr><td valign="top">';
  133. while ($j<$number_friends) {
  134. if (isset($friends[$j])) {
  135. $friend = $friends[$j];
  136. $user_name = api_xml_http_response_encode($friend['firstName'].' '.$friend['lastName']);
  137. $friends_profile = SocialManager::get_picture_user($friend['friend_user_id'], $friend['image'], 92);
  138. $friend_html.='<div onMouseover="show_icon_delete(this)" onMouseout="hide_icon_delete(this)" class="image-social-content" id=div_'.$friends[$j]['friend_user_id'].'>';
  139. $friend_html.='<span><a href="profile.php?u='.$friend['friend_user_id'].'"><center><img src="'.$friends_profile['file'].'" style="height:60px;border:3pt solid #eee" id="imgfriend_'.$friend['friend_user_id'].'" title="'.$user_name.'" /></center></a></span>';
  140. $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>';
  141. }
  142. $j++;
  143. }
  144. $friend_html.='</td></tr>';
  145. }
  146. $friend_html.='<br/></table>';
  147. echo '</div>';
  148. echo $friend_html;
  149. echo '</div>';
  150. echo '</div>';
  151. ?>
  152. </td>
  153. </tr>
  154. </table></td>
  155. </tr>
  156. </table>
  157. </div>
  158. <?php
  159. }
  160. echo '</div>';
  161. echo '</div>';
  162. Display :: display_footer();
  163. ?>