create_paint.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. /**
  13. * Code
  14. */
  15. /* INIT SECTION */
  16. $language_file = array('document');
  17. require_once '../inc/global.inc.php';
  18. $_SESSION['whereami'] = 'document/createpaint';
  19. $this_section = SECTION_COURSES;
  20. require_once 'document.inc.php';
  21. require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
  22. $nameTools = get_lang('PhotoRetouching');
  23. api_protect_course_script();
  24. api_block_anonymous_users();
  25. if (api_get_setting('enabled_support_paint') == 'false') {
  26. api_not_allowed(true);
  27. }
  28. $document_data = DocumentManager::get_document_data_by_id($_GET['id'], api_get_course_id(), true);
  29. if (empty($document_data)) {
  30. if (api_is_in_group()) {
  31. $group_properties = GroupManager::get_group_properties(api_get_group_id());
  32. $document_id = DocumentManager::get_document_id(api_get_course_info(), $group_properties['directory']);
  33. $document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id());
  34. }
  35. }
  36. $document_id = $document_data['id'];
  37. $dir = $document_data['path'];
  38. //$dir = isset($_GET['dir']) ? Security::remove_XSS($_GET['dir']) : Security::remove_XSS($_POST['dir']);
  39. $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
  40. //path for pixlr save
  41. $_SESSION['paint_dir']=Security::remove_XSS($dir);
  42. if ($_SESSION['paint_dir']=='/'){
  43. $_SESSION['paint_dir']='';
  44. }
  45. $_SESSION['paint_file']=get_lang('NewImage');
  46. // Please, do not modify this dirname formatting
  47. if (strstr($dir, '..')) {
  48. $dir = '/';
  49. }
  50. if ($dir[0] == '.') {
  51. $dir = substr($dir, 1);
  52. }
  53. if ($dir[0] != '/') {
  54. $dir = '/'.$dir;
  55. }
  56. if ($dir[strlen($dir) - 1] != '/') {
  57. $dir .= '/';
  58. }
  59. $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir;
  60. if (!is_dir($filepath)) {
  61. $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
  62. $dir = '/';
  63. }
  64. //groups //TODO: clean
  65. if (isset ($_SESSION['_gid']) && $_SESSION['_gid'] != 0) {
  66. $req_gid = '&amp;gidReq='.$_SESSION['_gid'];
  67. $interbreadcrumb[] = array ("url" => "../group/group_space.php?gidReq=".$_SESSION['_gid'], "name" => get_lang('GroupSpace'));
  68. $noPHP_SELF = true;
  69. $to_group_id = $_SESSION['_gid'];
  70. $group = GroupManager :: get_group_properties($to_group_id);
  71. $path = explode('/', $dir);
  72. if ('/'.$path[1] != $group['directory']) {
  73. api_not_allowed(true);
  74. }
  75. }
  76. $interbreadcrumb[] = array ("url" => "./document.php?curdirpath=".urlencode($dir).$req_gid, "name" => get_lang('Documents'));
  77. if (!$is_allowed_in_course) {
  78. api_not_allowed(true);
  79. }
  80. 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()))) {
  81. api_not_allowed(true);
  82. }
  83. /* Header */
  84. event_access_tool(TOOL_DOCUMENT);
  85. $display_dir = $dir;
  86. if (isset ($group)) {
  87. $display_dir = explode('/', $dir);
  88. unset ($display_dir[0]);
  89. unset ($display_dir[1]);
  90. $display_dir = implode('/', $display_dir);
  91. }
  92. // Interbreadcrumb for the current directory root path
  93. if (empty($document_data['parents'])) {
  94. $interbreadcrumb[] = array('url' => '#', 'name' => $document_data['title']);
  95. } else {
  96. foreach($document_data['parents'] as $document_sub_data) {
  97. $interbreadcrumb[] = array('url' => $document_sub_data['document_url'], 'name' => $document_sub_data['title']);
  98. }
  99. }
  100. Display :: display_header($nameTools, 'Doc');
  101. echo '<div class="actions">';
  102. echo '<a href="document.php?id='.$document_id.'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>';
  103. echo '</div>';
  104. ///pixlr
  105. // max size 1 Mb ??
  106. $title=urlencode(utf8_encode(get_lang('NewImage')));//TODO:check
  107. //
  108. $image=api_get_path(WEB_IMG_PATH).'canvas1024x768.png';
  109. //
  110. $pixlr_code_translation_table = array('' => 'en', 'pt' => 'pt-Pt', 'sr' => 'sr_latn');
  111. $langpixlr = api_get_language_isocode();
  112. $langpixlr = isset($pixlr_code_translation_table[$langpixlr]) ? $pixlredit_code_translation_table[$langpixlr] : $langpixlr;
  113. $loc=$langpixlr;// deprecated ?? TODO:check pixlr read user browser
  114. $exit_path=api_get_path(WEB_CODE_PATH).'document/exit_pixlr.php';
  115. $_SESSION['exit_pixlr']=$document_data['path'];
  116. $referrer="Chamilo";
  117. $target_path=api_get_path(WEB_CODE_PATH).'document/save_pixlr.php';
  118. $target=$target_path;
  119. $locktarget="true";
  120. $locktitle="false";
  121. 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.'\'>';
  122. echo '</iframe>';