--- /dev/null
+<?php //$Id$
+$string['repository'] = 'Repository';
+$string['repositories'] = 'Repositories';
+$string['manageuserrepository'] = 'Manage individual repository';
+$string['plugin'] = 'Repository Plug-ins';
+$string['settings'] = 'Settings';
try {
var ret = YAHOO.lang.JSON.parse(o.responseText);
} catch(e) {
- alert('Invalid JSON String\n'+o.responseText);
+ alert('Callback: Invalid JSON String\n'+o.responseText);
}
if(ret.e){
panel.get('element').innerHTML = ret.e;
<?php
$string['repositoryname'] = 'Box.net';
$string['repositorydesc'] = 'Repository for box.net';
+$string['configplugin'] = 'Box.net configuration';
+$string['username'] = 'Username for Box.net';
+$string['password'] = 'Password';
+$string['saved'] = 'Box.net data saved.';
class repository_boxnet extends repository{
private $box;
+ public $type = 'boxnet';
public function __construct($repositoryid, $context = SITEID, $options = array()){
global $SESSION, $action;
parent::__construct($repositoryid, $context, $options);
}
+ public function get_login(){
+ global $DB;
+ $repository = new stdclass;
+ $repository->id = $this->repositoryid;
+ if ($entry = $DB->get_record('repository', $repository)) {
+ $ret->username = $entry->username;
+ $ret->password = $entry->password;
+ }
+ return $ret;
+ }
public function get_listing($path = '/', $search = ''){
global $CFG;
$list = array();
} else {
$t = $this->box->getTicket();
if(empty($this->options['auth_token'])) {
+ $ret = $this->get_login();
$str = '';
$str .= '<form id="moodle-repo-login">';
$str .= '<input type="hidden" name="ticket" value="'.
$t['ticket'].'" />';
$str .= '<input type="hidden" name="id" value="'.$this->repositoryid.'" />';
$str .= '<label for="box_username">Username: <label><br/>';
- $str .= '<input type="text" id="box_username" name="username" />';
+ $str .= '<input type="text" id="box_username" name="username" value="'.$ret->username.'" />';
$str .= '<br/>';
$str .= '<label for="box_password">Password: <label><br/>';
- $str .= '<input type="password" id="box_password" name="password" /><br/>';
+ $str .= '<input type="password" value="'.$ret->password.'" id="box_password" name="password" /><br/>';
$str .= '<input type="button" onclick="repository_client.login()" value="Go" />';
$str .= '</form>';
if($this->options['ajax']){
require_once($CFG->dirroot.'/repository/flickr/'.'phpFlickr.php');
class repository_flickr extends repository{
- var $flickr;
- var $photos;
+ private $flickr;
+ public $photos;
+ public $type = 'flickr';
+
public function __construct($repositoryid, $context = SITEID, $options = array()){
global $SESSION, $action, $CFG;
$options['page'] = optional_param('p', 1, PARAM_INT);
* @package repository
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*/
-require_once('../config.php');
-require_once('../lib/filelib.php');
+require_once(dirname(dirname(__FILE__)) . '/config.php');
+require_once($CFG->libdir.'/filelib.php');
abstract class repository {
protected $options;
* @return array the list of files, including meta infomation
*/
public function __construct($repositoryid, $context = SITEID, $options = array()){
- $this->name = 'repository_base';
$this->context = $context;
$this->repositoryid = $repositoryid;
$this->options = array();
* @param string $userid The id of specific user
* @return array the list of files, including meta infomation
*/
- public function store_login($username = '', $password = '', $userid = -1, $contextid = SITEID) {
+ public function store_login($username = '', $password = '', $userid = 1, $contextid = SITEID) {
global $DB;
$repository = new stdclass;
- $repository->userid = $userid;
- $repository->repositorytype = $this->name;
- $repository->contextid = $contextid;
+ if (!empty($this->repositoryid)) {
+ $repository->id = $this->repositoryid;
+ } else {
+ $repository->userid = $userid;
+ $repository->repositorytype = $this->type;
+ $repository->contextid = $contextid;
+ }
if ($entry = $DB->get_record('repository', $repository)) {
$repository->id = $entry->id;
$repository->username = $username;
}
return $repos;
}
+function repository_instance($id){
+ global $DB, $CFG;
+
+ if (!$instance = $DB->get_record('repository', array('id' => $id))) {
+ return false;
+ }
+ require_once($CFG->dirroot . '/repository/'. $instance->repositorytype
+ . '/repository.class.php');
+ $classname = 'repository_' . $instance->repositorytype;
+ return new $classname($instance->id, $instance->contextid);
+}
function repository_get_plugins(){
global $CFG;
$repo = $CFG->dirroot.'/repository/';
} catch (repository_exception $e){
$err = new stdclass;
$err->e = $e->getMessage();
- die(json_encode($err));
+ die(json_encode($err.time()));
}
} else {
$err = new stdclass;
--- /dev/null
+<?php //$Id$
+
+require_once(dirname(dirname(__FILE__)) . '/config.php');
+require_once($CFG->dirroot . '/repository/lib.php');
+
+$config = optional_param('config', 0, PARAM_INT);
+
+$course = optional_param('course', SITEID, PARAM_INT);
+
+if (! $course = $DB->get_record("course", array("id"=>$course))) {
+ print_error('invalidcourseid');
+}
+
+$user = $USER;
+$baseurl = $CFG->wwwroot . '/user/repository.php';
+$namestr = get_string('name');
+$fullname = fullname($user);
+$strrepos = get_string('repositories', 'repository');
+$configstr = get_string('manageuserrepository', 'repository');
+$pluginstr = get_string('plugin', 'repository');
+
+require_login($course, false);
+
+$navlinks[] = array('name' => $fullname, 'link' => $CFG->wwwroot . '/user/view.php?id=' . $user->id, 'type' => 'misc');
+$navlinks[] = array('name' => $strrepos, 'link' => null, 'type' => 'misc');
+
+$navigation = build_navigation($navlinks);
+
+print_header("$course->fullname: $fullname: $strrepos", $course->fullname,
+ $navigation, "", "", true, " ", navmenu($course));
+
+$currenttab = 'repositories';
+include('tabs.php');
+
+print_heading($configstr);
+print_simple_box_start();
+
+if (!$instances = repository_instances(true, false)) {
+ print_error('noinstances', 'repository', $CFG->wwwroot . '/user/view.php');
+}
+
+$table = new StdClass;
+$table->head = array($namestr, $pluginstr, '');
+$table->data = array();
+
+foreach ($instances as $i) {
+ $path = '/repository/'.$i->repositorytype.'/settings.php';
+ $settings = file_exists($CFG->dirroot.$path);
+ $table->data[] = array($i->repositoryname, $i->repositorytype,
+ $settings ? '<a href="'.$CFG->wwwroot.$path.'">'
+ .get_string('settings', 'repository').'</a>' : '');
+}
+
+print_table($table);
+print_footer();
+
+?>
// @todo penny permissions check?
$toprow[] = new tabobject('portfolios', $CFG->wwwroot .'/user/portfolio.php', get_string('portfolios', 'portfolio'));
}
-
- /// Messaging tab
- if (has_capability('moodle/user:editownmessageprofile', $systemcontext)) {
- $toprow[] = new tabobject('editmessage', $CFG->wwwroot.'/message/edit.php?id='.$user->id.'&course='.$course->id, get_string('editmymessage', 'message'));
+ }
+
+ // Repository Tab
+ if ($user->id == $USER->id) {
+ require_once($CFG->dirroot . '/repository/lib.php');
+ if (repository_instances()) {
+ $toprow[] = new tabobject('repositories', $CFG->wwwroot .'/user/repository.php', get_string('repositories', 'repository'));
}
}
+ /// Messaging tab
+ if (has_capability('moodle/user:editownmessageprofile', $systemcontext)) {
+ $toprow[] = new tabobject('editmessage', $CFG->wwwroot.'/message/edit.php?id='.$user->id.'&course='.$course->id, get_string('editmymessage', 'message'));
+ }
+
/// Add second row to display if there is one