Example #1
0
function lightboxgallery_allowed_filetype($element)
{
    $extension = lightboxgallery_get_file_extension($element);
    return in_array($extension, lightboxgallery_allowed_filetypes());
}
                            $resizeoption = $formdata->resize;
                        }
                    }
                    if ($resizeoption > 0) {
                        $resizeoptions = lightboxgallery_resize_options();
                        list($width, $height) = explode('x', $resizeoptions[$resizeoption]);
                        if ($uploadedimage->resize($width, $height)) {
                            $messages[] = get_string('imageresized', 'lightboxgallery', $resizeoptions[$resizeoption]);
                        }
                    }
                    if (has_capability('mod/lightboxgallery:edit', $context)) {
                        $messages[] = '<a href="' . $CFG->wwwroot . '/mod/lightboxgallery/imageedit.php?id=' . $gallery->id . '&amp;image=' . $filename . '">' . get_string('editimage', 'lightboxgallery') . '</a>';
                    }
                } else {
                    unlink($CFG->dataroot . '/' . $uploaddir . '/' . $filename);
                    error(get_string('erroruploadimage', 'lightboxgallery') . ' (' . implode(', ', lightboxgallery_allowed_filetypes()) . ')', $CFG->wwwroot . '/mod/lightboxgallery/imageadd.php?id=' . $gallery->id);
                }
            }
            $table = new object();
            $table->width = '*';
            $table->align = array('center', 'left');
            $table->data[] = array($thumb, '<ul id="messages"><li>' . implode('</li><li>', $messages) . '</li></ul>');
            echo '<br />';
            print_table($table);
            echo '<br />';
            add_to_log($course->id, 'lightboxgallery', 'addimage', 'view.php?id=' . $cm->id, $filename, $cm->id, $USER->id);
        }
    }
}
echo '<div style="margin-left: auto; margin-right: auto; font-size: 0.8em; width: 635px;">';
$mform->display();
function lightboxgallery_allowed_filetype($element)
{
    $extension = strtolower(substr(strrchr($element, '.'), 1));
    return in_array($extension, lightboxgallery_allowed_filetypes());
}