mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
"MDL-19654, implement draft files browsing and management"
This commit is contained in:
parent
48adf91aaf
commit
4deb544fbe
3
lang/en_utf8/repository_draft.php
Normal file
3
lang/en_utf8/repository_draft.php
Normal file
@ -0,0 +1,3 @@
|
||||
<?php
|
||||
$string['repositoryname'] = 'Current files';
|
||||
$string['repositorydesc'] = 'A plug-in for browsing current draft files';
|
12
repository/draft/db/install.php
Executable file
12
repository/draft/db/install.php
Executable file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
function xmldb_repository_draft_install() {
|
||||
global $CFG;
|
||||
$result = true;
|
||||
require_once($CFG->dirroot.'/repository/lib.php');
|
||||
$draft_plugin = new repository_type('draft', array(), true);
|
||||
if(!$id = $draft_plugin->create(true)) {
|
||||
$result = false;
|
||||
}
|
||||
return $result;
|
||||
}
|
20
repository/draft/db/upgrade.php
Executable file
20
repository/draft/db/upgrade.php
Executable file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
function xmldb_repository_draft_upgrade($oldversion) {
|
||||
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
$result = true;
|
||||
|
||||
/// And upgrade begins here. For each one, you'll need one
|
||||
/// block of code similar to the next one. Please, delete
|
||||
/// this comment lines once this file start handling proper
|
||||
/// upgrade code.
|
||||
|
||||
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
|
||||
/// $result = result of database_manager methods
|
||||
/// }
|
||||
|
||||
return $result;
|
||||
}
|
BIN
repository/draft/icon.png
Executable file
BIN
repository/draft/icon.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 582 B |
90
repository/draft/repository.class.php
Executable file
90
repository/draft/repository.class.php
Executable file
@ -0,0 +1,90 @@
|
||||
<?php
|
||||
/**
|
||||
* repository_draft class
|
||||
* This is a subclass of repository class
|
||||
*
|
||||
* @version $Id$
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
*/
|
||||
class repository_draft extends repository {
|
||||
|
||||
/**
|
||||
* @param int $repositoryid
|
||||
* @param int $context
|
||||
* @param array $options
|
||||
*/
|
||||
public function __construct($repositoryid, $context = SITEID, $options = array()) {
|
||||
parent::__construct($repositoryid, $context, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $ajax
|
||||
* @return mixed
|
||||
*/
|
||||
public function print_login() {
|
||||
return $this->get_listing();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $path not used by this plugin
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_listing($path = '', $page = '') {
|
||||
global $CFG, $USER, $itemid;
|
||||
$ret = array();
|
||||
$ret['dynload'] = true;
|
||||
$ret['nosearch'] = true;
|
||||
$ret['nologin'] = true;
|
||||
$ret['draftfiles'] = true;
|
||||
$list = array();
|
||||
|
||||
$fs = get_file_storage();
|
||||
$context = get_context_instance(CONTEXT_USER, $USER->id);
|
||||
$files = $fs->get_area_files($context->id, 'user_draft', $itemid);
|
||||
foreach ($files as $file) {
|
||||
if ($file->get_filename()!='.') {
|
||||
$node = array(
|
||||
'title' => $file->get_filename(),
|
||||
'size' => 0,
|
||||
'date' => '',
|
||||
'source'=> $file->get_id(),
|
||||
'thumbnail' => $CFG->pixpath .'/f/text-32.png'
|
||||
);
|
||||
$list[] = $node;
|
||||
}
|
||||
}
|
||||
$ret['list'] = $list;
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return draft files information
|
||||
*
|
||||
* @global object $USER
|
||||
* @param string $fid file id
|
||||
* @param string $title
|
||||
* @param string $itemid
|
||||
* @return string the location of the file
|
||||
*/
|
||||
public function get_file($fid, $title = '', $itemid = '') {
|
||||
global $USER;
|
||||
$ret = array();
|
||||
$browser = get_file_browser();
|
||||
$user_context = get_context_instance(CONTEXT_USER, $USER->id);
|
||||
$ret['itemid'] = $itemid;
|
||||
$ret['title'] = $title;
|
||||
$ret['contextid'] = $user_context->id;
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string repository name
|
||||
*/
|
||||
public function get_name(){
|
||||
return get_string('repositoryname', 'repository_draft');;
|
||||
}
|
||||
}
|
||||
?>
|
2
repository/draft/version.php
Executable file
2
repository/draft/version.php
Executable file
@ -0,0 +1,2 @@
|
||||
<?php
|
||||
$plugin->version = 2009062000;
|
@ -249,6 +249,7 @@ repository_client.req = function(client_id, id, path, page) {
|
||||
params['ctx_id']=fp_config.contextid;
|
||||
params['client_id'] = client_id;
|
||||
params['repo_id']=id;
|
||||
params['itemid'] = repository_client.fp[client_id].itemid;
|
||||
if (!!page) { // convert page to boolean value
|
||||
params['page']=page;
|
||||
}
|
||||
@ -781,6 +782,33 @@ repository_client.view_as_icons = function(client_id, data) {
|
||||
link.appendChild(img);
|
||||
frame.appendChild(link);
|
||||
el.appendChild(frame);
|
||||
if (fp.fs.draftfiles && !list[k].children) {
|
||||
var delbtn = document.createElement('A');
|
||||
delbtn.href = '###';
|
||||
delbtn.innerHTML = "[X]";
|
||||
delbtn.id = 'del-id-'+String(count);
|
||||
el.appendChild(delbtn);
|
||||
delbtn.itemid=fp.itemid;
|
||||
delbtn.client_id=client_id;
|
||||
delbtn.title=list[k].title;
|
||||
delbtn.repo_id=fp.fs.repo_id;
|
||||
delbtn.onclick = function() {
|
||||
if (confirm('Sure?')) {
|
||||
var params = [];
|
||||
params['client_id'] = this.client_id;
|
||||
params['itemid'] = this.itemid;
|
||||
params['title'] = this.title;
|
||||
var trans = YAHOO.util.Connect.asyncRequest('POST',
|
||||
moodle_cfg.wwwroot+'/repository/ws.php?action=delete',
|
||||
this,
|
||||
repository_client.postdata(params)
|
||||
);
|
||||
}
|
||||
}
|
||||
delbtn.success = function(o) {
|
||||
repository_client.req(o.responseText, this.repo_id);
|
||||
}
|
||||
}
|
||||
el.appendChild(title);
|
||||
panel.appendChild(el);
|
||||
if(list[k].children) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user