mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
"MDL-15348, get options from database"
This commit is contained in:
parent
7851038bd8
commit
8b65d45c2f
@ -50,6 +50,7 @@
|
||||
* @package repository_api
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
*/
|
||||
require_once('../config.php');
|
||||
|
||||
abstract class repository {
|
||||
protected $options;
|
||||
@ -221,4 +222,28 @@ abstract class repository {
|
||||
abstract class repository_listing {
|
||||
}
|
||||
|
||||
function repository_set_option($id, $position, $config = array()){
|
||||
global $DB;
|
||||
$repository = new stdclass;
|
||||
$position = (int)$position;
|
||||
$config = serialize($config);
|
||||
if( $position < 1 || $position > 5){
|
||||
print_error('invalidoption', 'repository', '', $position);
|
||||
}
|
||||
if ($entry = $DB->get_record('repository', array('id'=>$id))) {
|
||||
$option = 'option'.$position;
|
||||
$repository->id = $entry->id;
|
||||
$repository->$option = $config;
|
||||
return $DB->update_record('repository', $repository);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function repository_get_option($id, $position){
|
||||
global $DB;
|
||||
$entry = $DB->get_record('repository', array('id'=>$id));
|
||||
$option = 'option'.$position;
|
||||
$ret = (array)unserialize($entry->$option);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -1,6 +1,28 @@
|
||||
<?php
|
||||
require_once('../config.php');
|
||||
require_once('lib.php');
|
||||
// Obtain parameters
|
||||
$id = required_param('id', PARAM_INT);
|
||||
$options = repository_get_option($id, 1);
|
||||
if(!empty($options['required'])) {
|
||||
foreach($options['required'] as $param){
|
||||
$options[$param] = optional_param($param, 0, PARAM_RAW);
|
||||
}
|
||||
}
|
||||
$courseid = optional_param('course', 0, PARAM_INT);
|
||||
$contextid = SITEID;
|
||||
|
||||
/*
|
||||
if (!$course = $DB->get_record('course', array('id'=>$courseid))) {
|
||||
print_error('invalidcourseid');
|
||||
}
|
||||
*/
|
||||
if(!$repository = $DB->get_record('repository', array('id'=>$id))) {
|
||||
print_error('invalidrepostoryid');
|
||||
}
|
||||
require_once($CFG->dirroot.'/repository/'.$repository->repositorytype.'/repository.class.php');
|
||||
$classname = 'repository_'.$repository->repositorytype;
|
||||
$repo = new $classname($id, SITEID, $options);
|
||||
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
@ -45,7 +67,14 @@ require_once('lib.php');
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<iframe src="ibrowse.php" width="100%" height='250px' class="frame"></iframe>
|
||||
<div>
|
||||
<?php
|
||||
$repo->print_login();
|
||||
?>
|
||||
</div>
|
||||
<!--
|
||||
<iframe src="ibrowse.php" width="100%" height='250px' class="frame"></iframe>
|
||||
-->
|
||||
<div class="right">
|
||||
<input type="submit" value="Select" name="select" />
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user