return $this->getFrozenHtml();
} else {
$strsaved = get_string('filesaved', 'repository');
- // TODO
- // Use a better itemid value to identify a repository
- // file
- $itemid = time();
+ $itemid = substr(hexdec(uniqid()), 0, 9)+rand(1,100);
$ret = get_repository_client();
$suffix = $ret['suffix'];
$str = $this->_getTabs();
$ret = (array)unserialize($entry->$option);
return $ret;
}
-function repository_instances(){
+function repository_instances($contextid = SITEID){
global $DB, $CFG, $USER;
- $contextid = 0;
$params = array();
$sql = 'SELECT * FROM {repository} r WHERE ';
$sql .= ' (r.userid = 0 or r.userid = ?) ';
if ($file = $fs->create_file_from_pathname($entry, $path)) {
$id = json_encode($file->get_itemid());
$ret = $browser->get_file_info($context, $file->get_filearea(), $file->get_itemid(), $file->get_filepath(), $file->get_filename());
- // TODO
- // get_params should include id value, talk to Petr.
return array('url'=>$ret->get_url(),'id'=>$file->get_itemid());
} else {
return null;
}
}
-
+// TODO
+// Need to pass contextid and contextlevel here
function get_repository_client(){
- global $CFG;
+ global $CFG, $USER;
$suffix = uniqid();
$strsubmit = get_string('submit', 'repository');
$strlistview = get_string('listview', 'repository');
$search = optional_param('s', '', PARAM_RAW);
// id of repository
$repo_id = optional_param('repo_id', 1, PARAM_INT);
-$itemid = optional_param('itemid', 0, PARAM_INT);
+// context id
+$ctx_id = optional_param('ctx_id', SITEID, PARAM_INT);
+$itemid = optional_param('itemid', 0, PARAM_INT);
+$userid = $USER->id;
-if(!$repository = $DB->get_record('repository', array('id'=>$repo_id))) {
+if(!$repository = $DB->get_record('repository', array('id'=>$repo_id)))
+{
$err = new stdclass;
$err->e = get_string('invalidrepositoryid', 'repository');
die(json_encode($err));
die(json_encode($err));
}
}
-
-?>