break;
 case 'unzip':
     $zipper = new zip_packer();
     $file = $fs->get_file($user_context->id, 'user', 'draft', $itemid, $draftpath, $filename);
     if ($newfile = $file->extract_to_storage($zipper, $user_context->id, 'user', 'draft', $itemid, $draftpath, $USER->id)) {
         $str = get_string('unzipped', 'repository');
     } else {
         $str = get_string('cannotunzip', 'error');
     }
     $home_url->param('action', 'browse');
     $home_url->param('draftpath', $draftpath);
     redirect($home_url, $str);
     break;
 case 'movefile':
     if (!empty($targetpath)) {
         repository::update_draftfile($itemid, $draftpath, $filename, array('filepath' => $targetpath));
         $home_url->param('action', 'browse');
         $home_url->param('draftpath', $targetpath);
         redirect($home_url);
     }
     echo $OUTPUT->header();
     echo $OUTPUT->container_start();
     echo html_writer::link($home_url, get_string('back', 'repository'));
     echo $OUTPUT->container_end();
     $data = new stdClass();
     $home_url->param('action', 'movefile');
     $home_url->param('draftpath', $draftpath);
     $home_url->param('filename', $filename);
     file_get_drafarea_folders($itemid, '/', $data);
     print_draft_area_tree($data, true, $home_url);
     echo $OUTPUT->footer();
Beispiel #2
0
            $updatedata['author'] = $v;
        }
        try {
            repository::update_draftfile($draftid, $filepath, $filename, $updatedata);
        } catch (moodle_exception $e) {
            die(json_encode((object)array('error' => $e->getMessage())));
        }
        die(json_encode((object)array('filepath' => $newfilepath)));

    case 'updatedir':
        $filepath = required_param('filepath', PARAM_PATH);
        $newdirname = required_param('newdirname', PARAM_FILE);
        $parent = required_param('newfilepath', PARAM_PATH);
        $newfilepath = clean_param($parent . '/' . $newdirname . '/', PARAM_PATH);
        try {
            repository::update_draftfile($draftid, $filepath, '.', array('filepath' => $newfilepath));
        } catch (moodle_exception $e) {
            die(json_encode((object)array('error' => $e->getMessage())));
        }
        die(json_encode((object)array('filepath' => $parent)));

    case 'zip':
        $filepath = required_param('filepath', PARAM_PATH);

        $zipper = get_file_packer('application/zip');
        $fs = get_file_storage();

        $file = $fs->get_file($user_context->id, 'user', 'draft', $draftid, $filepath, '.');

        $parent_path = $file->get_parent_directory()->get_filepath();