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
|
|
|
|
*/
|
|
|
|
|
|
|
|
class repository_upload extends repository {
|
|
|
|
|
2008-09-18 05:33:44 +00:00
|
|
|
/**
|
|
|
|
*
|
2009-04-21 05:53:35 +00:00
|
|
|
* @global object $SESSION
|
|
|
|
* @global string $action
|
|
|
|
* @global object $CFG
|
|
|
|
* @param int $repositoryid
|
|
|
|
* @param object $context
|
|
|
|
* @param array $options
|
2008-09-18 05:33:44 +00:00
|
|
|
*/
|
2008-09-01 08:21:39 +00:00
|
|
|
public function __construct($repositoryid, $context = SITEID, $options = array()){
|
2009-06-18 06:31:51 +00:00
|
|
|
global $_FILES, $SESSION, $action, $CFG;
|
2008-09-01 08:21:39 +00:00
|
|
|
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'){
|
2009-04-20 08:59:00 +00:00
|
|
|
$filepath = '/';
|
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
|
|
|
/**
|
|
|
|
*
|
2009-04-21 05:53:35 +00:00
|
|
|
* @global object $SESSION
|
|
|
|
* @param boolean $ajax
|
|
|
|
* @return mixed
|
2008-09-18 05:33:44 +00:00
|
|
|
*/
|
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
|
|
|
/**
|
|
|
|
*
|
2009-04-21 05:53:35 +00:00
|
|
|
* @global object $CFG
|
|
|
|
* @global string $action
|
|
|
|
* @param mixed $path
|
|
|
|
* @param string $search
|
|
|
|
* @return array
|
2008-09-18 05:33:44 +00:00
|
|
|
*/
|
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
|
|
|
/**
|
|
|
|
*
|
2009-04-21 05:53:35 +00:00
|
|
|
* @return string
|
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
|
|
|
}
|
|
|
|
?>
|