create_paint.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This file allows creating audio files from a text.
  5. *
  6. * @package chamilo.document
  7. *
  8. * @author Juan Carlos Raña Trabado
  9. * @since 30/January/2011
  10. * TODO:clean all file
  11. */
  12. /* INIT SECTION */
  13. $language_file = array('document');
  14. require_once '../inc/global.inc.php';
  15. $_SESSION['whereami'] = 'document/createpaint';
  16. $this_section = SECTION_COURSES;
  17. require_once 'document.inc.php';
  18. require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
  19. $nameTools = get_lang('PhotoRetouching');
  20. api_protect_course_script();
  21. api_block_anonymous_users();
  22. if (api_get_setting('enabled_support_paint') == 'false') {
  23. api_not_allowed(true);
  24. }
  25. $document_data = DocumentManager::get_document_data_by_id($_GET['id'], api_get_course_id());
  26. if (empty($document_data)) {
  27. if (api_is_in_group()) {
  28. $group_properties = GroupManager::get_group_properties(api_get_group_id());
  29. $document_id = DocumentManager::get_document_id(api_get_course_info(), $group_properties['directory']);
  30. $document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id());
  31. }
  32. }
  33. $document_id = $document_data['id'];
  34. $dir = $document_data['path'];
  35. //$dir = isset($_GET['dir']) ? Security::remove_XSS($_GET['dir']) : Security::remove_XSS($_POST['dir']);
  36. $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
  37. //path for pixlr save
  38. $_SESSION['paint_dir']=Security::remove_XSS($dir);
  39. if ($_SESSION['paint_dir']=='/'){
  40. $_SESSION['paint_dir']='';
  41. }
  42. $_SESSION['paint_file']=get_lang('NewImage');
  43. // Please, do not modify this dirname formatting
  44. if (strstr($dir, '..')) {
  45. $dir = '/';
  46. }
  47. if ($dir[0] == '.') {
  48. $dir = substr($dir, 1);
  49. }
  50. if ($dir[0] != '/') {
  51. $dir = '/'.$dir;
  52. }
  53. if ($dir[strlen($dir) - 1] != '/') {
  54. $dir .= '/';
  55. }
  56. $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir;
  57. if (!is_dir($filepath)) {
  58. $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
  59. $dir = '/';
  60. }
  61. //groups //TODO: clean
  62. if (isset ($_SESSION['_gid']) && $_SESSION['_gid'] != 0) {
  63. $req_gid = '&amp;gidReq='.$_SESSION['_gid'];
  64. $interbreadcrumb[] = array ("url" => "../group/group_space.php?gidReq=".$_SESSION['_gid'], "name" => get_lang('GroupSpace'));
  65. $noPHP_SELF = true;
  66. $to_group_id = $_SESSION['_gid'];
  67. $group = GroupManager :: get_group_properties($to_group_id);
  68. $path = explode('/', $dir);
  69. if ('/'.$path[1] != $group['directory']) {
  70. api_not_allowed(true);
  71. }
  72. }
  73. $interbreadcrumb[] = array ("url" => "./document.php?curdirpath=".urlencode($dir).$req_gid, "name" => get_lang('Documents'));
  74. if (!$is_allowed_in_course) {
  75. api_not_allowed(true);
  76. }
  77. if (!($is_allowed_to_edit || $_SESSION['group_member_with_upload_rights'] || is_my_shared_folder($_user['user_id'], Security::remove_XSS($dir),api_get_session_id()))) {
  78. api_not_allowed(true);
  79. }
  80. /* Header */
  81. event_access_tool(TOOL_DOCUMENT);
  82. $display_dir = $dir;
  83. if (isset ($group)) {
  84. $display_dir = explode('/', $dir);
  85. unset ($display_dir[0]);
  86. unset ($display_dir[1]);
  87. $display_dir = implode('/', $display_dir);
  88. }
  89. // Interbreadcrumb for the current directory root path
  90. // Copied from document.php
  91. $dir_array = explode('/', $dir);
  92. $array_len = count($dir_array);
  93. $dir_acum = '';
  94. for ($i = 0; $i < $array_len; $i++) {
  95. $url_dir = 'document.php?&curdirpath='.$dir_acum.$dir_array[$i];
  96. //Max char 80
  97. $url_to_who = cut($dir_array[$i],80);
  98. if ($is_certificate_mode) {
  99. $interbreadcrumb[] = array('url' => $url_dir.'&selectcat='.Security::remove_XSS($_GET['selectcat']), 'name' => $url_to_who);
  100. } else {
  101. $interbreadcrumb[] = array('url' => $url_dir, 'name' => $url_to_who);
  102. }
  103. $dir_acum .= $dir_array[$i].'/';
  104. }
  105. //
  106. Display :: display_header($nameTools, 'Doc');
  107. echo '<div class="actions">';
  108. echo '<a href="document.php?id='.$document_id.'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('DocumentsOverview'),'','32').'</a>';
  109. echo '</div>';
  110. ///pixlr
  111. // max size 1 Mb
  112. $title=urlencode(utf8_encode(get_lang('NewImage')));//TODO:check
  113. //
  114. $image=api_get_path(WEB_IMG_PATH).'canvas1024x768.png';
  115. //
  116. $pixlr_code_translation_table = array('' => 'en', 'pt' => 'pt-Pt', 'sr' => 'sr_latn');
  117. $langpixlr = api_get_language_isocode();
  118. $langpixlr = isset($pixlr_code_translation_table[$langpixlr]) ? $pixlredit_code_translation_table[$langpixlr] : $langpixlr;
  119. $loc=$langpixlr;// deprecated ?? TODO:check pixlr read user browser
  120. $exit_path=api_get_path(WEB_CODE_PATH).'document/exit_pixlr.php';
  121. $_SESSION['exit_pixlr']= Security::remove_XSS($dir);
  122. $referrer="Chamilo";
  123. $target_path=api_get_path(WEB_CODE_PATH).'document/save_pixlr.php';
  124. $target=$target_path;
  125. $locktarget="true";
  126. $locktitle="false";
  127. echo '<iframe style=\'height: 600px; width: 100%;\' scrolling=\'no\' frameborder=\'0\' src=\'http://pixlr.com/editor/?title='.$title.'&amp;image='.$image.'&amp;loc='.$loc.'&amp;referrer='.$referrer.'&amp;target='.$target.'&amp;exit='.$exit_path.'&amp;locktarget='.$locktarget.'&amp;locktitle='.$locktitle.'\'>';
  128. echo '</iframe>';