myfiles.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @author Juan Carlos Trabado herodoto@telefonica.net
  5. * @package chamilo.social
  6. */
  7. /**
  8. * Initialization
  9. */
  10. $language_file = array('messages', '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. require_once api_get_path(LIBRARY_PATH) . 'group_portal_manager.lib.php';
  18. $this_section = SECTION_SOCIAL;
  19. $_SESSION['this_section'] = $this_section;
  20. $interbreadcrumb[] = array(
  21. 'url' => 'profile.php',
  22. 'name' => get_lang('SocialNetwork')
  23. );
  24. $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('MyFiles'));
  25. $htmlHeadXtra[] = '
  26. <script>
  27. function denied_friend (element_input) {
  28. name_button=$(element_input).attr("id");
  29. name_div_id="id_"+name_button.substring(13);
  30. user_id=name_div_id.split("_");
  31. friend_user_id=user_id[1];
  32. $.ajax({
  33. contentType: "application/x-www-form-urlencoded",
  34. beforeSend: function(objeto) {
  35. $("#id_response").html("<img src=\'../inc/lib/javascript/indicator.gif\' />"); },
  36. type: "POST",
  37. url: "' . api_get_path(WEB_AJAX_PATH) . 'social.ajax.php?a=deny_friend",
  38. data: "denied_friend_id="+friend_user_id,
  39. success: function(datos) {
  40. $("div#"+name_div_id).hide("slow");
  41. $("#id_response").html(datos);
  42. }
  43. });
  44. }
  45. function register_friend(element_input) {
  46. if(confirm("' . get_lang('AddToFriends') . '")) {
  47. name_button=$(element_input).attr("id");
  48. name_div_id="id_"+name_button.substring(13);
  49. user_id=name_div_id.split("_");
  50. user_friend_id=user_id[1];
  51. $.ajax({
  52. contentType: "application/x-www-form-urlencoded",
  53. beforeSend: function(objeto) {
  54. $("div#dpending_"+user_friend_id).html("<img src=\'../inc/lib/javascript/indicator.gif\' />"); },
  55. type: "POST",
  56. url: "' . api_get_path(WEB_AJAX_PATH) . 'social.ajax.php?a=add_friend",
  57. data: "friend_id="+user_friend_id+"&is_my_friend="+"friend",
  58. success: function(datos) { $("div#"+name_div_id).hide("slow");
  59. $("form").submit()
  60. }
  61. });
  62. }
  63. }
  64. </script>';
  65. $show_message = null;
  66. // easy links
  67. if (is_array($_GET) && count($_GET) > 0) {
  68. foreach ($_GET as $key => $value) {
  69. switch ($key) {
  70. case 'accept':
  71. $user_role = GroupPortalManager::get_user_group_role(
  72. api_get_user_id(),
  73. $value
  74. );
  75. if (in_array(
  76. $user_role,
  77. array(
  78. GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER,
  79. GROUP_USER_PERMISSION_PENDING_INVITATION
  80. )
  81. )
  82. ) {
  83. GroupPortalManager::update_user_role(
  84. api_get_user_id(),
  85. $value,
  86. GROUP_USER_PERMISSION_READER
  87. );
  88. $show_message = get_lang('UserIsSubscribedToThisGroup');
  89. } elseif (in_array(
  90. $user_role,
  91. array(
  92. GROUP_USER_PERMISSION_READER,
  93. GROUP_USER_PERMISSION_ADMIN,
  94. GROUP_USER_PERMISSION_MODERATOR
  95. )
  96. )
  97. ) {
  98. $show_message = get_lang(
  99. 'UserIsAlreadySubscribedToThisGroup'
  100. );
  101. } else {
  102. $show_message = get_lang('UserIsNotSubscribedToThisGroup');
  103. }
  104. break 2;
  105. case 'deny':
  106. // delete invitation
  107. GroupPortalManager::delete_user_rel_group(
  108. api_get_user_id(),
  109. $value
  110. );
  111. $show_message = get_lang('GroupInvitationWasDeny');
  112. break 2;
  113. }
  114. }
  115. }
  116. $social_avatar_block = SocialManager::show_social_avatar_block('myfiles');
  117. $social_menu_block = SocialManager::show_social_menu('myfiles');
  118. $actions = null;
  119. if (isset($_GET['cidReq'])) {
  120. $actions = '<a href="' . api_get_path(
  121. WEB_CODE_PATH
  122. ) . 'document/document.php?cidReq=' . Security::remove_XSS(
  123. $_GET['cidReq']
  124. ) . '&amp;id_session=' . Security::remove_XSS(
  125. $_GET['id_session']
  126. ) . '&amp;gidReq=' . Security::remove_XSS(
  127. $_GET['gidReq']
  128. ) . '&amp;id=' . Security::remove_XSS(
  129. $_GET['parent_id']
  130. ) . '">' . Display::return_icon(
  131. 'back.png',
  132. get_lang('BackTo') . ' ' . get_lang('Documents') . ' (' . get_lang(
  133. 'Course'
  134. ) . ')'
  135. ) . '</a>';
  136. }
  137. $social_right_content = '<div class="span9">';
  138. $social_right_content .= '<iframe name="fileManager" id="fileManager" src="' . api_get_path(
  139. WEB_PATH
  140. ) . 'main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajaxfilemanager.php?editor=stand_alone" scrolling="no" noresize="noresize" frameborder="no" style="height:480px; width:100%; float:left"></iframe>';
  141. $social_right_content .= '</div>';
  142. $tpl = new Template();
  143. $tpl->assign('social_avatar_block', $social_avatar_block);
  144. $tpl->assign('social_menu_block', $social_menu_block);
  145. $tpl->assign('social_right_content', $social_right_content);
  146. $tpl->assign('actions', $actions);
  147. $tpl->assign('message', $show_message);
  148. $social_layout = $tpl->get_template('layout/social_layout.tpl');
  149. $tpl->display($social_layout);