MDL-13766
1. Chanage database, create 2 more tables for repository 2. One-step download in file picker
This commit is contained in:
@@ -40,13 +40,15 @@ if (!empty($edit) || !empty($new)) {
|
||||
$instance = repository_instance($edit);
|
||||
$configs = $instance->get_option_names();
|
||||
$plugin = $instance->type;
|
||||
$typeid = $instance->typeid;
|
||||
} else {
|
||||
$plugin = $new;
|
||||
$typeid = $new;
|
||||
$instance = null;
|
||||
}
|
||||
$CFG->pagepath = 'admin/managerepository/' . $plugin;
|
||||
// display the edit form for this instance
|
||||
$mform = new repository_admin_form('', array('plugin' => $plugin, 'instance' => $instance));
|
||||
$mform = new repository_admin_form('', array('plugin' => $plugin, 'typeid'=> $typeid, 'instance' => $instance));
|
||||
// end setup, begin output
|
||||
|
||||
if ($mform->is_cancelled()){
|
||||
|
||||
+42
-26
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<XMLDB PATH="lib/db" VERSION="20080820" COMMENT="XMLDB file for core Moodle tables"
|
||||
<XMLDB PATH="lib/db" VERSION="20080826" COMMENT="XMLDB file for core Moodle tables"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
|
||||
>
|
||||
@@ -1776,7 +1776,7 @@
|
||||
<INDEX NAME="courseid-name" UNIQUE="true" FIELDS="courseid, name"/>
|
||||
</INDEXES>
|
||||
</TABLE>
|
||||
<TABLE NAME="webdav_locks" COMMENT="Resource locks for WebDAV users" PREVIOUS="grade_settings" NEXT="repository">
|
||||
<TABLE NAME="webdav_locks" COMMENT="Resource locks for WebDAV users" PREVIOUS="grade_settings" NEXT="portfolio_instance">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="token"/>
|
||||
<FIELD NAME="token" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="path"/>
|
||||
@@ -1798,29 +1798,7 @@
|
||||
<INDEX NAME="expiry" UNIQUE="false" FIELDS="expiry" PREVIOUS="path"/>
|
||||
</INDEXES>
|
||||
</TABLE>
|
||||
<TABLE NAME="repository" COMMENT="This table contains one entry for every configured external repository instance." PREVIOUS="webdav_locks" NEXT="portfolio_instance">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="repositoryname"/>
|
||||
<FIELD NAME="repositoryname" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="repositorytype"/>
|
||||
<FIELD NAME="repositorytype" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="repositoryname" NEXT="userid"/>
|
||||
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="repositorytype" NEXT="contextid"/>
|
||||
<FIELD NAME="contextid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="userid" NEXT="username"/>
|
||||
<FIELD NAME="username" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="contextid" NEXT="password"/>
|
||||
<FIELD NAME="password" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="username" NEXT="data1"/>
|
||||
<FIELD NAME="data1" TYPE="text" LENGTH="big" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="password" NEXT="data2"/>
|
||||
<FIELD NAME="data2" TYPE="text" LENGTH="big" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="data1" NEXT="data3"/>
|
||||
<FIELD NAME="data3" TYPE="text" LENGTH="big" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="data2" NEXT="data4"/>
|
||||
<FIELD NAME="data4" TYPE="text" LENGTH="big" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="data3" NEXT="data5"/>
|
||||
<FIELD NAME="data5" TYPE="text" LENGTH="big" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="data4" NEXT="timecreated"/>
|
||||
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="data5" NEXT="timemodified"/>
|
||||
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="timecreated" NEXT="visible"/>
|
||||
<FIELD NAME="visible" TYPE="int" LENGTH="1" NOTNULL="false" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="timemodified"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="portfolio_instance" COMMENT="base table (not including config data) for instances of portfolio plugins." PREVIOUS="repository" NEXT="portfolio_instance_config">
|
||||
<TABLE NAME="portfolio_instance" COMMENT="base table (not including config data) for instances of portfolio plugins." PREVIOUS="webdav_locks" NEXT="portfolio_instance_config">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="plugin"/>
|
||||
<FIELD NAME="plugin" TYPE="char" LENGTH="50" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="fk to plugin" PREVIOUS="id" NEXT="name"/>
|
||||
@@ -1949,7 +1927,7 @@
|
||||
<INDEX NAME="pathnamehash" UNIQUE="true" FIELDS="pathnamehash" PREVIOUS="contenthash"/>
|
||||
</INDEXES>
|
||||
</TABLE>
|
||||
<TABLE NAME="files_cleanup" COMMENT="File pool cleanup candidates" PREVIOUS="files">
|
||||
<TABLE NAME="files_cleanup" COMMENT="File pool cleanup candidates" PREVIOUS="files" NEXT="repository">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="contenthash"/>
|
||||
<FIELD NAME="contenthash" TYPE="char" LENGTH="40" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="id"/>
|
||||
@@ -1961,6 +1939,44 @@
|
||||
<INDEX NAME="contenthash" UNIQUE="true" FIELDS="contenthash"/>
|
||||
</INDEXES>
|
||||
</TABLE>
|
||||
<TABLE NAME="repository" COMMENT="This table contains one entry for every configured external repository instance." PREVIOUS="files_cleanup" NEXT="repository_instances">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="type"/>
|
||||
<FIELD NAME="type" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="visible"/>
|
||||
<FIELD NAME="visible" TYPE="int" LENGTH="1" NOTNULL="false" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="type" NEXT="sortorder"/>
|
||||
<FIELD NAME="sortorder" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="visible"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="repository_instances" COMMENT="This table contains one entry for every configured external repository instance. " PREVIOUS="repository" NEXT="repository_instance_config">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="name"/>
|
||||
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="typeid"/>
|
||||
<FIELD NAME="typeid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="userid"/>
|
||||
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="typeid" NEXT="contextid"/>
|
||||
<FIELD NAME="contextid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="userid" NEXT="username"/>
|
||||
<FIELD NAME="username" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="contextid" NEXT="password"/>
|
||||
<FIELD NAME="password" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="username" NEXT="timecreated"/>
|
||||
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="password" NEXT="timemodified"/>
|
||||
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="timecreated"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="repository_instance_config" COMMENT="The config for intances" PREVIOUS="repository_instances">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="instanceid"/>
|
||||
<FIELD NAME="instanceid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="name"/>
|
||||
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="instanceid" NEXT="value"/>
|
||||
<FIELD NAME="value" TYPE="text" LENGTH="big" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="name"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
<STATEMENTS>
|
||||
<STATEMENT NAME="insert mnet_application" TYPE="insert" TABLE="mnet_application" COMMENT="Initial insert of records on table mnet_application" NEXT="insert log_display">
|
||||
|
||||
@@ -699,6 +699,75 @@ function xmldb_main_upgrade($oldversion) {
|
||||
|
||||
upgrade_main_savepoint($result, 2008081900);
|
||||
}
|
||||
if ($result && $oldversion < 2008082600) {
|
||||
|
||||
/// Define table repository to be dropped
|
||||
$table = new xmldb_table('repository');
|
||||
|
||||
/// Conditionally launch drop table for repository
|
||||
if ($dbman->table_exists($table)) {
|
||||
$dbman->drop_table($table);
|
||||
}
|
||||
|
||||
/// Define table repository to be created
|
||||
$table = new xmldb_table('repository');
|
||||
|
||||
/// Adding fields to table repository
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
||||
$table->add_field('type', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('visible', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null, null, '1');
|
||||
$table->add_field('sortorder', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
|
||||
|
||||
/// Adding keys to table repository
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
|
||||
/// Conditionally launch create table for repository
|
||||
if (!$dbman->table_exists($table)) {
|
||||
$dbman->create_table($table);
|
||||
}
|
||||
/// Define table repository_instances to be created
|
||||
$table = new xmldb_table('repository_instances');
|
||||
|
||||
/// Adding fields to table repository_instances
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
||||
$table->add_field('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('typeid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
|
||||
$table->add_field('contextid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('username', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
|
||||
$table->add_field('password', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
|
||||
$table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
|
||||
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
|
||||
|
||||
/// Adding keys to table repository_instances
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
|
||||
/// Conditionally launch create table for repository_instances
|
||||
if (!$dbman->table_exists($table)) {
|
||||
$dbman->create_table($table);
|
||||
}
|
||||
|
||||
/// Define table repository_instance_config to be created
|
||||
$table = new xmldb_table('repository_instance_config');
|
||||
|
||||
/// Adding fields to table repository_instance_config
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
|
||||
$table->add_field('instanceid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
|
||||
$table->add_field('value', XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null);
|
||||
|
||||
/// Adding keys to table repository_instance_config
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
|
||||
/// Conditionally launch create table for repository_instance_config
|
||||
if (!$dbman->table_exists($table)) {
|
||||
$dbman->create_table($table);
|
||||
}
|
||||
|
||||
/// Main savepoint reached
|
||||
upgrade_main_savepoint($result, 2008082600);
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -14,20 +14,21 @@ class repository_boxnet extends repository{
|
||||
private $box;
|
||||
|
||||
public function set_option($options = array()){
|
||||
$ret = parent::set_option($options);
|
||||
if (!empty($options['api_key'])) {
|
||||
set_config('api_key', $options['api_key'], 'boxnet');
|
||||
}
|
||||
unset($options['api_key']);
|
||||
$ret = parent::set_option($options);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function get_option($config = ''){
|
||||
$options = parent::get_option($config);
|
||||
if($config==='api_key'){
|
||||
return get_config('boxnet', 'api_key');
|
||||
} else {
|
||||
$options['api_key'] = get_config('boxnet', 'api_key');
|
||||
}
|
||||
$options = parent::get_option($config);
|
||||
return $options;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,25 @@ class repository_flickr extends repository{
|
||||
private $flickr;
|
||||
public $photos;
|
||||
|
||||
public function set_option($options = array()){
|
||||
if (!empty($options['api_key'])) {
|
||||
set_config('api_key', $options['api_key'], 'flickr');
|
||||
}
|
||||
unset($options['api_key']);
|
||||
$ret = parent::set_option($options);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function get_option($config = ''){
|
||||
if($config==='api_key'){
|
||||
return get_config('flickr', 'api_key');
|
||||
} else {
|
||||
$options['api_key'] = get_config('flickr', 'api_key');
|
||||
}
|
||||
$options = parent::get_option($config);
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function __construct($repositoryid, $context = SITEID, $options = array()){
|
||||
global $SESSION, $action, $CFG;
|
||||
$options['page'] = optional_param('p', 1, PARAM_INT);
|
||||
|
||||
+76
-52
@@ -179,9 +179,9 @@ abstract class repository {
|
||||
final public function ajax_info() {
|
||||
global $CFG;
|
||||
$repo = new stdclass;
|
||||
$repo->id = $this->id;
|
||||
$repo->name = $this->options['name'];
|
||||
$repo->type = $this->options['type'];
|
||||
$repo->id = $this->options['id'];
|
||||
$repo->icon = $CFG->wwwroot.'/repository/'.$repo->type.'/icon.png';
|
||||
return $repo;
|
||||
}
|
||||
@@ -297,21 +297,30 @@ abstract class repository {
|
||||
*/
|
||||
public function set_option($options = array()){
|
||||
global $DB;
|
||||
if (is_array($options)) {
|
||||
$options = array_merge($this->get_option(), $options);
|
||||
} else {
|
||||
$options = $this->get_option();
|
||||
$r = new object();
|
||||
$r->id = $this->id;
|
||||
$r->name = $options['name'];
|
||||
$DB->update_record('repository_instances', $r);
|
||||
unset($options['name']);
|
||||
foreach ($options as $name=>$value) {
|
||||
if ($id = $DB->get_field('repository_instance_config', 'id', array('name'=>$name, 'instanceid'=>$this->id))) {
|
||||
if ($value===null) {
|
||||
return $DB->delete_records('repository_instance_config', array('name'=>$name, 'instanceid'=>$this->id));
|
||||
} else {
|
||||
return $DB->set_field('repository_instance_config', 'value', $value, array('id'=>$id));
|
||||
}
|
||||
} else {
|
||||
if ($value===null) {
|
||||
return true;
|
||||
}
|
||||
$config = new object();
|
||||
$config->instanceid = $this->id;
|
||||
$config->name = $name;
|
||||
$config->value = $value;
|
||||
return $DB->insert_record('repository_instance_config', $config);
|
||||
}
|
||||
}
|
||||
$repository = new stdclass;
|
||||
$position = 1;
|
||||
$options = serialize($options);
|
||||
if ($entry = $DB->get_record('repository', array('id'=>$this->id))) {
|
||||
$field = 'data'.$position;
|
||||
$repository->id = $entry->id;
|
||||
$repository->$field = $options;
|
||||
return $DB->update_record('repository', $repository);
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -322,23 +331,13 @@ abstract class repository {
|
||||
*/
|
||||
public function get_option($config = ''){
|
||||
global $DB;
|
||||
$entry = $DB->get_record('repository', array('id'=>$this->id));
|
||||
if (!empty($entry->visible)) {
|
||||
$ret['visible'] = 1;
|
||||
} else {
|
||||
$ret['visible'] = 0;
|
||||
$entries = $DB->get_records('repository_instance_config', array('instanceid'=>$this->id));
|
||||
$ret = array();
|
||||
if (empty($entries)) {
|
||||
return $ret;
|
||||
}
|
||||
$ret['type'] = $entry->repositorytype;
|
||||
$ret['name'] = $entry->repositoryname;
|
||||
$ret['id'] = $entry->id;
|
||||
for ($i=1;$i<6;$i++) {
|
||||
$field = 'data'.$i;
|
||||
$data = unserialize($entry->$field);
|
||||
if (!empty($data)) {
|
||||
if (is_array($data)) {
|
||||
$ret = array_merge($ret, $data);
|
||||
}
|
||||
}
|
||||
foreach($entries as $entry){
|
||||
$ret[$entry->name] = $entry->value;
|
||||
}
|
||||
if (!empty($config)) {
|
||||
return $ret[$config];
|
||||
@@ -438,16 +437,17 @@ class repository_exception extends moodle_exception {
|
||||
function repository_instances($context, $userid = null, $visible = true){
|
||||
global $DB, $CFG, $USER;
|
||||
$params = array();
|
||||
$sql = 'SELECT * FROM {repository} r WHERE ';
|
||||
$sql = 'SELECT i.*, r.type AS repositorytype, r.visible FROM {repository} r, {repository_instances} i WHERE ';
|
||||
$sql .= 'i.typeid = r.id AND ';
|
||||
if (!empty($userid) && is_numeric($userid)) {
|
||||
$sql .= ' (r.userid = 0 or r.userid = ?) AND ';
|
||||
$sql .= ' (i.userid = 0 or i.userid = ?) AND ';
|
||||
$params[] = $userid;
|
||||
}
|
||||
if($context->id == SYSCONTEXTID) {
|
||||
$sql .= ' (r.contextid = ?)';
|
||||
$sql .= ' (i.contextid = ?)';
|
||||
$params[] = SYSCONTEXTID;
|
||||
} else {
|
||||
$sql .= ' (r.contextid = ? or r.contextid = ?)';
|
||||
$sql .= ' (i.contextid = ? or i.contextid = ?)';
|
||||
$params[] = SYSCONTEXTID;
|
||||
$params[] = $context->id;
|
||||
}
|
||||
@@ -461,8 +461,12 @@ function repository_instances($context, $userid = null, $visible = true){
|
||||
foreach($repos as $repo) {
|
||||
require_once($CFG->dirroot . '/repository/'. $repo->repositorytype
|
||||
. '/repository.class.php');
|
||||
$options['visible'] = $repo->visible;
|
||||
$options['name'] = $repo->name;
|
||||
$options['type'] = $repo->repositorytype;
|
||||
$options['typeid'] = $repo->typeid;
|
||||
$classname = 'repository_' . $repo->repositorytype;
|
||||
$ret[] = new $classname($repo->id, $repo->contextid);
|
||||
$ret[] = new $classname($repo->id, $repo->contextid, $options);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
@@ -475,14 +479,20 @@ function repository_instances($context, $userid = null, $visible = true){
|
||||
*/
|
||||
function repository_instance($id){
|
||||
global $DB, $CFG;
|
||||
$sql = 'SELECT i.*, r.type AS repositorytype, r.visible FROM {repository} r, {repository_instances} i WHERE ';
|
||||
$sql .= 'i.typeid = r.id AND ';
|
||||
$sql .= 'i.id = '.$id;
|
||||
|
||||
if (!$instance = $DB->get_record('repository', array('id' => $id))) {
|
||||
if(!$instance = $DB->get_record_sql($sql)) {
|
||||
return false;
|
||||
}
|
||||
require_once($CFG->dirroot . '/repository/'. $instance->repositorytype
|
||||
. '/repository.class.php');
|
||||
$classname = 'repository_' . $instance->repositorytype;
|
||||
return new $classname($instance->id, $instance->contextid);
|
||||
$options['typeid'] = $instance->typeid;
|
||||
$options['type'] = $instance->repositorytype;
|
||||
$options['name'] = $instance->name;
|
||||
return new $classname($instance->id, $instance->contextid, $options);
|
||||
}
|
||||
|
||||
function repository_static_function($plugin, $function) {
|
||||
@@ -587,8 +597,9 @@ function get_repository_client($context){
|
||||
#list-$suffix li a:hover{ background: gray; color:white; }
|
||||
#repo-list-$suffix .repo-name{}
|
||||
#repo-list-$suffix li{margin-bottom: 1em}
|
||||
#paging-$suffix{margin:10px 5px; clear:both}
|
||||
#paging-$suffix a{padding: 4px; border: 1px solid gray}
|
||||
#paging-$suffix{margin:10px 5px; clear:both;}
|
||||
#paging-$suffix a{padding: 4px;border: 1px solid #CCC}
|
||||
#path-$suffix a{padding: 4px;background: gray}
|
||||
#panel-$suffix{padding:0;margin:0; text-align:left;}
|
||||
p.upload{text-align:right;margin: 5px}
|
||||
p.upload a{font-size: 14px;background: #ccc;color:black;padding: 3px}
|
||||
@@ -827,6 +838,7 @@ _client.navbar = function(){
|
||||
var str = '';
|
||||
str += _client.uploadcontrol();
|
||||
str += _client.makepage();
|
||||
str += _client.makepath();
|
||||
return str;
|
||||
}
|
||||
// TODO
|
||||
@@ -1008,6 +1020,21 @@ _client.makepage = function(){
|
||||
}
|
||||
return str;
|
||||
}
|
||||
_client.makepath = function(){
|
||||
var str = '';
|
||||
var p = _client.ds.path;
|
||||
if(p && p.length!=0){
|
||||
str += '<div id="path-$suffix">';
|
||||
if(p.path && p.name)
|
||||
for(var i = 0; i < _client.ds.path.length; i++) {
|
||||
str += '<a onclick="repository_client_$suffix.req('+_client.repositoryid+', "'+_client.ds.path[i].path+'", 0)" href="###">';
|
||||
str += _client.ds.path[i].name;
|
||||
str += '</a> ';
|
||||
}
|
||||
str += '</div>';
|
||||
}
|
||||
return str;
|
||||
}
|
||||
// send download request
|
||||
_client.download = function(){
|
||||
var title = document.getElementById('newname-$suffix').value;
|
||||
@@ -1121,16 +1148,7 @@ _client.dlfile = {
|
||||
panel.get('element').innerHTML = ret.e;
|
||||
return;
|
||||
}
|
||||
var title = document.createElement('h1');
|
||||
title.innerHTML = '$strdownload';
|
||||
var btn = document.createElement('button');
|
||||
btn.innerHTML = '$stradd';
|
||||
btn.onclick = function(){
|
||||
repository_client_$suffix.end(ret);
|
||||
}
|
||||
panel.get('element').innerHTML = '';
|
||||
panel.get('element').appendChild(title);
|
||||
panel.get('element').appendChild(btn);
|
||||
repository_client_$suffix.end(ret);
|
||||
}
|
||||
}
|
||||
// request file list or login
|
||||
@@ -1197,6 +1215,7 @@ final class repository_admin_form extends moodleform {
|
||||
global $CFG;
|
||||
// type of plugin, string
|
||||
$this->plugin = $this->_customdata['plugin'];
|
||||
$this->typeid = $this->_customdata['typeid'];
|
||||
$this->instance = (isset($this->_customdata['instance'])
|
||||
&& is_subclass_of($this->_customdata['instance'], 'repository'))
|
||||
? $this->_customdata['instance'] : null;
|
||||
@@ -1207,6 +1226,7 @@ final class repository_admin_form extends moodleform {
|
||||
$mform->addElement('hidden', 'edit', ($this->instance) ? $this->instance->id : 0);
|
||||
$mform->addElement('hidden', 'new', $this->plugin);
|
||||
$mform->addElement('hidden', 'plugin', $this->plugin);
|
||||
$mform->addElement('hidden', 'typeid', $this->typeid);
|
||||
|
||||
$mform->addElement('text', 'name', get_string('name'), 'maxlength="100" size="30"');
|
||||
$mform->addRule('name', $strrequired, 'required', null, 'client');
|
||||
@@ -1225,7 +1245,11 @@ final class repository_admin_form extends moodleform {
|
||||
$data = array();
|
||||
$data['name'] = $this->instance->name;
|
||||
foreach ($this->instance->get_option_names() as $config) {
|
||||
$data[$config] = $this->instance->$config;
|
||||
if (!empty($this->instance->$config)) {
|
||||
$data[$config] = $this->instance->$config;
|
||||
} else {
|
||||
$data[$config] = '';
|
||||
}
|
||||
}
|
||||
$this->set_data($data);
|
||||
}
|
||||
@@ -1236,7 +1260,7 @@ final class repository_admin_form extends moodleform {
|
||||
global $DB;
|
||||
|
||||
$errors = array();
|
||||
if ($DB->count_records('repository', array('repositoryname' => $data['name'], 'repositorytype' => $data['plugin'])) > 1) {
|
||||
if ($DB->count_records('repository_instances', array('name' => $data['name'], 'typeid' => $data['typeid'])) > 1) {
|
||||
$errors = array('name' => get_string('err_uniquename', 'repository'));
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -34,11 +34,11 @@ if(!$repository = $DB->get_record('repository', array('id'=>$repo_id)))
|
||||
}
|
||||
|
||||
if(file_exists($CFG->dirroot.'/repository/'.
|
||||
$repository->repositorytype.'/repository.class.php'))
|
||||
$repository->type.'/repository.class.php'))
|
||||
{
|
||||
require_once($CFG->dirroot.'/repository/'.
|
||||
$repository->repositorytype.'/repository.class.php');
|
||||
$classname = 'repository_' . $repository->repositorytype;
|
||||
$repository->type.'/repository.class.php');
|
||||
$classname = 'repository_' . $repository->type;
|
||||
try{
|
||||
$repo = new $classname($repo_id, $ctx_id, array('ajax'=>true));
|
||||
} catch (repository_exception $e){
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
// This is compared against the values stored in the database to determine
|
||||
// whether upgrades should be performed (see lib/db/*.php)
|
||||
|
||||
$version = 2008082600; // YYYYMMDD = date of the last version bump
|
||||
$version = 2008082601; // YYYYMMDD = date of the last version bump
|
||||
// XX = daily increments
|
||||
|
||||
$release = '2.0 dev (Build: 20080826)'; // Human-friendly version name
|
||||
|
||||
Reference in New Issue
Block a user