@@ -48,9 +48,9 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | //user has submitted a file |
| 50 | 50 | if (isset($_FILES['user_upload'])) { |
| 51 | - $upload_ok = process_uploaded_file($_FILES['user_upload']); |
|
| 52 | - if ($upload_ok) { |
|
| 53 | - //file got on the server without problems, now process it |
|
| 51 | + $upload_ok = process_uploaded_file($_FILES['user_upload']); |
|
| 52 | + if ($upload_ok) { |
|
| 53 | + //file got on the server without problems, now process it |
|
| 54 | 54 | $new_path = handle_uploaded_document( |
| 55 | 55 | $_course, |
| 56 | 56 | $_FILES['user_upload'], |
@@ -62,17 +62,17 @@ discard block |
||
| 62 | 62 | $_POST['unzip'], |
| 63 | 63 | $_POST['if_exists'] |
| 64 | 64 | ); |
| 65 | - $new_comment = isset($_POST['comment']) ? trim($_POST['comment']) : ''; |
|
| 66 | - $new_title = isset($_POST['title']) ? trim($_POST['title']) : ''; |
|
| 65 | + $new_comment = isset($_POST['comment']) ? trim($_POST['comment']) : ''; |
|
| 66 | + $new_title = isset($_POST['title']) ? trim($_POST['title']) : ''; |
|
| 67 | 67 | |
| 68 | - if ($new_path && ($new_comment || $new_title)) |
|
| 69 | - if (($docid = DocumentManager::get_document_id($_course, $new_path))) { |
|
| 70 | - $table_document = Database::get_course_table(TABLE_DOCUMENT); |
|
| 71 | - $ct = ''; |
|
| 72 | - if ($new_comment) $ct .= ", comment='$new_comment'"; |
|
| 73 | - if ($new_title) $ct .= ", title='$new_title'"; |
|
| 74 | - Database::query("UPDATE $table_document SET" . substr($ct, 1) ." WHERE id = '$docid'"); |
|
| 75 | - } |
|
| 68 | + if ($new_path && ($new_comment || $new_title)) |
|
| 69 | + if (($docid = DocumentManager::get_document_id($_course, $new_path))) { |
|
| 70 | + $table_document = Database::get_course_table(TABLE_DOCUMENT); |
|
| 71 | + $ct = ''; |
|
| 72 | + if ($new_comment) $ct .= ", comment='$new_comment'"; |
|
| 73 | + if ($new_title) $ct .= ", title='$new_title'"; |
|
| 74 | + Database::query("UPDATE $table_document SET" . substr($ct, 1) ." WHERE id = '$docid'"); |
|
| 75 | + } |
|
| 76 | 76 | //check for missing images in html files |
| 77 | 77 | $missing_files = check_for_missing_files($base_work_dir.$_POST['curdirpath'].$new_path); |
| 78 | 78 | if ($missing_files) { |
@@ -128,8 +128,8 @@ discard block |
||
| 128 | 128 | } |
| 129 | 129 | //they want to create a directory |
| 130 | 130 | if (isset($_POST['create_dir']) && $_POST['dirname']!='') { |
| 131 | - $added_slash = ($path=='/')?'':'/'; |
|
| 132 | - $dir_name = $path.$added_slash.api_replace_dangerous_char($_POST['dirname']); |
|
| 131 | + $added_slash = ($path=='/')?'':'/'; |
|
| 132 | + $dir_name = $path.$added_slash.api_replace_dangerous_char($_POST['dirname']); |
|
| 133 | 133 | $created_dir = create_unexisting_directory( |
| 134 | 134 | $_course, |
| 135 | 135 | $_user['user_id'], |
@@ -149,15 +149,15 @@ discard block |
||
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | if (isset($_GET['createdir'])) { |
| 152 | - //create the form that asks for the directory name |
|
| 153 | - $new_folder_text = '<form action="'.api_get_self().'" method="POST">'; |
|
| 154 | - $new_folder_text .= '<input type="hidden" name="curdirpath" value="'.$path.'"/>'; |
|
| 155 | - $new_folder_text .= get_lang('NewDir') .' '; |
|
| 156 | - $new_folder_text .= '<input type="text" name="dirname"/>'; |
|
| 157 | - $new_folder_text .= '<input type="submit" name="create_dir" value="'.get_lang('Ok').'"/>'; |
|
| 158 | - $new_folder_text .= '</form>'; |
|
| 159 | - //show the form |
|
| 160 | - Display::display_normal_message($new_folder_text); |
|
| 152 | + //create the form that asks for the directory name |
|
| 153 | + $new_folder_text = '<form action="'.api_get_self().'" method="POST">'; |
|
| 154 | + $new_folder_text .= '<input type="hidden" name="curdirpath" value="'.$path.'"/>'; |
|
| 155 | + $new_folder_text .= get_lang('NewDir') .' '; |
|
| 156 | + $new_folder_text .= '<input type="text" name="dirname"/>'; |
|
| 157 | + $new_folder_text .= '<input type="submit" name="create_dir" value="'.get_lang('Ok').'"/>'; |
|
| 158 | + $new_folder_text .= '</form>'; |
|
| 159 | + //show the form |
|
| 160 | + Display::display_normal_message($new_folder_text); |
|
| 161 | 161 | } else { //give them a link to create a directory |
| 162 | 162 | ?> |
| 163 | 163 | <p> |
@@ -15,15 +15,15 @@ discard block |
||
| 15 | 15 | $slide_id = isset($_GET['slide_id']) ? Security::remove_XSS($_GET['slide_id']) : null; |
| 16 | 16 | |
| 17 | 17 | if (empty($slide_id)) { |
| 18 | - $edit_slide_id = 1; |
|
| 18 | + $edit_slide_id = 1; |
|
| 19 | 19 | } else { |
| 20 | - $edit_slide_id = $slide_id; |
|
| 20 | + $edit_slide_id = $slide_id; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | if ($path != '/') { |
| 24 | - $folder = $path.'/'; |
|
| 24 | + $folder = $path.'/'; |
|
| 25 | 25 | } else { |
| 26 | - $folder = '/'; |
|
| 26 | + $folder = '/'; |
|
| 27 | 27 | } |
| 28 | 28 | $sys_course_path = api_get_path(SYS_COURSE_PATH); |
| 29 | 29 | |
@@ -41,15 +41,15 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | // Loading the slides from the session |
| 43 | 43 | if (isset($_SESSION['image_files_only'])) { |
| 44 | - $image_files_only = $_SESSION['image_files_only']; |
|
| 44 | + $image_files_only = $_SESSION['image_files_only']; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | // Calculating the current slide, next slide, previous slide and the number of slides |
| 48 | 48 | $slide = null; |
| 49 | 49 | if ($slide_id != 'all') { |
| 50 | - $slide = $slide_id ? $slide_id : 0; |
|
| 51 | - $previous_slide = $slide - 1; |
|
| 52 | - $next_slide = $slide + 1; |
|
| 50 | + $slide = $slide_id ? $slide_id : 0; |
|
| 51 | + $previous_slide = $slide - 1; |
|
| 52 | + $next_slide = $slide + 1; |
|
| 53 | 53 | } |
| 54 | 54 | $total_slides = count($image_files_only); |
| 55 | 55 | ?> |
@@ -62,62 +62,62 @@ discard block |
||
| 62 | 62 | <?php |
| 63 | 63 | |
| 64 | 64 | if ($slide_id != 'all') { |
| 65 | - $image = null; |
|
| 66 | - if (isset($image_files_only[$slide])) { |
|
| 67 | - $image = $sys_course_path . $_course['path'] . '/document' . $folder . $image_files_only[$slide]; |
|
| 68 | - } |
|
| 69 | - if (file_exists($image)) { |
|
| 70 | - echo '<div class="actions-pagination">'; |
|
| 71 | - |
|
| 72 | - // Back forward buttons |
|
| 73 | - if ($slide == 0) { |
|
| 74 | - $imgp = 'action_prev_na.png'; |
|
| 75 | - $first = Display::return_icon('action_first_na.png'); |
|
| 76 | - } else { |
|
| 77 | - $imgp = 'action_prev.png'; |
|
| 78 | - $first = '<a href="slideshow.php?slide_id=0&curdirpath='.$pathurl.'"> |
|
| 65 | + $image = null; |
|
| 66 | + if (isset($image_files_only[$slide])) { |
|
| 67 | + $image = $sys_course_path . $_course['path'] . '/document' . $folder . $image_files_only[$slide]; |
|
| 68 | + } |
|
| 69 | + if (file_exists($image)) { |
|
| 70 | + echo '<div class="actions-pagination">'; |
|
| 71 | + |
|
| 72 | + // Back forward buttons |
|
| 73 | + if ($slide == 0) { |
|
| 74 | + $imgp = 'action_prev_na.png'; |
|
| 75 | + $first = Display::return_icon('action_first_na.png'); |
|
| 76 | + } else { |
|
| 77 | + $imgp = 'action_prev.png'; |
|
| 78 | + $first = '<a href="slideshow.php?slide_id=0&curdirpath='.$pathurl.'"> |
|
| 79 | 79 | '.Display::return_icon('action_first.png', get_lang('FirstSlide')).' |
| 80 | 80 | </a>'; |
| 81 | - } |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - // First slide |
|
| 84 | - echo $first; |
|
| 83 | + // First slide |
|
| 84 | + echo $first; |
|
| 85 | 85 | |
| 86 | - // Previous slide |
|
| 87 | - if ($slide > 0) { |
|
| 88 | - echo '<a href="slideshow.php?slide_id='.$previous_slide.'&curdirpath='.$pathurl.'">'; |
|
| 89 | - } |
|
| 86 | + // Previous slide |
|
| 87 | + if ($slide > 0) { |
|
| 88 | + echo '<a href="slideshow.php?slide_id='.$previous_slide.'&curdirpath='.$pathurl.'">'; |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | 91 | echo Display::return_icon($imgp, get_lang('Previous')); |
| 92 | - if ($slide > 0) { |
|
| 93 | - echo '</a>'; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - // Divider |
|
| 97 | - echo ' [ '.$next_slide.'/'.$total_slides.' ] '; |
|
| 98 | - |
|
| 99 | - // Next slide |
|
| 100 | - if ($slide < $total_slides - 1) { |
|
| 101 | - echo '<a href="slideshow.php?slide_id='.$next_slide.'&curdirpath='.$pathurl.'">'; |
|
| 102 | - } |
|
| 103 | - if ($slide == $total_slides - 1) { |
|
| 104 | - $imgn = 'action_next_na.png'; |
|
| 92 | + if ($slide > 0) { |
|
| 93 | + echo '</a>'; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + // Divider |
|
| 97 | + echo ' [ '.$next_slide.'/'.$total_slides.' ] '; |
|
| 98 | + |
|
| 99 | + // Next slide |
|
| 100 | + if ($slide < $total_slides - 1) { |
|
| 101 | + echo '<a href="slideshow.php?slide_id='.$next_slide.'&curdirpath='.$pathurl.'">'; |
|
| 102 | + } |
|
| 103 | + if ($slide == $total_slides - 1) { |
|
| 104 | + $imgn = 'action_next_na.png'; |
|
| 105 | 105 | $last = Display::return_icon('action_last_na.png', get_lang('LastSlide')); |
| 106 | - } else { |
|
| 107 | - $imgn = 'action_next.png'; |
|
| 108 | - $last = '<a href="slideshow.php?slide_id='.($total_slides-1).'&curdirpath='.$pathurl.'"> |
|
| 106 | + } else { |
|
| 107 | + $imgn = 'action_next.png'; |
|
| 108 | + $last = '<a href="slideshow.php?slide_id='.($total_slides-1).'&curdirpath='.$pathurl.'"> |
|
| 109 | 109 | '.Display::return_icon('action_last.png', get_lang('LastSlide')).' |
| 110 | 110 | </a>'; |
| 111 | - } |
|
| 111 | + } |
|
| 112 | 112 | echo Display::return_icon($imgn, get_lang('Next')); |
| 113 | - if ($slide > 0) { |
|
| 114 | - echo '</a>'; |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - // Last slide |
|
| 118 | - echo $last; |
|
| 119 | - echo '</div>'; |
|
| 120 | - } |
|
| 113 | + if ($slide > 0) { |
|
| 114 | + echo '</a>'; |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + // Last slide |
|
| 118 | + echo $last; |
|
| 119 | + echo '</div>'; |
|
| 120 | + } |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | // Exit the slideshow |
@@ -126,10 +126,10 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | // Show thumbnails |
| 128 | 128 | if ($slide_id != 'all') { |
| 129 | - echo '<a href="slideshow.php?slide_id=all&curdirpath='.$pathurl.'&'.api_get_cidreq().'">'. |
|
| 129 | + echo '<a href="slideshow.php?slide_id=all&curdirpath='.$pathurl.'&'.api_get_cidreq().'">'. |
|
| 130 | 130 | Display::return_icon('thumbnails.png',get_lang('ShowThumbnails'),'',ICON_SIZE_MEDIUM).'</a>'; |
| 131 | 131 | } else { |
| 132 | - echo Display::return_icon('thumbnails_na.png',get_lang('ShowThumbnails'),'',ICON_SIZE_MEDIUM); |
|
| 132 | + echo Display::return_icon('thumbnails_na.png',get_lang('ShowThumbnails'),'',ICON_SIZE_MEDIUM); |
|
| 133 | 133 | } |
| 134 | 134 | // Slideshow options |
| 135 | 135 | echo '<a href="slideshowoptions.php?curdirpath='.$pathurl.'&'.api_get_cidreq().'">'. |
@@ -142,24 +142,24 @@ discard block |
||
| 142 | 142 | |
| 143 | 143 | // If we come from slideshowoptions.php we sessionize (new word !!! ;-) the options |
| 144 | 144 | if (isset($_POST['Submit'])) { |
| 145 | - // We come from slideshowoptions.php |
|
| 146 | - //$_SESSION["auto_image_resizing"]=Security::remove_XSS($_POST['auto_radio_resizing']); |
|
| 147 | - $_SESSION["image_resizing"] = Security::remove_XSS($_POST['radio_resizing']); |
|
| 148 | - if ($_POST['radio_resizing'] == "resizing" && $_POST['width'] != '' && $_POST['height'] != '') { |
|
| 149 | - //echo "resizing"; |
|
| 150 | - $_SESSION["image_resizing_width"] = Security::remove_XSS($_POST['width']); |
|
| 151 | - $_SESSION["image_resizing_height"] = Security::remove_XSS($_POST['height']); |
|
| 152 | - } else { |
|
| 153 | - //echo "unsetting the session heighte and width"; |
|
| 154 | - $_SESSION["image_resizing_width"] = null; |
|
| 155 | - $_SESSION["image_resizing_height"] = null; |
|
| 156 | - } |
|
| 145 | + // We come from slideshowoptions.php |
|
| 146 | + //$_SESSION["auto_image_resizing"]=Security::remove_XSS($_POST['auto_radio_resizing']); |
|
| 147 | + $_SESSION["image_resizing"] = Security::remove_XSS($_POST['radio_resizing']); |
|
| 148 | + if ($_POST['radio_resizing'] == "resizing" && $_POST['width'] != '' && $_POST['height'] != '') { |
|
| 149 | + //echo "resizing"; |
|
| 150 | + $_SESSION["image_resizing_width"] = Security::remove_XSS($_POST['width']); |
|
| 151 | + $_SESSION["image_resizing_height"] = Security::remove_XSS($_POST['height']); |
|
| 152 | + } else { |
|
| 153 | + //echo "unsetting the session heighte and width"; |
|
| 154 | + $_SESSION["image_resizing_width"] = null; |
|
| 155 | + $_SESSION["image_resizing_height"] = null; |
|
| 156 | + } |
|
| 157 | 157 | } |
| 158 | 158 | $target_width = $target_height = null; |
| 159 | 159 | // The target height and width depends if we choose resizing or no resizing |
| 160 | 160 | if (isset($_SESSION["image_resizing"]) && $_SESSION["image_resizing"] == "resizing") { |
| 161 | - $target_width = $_SESSION["image_resizing_width"]; |
|
| 162 | - $target_height = $_SESSION["image_resizing_height"]; |
|
| 161 | + $target_width = $_SESSION["image_resizing_width"]; |
|
| 162 | + $target_height = $_SESSION["image_resizing_height"]; |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /* THUMBNAIL VIEW */ |
@@ -169,59 +169,59 @@ discard block |
||
| 169 | 169 | $html = ''; |
| 170 | 170 | if ($slide_id == 'all') { |
| 171 | 171 | |
| 172 | - // Config for make thumbnails |
|
| 172 | + // Config for make thumbnails |
|
| 173 | 173 | $allowed_thumbnail_types = array('jpg', 'jpeg', 'gif', 'png'); |
| 174 | - $max_thumbnail_width = 250; |
|
| 175 | - $max_thumbnail_height = 250; |
|
| 176 | - $png_compression = 0; // 0(none)-9 |
|
| 177 | - $jpg_quality = 75; // from 0 to 100 (default is 75). More quality less compression |
|
| 174 | + $max_thumbnail_width = 250; |
|
| 175 | + $max_thumbnail_height = 250; |
|
| 176 | + $png_compression = 0; // 0(none)-9 |
|
| 177 | + $jpg_quality = 75; // from 0 to 100 (default is 75). More quality less compression |
|
| 178 | 178 | |
| 179 | - $directory_thumbnails = $sys_course_path.$_course['path'].'/document'.$folder.'.thumbs/'; |
|
| 179 | + $directory_thumbnails = $sys_course_path.$_course['path'].'/document'.$folder.'.thumbs/'; |
|
| 180 | 180 | |
| 181 | - //Other parameters only for show tumbnails |
|
| 182 | - $row_items = 4;//only in slideshow.php |
|
| 183 | - $number_image = 7;//num icons cols to show |
|
| 184 | - $thumbnail_width_frame = $max_thumbnail_width;//optional $max_thumbnail_width+x |
|
| 185 | - $thumbnail_height_frame = $max_thumbnail_height; |
|
| 181 | + //Other parameters only for show tumbnails |
|
| 182 | + $row_items = 4;//only in slideshow.php |
|
| 183 | + $number_image = 7;//num icons cols to show |
|
| 184 | + $thumbnail_width_frame = $max_thumbnail_width;//optional $max_thumbnail_width+x |
|
| 185 | + $thumbnail_height_frame = $max_thumbnail_height; |
|
| 186 | 186 | |
| 187 | - // Create the template_thumbnails folder (if no exist) |
|
| 187 | + // Create the template_thumbnails folder (if no exist) |
|
| 188 | 188 | |
| 189 | - if (!file_exists($directory_thumbnails)) { |
|
| 190 | - @mkdir($directory_thumbnails, api_get_permissions_for_new_directories()); |
|
| 189 | + if (!file_exists($directory_thumbnails)) { |
|
| 190 | + @mkdir($directory_thumbnails, api_get_permissions_for_new_directories()); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - // check files and thumbnails |
|
| 194 | - if (is_array($image_files_only)) { |
|
| 193 | + // check files and thumbnails |
|
| 194 | + if (is_array($image_files_only)) { |
|
| 195 | 195 | |
| 196 | - foreach ($image_files_only as $one_image_file) { |
|
| 197 | - $image = $sys_course_path.$_course['path'].'/document'.$folder.$one_image_file; |
|
| 198 | - $image_thumbnail= $directory_thumbnails.'.'.$one_image_file; |
|
| 196 | + foreach ($image_files_only as $one_image_file) { |
|
| 197 | + $image = $sys_course_path.$_course['path'].'/document'.$folder.$one_image_file; |
|
| 198 | + $image_thumbnail= $directory_thumbnails.'.'.$one_image_file; |
|
| 199 | 199 | |
| 200 | - if (file_exists($image)) { |
|
| 201 | - //check thumbnail |
|
| 202 | - $imagetype = explode(".", $image); |
|
| 200 | + if (file_exists($image)) { |
|
| 201 | + //check thumbnail |
|
| 202 | + $imagetype = explode(".", $image); |
|
| 203 | 203 | //or check $imagetype = image_type_to_extension(exif_imagetype($image), false); |
| 204 | - $imagetype = strtolower($imagetype[count($imagetype)-1]); |
|
| 204 | + $imagetype = strtolower($imagetype[count($imagetype)-1]); |
|
| 205 | 205 | |
| 206 | - if (in_array($imagetype,$allowed_thumbnail_types)) { |
|
| 207 | - if (!file_exists($image_thumbnail)){ |
|
| 206 | + if (in_array($imagetype,$allowed_thumbnail_types)) { |
|
| 207 | + if (!file_exists($image_thumbnail)){ |
|
| 208 | 208 | //run each once we view thumbnails is too heavy, then need move into !file_exists($image_thumbnail, and only run when haven't the thumbnail |
| 209 | - $original_image_size = api_getimagesize($image); |
|
| 210 | - |
|
| 211 | - switch($imagetype) { |
|
| 212 | - case 'gif': |
|
| 213 | - $source_img = imagecreatefromgif($image); |
|
| 214 | - break; |
|
| 215 | - case 'jpg': |
|
| 216 | - $source_img = imagecreatefromjpeg($image); |
|
| 217 | - break; |
|
| 218 | - case 'jpeg': |
|
| 219 | - $source_img = imagecreatefromjpeg($image); |
|
| 220 | - break; |
|
| 221 | - case 'png': |
|
| 222 | - $source_img = imagecreatefrompng($image); |
|
| 223 | - break; |
|
| 224 | - } |
|
| 209 | + $original_image_size = api_getimagesize($image); |
|
| 210 | + |
|
| 211 | + switch($imagetype) { |
|
| 212 | + case 'gif': |
|
| 213 | + $source_img = imagecreatefromgif($image); |
|
| 214 | + break; |
|
| 215 | + case 'jpg': |
|
| 216 | + $source_img = imagecreatefromjpeg($image); |
|
| 217 | + break; |
|
| 218 | + case 'jpeg': |
|
| 219 | + $source_img = imagecreatefromjpeg($image); |
|
| 220 | + break; |
|
| 221 | + case 'png': |
|
| 222 | + $source_img = imagecreatefrompng($image); |
|
| 223 | + break; |
|
| 224 | + } |
|
| 225 | 225 | |
| 226 | 226 | $new_thumbnail_size = api_calculate_image_size( |
| 227 | 227 | $original_image_size['width'], |
@@ -229,33 +229,33 @@ discard block |
||
| 229 | 229 | $max_thumbnail_width, |
| 230 | 230 | $max_thumbnail_height |
| 231 | 231 | ); |
| 232 | - if ($max_thumbnail_width>$original_image_size['width'] && $max_thumbnail_height>$original_image_size['height']){ |
|
| 233 | - $new_thumbnail_size['width']=$original_image_size['width']; |
|
| 234 | - $new_thumbnail_size['height']=$original_image_size['height']; |
|
| 235 | - } |
|
| 236 | - |
|
| 237 | - $crop = imagecreatetruecolor($new_thumbnail_size['width'], $new_thumbnail_size['height']); |
|
| 238 | - |
|
| 239 | - // preserve transparency |
|
| 240 | - if ($imagetype == "png"){ |
|
| 241 | - imagesavealpha($crop, true); |
|
| 242 | - $color = imagecolorallocatealpha($crop,0x00,0x00,0x00,127); |
|
| 243 | - imagefill($crop, 0, 0, $color); |
|
| 244 | - } |
|
| 245 | - |
|
| 246 | - if ($imagetype == "gif") { |
|
| 247 | - $transindex = imagecolortransparent($source_img); |
|
| 232 | + if ($max_thumbnail_width>$original_image_size['width'] && $max_thumbnail_height>$original_image_size['height']){ |
|
| 233 | + $new_thumbnail_size['width']=$original_image_size['width']; |
|
| 234 | + $new_thumbnail_size['height']=$original_image_size['height']; |
|
| 235 | + } |
|
| 236 | + |
|
| 237 | + $crop = imagecreatetruecolor($new_thumbnail_size['width'], $new_thumbnail_size['height']); |
|
| 238 | + |
|
| 239 | + // preserve transparency |
|
| 240 | + if ($imagetype == "png"){ |
|
| 241 | + imagesavealpha($crop, true); |
|
| 242 | + $color = imagecolorallocatealpha($crop,0x00,0x00,0x00,127); |
|
| 243 | + imagefill($crop, 0, 0, $color); |
|
| 244 | + } |
|
| 245 | + |
|
| 246 | + if ($imagetype == "gif") { |
|
| 247 | + $transindex = imagecolortransparent($source_img); |
|
| 248 | 248 | $palletsize = imagecolorstotal($source_img); |
| 249 | - //GIF89a for transparent and anim (first clip), either GIF87a |
|
| 250 | - if ($transindex >= 0 && $transindex < $palletsize){ |
|
| 251 | - $transcol = imagecolorsforindex($source_img, $transindex); |
|
| 252 | - $transindex = imagecolorallocatealpha($crop, $transcol['red'], $transcol['green'], $transcol['blue'], 127); |
|
| 253 | - imagefill($crop, 0, 0, $transindex); |
|
| 254 | - imagecolortransparent($crop, $transindex); |
|
| 255 | - } |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - //resampled image |
|
| 249 | + //GIF89a for transparent and anim (first clip), either GIF87a |
|
| 250 | + if ($transindex >= 0 && $transindex < $palletsize){ |
|
| 251 | + $transcol = imagecolorsforindex($source_img, $transindex); |
|
| 252 | + $transindex = imagecolorallocatealpha($crop, $transcol['red'], $transcol['green'], $transcol['blue'], 127); |
|
| 253 | + imagefill($crop, 0, 0, $transindex); |
|
| 254 | + imagecolortransparent($crop, $transindex); |
|
| 255 | + } |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + //resampled image |
|
| 259 | 259 | imagecopyresampled( |
| 260 | 260 | $crop, |
| 261 | 261 | $source_img, |
@@ -269,69 +269,69 @@ discard block |
||
| 269 | 269 | $original_image_size['height'] |
| 270 | 270 | ); |
| 271 | 271 | |
| 272 | - switch ($imagetype) { |
|
| 273 | - case 'gif': |
|
| 274 | - imagegif($crop,$image_thumbnail); |
|
| 275 | - break; |
|
| 276 | - case 'jpg': |
|
| 277 | - imagejpeg($crop,$image_thumbnail,$jpg_quality); |
|
| 278 | - break; |
|
| 279 | - case 'jpeg': |
|
| 280 | - imagejpeg($crop,$image_thumbnail,$jpg_quality); |
|
| 281 | - break; |
|
| 282 | - case 'png': |
|
| 283 | - imagepng($crop,$image_thumbnail,$png_compression); |
|
| 284 | - break; |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - //clean memory |
|
| 288 | - imagedestroy($crop); |
|
| 289 | - }//end !exist thumbnail |
|
| 290 | - |
|
| 291 | - //show thumbnail and link |
|
| 292 | - |
|
| 293 | - $one_image_thumbnail_file='.thumbs/.'.$one_image_file;//get path thumbnail |
|
| 294 | - $doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_thumbnail_file : $path.$one_image_thumbnail_file; |
|
| 295 | - $image_tag[] = '<img class="img-gallery" src="download.php?doc_url='.$doc_url.'" border="0" title="'.$one_image_file.'">'; |
|
| 296 | - } else { |
|
| 297 | - //if images aren't support by gd (not gif, jpg, jpeg, png) |
|
| 298 | - if ($imagetype=="bmp") { |
|
| 272 | + switch ($imagetype) { |
|
| 273 | + case 'gif': |
|
| 274 | + imagegif($crop,$image_thumbnail); |
|
| 275 | + break; |
|
| 276 | + case 'jpg': |
|
| 277 | + imagejpeg($crop,$image_thumbnail,$jpg_quality); |
|
| 278 | + break; |
|
| 279 | + case 'jpeg': |
|
| 280 | + imagejpeg($crop,$image_thumbnail,$jpg_quality); |
|
| 281 | + break; |
|
| 282 | + case 'png': |
|
| 283 | + imagepng($crop,$image_thumbnail,$png_compression); |
|
| 284 | + break; |
|
| 285 | + } |
|
| 286 | + |
|
| 287 | + //clean memory |
|
| 288 | + imagedestroy($crop); |
|
| 289 | + }//end !exist thumbnail |
|
| 290 | + |
|
| 291 | + //show thumbnail and link |
|
| 292 | + |
|
| 293 | + $one_image_thumbnail_file='.thumbs/.'.$one_image_file;//get path thumbnail |
|
| 294 | + $doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_thumbnail_file : $path.$one_image_thumbnail_file; |
|
| 295 | + $image_tag[] = '<img class="img-gallery" src="download.php?doc_url='.$doc_url.'" border="0" title="'.$one_image_file.'">'; |
|
| 296 | + } else { |
|
| 297 | + //if images aren't support by gd (not gif, jpg, jpeg, png) |
|
| 298 | + if ($imagetype=="bmp") { |
|
| 299 | 299 | // use getimagesize instead api_getimagesize($image); becasuse api_getimagesize doesn't support bmp files. Put here for each show, only for a few bmp files isn't heavy |
| 300 | - $original_image_size = getimagesize($image); |
|
| 301 | - if ($max_thumbnail_width<$original_image_size[0] || $max_thumbnail_height<$original_image_size[1]){ |
|
| 302 | - $thumbnail_size=api_calculate_image_size($original_image_size[0], $original_image_size[1], $max_thumbnail_width, $max_thumbnail_height);//don't use resize_image because doesn't run with bmp files |
|
| 303 | - $image_height = $thumbnail_size['height']; |
|
| 304 | - $image_width = $thumbnail_size['width']; |
|
| 305 | - } else { |
|
| 306 | - $image_height=$original_image_size[0]; |
|
| 307 | - $image_width=$original_image_size[1]; |
|
| 308 | - } |
|
| 309 | - } else { |
|
| 310 | - //example for svg files,... |
|
| 311 | - $image_width=$max_thumbnail_width; |
|
| 312 | - $image_height=$max_thumbnail_height; |
|
| 313 | - } |
|
| 314 | - |
|
| 315 | - $doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_file : $path.$one_image_file; |
|
| 316 | - $image_tag[] = '<img src="download.php?doc_url='.$doc_url.'" border="0" width="'.$image_width.'" height="'.$image_height.'" title="'.$one_image_file.'">'; |
|
| 317 | - |
|
| 318 | - }//end allowed image types |
|
| 319 | - }//end if exist file image |
|
| 320 | - }//end foreach |
|
| 321 | - }//end image files only |
|
| 322 | - |
|
| 323 | - // Creating the table |
|
| 324 | - $html_table = ''; |
|
| 325 | - |
|
| 326 | - $i = 0; |
|
| 327 | - $count_image = count($image_tag); |
|
| 328 | - $number_iteration = ceil($count_image/$number_image); |
|
| 329 | - $p = 0; |
|
| 300 | + $original_image_size = getimagesize($image); |
|
| 301 | + if ($max_thumbnail_width<$original_image_size[0] || $max_thumbnail_height<$original_image_size[1]){ |
|
| 302 | + $thumbnail_size=api_calculate_image_size($original_image_size[0], $original_image_size[1], $max_thumbnail_width, $max_thumbnail_height);//don't use resize_image because doesn't run with bmp files |
|
| 303 | + $image_height = $thumbnail_size['height']; |
|
| 304 | + $image_width = $thumbnail_size['width']; |
|
| 305 | + } else { |
|
| 306 | + $image_height=$original_image_size[0]; |
|
| 307 | + $image_width=$original_image_size[1]; |
|
| 308 | + } |
|
| 309 | + } else { |
|
| 310 | + //example for svg files,... |
|
| 311 | + $image_width=$max_thumbnail_width; |
|
| 312 | + $image_height=$max_thumbnail_height; |
|
| 313 | + } |
|
| 314 | + |
|
| 315 | + $doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_file : $path.$one_image_file; |
|
| 316 | + $image_tag[] = '<img src="download.php?doc_url='.$doc_url.'" border="0" width="'.$image_width.'" height="'.$image_height.'" title="'.$one_image_file.'">'; |
|
| 317 | + |
|
| 318 | + }//end allowed image types |
|
| 319 | + }//end if exist file image |
|
| 320 | + }//end foreach |
|
| 321 | + }//end image files only |
|
| 322 | + |
|
| 323 | + // Creating the table |
|
| 324 | + $html_table = ''; |
|
| 325 | + |
|
| 326 | + $i = 0; |
|
| 327 | + $count_image = count($image_tag); |
|
| 328 | + $number_iteration = ceil($count_image/$number_image); |
|
| 329 | + $p = 0; |
|
| 330 | 330 | $html = ''; |
| 331 | 331 | $html .= '<div class="gallery">'; |
| 332 | - for ($k = 0; $k < $number_iteration; $k++) { |
|
| 333 | - for ($i = 0; $i < $number_image; $i++) { |
|
| 334 | - if (isset($image_tag[$p])) { |
|
| 332 | + for ($k = 0; $k < $number_iteration; $k++) { |
|
| 333 | + for ($i = 0; $i < $number_image; $i++) { |
|
| 334 | + if (isset($image_tag[$p])) { |
|
| 335 | 335 | $html .= '<div class="col-xs-6 col-sm-3 col-md-2">'; |
| 336 | 336 | $html .= '<div class="canvas-one">'; |
| 337 | 337 | $html .= '<a class="canvas-two" href="slideshow.php?slide_id='.$p.'&curdirpath='.$pathurl.'">'; |
@@ -343,10 +343,10 @@ discard block |
||
| 343 | 343 | $html .= '</a>'; |
| 344 | 344 | $html .= '</div>'; |
| 345 | 345 | $html .= '</div>'; |
| 346 | - } |
|
| 347 | - $p++; |
|
| 348 | - } |
|
| 349 | - } |
|
| 346 | + } |
|
| 347 | + $p++; |
|
| 348 | + } |
|
| 349 | + } |
|
| 350 | 350 | $html .= '</div>'; |
| 351 | 351 | |
| 352 | 352 | }//end slide==all |
@@ -357,43 +357,43 @@ discard block |
||
| 357 | 357 | // This is for viewing all the images in the slideshow one at a time. |
| 358 | 358 | |
| 359 | 359 | if ($slide_id != 'all' && !empty($image_files_only)) { |
| 360 | - if (file_exists($image) && is_file($image)) { |
|
| 361 | - $image_height_width = resize_image($image, $target_width, $target_height); |
|
| 362 | - |
|
| 363 | - $image_height = $image_height_width[0]; |
|
| 364 | - $image_width = $image_height_width[1]; |
|
| 365 | - |
|
| 366 | - $height_width_tags = null; |
|
| 367 | - if (isset($_SESSION['image_resizing']) && $_SESSION['image_resizing'] == 'resizing') { |
|
| 368 | - $height_width_tags = 'width="'.$image_width.'" height="'.$image_height.'"'; |
|
| 369 | - } |
|
| 370 | - |
|
| 371 | - // This is done really quickly and should be cleaned up a little bit using the API functions |
|
| 372 | - $tbl_documents = Database::get_course_table(TABLE_DOCUMENT); |
|
| 373 | - if ($path == '/') { |
|
| 374 | - $pathpart = '/'; |
|
| 375 | - } else { |
|
| 376 | - $pathpart = $path.'/'; |
|
| 377 | - } |
|
| 378 | - $sql = "SELECT * FROM $tbl_documents |
|
| 360 | + if (file_exists($image) && is_file($image)) { |
|
| 361 | + $image_height_width = resize_image($image, $target_width, $target_height); |
|
| 362 | + |
|
| 363 | + $image_height = $image_height_width[0]; |
|
| 364 | + $image_width = $image_height_width[1]; |
|
| 365 | + |
|
| 366 | + $height_width_tags = null; |
|
| 367 | + if (isset($_SESSION['image_resizing']) && $_SESSION['image_resizing'] == 'resizing') { |
|
| 368 | + $height_width_tags = 'width="'.$image_width.'" height="'.$image_height.'"'; |
|
| 369 | + } |
|
| 370 | + |
|
| 371 | + // This is done really quickly and should be cleaned up a little bit using the API functions |
|
| 372 | + $tbl_documents = Database::get_course_table(TABLE_DOCUMENT); |
|
| 373 | + if ($path == '/') { |
|
| 374 | + $pathpart = '/'; |
|
| 375 | + } else { |
|
| 376 | + $pathpart = $path.'/'; |
|
| 377 | + } |
|
| 378 | + $sql = "SELECT * FROM $tbl_documents |
|
| 379 | 379 | WHERE c_id = $course_id AND path='".Database::escape_string($pathpart.$image_files_only[$slide])."'"; |
| 380 | - $result = Database::query($sql); |
|
| 381 | - $row = Database::fetch_array($result); |
|
| 380 | + $result = Database::query($sql); |
|
| 381 | + $row = Database::fetch_array($result); |
|
| 382 | 382 | |
| 383 | 383 | echo '<div class="thumbnail">'; |
| 384 | - if ($slide < $total_slides - 1 && $slide_id != 'all') { |
|
| 385 | - echo "<a href='slideshow.php?slide_id=".$next_slide."&curdirpath=$pathurl'>"; |
|
| 386 | - } else { |
|
| 387 | - echo "<a href='slideshow.php?slide_id=0&curdirpath=$pathurl'>"; |
|
| 388 | - } |
|
| 384 | + if ($slide < $total_slides - 1 && $slide_id != 'all') { |
|
| 385 | + echo "<a href='slideshow.php?slide_id=".$next_slide."&curdirpath=$pathurl'>"; |
|
| 386 | + } else { |
|
| 387 | + echo "<a href='slideshow.php?slide_id=0&curdirpath=$pathurl'>"; |
|
| 388 | + } |
|
| 389 | 389 | if ($path == '/') { |
| 390 | - $path = ''; |
|
| 390 | + $path = ''; |
|
| 391 | 391 | } |
| 392 | 392 | |
| 393 | - list($width, $height) = getimagesize($image); |
|
| 394 | - // Auto resize |
|
| 395 | - if (isset($_SESSION["image_resizing"]) && $_SESSION["image_resizing"] == 'resizing') { |
|
| 396 | - ?> |
|
| 393 | + list($width, $height) = getimagesize($image); |
|
| 394 | + // Auto resize |
|
| 395 | + if (isset($_SESSION["image_resizing"]) && $_SESSION["image_resizing"] == 'resizing') { |
|
| 396 | + ?> |
|
| 397 | 397 | |
| 398 | 398 | <script type="text/javascript"> |
| 399 | 399 | var initial_width='<?php echo $width; ?>'; |
@@ -446,21 +446,21 @@ discard block |
||
| 446 | 446 | |
| 447 | 447 | </script> |
| 448 | 448 | <?php |
| 449 | - } else { |
|
| 450 | - echo "<img class=\"img-responsive\" src='download.php?doc_url=$path/".$image_files_only[$slide]."' alt='".$image_files_only[$slide]."' border='0'".$height_width_tags.">"; |
|
| 451 | - } |
|
| 449 | + } else { |
|
| 450 | + echo "<img class=\"img-responsive\" src='download.php?doc_url=$path/".$image_files_only[$slide]."' alt='".$image_files_only[$slide]."' border='0'".$height_width_tags.">"; |
|
| 451 | + } |
|
| 452 | 452 | |
| 453 | - echo '</a>'; |
|
| 453 | + echo '</a>'; |
|
| 454 | 454 | echo '<div class="caption text-center">'; |
| 455 | 455 | echo Display::tag('h3', $row['title']); |
| 456 | 456 | echo '<p>' . $row['comment'] . '</p>'; |
| 457 | 457 | echo '</div>'; |
| 458 | 458 | echo '</div>'; |
| 459 | 459 | |
| 460 | - if (api_is_allowed_to_edit(null, true)) { |
|
| 460 | + if (api_is_allowed_to_edit(null, true)) { |
|
| 461 | 461 | echo '<ul class="list-unstyled">'; |
| 462 | - $aux = explode('.', htmlspecialchars($image_files_only[$slide])); |
|
| 463 | - $ext = $aux[count($aux) - 1]; |
|
| 462 | + $aux = explode('.', htmlspecialchars($image_files_only[$slide])); |
|
| 463 | + $ext = $aux[count($aux) - 1]; |
|
| 464 | 464 | |
| 465 | 465 | if (isset($_SESSION['image_resizing']) && $_SESSION['image_resizing'] == 'resizing') { |
| 466 | 466 | $resize_info = get_lang('Resizing').'<br />'; |
@@ -472,8 +472,8 @@ discard block |
||
| 472 | 472 | $resize_height = get_lang('Auto'); |
| 473 | 473 | } else { |
| 474 | 474 | $resize_info = get_lang('NoResizing').'<br />'; |
| 475 | - $resize_width = ''; |
|
| 476 | - $resize_height = ''; |
|
| 475 | + $resize_width = ''; |
|
| 476 | + $resize_height = ''; |
|
| 477 | 477 | } |
| 478 | 478 | |
| 479 | 479 | echo '<li class="text-center">'; |
@@ -493,16 +493,16 @@ discard block |
||
| 493 | 493 | ); |
| 494 | 494 | echo '</li>'; |
| 495 | 495 | echo '<li class="text-center">' . $width.' x '.$height . '</li>'; |
| 496 | - echo '<li class="text-center">' . round((filesize($image) / 1024), 2) . ' KB - ' . $ext . '</li>'; |
|
| 496 | + echo '<li class="text-center">' . round((filesize($image) / 1024), 2) . ' KB - ' . $ext . '</li>'; |
|
| 497 | 497 | echo '<li class="text-center">' . $resize_info . '</li>'; |
| 498 | - echo '<li class="text-center">' . $resize_width . '</li>'; |
|
| 499 | - echo '<li class="text-center">' . $resize_height . '</li>'; |
|
| 498 | + echo '<li class="text-center">' . $resize_width . '</li>'; |
|
| 499 | + echo '<li class="text-center">' . $resize_height . '</li>'; |
|
| 500 | 500 | echo '</ul>'; |
| 501 | - } |
|
| 501 | + } |
|
| 502 | 502 | |
| 503 | - } else { |
|
| 504 | - Display::display_warning_message(get_lang('FileNotFound')); |
|
| 505 | - } |
|
| 503 | + } else { |
|
| 504 | + Display::display_warning_message(get_lang('FileNotFound')); |
|
| 505 | + } |
|
| 506 | 506 | } else { |
| 507 | 507 | if ($slide_id != 'all') { |
| 508 | 508 | Display::display_warning_message(get_lang('NoDataAvailable')); |
@@ -25,38 +25,38 @@ discard block |
||
| 25 | 25 | function store_permissions($content, $id) { |
| 26 | 26 | $course_id = api_get_course_int_id(); |
| 27 | 27 | |
| 28 | - // Which database are we using (depending on the $content parameter) |
|
| 29 | - if ($content=='user') |
|
| 30 | - { |
|
| 31 | - $table=Database::get_course_table(TABLE_PERMISSION_USER); |
|
| 32 | - $id_field = user_id; |
|
| 33 | - } |
|
| 34 | - if ($content=='group') |
|
| 35 | - { |
|
| 36 | - $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
| 37 | - $id_field = group_id; |
|
| 38 | - } |
|
| 39 | - if ($content=='role') |
|
| 40 | - { |
|
| 41 | - $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
| 42 | - $id_field = role_id; |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - // We first delete all the existing permissions for that user/group/role |
|
| 46 | - $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."'"; |
|
| 47 | - $result=Database::query($sql); |
|
| 48 | - |
|
| 49 | - // looping through the post values to find the permission (containing the string permission* ) |
|
| 50 | - foreach ($_POST as $key => $value) |
|
| 51 | - { |
|
| 52 | - if (strstr($key,"permission*")) |
|
| 53 | - { |
|
| 54 | - list($brol,$tool,$action)=explode("*",$key); |
|
| 55 | - $sql="INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($action)."')"; |
|
| 56 | - $result=Database::query($sql); |
|
| 57 | - } |
|
| 58 | - } |
|
| 59 | - return get_lang('PermissionsStored'); |
|
| 28 | + // Which database are we using (depending on the $content parameter) |
|
| 29 | + if ($content=='user') |
|
| 30 | + { |
|
| 31 | + $table=Database::get_course_table(TABLE_PERMISSION_USER); |
|
| 32 | + $id_field = user_id; |
|
| 33 | + } |
|
| 34 | + if ($content=='group') |
|
| 35 | + { |
|
| 36 | + $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
| 37 | + $id_field = group_id; |
|
| 38 | + } |
|
| 39 | + if ($content=='role') |
|
| 40 | + { |
|
| 41 | + $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
| 42 | + $id_field = role_id; |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + // We first delete all the existing permissions for that user/group/role |
|
| 46 | + $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."'"; |
|
| 47 | + $result=Database::query($sql); |
|
| 48 | + |
|
| 49 | + // looping through the post values to find the permission (containing the string permission* ) |
|
| 50 | + foreach ($_POST as $key => $value) |
|
| 51 | + { |
|
| 52 | + if (strstr($key,"permission*")) |
|
| 53 | + { |
|
| 54 | + list($brol,$tool,$action)=explode("*",$key); |
|
| 55 | + $sql="INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($action)."')"; |
|
| 56 | + $result=Database::query($sql); |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | + return get_lang('PermissionsStored'); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -70,50 +70,50 @@ discard block |
||
| 70 | 70 | * @version 1.0 |
| 71 | 71 | */ |
| 72 | 72 | function store_one_permission($content, $action, $id, $tool,$permission) { |
| 73 | - global $rights_full; |
|
| 73 | + global $rights_full; |
|
| 74 | 74 | $course_id = api_get_course_int_id(); |
| 75 | - // for some reason I don't know, he can't get to the $rights_full array, so commented the following lines out. |
|
| 75 | + // for some reason I don't know, he can't get to the $rights_full array, so commented the following lines out. |
|
| 76 | 76 | |
| 77 | - // check |
|
| 78 | - //if(!in_array($permission, $rights_full)) |
|
| 79 | - //{ |
|
| 80 | - // return get_lang('Error'); |
|
| 81 | - //} |
|
| 77 | + // check |
|
| 78 | + //if(!in_array($permission, $rights_full)) |
|
| 79 | + //{ |
|
| 80 | + // return get_lang('Error'); |
|
| 81 | + //} |
|
| 82 | 82 | |
| 83 | - // Which database are we using (depending on the $content parameter) |
|
| 83 | + // Which database are we using (depending on the $content parameter) |
|
| 84 | 84 | |
| 85 | - if ($content=='user') { |
|
| 86 | - $table=Database::get_course_table(TABLE_PERMISSION_USER); |
|
| 87 | - $id_field = user_id; |
|
| 88 | - } |
|
| 89 | - if ($content=='group') |
|
| 90 | - { |
|
| 91 | - $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
| 92 | - $id_field = group_id; |
|
| 93 | - } |
|
| 94 | - if ($content=='role') |
|
| 95 | - { |
|
| 96 | - $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
| 97 | - $id_field = role_id; |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - // grating a right |
|
| 101 | - if ($action=='grant') { |
|
| 102 | - $sql="INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($permission)."')"; |
|
| 103 | - $result=Database::query($sql); |
|
| 104 | - if($result) { |
|
| 105 | - $result_message=get_lang('PermissionGranted'); |
|
| 106 | - } |
|
| 107 | - } |
|
| 108 | - if ($action=='revoke') |
|
| 109 | - { |
|
| 110 | - $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND tool='".Database::escape_string($tool)."' AND action='".Database::escape_string($permission)."'"; |
|
| 111 | - $result=Database::query($sql); |
|
| 112 | - if($result) { |
|
| 113 | - $result_message=get_lang('PermissionRevoked'); |
|
| 114 | - } |
|
| 115 | - } |
|
| 116 | - return $result_message; |
|
| 85 | + if ($content=='user') { |
|
| 86 | + $table=Database::get_course_table(TABLE_PERMISSION_USER); |
|
| 87 | + $id_field = user_id; |
|
| 88 | + } |
|
| 89 | + if ($content=='group') |
|
| 90 | + { |
|
| 91 | + $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
| 92 | + $id_field = group_id; |
|
| 93 | + } |
|
| 94 | + if ($content=='role') |
|
| 95 | + { |
|
| 96 | + $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
| 97 | + $id_field = role_id; |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + // grating a right |
|
| 101 | + if ($action=='grant') { |
|
| 102 | + $sql="INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($permission)."')"; |
|
| 103 | + $result=Database::query($sql); |
|
| 104 | + if($result) { |
|
| 105 | + $result_message=get_lang('PermissionGranted'); |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | + if ($action=='revoke') |
|
| 109 | + { |
|
| 110 | + $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND tool='".Database::escape_string($tool)."' AND action='".Database::escape_string($permission)."'"; |
|
| 111 | + $result=Database::query($sql); |
|
| 112 | + if($result) { |
|
| 113 | + $result_message=get_lang('PermissionRevoked'); |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | + return $result_message; |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
@@ -125,47 +125,47 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | function get_permissions($content, $id) { |
| 127 | 127 | $course_id = api_get_course_int_id(); |
| 128 | - $currentpermissions=array(); |
|
| 129 | - // Which database are we using (depending on the $content parameter) |
|
| 128 | + $currentpermissions=array(); |
|
| 129 | + // Which database are we using (depending on the $content parameter) |
|
| 130 | 130 | $course_id_condition = " c_id = $course_id AND "; |
| 131 | - if ($content == 'user') |
|
| 132 | - { |
|
| 133 | - $table=Database::get_course_table(TABLE_PERMISSION_USER); |
|
| 134 | - $id_field = 'user_id'; |
|
| 135 | - } |
|
| 136 | - elseif ($content == 'group') |
|
| 137 | - { |
|
| 138 | - $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
| 139 | - $id_field = 'group_id'; |
|
| 140 | - } |
|
| 141 | - elseif ($content == 'role') |
|
| 142 | - { |
|
| 143 | - $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
| 144 | - $id_field = 'role_id'; |
|
| 145 | - } |
|
| 146 | - elseif ($content == 'platform_role') |
|
| 147 | - { |
|
| 148 | - $table=Database::get_main_table(TABLE_ROLE_PERMISSION); |
|
| 149 | - $id_field = 'role_id'; |
|
| 131 | + if ($content == 'user') |
|
| 132 | + { |
|
| 133 | + $table=Database::get_course_table(TABLE_PERMISSION_USER); |
|
| 134 | + $id_field = 'user_id'; |
|
| 135 | + } |
|
| 136 | + elseif ($content == 'group') |
|
| 137 | + { |
|
| 138 | + $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
| 139 | + $id_field = 'group_id'; |
|
| 140 | + } |
|
| 141 | + elseif ($content == 'role') |
|
| 142 | + { |
|
| 143 | + $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
| 144 | + $id_field = 'role_id'; |
|
| 145 | + } |
|
| 146 | + elseif ($content == 'platform_role') |
|
| 147 | + { |
|
| 148 | + $table=Database::get_main_table(TABLE_ROLE_PERMISSION); |
|
| 149 | + $id_field = 'role_id'; |
|
| 150 | 150 | $course_id_condition = ''; |
| 151 | - } |
|
| 152 | - elseif ($content == 'task') |
|
| 153 | - { |
|
| 154 | - $table=Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
| 155 | - $id_field = 'task_id'; |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - // finding all the permissions. We store this in a multidimensional array |
|
| 159 | - // where the first dimension is the tool. |
|
| 160 | - $sql=" |
|
| 151 | + } |
|
| 152 | + elseif ($content == 'task') |
|
| 153 | + { |
|
| 154 | + $table=Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
| 155 | + $id_field = 'task_id'; |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + // finding all the permissions. We store this in a multidimensional array |
|
| 159 | + // where the first dimension is the tool. |
|
| 160 | + $sql=" |
|
| 161 | 161 | SELECT * FROM " . $table . " |
| 162 | 162 | WHERE $course_id_condition " . $id_field . "='" . Database::escape_string($id) . "'"; |
| 163 | - $result = Database::query($sql); |
|
| 163 | + $result = Database::query($sql); |
|
| 164 | 164 | |
| 165 | - while($row = Database::fetch_array($result)) |
|
| 166 | - $currentpermissions[$row['tool']][] = $row['action']; |
|
| 165 | + while($row = Database::fetch_array($result)) |
|
| 166 | + $currentpermissions[$row['tool']][] = $row['action']; |
|
| 167 | 167 | |
| 168 | - return $currentpermissions; |
|
| 168 | + return $currentpermissions; |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | /** |
@@ -179,38 +179,38 @@ discard block |
||
| 179 | 179 | */ |
| 180 | 180 | function limited_or_full($current_permissions) |
| 181 | 181 | { |
| 182 | - if (api_get_setting('permissions')=='limited') |
|
| 183 | - { |
|
| 184 | - foreach ($current_permissions as $tool=>$tool_rights) |
|
| 185 | - { |
|
| 186 | - // we loop through the possible permissions of a tool and unset the entry if it is view |
|
| 187 | - // if it is visibility or move we have to grant the edit right |
|
| 188 | - foreach ($tool_rights as $key=>$value) |
|
| 189 | - { |
|
| 190 | - if ($value=='View') |
|
| 191 | - { |
|
| 192 | - unset($current_permissions[$tool][$key]); |
|
| 193 | - } |
|
| 194 | - if ($value=='Visibility' OR $value=='Move') |
|
| 195 | - { |
|
| 196 | - if (!in_array('Edit',$current_permissions[$tool])) |
|
| 197 | - { |
|
| 198 | - $current_permissions[$tool][]='Edit'; |
|
| 199 | - } |
|
| 200 | - unset($current_permissions[$tool][$key]); |
|
| 201 | - } |
|
| 202 | - //else |
|
| 203 | - //{ |
|
| 204 | - // $current_permissions[$tool][]=$value; |
|
| 205 | - //} |
|
| 206 | - } |
|
| 207 | - } |
|
| 208 | - return $current_permissions; |
|
| 209 | - } |
|
| 210 | - if (api_get_setting('permissions')=='full') |
|
| 211 | - { |
|
| 212 | - return $current_permissions; |
|
| 213 | - } |
|
| 182 | + if (api_get_setting('permissions')=='limited') |
|
| 183 | + { |
|
| 184 | + foreach ($current_permissions as $tool=>$tool_rights) |
|
| 185 | + { |
|
| 186 | + // we loop through the possible permissions of a tool and unset the entry if it is view |
|
| 187 | + // if it is visibility or move we have to grant the edit right |
|
| 188 | + foreach ($tool_rights as $key=>$value) |
|
| 189 | + { |
|
| 190 | + if ($value=='View') |
|
| 191 | + { |
|
| 192 | + unset($current_permissions[$tool][$key]); |
|
| 193 | + } |
|
| 194 | + if ($value=='Visibility' OR $value=='Move') |
|
| 195 | + { |
|
| 196 | + if (!in_array('Edit',$current_permissions[$tool])) |
|
| 197 | + { |
|
| 198 | + $current_permissions[$tool][]='Edit'; |
|
| 199 | + } |
|
| 200 | + unset($current_permissions[$tool][$key]); |
|
| 201 | + } |
|
| 202 | + //else |
|
| 203 | + //{ |
|
| 204 | + // $current_permissions[$tool][]=$value; |
|
| 205 | + //} |
|
| 206 | + } |
|
| 207 | + } |
|
| 208 | + return $current_permissions; |
|
| 209 | + } |
|
| 210 | + if (api_get_setting('permissions')=='full') |
|
| 211 | + { |
|
| 212 | + return $current_permissions; |
|
| 213 | + } |
|
| 214 | 214 | } |
| 215 | 215 | /** |
| 216 | 216 | * This function displays a checked or unchecked checkbox. The checkbox will be checked if the |
@@ -224,12 +224,12 @@ discard block |
||
| 224 | 224 | */ |
| 225 | 225 | function display_checkbox_matrix($permission_array, $tool, $permission, $inherited_permissions=array()) |
| 226 | 226 | { |
| 227 | - $checked=""; |
|
| 228 | - if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) |
|
| 229 | - { |
|
| 230 | - $checked="checked"; |
|
| 231 | - } |
|
| 232 | - echo "\t\t\t<input type=\"checkbox\" name=\"permission*$tool*$permission\" $checked>\n"; |
|
| 227 | + $checked=""; |
|
| 228 | + if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) |
|
| 229 | + { |
|
| 230 | + $checked="checked"; |
|
| 231 | + } |
|
| 232 | + echo "\t\t\t<input type=\"checkbox\" name=\"permission*$tool*$permission\" $checked>\n"; |
|
| 233 | 233 | |
| 234 | 234 | } |
| 235 | 235 | |
@@ -245,62 +245,62 @@ discard block |
||
| 245 | 245 | */ |
| 246 | 246 | function display_image_matrix($permission_array, $tool, $permission,$inherited_permissions=array(), $course_admin=false, $editable=true) |
| 247 | 247 | { |
| 248 | - if ($course_admin) { |
|
| 249 | - echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
|
| 250 | - } else { |
|
| 251 | - if (in_array($permission,$inherited_permissions[$tool])) { |
|
| 252 | - echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
|
| 253 | - } else { |
|
| 254 | - if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) { |
|
| 255 | - if ($editable) { |
|
| 256 | - $url=api_get_self(); |
|
| 257 | - $urlparameters = ''; |
|
| 258 | - foreach($_GET as $key=>$value) { |
|
| 259 | - $parameter[$key]=$value; |
|
| 260 | - } |
|
| 261 | - $parameter['action']='revoke'; |
|
| 262 | - $parameter['permission']=$permission; |
|
| 263 | - $parameter['tool']=$tool; |
|
| 264 | - foreach ($parameter as $key=>$value) { |
|
| 265 | - $urlparameters.=$key.'='.$value.'&'; |
|
| 266 | - } |
|
| 267 | - $url=$url.'?'.$urlparameters; |
|
| 268 | - |
|
| 269 | - echo "\t\t\t <a href=\"".$url."\">"; |
|
| 270 | - } |
|
| 271 | - echo "<img src=\"../img/checkbox_on2.gif\" border=\"0\"/>"; |
|
| 272 | - if ($editable) { |
|
| 273 | - echo "</a>"; |
|
| 274 | - } |
|
| 275 | - } else { |
|
| 276 | - if ($editable) |
|
| 277 | - { |
|
| 278 | - $url=api_get_self(); |
|
| 279 | - $urlparameters = ''; |
|
| 280 | - foreach ($_GET as $key=>$value) |
|
| 281 | - { |
|
| 282 | - $parameter[$key]=$value; |
|
| 283 | - } |
|
| 284 | - $parameter['action']='grant'; |
|
| 285 | - $parameter['permission']=$permission; |
|
| 286 | - $parameter['tool']=$tool; |
|
| 287 | - foreach ($parameter as $key=>$value) |
|
| 288 | - { |
|
| 289 | - $urlparameters.=$key.'='.$value.'&'; |
|
| 290 | - } |
|
| 291 | - $url=$url.'?'.$urlparameters; |
|
| 292 | - |
|
| 293 | - //echo "\t\t\t <a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=grant&permission=$permission&tool=$tool\">"; |
|
| 294 | - echo "\t\t\t <a href=\"".$url."\">"; |
|
| 295 | - } |
|
| 296 | - echo "<img src=\"../img/wrong.gif\" border=\"0\"/>"; |
|
| 297 | - if ($editable) |
|
| 298 | - { |
|
| 299 | - echo "</a>"; |
|
| 300 | - } |
|
| 301 | - } |
|
| 302 | - } |
|
| 303 | - } |
|
| 248 | + if ($course_admin) { |
|
| 249 | + echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
|
| 250 | + } else { |
|
| 251 | + if (in_array($permission,$inherited_permissions[$tool])) { |
|
| 252 | + echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
|
| 253 | + } else { |
|
| 254 | + if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) { |
|
| 255 | + if ($editable) { |
|
| 256 | + $url=api_get_self(); |
|
| 257 | + $urlparameters = ''; |
|
| 258 | + foreach($_GET as $key=>$value) { |
|
| 259 | + $parameter[$key]=$value; |
|
| 260 | + } |
|
| 261 | + $parameter['action']='revoke'; |
|
| 262 | + $parameter['permission']=$permission; |
|
| 263 | + $parameter['tool']=$tool; |
|
| 264 | + foreach ($parameter as $key=>$value) { |
|
| 265 | + $urlparameters.=$key.'='.$value.'&'; |
|
| 266 | + } |
|
| 267 | + $url=$url.'?'.$urlparameters; |
|
| 268 | + |
|
| 269 | + echo "\t\t\t <a href=\"".$url."\">"; |
|
| 270 | + } |
|
| 271 | + echo "<img src=\"../img/checkbox_on2.gif\" border=\"0\"/>"; |
|
| 272 | + if ($editable) { |
|
| 273 | + echo "</a>"; |
|
| 274 | + } |
|
| 275 | + } else { |
|
| 276 | + if ($editable) |
|
| 277 | + { |
|
| 278 | + $url=api_get_self(); |
|
| 279 | + $urlparameters = ''; |
|
| 280 | + foreach ($_GET as $key=>$value) |
|
| 281 | + { |
|
| 282 | + $parameter[$key]=$value; |
|
| 283 | + } |
|
| 284 | + $parameter['action']='grant'; |
|
| 285 | + $parameter['permission']=$permission; |
|
| 286 | + $parameter['tool']=$tool; |
|
| 287 | + foreach ($parameter as $key=>$value) |
|
| 288 | + { |
|
| 289 | + $urlparameters.=$key.'='.$value.'&'; |
|
| 290 | + } |
|
| 291 | + $url=$url.'?'.$urlparameters; |
|
| 292 | + |
|
| 293 | + //echo "\t\t\t <a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=grant&permission=$permission&tool=$tool\">"; |
|
| 294 | + echo "\t\t\t <a href=\"".$url."\">"; |
|
| 295 | + } |
|
| 296 | + echo "<img src=\"../img/wrong.gif\" border=\"0\"/>"; |
|
| 297 | + if ($editable) |
|
| 298 | + { |
|
| 299 | + echo "</a>"; |
|
| 300 | + } |
|
| 301 | + } |
|
| 302 | + } |
|
| 303 | + } |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | |
@@ -318,72 +318,72 @@ discard block |
||
| 318 | 318 | function display_image_matrix_for_blogs($permission_array, $user_id, $tool, $permission,$inherited_permissions=array(), $course_admin=false, $editable=true) |
| 319 | 319 | { |
| 320 | 320 | |
| 321 | - if ($course_admin) |
|
| 322 | - { |
|
| 323 | - echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
|
| 324 | - } |
|
| 325 | - else |
|
| 326 | - { |
|
| 327 | - if (!empty($inherited_permissions) and in_array($permission,$inherited_permissions[$tool])) |
|
| 328 | - { |
|
| 329 | - echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
|
| 330 | - } |
|
| 331 | - else |
|
| 332 | - { |
|
| 333 | - if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) |
|
| 334 | - { |
|
| 335 | - if ($editable) |
|
| 336 | - { |
|
| 337 | - $url = api_get_self(); |
|
| 338 | - $urlparameters = ''; |
|
| 339 | - foreach($_GET as $key => $value) |
|
| 340 | - { |
|
| 341 | - $parameter[$key] = $value; |
|
| 342 | - } |
|
| 343 | - $parameter['action']='manage_rights'; |
|
| 344 | - $parameter['do']='revoke'; |
|
| 345 | - $parameter['permission']=$permission; |
|
| 346 | - $parameter['tool']=$tool; |
|
| 347 | - $parameter['user_id']=$user_id; |
|
| 348 | - foreach ($parameter as $key=>$value) |
|
| 349 | - { |
|
| 350 | - $urlparameters .= $key . '=' . $value . '&'; |
|
| 351 | - } |
|
| 352 | - $url = $url . '?' . $urlparameters; |
|
| 353 | - |
|
| 354 | - echo "\t\t\t <a href=\"".$url."\">"; |
|
| 355 | - } |
|
| 356 | - echo "<img src=\"../img/checkbox_on2.gif\" border=\"0\"/ title=\"".get_lang('UserHasPermission')."\">"; |
|
| 357 | - if ($editable) { |
|
| 358 | - echo "</a>"; |
|
| 359 | - } |
|
| 360 | - } else { |
|
| 361 | - if ($editable) { |
|
| 362 | - $url = api_get_self(); |
|
| 363 | - $urlparameters = ''; |
|
| 364 | - foreach ($_GET as $key=>$value) { |
|
| 365 | - $parameter[$key]=$value; |
|
| 366 | - } |
|
| 367 | - $parameter['action']='manage_rights'; |
|
| 368 | - $parameter['do']='grant'; |
|
| 369 | - $parameter['permission']=$permission; |
|
| 370 | - $parameter['tool']=$tool; |
|
| 371 | - $parameter['user_id']=$user_id; |
|
| 372 | - foreach ($parameter as $key=>$value) { |
|
| 373 | - $urlparameters .= $key . '=' . $value . '&'; |
|
| 374 | - } |
|
| 375 | - $url=$url.'?'.$urlparameters; |
|
| 376 | - |
|
| 377 | - //echo "\t\t\t <a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=grant&permission=$permission&tool=$tool\">"; |
|
| 378 | - echo "\t\t\t <a href=\"".$url."\">"; |
|
| 379 | - } |
|
| 380 | - echo "<img src=\"../img/wrong.gif\" border=\"0\"/ title=\"".get_lang('UserHasPermissionNot')."\">"; |
|
| 381 | - if ($editable) { |
|
| 382 | - echo "</a>"; |
|
| 383 | - } |
|
| 384 | - } |
|
| 385 | - } |
|
| 386 | - } |
|
| 321 | + if ($course_admin) |
|
| 322 | + { |
|
| 323 | + echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
|
| 324 | + } |
|
| 325 | + else |
|
| 326 | + { |
|
| 327 | + if (!empty($inherited_permissions) and in_array($permission,$inherited_permissions[$tool])) |
|
| 328 | + { |
|
| 329 | + echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
|
| 330 | + } |
|
| 331 | + else |
|
| 332 | + { |
|
| 333 | + if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) |
|
| 334 | + { |
|
| 335 | + if ($editable) |
|
| 336 | + { |
|
| 337 | + $url = api_get_self(); |
|
| 338 | + $urlparameters = ''; |
|
| 339 | + foreach($_GET as $key => $value) |
|
| 340 | + { |
|
| 341 | + $parameter[$key] = $value; |
|
| 342 | + } |
|
| 343 | + $parameter['action']='manage_rights'; |
|
| 344 | + $parameter['do']='revoke'; |
|
| 345 | + $parameter['permission']=$permission; |
|
| 346 | + $parameter['tool']=$tool; |
|
| 347 | + $parameter['user_id']=$user_id; |
|
| 348 | + foreach ($parameter as $key=>$value) |
|
| 349 | + { |
|
| 350 | + $urlparameters .= $key . '=' . $value . '&'; |
|
| 351 | + } |
|
| 352 | + $url = $url . '?' . $urlparameters; |
|
| 353 | + |
|
| 354 | + echo "\t\t\t <a href=\"".$url."\">"; |
|
| 355 | + } |
|
| 356 | + echo "<img src=\"../img/checkbox_on2.gif\" border=\"0\"/ title=\"".get_lang('UserHasPermission')."\">"; |
|
| 357 | + if ($editable) { |
|
| 358 | + echo "</a>"; |
|
| 359 | + } |
|
| 360 | + } else { |
|
| 361 | + if ($editable) { |
|
| 362 | + $url = api_get_self(); |
|
| 363 | + $urlparameters = ''; |
|
| 364 | + foreach ($_GET as $key=>$value) { |
|
| 365 | + $parameter[$key]=$value; |
|
| 366 | + } |
|
| 367 | + $parameter['action']='manage_rights'; |
|
| 368 | + $parameter['do']='grant'; |
|
| 369 | + $parameter['permission']=$permission; |
|
| 370 | + $parameter['tool']=$tool; |
|
| 371 | + $parameter['user_id']=$user_id; |
|
| 372 | + foreach ($parameter as $key=>$value) { |
|
| 373 | + $urlparameters .= $key . '=' . $value . '&'; |
|
| 374 | + } |
|
| 375 | + $url=$url.'?'.$urlparameters; |
|
| 376 | + |
|
| 377 | + //echo "\t\t\t <a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=grant&permission=$permission&tool=$tool\">"; |
|
| 378 | + echo "\t\t\t <a href=\"".$url."\">"; |
|
| 379 | + } |
|
| 380 | + echo "<img src=\"../img/wrong.gif\" border=\"0\"/ title=\"".get_lang('UserHasPermissionNot')."\">"; |
|
| 381 | + if ($editable) { |
|
| 382 | + echo "</a>"; |
|
| 383 | + } |
|
| 384 | + } |
|
| 385 | + } |
|
| 386 | + } |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | |
@@ -394,41 +394,41 @@ discard block |
||
| 394 | 394 | */ |
| 395 | 395 | function display_role_list($current_course_roles, $current_platform_roles) |
| 396 | 396 | { |
| 397 | - global $setting_visualisation; |
|
| 397 | + global $setting_visualisation; |
|
| 398 | 398 | $course_id = api_get_course_int_id(); |
| 399 | 399 | |
| 400 | - $coures_roles_table=Database::get_course_table(TABLE_ROLE); |
|
| 401 | - |
|
| 402 | - // course roles |
|
| 403 | - $sql="SELECT * FROM $coures_roles_table WHERE c_id = $course_id "; |
|
| 404 | - $result=Database::query($sql); |
|
| 405 | - while ($row=Database::fetch_array($result)) |
|
| 406 | - { |
|
| 407 | - if (in_array($row['role_id'], $current_course_roles)) |
|
| 408 | - { |
|
| 409 | - $checked='checked'; |
|
| 410 | - $image='checkbox_on2.gif'; |
|
| 411 | - $action='revoke'; |
|
| 412 | - } |
|
| 413 | - else |
|
| 414 | - { |
|
| 415 | - $checked=''; |
|
| 416 | - $image='wrong.gif'; |
|
| 417 | - $action='grant'; |
|
| 418 | - } |
|
| 419 | - if ($setting_visualisation=='checkbox') |
|
| 420 | - { |
|
| 421 | - echo "<input type=\"checkbox\" name=\"role*course*".$row['role_id']."\" $checked>"; |
|
| 422 | - } |
|
| 423 | - if ($setting_visualisation=='image') |
|
| 424 | - { |
|
| 425 | - echo "<a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=$action&role=".$row['role_id']."&scope=course\"><img src=\"../img/".$image."\" border=\"0\"/></a>"; |
|
| 426 | - } |
|
| 427 | - |
|
| 428 | - |
|
| 429 | - echo $row['role_name']." <a href=\"../permissions/roles.php?role_id=".$row['role_id']."&scope=course\"><img src=\"../img/edit.gif\" /></a><br />\n"; |
|
| 430 | - echo $row['role_comment']."<br />\n"; |
|
| 431 | - } |
|
| 400 | + $coures_roles_table=Database::get_course_table(TABLE_ROLE); |
|
| 401 | + |
|
| 402 | + // course roles |
|
| 403 | + $sql="SELECT * FROM $coures_roles_table WHERE c_id = $course_id "; |
|
| 404 | + $result=Database::query($sql); |
|
| 405 | + while ($row=Database::fetch_array($result)) |
|
| 406 | + { |
|
| 407 | + if (in_array($row['role_id'], $current_course_roles)) |
|
| 408 | + { |
|
| 409 | + $checked='checked'; |
|
| 410 | + $image='checkbox_on2.gif'; |
|
| 411 | + $action='revoke'; |
|
| 412 | + } |
|
| 413 | + else |
|
| 414 | + { |
|
| 415 | + $checked=''; |
|
| 416 | + $image='wrong.gif'; |
|
| 417 | + $action='grant'; |
|
| 418 | + } |
|
| 419 | + if ($setting_visualisation=='checkbox') |
|
| 420 | + { |
|
| 421 | + echo "<input type=\"checkbox\" name=\"role*course*".$row['role_id']."\" $checked>"; |
|
| 422 | + } |
|
| 423 | + if ($setting_visualisation=='image') |
|
| 424 | + { |
|
| 425 | + echo "<a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=$action&role=".$row['role_id']."&scope=course\"><img src=\"../img/".$image."\" border=\"0\"/></a>"; |
|
| 426 | + } |
|
| 427 | + |
|
| 428 | + |
|
| 429 | + echo $row['role_name']." <a href=\"../permissions/roles.php?role_id=".$row['role_id']."&scope=course\"><img src=\"../img/edit.gif\" /></a><br />\n"; |
|
| 430 | + echo $row['role_comment']."<br />\n"; |
|
| 431 | + } |
|
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | /** |
@@ -442,24 +442,24 @@ discard block |
||
| 442 | 442 | */ |
| 443 | 443 | function get_roles($content,$id, $scope='course') { |
| 444 | 444 | $course_id = api_get_course_int_id(); |
| 445 | - if ($content=='user') { |
|
| 446 | - $table=Database::get_course_table(TABLE_ROLE_USER); |
|
| 447 | - $id_field = user_id; |
|
| 448 | - } |
|
| 449 | - if ($content=='group') { |
|
| 450 | - $table=Database::get_course_table(TABLE_ROLE_GROUP); |
|
| 451 | - $id_field = 'group_id'; |
|
| 452 | - } |
|
| 453 | - $table_role=Database::get_course_table(TABLE_ROLE); |
|
| 454 | - |
|
| 455 | - $current_roles=array(); |
|
| 456 | - //$sql="SELECT role.role_id FROM $table role_group_user, $table_role role WHERE role_group_user.$id_field = '$id' AND role_group_user.role_id=role.role_id AND role_group_user.scope='".$scope."'";$sql="SELECT role.role_id FROM $table role_group_user, $table_role role WHERE role_group_user.$id_field = '$id' AND role_group_user.role_id=role.role_id AND role_group_user.scope='".$scope."'"; |
|
| 457 | - $sql="SELECT role_id FROM $table WHERE c_id = $course_id AND $id_field = '$id' AND scope='".$scope."'"; |
|
| 458 | - $result=Database::query($sql); |
|
| 459 | - while ($row=Database::fetch_array($result)) { |
|
| 460 | - $current_roles[]=$row['role_id']; |
|
| 461 | - } |
|
| 462 | - return $current_roles; |
|
| 445 | + if ($content=='user') { |
|
| 446 | + $table=Database::get_course_table(TABLE_ROLE_USER); |
|
| 447 | + $id_field = user_id; |
|
| 448 | + } |
|
| 449 | + if ($content=='group') { |
|
| 450 | + $table=Database::get_course_table(TABLE_ROLE_GROUP); |
|
| 451 | + $id_field = 'group_id'; |
|
| 452 | + } |
|
| 453 | + $table_role=Database::get_course_table(TABLE_ROLE); |
|
| 454 | + |
|
| 455 | + $current_roles=array(); |
|
| 456 | + //$sql="SELECT role.role_id FROM $table role_group_user, $table_role role WHERE role_group_user.$id_field = '$id' AND role_group_user.role_id=role.role_id AND role_group_user.scope='".$scope."'";$sql="SELECT role.role_id FROM $table role_group_user, $table_role role WHERE role_group_user.$id_field = '$id' AND role_group_user.role_id=role.role_id AND role_group_user.scope='".$scope."'"; |
|
| 457 | + $sql="SELECT role_id FROM $table WHERE c_id = $course_id AND $id_field = '$id' AND scope='".$scope."'"; |
|
| 458 | + $result=Database::query($sql); |
|
| 459 | + while ($row=Database::fetch_array($result)) { |
|
| 460 | + $current_roles[]=$row['role_id']; |
|
| 461 | + } |
|
| 462 | + return $current_roles; |
|
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | /** |
@@ -472,25 +472,25 @@ discard block |
||
| 472 | 472 | $course_id = api_get_course_int_id(); |
| 473 | 473 | $course_id_condition = " WHERE c_id = $course_id "; |
| 474 | 474 | |
| 475 | - if ($content=='course') |
|
| 476 | - { |
|
| 477 | - $table_role=Database::get_course_table(TABLE_ROLE); |
|
| 478 | - } |
|
| 479 | - if ($content=='platform') |
|
| 480 | - { |
|
| 481 | - $table_role=Database::get_main_table(TABLE_ROLE); |
|
| 482 | - $course_id_condition = ''; |
|
| 483 | - } |
|
| 484 | - |
|
| 485 | - $current_roles=array(); |
|
| 486 | - $sql="SELECT * FROM $table_role $course_id_condition "; |
|
| 487 | - $result=Database::query($sql); |
|
| 488 | - while ($row=Database::fetch_array($result)) |
|
| 489 | - { |
|
| 490 | - $roles[]=$row; |
|
| 491 | - } |
|
| 492 | - |
|
| 493 | - return $roles; |
|
| 475 | + if ($content=='course') |
|
| 476 | + { |
|
| 477 | + $table_role=Database::get_course_table(TABLE_ROLE); |
|
| 478 | + } |
|
| 479 | + if ($content=='platform') |
|
| 480 | + { |
|
| 481 | + $table_role=Database::get_main_table(TABLE_ROLE); |
|
| 482 | + $course_id_condition = ''; |
|
| 483 | + } |
|
| 484 | + |
|
| 485 | + $current_roles=array(); |
|
| 486 | + $sql="SELECT * FROM $table_role $course_id_condition "; |
|
| 487 | + $result=Database::query($sql); |
|
| 488 | + while ($row=Database::fetch_array($result)) |
|
| 489 | + { |
|
| 490 | + $roles[]=$row; |
|
| 491 | + } |
|
| 492 | + |
|
| 493 | + return $roles; |
|
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | |
@@ -506,34 +506,34 @@ discard block |
||
| 506 | 506 | */ |
| 507 | 507 | function get_roles_permissions($content,$id, $scope='course') { |
| 508 | 508 | $course_id = api_get_course_int_id(); |
| 509 | - if ($content == 'user') { |
|
| 510 | - $table=Database::get_course_table(TABLE_ROLE_USER); |
|
| 511 | - $id_field = 'user_id'; |
|
| 512 | - } |
|
| 513 | - |
|
| 514 | - if ($content == 'group') { |
|
| 515 | - $table = Database::get_course_table(TABLE_ROLE_GROUP); |
|
| 516 | - $id_field = 'group_id'; |
|
| 517 | - } |
|
| 518 | - |
|
| 519 | - // course roles or platform roles |
|
| 520 | - $scope = 'course'; |
|
| 521 | - if ($scope == 'course') { |
|
| 522 | - $table_role = Database::get_course_table(TABLE_ROLE); |
|
| 523 | - $table_role_permissions = Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
| 509 | + if ($content == 'user') { |
|
| 510 | + $table=Database::get_course_table(TABLE_ROLE_USER); |
|
| 511 | + $id_field = 'user_id'; |
|
| 512 | + } |
|
| 513 | + |
|
| 514 | + if ($content == 'group') { |
|
| 515 | + $table = Database::get_course_table(TABLE_ROLE_GROUP); |
|
| 516 | + $id_field = 'group_id'; |
|
| 517 | + } |
|
| 518 | + |
|
| 519 | + // course roles or platform roles |
|
| 520 | + $scope = 'course'; |
|
| 521 | + if ($scope == 'course') { |
|
| 522 | + $table_role = Database::get_course_table(TABLE_ROLE); |
|
| 523 | + $table_role_permissions = Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
| 524 | 524 | |
| 525 | 525 | $role_condition = " role.c_id = $course_id AND role_permissions.c_id = $course_id AND "; |
| 526 | - } |
|
| 526 | + } |
|
| 527 | 527 | |
| 528 | - if ($scope == 'platform') { |
|
| 529 | - $table_role = Database::get_main_table(TABLE_ROLE); |
|
| 530 | - $table_role_permissions = Database::get_main_table(TABLE_ROLE_PERMISSION); |
|
| 528 | + if ($scope == 'platform') { |
|
| 529 | + $table_role = Database::get_main_table(TABLE_ROLE); |
|
| 530 | + $table_role_permissions = Database::get_main_table(TABLE_ROLE_PERMISSION); |
|
| 531 | 531 | $role_condition = ''; |
| 532 | - } |
|
| 532 | + } |
|
| 533 | 533 | |
| 534 | - $current_roles = array(); |
|
| 534 | + $current_roles = array(); |
|
| 535 | 535 | |
| 536 | - $sql = " |
|
| 536 | + $sql = " |
|
| 537 | 537 | SELECT * |
| 538 | 538 | FROM |
| 539 | 539 | " . $table . " role_group_user, |
@@ -547,12 +547,12 @@ discard block |
||
| 547 | 547 | role_group_user.role_id = role.role_id AND |
| 548 | 548 | role.role_id = role_permissions.role_id"; |
| 549 | 549 | |
| 550 | - $result = Database::query($sql); |
|
| 550 | + $result = Database::query($sql); |
|
| 551 | 551 | $current_role_permissions = array(); |
| 552 | - while ($row=Database::fetch_array($result)) { |
|
| 553 | - $current_role_permissions[$row['tool']][]=$row['action']; |
|
| 552 | + while ($row=Database::fetch_array($result)) { |
|
| 553 | + $current_role_permissions[$row['tool']][]=$row['action']; |
|
| 554 | 554 | } |
| 555 | - return $current_role_permissions; |
|
| 555 | + return $current_role_permissions; |
|
| 556 | 556 | } |
| 557 | 557 | |
| 558 | 558 | /** |
@@ -566,34 +566,34 @@ discard block |
||
| 566 | 566 | |
| 567 | 567 | function assign_role($content, $action, $id, $role_id, $scope='course') { |
| 568 | 568 | $course_id = api_get_course_int_id(); |
| 569 | - // Which database are we using (depending on the $content parameter) |
|
| 570 | - if ($content=='user') { |
|
| 571 | - $table=Database::get_course_table(TABLE_ROLE_USER); |
|
| 572 | - $id_field = 'user_id'; |
|
| 573 | - } elseif($content=='group') { |
|
| 574 | - $table=Database::get_course_table(TABLE_ROLE_GROUP); |
|
| 575 | - $id_field = 'group_id'; |
|
| 576 | - } else { |
|
| 577 | - return get_lang('Error'); |
|
| 578 | - } |
|
| 579 | - |
|
| 580 | - // grating a right |
|
| 581 | - if ($action=='grant') { |
|
| 582 | - $sql="INSERT INTO $table (c_id, role_id, scope, $id_field) VALUES ($course_id, '".Database::escape_string($role_id)."','".Database::escape_string($scope)."','".Database::escape_string($id)."')"; |
|
| 583 | - $result=Database::query($sql); |
|
| 584 | - if ($result) { |
|
| 585 | - $result_message=get_lang('RoleGranted'); |
|
| 586 | - } |
|
| 587 | - } |
|
| 569 | + // Which database are we using (depending on the $content parameter) |
|
| 570 | + if ($content=='user') { |
|
| 571 | + $table=Database::get_course_table(TABLE_ROLE_USER); |
|
| 572 | + $id_field = 'user_id'; |
|
| 573 | + } elseif($content=='group') { |
|
| 574 | + $table=Database::get_course_table(TABLE_ROLE_GROUP); |
|
| 575 | + $id_field = 'group_id'; |
|
| 576 | + } else { |
|
| 577 | + return get_lang('Error'); |
|
| 578 | + } |
|
| 579 | + |
|
| 580 | + // grating a right |
|
| 581 | + if ($action=='grant') { |
|
| 582 | + $sql="INSERT INTO $table (c_id, role_id, scope, $id_field) VALUES ($course_id, '".Database::escape_string($role_id)."','".Database::escape_string($scope)."','".Database::escape_string($id)."')"; |
|
| 583 | + $result=Database::query($sql); |
|
| 584 | + if ($result) { |
|
| 585 | + $result_message=get_lang('RoleGranted'); |
|
| 586 | + } |
|
| 587 | + } |
|
| 588 | 588 | |
| 589 | - if ($action=='revoke') { |
|
| 590 | - $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND role_id='".Database::escape_string($role_id)."'"; |
|
| 591 | - $result=Database::query($sql); |
|
| 592 | - if ($result) { |
|
| 593 | - $result_message=get_lang('RoleRevoked'); |
|
| 594 | - } |
|
| 595 | - } |
|
| 596 | - return $result_message; |
|
| 589 | + if ($action=='revoke') { |
|
| 590 | + $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND role_id='".Database::escape_string($role_id)."'"; |
|
| 591 | + $result=Database::query($sql); |
|
| 592 | + if ($result) { |
|
| 593 | + $result_message=get_lang('RoleRevoked'); |
|
| 594 | + } |
|
| 595 | + } |
|
| 596 | + return $result_message; |
|
| 597 | 597 | } |
| 598 | 598 | |
| 599 | 599 | |
@@ -603,21 +603,21 @@ discard block |
||
| 603 | 603 | */ |
| 604 | 604 | function permission_array_merge($array1, $array2) |
| 605 | 605 | { |
| 606 | - foreach ($array2 as $tool=>$permissions) |
|
| 607 | - { |
|
| 608 | - foreach ($permissions as $permissionkey=>$permissionvalue) |
|
| 609 | - { |
|
| 610 | - $array1[$tool][]=$permissionvalue; |
|
| 611 | - } |
|
| 612 | - } |
|
| 613 | - return $array1; |
|
| 606 | + foreach ($array2 as $tool=>$permissions) |
|
| 607 | + { |
|
| 608 | + foreach ($permissions as $permissionkey=>$permissionvalue) |
|
| 609 | + { |
|
| 610 | + $array1[$tool][]=$permissionvalue; |
|
| 611 | + } |
|
| 612 | + } |
|
| 613 | + return $array1; |
|
| 614 | 614 | } |
| 615 | 615 | |
| 616 | 616 | |
| 617 | 617 | function my_print_r($array) |
| 618 | 618 | { |
| 619 | - echo '<pre>'; |
|
| 620 | - print_r($array); |
|
| 621 | - echo '</pre>'; |
|
| 619 | + echo '<pre>'; |
|
| 620 | + print_r($array); |
|
| 621 | + echo '</pre>'; |
|
| 622 | 622 | } |
| 623 | 623 | ?> |
@@ -17,17 +17,17 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | function updateProgress($div_id, $upload_id, $waitAfterupload = false) { |
| 19 | 19 | |
| 20 | - $objResponse = new xajaxResponse(); |
|
| 21 | - $ul_info = uploadprogress_get_info($upload_id); |
|
| 22 | - $percent = intval($ul_info['bytes_uploaded']*100/$ul_info['bytes_total']); |
|
| 23 | - if($waitAfterupload && $ul_info['est_sec']<2) { |
|
| 24 | - $percent = 100; |
|
| 25 | - $objResponse->addAssign($div_id.'_label' , 'innerHTML', get_lang('UploadFile').' : '.$percent.' %'); |
|
| 26 | - $objResponse->addAssign($div_id.'_waiter_frame','innerHTML', Display::return_icon('progress_bar.gif')); |
|
| 27 | - $objResponse->addScript('clearInterval("myUpload.__progress_bar_interval")'); |
|
| 28 | - } |
|
| 29 | - $objResponse->addAssign($div_id.'_label', 'innerHTML', get_lang('UploadFile').' : '.$percent.' %'); |
|
| 30 | - $objResponse->addAssign($div_id.'_filled', 'style.width', $percent.'%'); |
|
| 20 | + $objResponse = new xajaxResponse(); |
|
| 21 | + $ul_info = uploadprogress_get_info($upload_id); |
|
| 22 | + $percent = intval($ul_info['bytes_uploaded']*100/$ul_info['bytes_total']); |
|
| 23 | + if($waitAfterupload && $ul_info['est_sec']<2) { |
|
| 24 | + $percent = 100; |
|
| 25 | + $objResponse->addAssign($div_id.'_label' , 'innerHTML', get_lang('UploadFile').' : '.$percent.' %'); |
|
| 26 | + $objResponse->addAssign($div_id.'_waiter_frame','innerHTML', Display::return_icon('progress_bar.gif')); |
|
| 27 | + $objResponse->addScript('clearInterval("myUpload.__progress_bar_interval")'); |
|
| 28 | + } |
|
| 29 | + $objResponse->addAssign($div_id.'_label', 'innerHTML', get_lang('UploadFile').' : '.$percent.' %'); |
|
| 30 | + $objResponse->addAssign($div_id.'_filled', 'style.width', $percent.'%'); |
|
| 31 | 31 | |
| 32 | - return $objResponse; |
|
| 32 | + return $objResponse; |
|
| 33 | 33 | } |