From 8b65d45c2f476e852578ed5f853d4dbe9e1f94e1 Mon Sep 17 00:00:00 2001 From: dongsheng Date: Mon, 30 Jun 2008 05:24:00 +0000 Subject: [PATCH] "MDL-15348, get options from database" --- repository/lib.php | 25 +++++++++++++++++++++++++ repository/picker.php | 31 ++++++++++++++++++++++++++++++- 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/repository/lib.php b/repository/lib.php index 0715e98659..96d4bb5f11 100644 --- a/repository/lib.php +++ b/repository/lib.php @@ -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; +} + ?> diff --git a/repository/picker.php b/repository/picker.php index c59a8ed3c6..e5ef9eb503 100644 --- a/repository/picker.php +++ b/repository/picker.php @@ -1,6 +1,28 @@ 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); ?> @@ -45,7 +67,14 @@ require_once('lib.php'); - +
+ print_login(); + ?> +
+
   -- 2.39.5