if (!confirm_sesskey($skey)) { error("Session key error!!!"); } if (!$gallery->user_allowed_upload()) { error(get_string('unallowedupload', 'imagegallery'), "{$CFG->wwwroot}/mod/imagegallery/view.php?id={$gallery->cm->id}"); } if (!($category = get_record("imagegallery_categories", "id", $catid))) { $category = new stdClass(); $category->id = 0; } $strsuccess = ''; if ($data = data_submitted()) { include $CFG->libdir . '/filelib.php'; include $CFG->libdir . '/uploadlib.php'; // Process uploaded images or uploaded zip file. $dir = $gallery->file_area($category->id); $um = new upload_manager('userfile', false, true, $gallery->course, false, 0); if ($um->process_file_uploads($dir)) { $file = new stdClass(); $file->galleryid = $gallery->module->id; $file->categoryid = $catid; $file->userid = $USER->id; $file->name = $um->get_new_filename(); $file->path = $um->get_new_filepath(); if (preg_match($GALLERY_ALLOWED_TYPES, $file->name)) { // Check if uploaded file was a zip package. $icon = mimeinfo('icon', $file->name); if ($icon != 'zip.gif') { // Single file. $file->size = filesize($file->path); $file->mime = mimeinfo('type', $file->name);
$action = 'delete'; } else { $action = optional_param('action', '', PARAM_ALPHA); } } } if (!confirm_sesskey($sesskey)) { error("Session key error!!!"); } $gallery = new modImagegallery(); // Instantiate imagegallery object. if (!$gallery->isteacher) { error("You're not allowed to use this page!!!", "{$CFG->wwwroot}/mod/imagegallery/view.php?id={$gallery->cm->id}"); } // Check directory if (!$gallery->file_area()) { error("Could not create necessary directory!", "{$CFG->wwwroot}/course/view.php?id={$gallery->course->id}"); } if ($data = data_submitted()) { if (empty($data->cancel)) { $form = new stdClass(); $form->galleryid = clean_param($data->galleryid, PARAM_INT); $form->userid = clean_param($USER->id, PARAM_INT); switch ($data->action) { case 'add': $form->timecreated = time(); $form->timemodified = time(); $form->name = addslashes(trim(strip_tags($data->name))); $form->description = addslashes(trim(strip_tags($data->description))); if (!empty($form->name)) { // Insert only if it doesn't exists.
<?php // $Id: view.php,v 1.4 2006/10/19 12:06:28 janne Exp $ /// This page prints a particular instance of learningdiary require_once "../../config.php"; require_once "lib.php"; //include_once ("slideshow.php"); $edit = optional_param('edit', '', PARAM_ALPHA); $pageid = optional_param('page', 0, PARAM_INT); $catid = optional_param('catid', '0', PARAM_INT); $sort = optional_param('sort', 'name', PARAM_ALPHA); $dir = optional_param('dir', 'asc', PARAM_ALPHA); $gallery = new modImagegallery(); // Instantiate imagegallery object. // Check directory if (!$gallery->file_area()) { error("Could not create necessary directory!", "{$CFG->wwwroot}/course/view.php?id={$gallery->course->id}"); } if (!isset($USER->editing)) { $USER->editing = false; } $strimagegalleries = get_string("modulenameplural", "imagegallery"); $strimagegallery = get_string("modulename", "imagegallery"); if ($gallery->user_allowed_editing()) { if ($edit == 'on') { $USER->editing = true; } else { if ($edit == 'off') { $USER->editing = false; } }