myfiles.php 3.9 KB

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