myfiles.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use ChamiloSession as Session;
  4. /**
  5. * @author Juan Carlos Trabado herodoto@telefonica.net
  6. * @package chamilo.social
  7. */
  8. $cidReset = true;
  9. require_once __DIR__.'/../inc/global.inc.php';
  10. api_block_anonymous_users();
  11. if (api_get_setting('allow_my_files') === 'false') {
  12. api_not_allowed(true);
  13. }
  14. $htmlHeadXtra[] = '
  15. <script>
  16. function denied_friend (element_input) {
  17. name_button=$(element_input).attr("id");
  18. name_div_id="id_"+name_button.substring(13);
  19. user_id=name_div_id.split("_");
  20. friend_user_id=user_id[1];
  21. $.ajax({
  22. contentType: "application/x-www-form-urlencoded",
  23. beforeSend: function(objeto) {
  24. $("#id_response").html("<img src=\''.Display::return_icon('indicator.gif', '', [], ICON_SIZE_SMALL, true, true).'\' />"); },
  25. type: "POST",
  26. url: "' . api_get_path(WEB_AJAX_PATH).'social.ajax.php?a=deny_friend",
  27. data: "denied_friend_id="+friend_user_id,
  28. success: function(datos) {
  29. $("div#"+name_div_id).hide("slow");
  30. $("#id_response").html(datos);
  31. }
  32. });
  33. }
  34. function register_friend(element_input) {
  35. if(confirm("' . get_lang('AddToFriends').'")) {
  36. name_button=$(element_input).attr("id");
  37. name_div_id="id_"+name_button.substring(13);
  38. user_id=name_div_id.split("_");
  39. user_friend_id=user_id[1];
  40. $.ajax({
  41. contentType: "application/x-www-form-urlencoded",
  42. beforeSend: function(objeto) {
  43. $("div#dpending_"+user_friend_id).html("<img src=\''.Display::return_icon('indicator.gif', '', [], ICON_SIZE_SMALL, true, true).'\' />"); },
  44. type: "POST",
  45. url: "' . api_get_path(WEB_AJAX_PATH).'social.ajax.php?a=add_friend",
  46. data: "friend_id="+user_friend_id+"&is_my_friend="+"friend",
  47. success: function(datos) { $("div#"+name_div_id).hide("slow");
  48. $("form").submit()
  49. }
  50. });
  51. }
  52. }
  53. $(document).on("ready", function () {
  54. $("#el-finder").elfinder({
  55. url: "' . api_get_path(WEB_LIBRARY_PATH).'elfinder/php/connector.php",
  56. lang: "' . api_get_language_isocode().'",
  57. height: 600,
  58. resizable: false,
  59. rememberLastDir: false,
  60. }).elfinder("instance");
  61. });
  62. </script>';
  63. // Social Menu Block
  64. $social_menu_block = SocialManager::show_social_menu('myfiles');
  65. $actions = null;
  66. if (isset($_GET['cidReq'])) {
  67. $actions = Display::url(
  68. Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('Documents').' ('.get_lang('Course').')'),
  69. api_get_self().'?'.api_get_cidreq().'&id='.$_GET['parent_id']
  70. );
  71. }
  72. if (api_get_setting('allow_social_tool') == 'true') {
  73. Session::write('this_section', SECTION_SOCIAL);
  74. $interbreadcrumb[] = array(
  75. 'url' => 'profile.php',
  76. 'name' => get_lang('SocialNetwork')
  77. );
  78. } else {
  79. Session::write('this_section', SECTION_COURSES);
  80. $interbreadcrumb[] = array(
  81. 'url' => api_get_path(WEB_PATH).'user_portal.php',
  82. 'name' => get_lang('MyCourses')
  83. );
  84. }
  85. $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('MyFiles'));
  86. $tpl = new Template();
  87. SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'myfiles');
  88. $tpl->assign('show_media_element', 0);
  89. $tpl->assign('course_id', '');
  90. $tpl->assign('session_id', '');
  91. $tpl->assign('social_right_content', '');
  92. if (api_get_setting('allow_social_tool') == 'true') {
  93. $tpl->assign('social_menu_block', $social_menu_block);
  94. $social_layout = $tpl->get_template('social/myfiles.tpl');
  95. $tpl->display($social_layout);
  96. } else {
  97. $controller = new IndexManager(get_lang('MyCourses'));
  98. $tpl->assign(
  99. 'actions',
  100. Display::toolbarAction('toolbar', [$actions])
  101. );
  102. $tpl->assign('profile_block', $controller->return_profile_block());
  103. $tpl->assign('user_image_block', $controller->return_user_image_block());
  104. $tpl->assign('course_block', $controller->return_course_block());
  105. $tpl->display_two_col_template();
  106. }