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-18 05:33:44 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2008-09-01 08:21:39 +00:00
|
|
|
class repository_upload extends repository {
|
|
|
|
|
2008-09-18 05:33:44 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @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);
|
2008-12-02 07:05:15 +00:00
|
|
|
$itemid = optional_param('itemid', '', PARAM_INT);
|
2008-09-01 08:21:39 +00:00
|
|
|
if($action=='upload'){
|
2008-09-05 02:51:23 +00:00
|
|
|
$filepath = '/'.uniqid().'/';
|
2008-12-02 07:05:15 +00:00
|
|
|
$this->info = repository::store_to_filepool('repo_upload_file', 'user_draft', $filepath, $itemid);
|
2008-09-01 08:21:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-18 05:33:44 +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();
|
|
|
|
}
|
|
|
|
|
2008-09-18 05:33:44 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @global <type> $CFG
|
|
|
|
* @global <type> $action
|
|
|
|
* @param <type> $path
|
|
|
|
* @param <type> $search
|
|
|
|
* @return <type>
|
|
|
|
*/
|
2009-02-18 06:52:54 +00:00
|
|
|
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();
|
2008-09-02 04:05:11 +00:00
|
|
|
$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-18 05:33:44 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2008-09-01 08:21:39 +00:00
|
|
|
public function print_listing() {
|
2008-09-18 05:43:38 +00:00
|
|
|
// will be used in non-javascript file picker
|
2008-09-01 08:21:39 +00:00
|
|
|
}
|
|
|
|
|
2008-09-18 05:33:44 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @return <type>
|
|
|
|
*/
|
2008-09-01 08:21:39 +00:00
|
|
|
public function print_search() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-09-18 05:33:44 +00:00
|
|
|
/**
|
|
|
|
*
|
2008-11-26 07:03:10 +00:00
|
|
|
* @return <type>
|
2008-09-18 05:33:44 +00:00
|
|
|
*/
|
2008-09-02 04:05:11 +00:00
|
|
|
public function get_name(){
|
|
|
|
return get_string('repositoryname', 'repository_upload');;
|
|
|
|
}
|
2008-09-01 08:21:39 +00:00
|
|
|
}
|
|
|
|
?>
|