} catch (repository_exception $e) {
throw $e;
}
+ if ($SESSION->$sess_name) {
+ $action = 'list';
+ } else {
+ $action = 'login';
+ }
}
// already logged
if(!empty($SESSION->$sess_name)) {
}
} else {
$this->box = new boxclient($this->api_key);
- if(!empty($action)) {
- $action = '';
- }
+ // print login
+ $action = 'login';
}
}
set_user_preference('flickrmail'.$this->id, $account);
}
$SESSION->$sess_name = $account;
- if(empty($action)) {
+ if (empty($account)) {
$action = 'list';
+ } else {
+ $action = 'login';
}
} else {
throw new repository_exception('invalidemail', 'repository_flickr');
if(empty($action)) {
$action = 'list';
}
+ } else {
+ $action = 'login';
}
}
}
if(node.children){
tmpNode.isLeaf = false;
tmpNode.subfolder = node.children;
+ if (node.path) {
+ tmpNode.path = node.path;
+ } else {
+ tmpNode.path = '';
+ }
for(var c in node.children){
_client.buildtree(node.children[c], tmpNode);
}
// TODO: need to include filepath here
var trans = YAHOO.util.Connect.asyncRequest('GET',
'$CFG->wwwroot/repository/ws.php?ctx_id=$context->id&repo_id='
- +_client.repositoryid+'&action=list',
+ +_client.repositoryid+'&p='+node.path+'&action=list',
callback);
}
_client.viewlist = function(){
params['ctx_id'] = $context->id;
_client.loading();
var trans = YAHOO.util.Connect.asyncRequest('POST',
- '$CFG->wwwroot/repository/ws.php', _client.callback,
+ '$CFG->wwwroot/repository/ws.php?action=sign', _client.callback,
_client.postdata(params));
}
_client.end = function(str){
_client.viewbar.set('disabled', false);
_client.loading();
_client.repositoryid = id;
- var trans = YAHOO.util.Connect.asyncRequest('GET', '$CFG->wwwroot/repository/ws.php?ctx_id=$context->id&repo_id='+id+'&p='+path+'&reset='+reset+'&env='+_client.env, _client.callback);
+ var trans = YAHOO.util.Connect.asyncRequest('GET', '$CFG->wwwroot/repository/ws.php?action=list&ctx_id=$context->id&repo_id='+id+'&p='+path+'&reset='+reset+'&env='+_client.env, _client.callback);
}
_client.search = function(id){
var data = window.prompt("$strsearching");
}
_client.viewbar.set('disabled', false);
_client.loading();
- var trans = YAHOO.util.Connect.asyncRequest('GET', '$CFG->wwwroot/repository/ws.php?ctx_id=$context->id&repo_id='+id+'&s='+data+'&env='+_client.env, _client.callback);
+ var trans = YAHOO.util.Connect.asyncRequest('GET', '$CFG->wwwroot/repository/ws.php?action=search&ctx_id=$context->id&repo_id='+id+'&s='+data+'&env='+_client.env, _client.callback);
}
return _client;
})();
public function __construct($repositoryid, $context = SITEID, $options = array()){
global $SESSION, $action, $CFG;
parent::__construct($repositoryid, $context, $options);
+ // TODO:
// get the parameter from client side
// $this->context can be used here.
+ // When user upload a file, $action == 'upload'
+ // You can use $_FILES to find that file
}
public function print_login($ajax = true){
global $SESSION;
// TODO
// Return file list in moodle
- // Also, this plugin should have ability to
- // upload files in user's computer, a iframe
- // need to be created.
return $this->get_listing();
}
public function get_listing($path = '/', $search = ''){
global $SESSION;
$ret = new stdclass;
+
+ // this statement tells file picker to load files dramanically.
$ret->dynload = true;
+
+ // defina upload form in file picker
+ // Use ajax upload file
$ret->upload = array('name'=>get_string('attachment: '), 'id'=>'repo-form');
$ret->list = array();
- // call file api get the list of the file
+
+ // TODO: set path and file area for folders, for example
+ //
+ // $ret->list[] = array('title'=>'folder1', 'size'=>0,
+ // 'date'=>'', 'path'=>'/', 'file_area'=>'course_files');
+ //
+ // call FILE API get the list of the file
+ //
$ret->list[] = array('title'=>'title','source'=>'download url', 'thumbnail'=>'url of thumbnail', 'date'=>'', 'size'=>'unknown');
if(empty($ret)) {
throw new repository_exception('emptyfilelist', 'repository_local');
die(json_encode($err));
}
-if($action == 'list') {
+if ($action == 'list' || $action == 'search') {
try {
if(!empty($p)) {
echo json_encode($repo->get_listing($p));
$err->e = $e->getMessage();
die(json_encode($err));
}
-} else {
+} elseif ($action == 'login') {
try {
echo json_encode($repo->print_login());
} catch (repository_exception $e){