moodle/repository/upload/repository.class.php

94 lines
2.2 KiB
PHP
Raw Normal View History

2008-09-01 08:21:39 +00:00
<?php
/**
* repository_upload class
* A subclass of repository, which is used to upload file
*
* @version $Id$
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*/
/**
*
*/
2008-09-01 08:21:39 +00:00
class repository_upload extends repository {
/**
*
* @global <type> $SESSION
* @global <type> $action
* @global <type> $CFG
* @param <type> $repositoryid
* @param <type> $context
* @param <type> $options
*/
2008-09-01 08:21:39 +00:00
public function __construct($repositoryid, $context = SITEID, $options = array()){
global $SESSION, $action, $CFG;
parent::__construct($repositoryid, $context, $options);
$itemid = optional_param('itemid', '', PARAM_INT);
2008-09-01 08:21:39 +00:00
if($action=='upload'){
$filepath = '/'.uniqid().'/';
$this->info = repository::store_to_filepool('repo_upload_file', 'user_draft', $filepath, $itemid);
2008-09-01 08:21:39 +00:00
}
}
/**
*
* @global <type> $SESSION
* @param <type> $ajax
* @return <type>
*/
2008-09-01 08:21:39 +00:00
public function print_login($ajax = true) {
global $SESSION;
return $this->get_listing();
}
/**
*
* @global <type> $CFG
* @global <type> $action
* @param <type> $path
* @param <type> $search
* @return <type>
*/
public function get_listing($path='', $page='') {
2008-09-01 08:21:39 +00:00
global $CFG, $action;
if($action=='upload'){
return $this->info;
}else{
$ret = array();
$ret['nologin'] = true;
$ret['nosearch'] = true;
2008-09-01 08:21:39 +00:00
// define upload form in file picker
$ret['upload'] = array('label'=>get_string('attachment', 'repository'), 'id'=>'repo-form');
$ret['manage'] = $CFG->wwwroot .'/files/index.php'; // temporary
$ret['list'] = array();
$ret['dynload'] = false;
return $ret;
}
}
/**
*
*/
2008-09-01 08:21:39 +00:00
public function print_listing() {
// will be used in non-javascript file picker
2008-09-01 08:21:39 +00:00
}
/**
*
* @return <type>
*/
2008-09-01 08:21:39 +00:00
public function print_search() {
return true;
}
/**
*
* @return <type>
*/
public function get_name(){
return get_string('repositoryname', 'repository_upload');;
}
2008-09-01 08:21:39 +00:00
}
?>