friends.php 5.1 KB

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