@@ -5,7 +5,7 @@ |
||
5 | 5 | * @since 25/september/2010 |
6 | 6 | */ |
7 | 7 | |
8 | -require_once '../../../inc/global.inc.php';//hack for Chamilo |
|
8 | +require_once '../../../inc/global.inc.php'; //hack for Chamilo |
|
9 | 9 | api_protect_course_script(); |
10 | 10 | api_block_anonymous_users(); |
11 | 11 | if (!isset($_SESSION['draw_dir'])) { |
@@ -19,21 +19,21 @@ discard block |
||
19 | 19 | api_protect_course_script(); |
20 | 20 | api_block_anonymous_users(); |
21 | 21 | |
22 | -if(!isset($_POST['output_svg']) && !isset($_POST['output_png'])) { |
|
23 | - api_not_allowed();//from Chamilo |
|
22 | +if (!isset($_POST['output_svg']) && !isset($_POST['output_png'])) { |
|
23 | + api_not_allowed(); //from Chamilo |
|
24 | 24 | die(); |
25 | 25 | } |
26 | 26 | |
27 | 27 | $file = ''; |
28 | -$suffix = isset($_POST['output_svg'])?'svg':'png'; |
|
28 | +$suffix = isset($_POST['output_svg']) ? 'svg' : 'png'; |
|
29 | 29 | |
30 | -if(isset($_POST['filename']) && strlen($_POST['filename']) > 0) { |
|
30 | +if (isset($_POST['filename']) && strlen($_POST['filename']) > 0) { |
|
31 | 31 | $file = $_POST['filename']; |
32 | 32 | } else { |
33 | 33 | $file = 'image'; |
34 | 34 | } |
35 | 35 | |
36 | -if($suffix == 'svg') { |
|
36 | +if ($suffix == 'svg') { |
|
37 | 37 | $mime = 'image/svg+xml'; |
38 | 38 | $contents = rawurldecode($_POST['output_svg']); |
39 | 39 | } else { |
@@ -44,25 +44,25 @@ discard block |
||
44 | 44 | } |
45 | 45 | |
46 | 46 | //get SVG-Edit values |
47 | -$filename=$file;//from svg-edit |
|
48 | -$extension=$suffix;// from svg-edit |
|
49 | -$content=$contents;//from svg-edit |
|
47 | +$filename = $file; //from svg-edit |
|
48 | +$extension = $suffix; // from svg-edit |
|
49 | +$content = $contents; //from svg-edit |
|
50 | 50 | |
51 | -$title = Database::escape_string(str_replace('_',' ',$filename)); |
|
51 | +$title = Database::escape_string(str_replace('_', ' ', $filename)); |
|
52 | 52 | |
53 | 53 | //get Chamilo variables |
54 | 54 | |
55 | -if(!isset($_SESSION['draw_dir']) && !isset($_SESSION['whereami'])) { |
|
56 | - api_not_allowed();//from Chamilo |
|
55 | +if (!isset($_SESSION['draw_dir']) && !isset($_SESSION['whereami'])) { |
|
56 | + api_not_allowed(); //from Chamilo |
|
57 | 57 | die(); |
58 | 58 | } |
59 | 59 | |
60 | 60 | $current_session_id = api_get_session_id(); |
61 | -$groupId = api_get_group_id(); |
|
62 | -$relativeUrlPath=$_SESSION['draw_dir']; |
|
63 | -$currentTool=$_SESSION['whereami']; |
|
61 | +$groupId = api_get_group_id(); |
|
62 | +$relativeUrlPath = $_SESSION['draw_dir']; |
|
63 | +$currentTool = $_SESSION['whereami']; |
|
64 | 64 | $dirBaseDocuments = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; |
65 | -$saveDir=$dirBaseDocuments.$_SESSION['draw_dir']; |
|
65 | +$saveDir = $dirBaseDocuments.$_SESSION['draw_dir']; |
|
66 | 66 | |
67 | 67 | //a bit title security |
68 | 68 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | |
97 | 97 | //checks if the file exists, then rename the new |
98 | -if (file_exists($saveDir.'/'.$filename.$i.'.'.$extension) && $currentTool=='document/createdraw') { |
|
98 | +if (file_exists($saveDir.'/'.$filename.$i.'.'.$extension) && $currentTool == 'document/createdraw') { |
|
99 | 99 | $message = get_lang('FileExistsChangeToSave'); |
100 | 100 | $params = array( |
101 | 101 | 'message' => $message, |
@@ -111,21 +111,21 @@ discard block |
||
111 | 111 | $documentPath = $saveDir.'/'.$drawFileName; |
112 | 112 | |
113 | 113 | //add new document to disk |
114 | -file_put_contents( $documentPath, $contents ); |
|
114 | +file_put_contents($documentPath, $contents); |
|
115 | 115 | |
116 | -if ($currentTool=='document/createdraw') { |
|
116 | +if ($currentTool == 'document/createdraw') { |
|
117 | 117 | //add document to database |
118 | 118 | $doc_id = add_document($_course, $relativeUrlPath.'/'.$drawFileName, 'file', filesize($documentPath), $title); |
119 | 119 | api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'], $groupId, null, null, null, $current_session_id); |
120 | 120 | |
121 | -} elseif($currentTool=='document/editdraw') { |
|
121 | +} elseif ($currentTool == 'document/editdraw') { |
|
122 | 122 | |
123 | 123 | //check path |
124 | - if (!isset($_SESSION['draw_file'])){ |
|
125 | - api_not_allowed();//from Chamilo |
|
124 | + if (!isset($_SESSION['draw_file'])) { |
|
125 | + api_not_allowed(); //from Chamilo |
|
126 | 126 | die(); |
127 | 127 | } |
128 | - if ($_SESSION['draw_file'] == $drawFileName ){ |
|
128 | + if ($_SESSION['draw_file'] == $drawFileName) { |
|
129 | 129 | $document_id = DocumentManager::get_document_id($_course, $relativeUrlPath.'/'.$drawFileName); |
130 | 130 | update_existing_document($_course, $document_id, filesize($documentPath), null); |
131 | 131 | api_item_property_update($_course, TOOL_DOCUMENT, $document_id, 'DocumentUpdated', $_user['user_id'], $groupId, null, null, null, $current_session_id); |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | if (!in_array($info['mime'], $allowedMimeTypesBySuffix)) { |
32 | 32 | exit; |
33 | 33 | } |
34 | - $prefix = 'data:' . $info['mime'] . ';base64,'; |
|
34 | + $prefix = 'data:'.$info['mime'].';base64,'; |
|
35 | 35 | } |
36 | 36 | ?> |
37 | 37 | <html xmlns="http://www.w3.org/1999/xhtml"> |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | top.svgEditor.processFile("<?php |
43 | 43 | |
44 | 44 | // This should be safe since SVG edit does its own filtering (e.g., if an SVG file contains scripts) |
45 | -echo $prefix . base64_encode($output); |
|
45 | +echo $prefix.base64_encode($output); |
|
46 | 46 | |
47 | 47 | ?>", "<?php echo $type; ?>"); |
48 | 48 | </script> |
@@ -9,12 +9,12 @@ discard block |
||
9 | 9 | * |
10 | 10 | */ |
11 | 11 | exit; |
12 | -function encodeRFC5987ValueChars ($str) { |
|
12 | +function encodeRFC5987ValueChars($str) { |
|
13 | 13 | // See http://tools.ietf.org/html/rfc5987#section-3.2.1 |
14 | 14 | // For better readability within headers, add back the characters escaped by rawurlencode but still allowable |
15 | 15 | // Although RFC3986 reserves "!" (%21), RFC5987 does not |
16 | - return preg_replace_callback('@%(2[1346B]|5E|60|7C)@', function ($matches) { |
|
17 | - return chr('0x' . $matches[1]); |
|
16 | + return preg_replace_callback('@%(2[1346B]|5E|60|7C)@', function($matches) { |
|
17 | + return chr('0x'.$matches[1]); |
|
18 | 18 | }, rawurlencode($str)); |
19 | 19 | } |
20 | 20 | |
@@ -28,12 +28,12 @@ discard block |
||
28 | 28 | |
29 | 29 | $file = ''; |
30 | 30 | |
31 | -$suffix = '.' . array_search($mime, $allowedMimeTypesBySuffix); |
|
31 | +$suffix = '.'.array_search($mime, $allowedMimeTypesBySuffix); |
|
32 | 32 | |
33 | 33 | if (isset($_POST['filename']) && strlen($_POST['filename']) > 0) { |
34 | - $file = $_POST['filename'] . $suffix; |
|
34 | + $file = $_POST['filename'].$suffix; |
|
35 | 35 | } else { |
36 | - $file = 'image' . $suffix; |
|
36 | + $file = 'image'.$suffix; |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | if ($suffix == '.svg') { |
@@ -48,11 +48,11 @@ discard block |
||
48 | 48 | header("Content-Description: File Transfer"); |
49 | 49 | |
50 | 50 | // See http://tools.ietf.org/html/rfc6266#section-4.1 |
51 | -header("Content-Disposition: attachment; filename*=UTF-8''" . encodeRFC5987ValueChars( |
|
51 | +header("Content-Disposition: attachment; filename*=UTF-8''".encodeRFC5987ValueChars( |
|
52 | 52 | // preg_replace('@[\\\\/:*?"<>|]@', '', $file) // If we wanted to strip Windows-disallowed characters server-side (but not a security issue, so we can strip client-side instead) |
53 | 53 | $file |
54 | 54 | )); |
55 | -header("Content-Type: " . $mime); |
|
55 | +header("Content-Type: ".$mime); |
|
56 | 56 | header("Content-Transfer-Encoding: binary"); |
57 | 57 | |
58 | 58 | echo $contents; |
@@ -8,7 +8,7 @@ |
||
8 | 8 | exit; |
9 | 9 | } |
10 | 10 | $svg = $_POST['output_svg']; |
11 | - $filename = (isset($_POST['filename']) && !empty($_POST['filename']) ? preg_replace('@[\\\\/:*?"<>|]@u', '_', $_POST['filename']) : 'saved') . '.svg'; // These characters are indicated as prohibited by Windows |
|
11 | + $filename = (isset($_POST['filename']) && !empty($_POST['filename']) ? preg_replace('@[\\\\/:*?"<>|]@u', '_', $_POST['filename']) : 'saved').'.svg'; // These characters are indicated as prohibited by Windows |
|
12 | 12 | |
13 | 13 | $fh = fopen($filename, 'w') or die("Can't open file"); |
14 | 14 | fwrite($fh, $svg); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | $is_allowed_to_edit = api_is_allowed_to_edit(null, true); |
14 | 14 | |
15 | -$curdirpath='/images/gallery'; //path of library directory |
|
15 | +$curdirpath = '/images/gallery'; //path of library directory |
|
16 | 16 | |
17 | 17 | $course_info = api_get_course_info(); |
18 | 18 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $slideshow_extension = strrchr($file, '.'); |
37 | 37 | $slideshow_extension = strtolower($slideshow_extension); |
38 | 38 | if (in_array($slideshow_extension, $accepted_extensions)) { |
39 | - $png_svg_files[] =$file; |
|
39 | + $png_svg_files[] = $file; |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $style = '<style>'; |
48 | 48 | $style .= '@import "'.api_get_path(WEB_CSS_PATH).'base.css";'; |
49 | 49 | $style .= '@import "'.api_get_path(WEB_CSS_PATH).'themes/'.api_get_visual_theme().'/default.css";'; |
50 | -$style .='</style>'; |
|
50 | +$style .= '</style>'; |
|
51 | 51 | |
52 | 52 | ?> |
53 | 53 | <!doctype html> |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | if (!empty($png_svg_files)) { |
60 | 60 | echo '<h3>'.get_lang('SelectSVGEditImage').'</h3>'; |
61 | 61 | echo '<ul>'; |
62 | - foreach($png_svg_files as $filename) { |
|
63 | - $image=$disk_path.$filename; |
|
62 | + foreach ($png_svg_files as $filename) { |
|
63 | + $image = $disk_path.$filename; |
|
64 | 64 | |
65 | - if (strpos($filename, "svg")){ |
|
65 | + if (strpos($filename, "svg")) { |
|
66 | 66 | $new_sizes['width'] = 60; |
67 | 67 | $new_sizes['height'] = 60; |
68 | 68 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $slideshow_extension = strrchr($file, '.'); |
48 | 48 | $slideshow_extension = strtolower($slideshow_extension); |
49 | 49 | if (in_array($slideshow_extension, $accepted_extensions)) { |
50 | - $png_svg_files[] =$file; |
|
50 | + $png_svg_files[] = $file; |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | $style = '<style>'; |
56 | 56 | $style .= '@import "'.api_get_path(WEB_CSS_PATH).'base.css";'; |
57 | 57 | $style .= '@import "'.api_get_path(WEB_CSS_PATH).'themes/'.api_get_visual_theme().'/default.css";'; |
58 | -$style .='</style>'; |
|
58 | +$style .= '</style>'; |
|
59 | 59 | |
60 | 60 | ?> |
61 | 61 | <!doctype html> |
@@ -68,15 +68,15 @@ discard block |
||
68 | 68 | if (( |
69 | 69 | $group_properties['doc_state'] == 2 && |
70 | 70 | ($is_allowed_to_edit || GroupManager :: is_user_in_group($_user['user_id'], $groupId))) || $group_properties['doc_state'] == 1 |
71 | -){ |
|
71 | +) { |
|
72 | 72 | |
73 | 73 | if (!empty($png_svg_files)) { |
74 | 74 | echo '<h3>'.get_lang('SelectSVGEditImage').'</h3>'; |
75 | 75 | echo '<ul>'; |
76 | - foreach($png_svg_files as $filename) { |
|
76 | + foreach ($png_svg_files as $filename) { |
|
77 | 77 | $image = $group_disk_path.$filename; |
78 | 78 | |
79 | - if (strpos($filename, "svg")){ |
|
79 | + if (strpos($filename, "svg")) { |
|
80 | 80 | $new_sizes['width'] = 60; |
81 | 81 | $new_sizes['height'] = 60; |
82 | 82 | } else { |
@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | $slideshow_extension = strrchr($file, '.'); |
26 | 26 | $slideshow_extension = strtolower($slideshow_extension); |
27 | 27 | if (in_array($slideshow_extension, $accepted_extensions)) { |
28 | - $png_svg_files[] =$file; |
|
28 | + $png_svg_files[] = $file; |
|
29 | 29 | } |
30 | 30 | } |
31 | 31 | } |
32 | 32 | $style = '<style>'; |
33 | 33 | $style .= '@import "'.api_get_path(WEB_CSS_PATH).'base.css";'; |
34 | 34 | $style .= '@import "'.api_get_path(WEB_CSS_PATH).'themes/'.api_get_visual_theme().'/default.css";'; |
35 | -$style .='</style>'; |
|
35 | +$style .= '</style>'; |
|
36 | 36 | |
37 | 37 | ?> |
38 | 38 | <!doctype html> |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | if (!empty($png_svg_files)) { |
49 | 49 | echo '<h3>'.get_lang('SelectSVGEditImage').'</h3>'; |
50 | 50 | echo '<ul>'; |
51 | - foreach($png_svg_files as $filename) { |
|
51 | + foreach ($png_svg_files as $filename) { |
|
52 | 52 | $image = $user_disk_path.$filename; |
53 | 53 | |
54 | - if (strpos($filename, "svg")){ |
|
54 | + if (strpos($filename, "svg")) { |
|
55 | 55 | $new_sizes['width'] = 60; |
56 | 56 | $new_sizes['height'] = 60; |
57 | 57 | } else { |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | if ($i == $max_level) { |
332 | 332 | $select_part .= "rg$rg_number.group_id as id_$rg_number "; |
333 | 333 | } else { |
334 | - $select_part .="rg$rg_number.group_id as id_$rg_number, "; |
|
334 | + $select_part .= "rg$rg_number.group_id as id_$rg_number, "; |
|
335 | 335 | } |
336 | 336 | if ($i == 1) { |
337 | 337 | $cond_part .= "FROM $t_rel_group rg0 LEFT JOIN $t_rel_group rg$i on rg$rg_number.group_id = rg$i.subgroup_id "; |
@@ -1334,14 +1334,14 @@ discard block |
||
1334 | 1334 | */ |
1335 | 1335 | public static function get_groups_by_user_count($user_id = null, $relation_type = GROUP_USER_PERMISSION_READER, $with_image = false) |
1336 | 1336 | { |
1337 | - $table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP); |
|
1338 | - $tbl_group = Database::get_main_table(TABLE_MAIN_GROUP); |
|
1337 | + $table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP); |
|
1338 | + $tbl_group = Database::get_main_table(TABLE_MAIN_GROUP); |
|
1339 | 1339 | $user_id = intval($user_id); |
1340 | 1340 | |
1341 | 1341 | if ($relation_type == 0) { |
1342 | 1342 | $where_relation_condition = ''; |
1343 | 1343 | } else { |
1344 | - $relation_type = intval($relation_type); |
|
1344 | + $relation_type = intval($relation_type); |
|
1345 | 1345 | $where_relation_condition = "AND gu.relation_type = $relation_type "; |
1346 | 1346 | } |
1347 | 1347 | |
@@ -1394,7 +1394,7 @@ discard block |
||
1394 | 1394 | |
1395 | 1395 | // Picture |
1396 | 1396 | $form->addElement('file', 'picture', get_lang('AddPicture')); |
1397 | - $allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif'); |
|
1397 | + $allowed_picture_types = array('jpg', 'jpeg', 'png', 'gif'); |
|
1398 | 1398 | $form->addRule('picture', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types); |
1399 | 1399 | |
1400 | 1400 | if (!empty($groupData)) { |