public static function getPublicClientFromSession($repositoryid)
 {
     global $SESSION;
     // Get the Soap Client connection to the Hive web services from the session
     $publicClient = unserialize($SESSION->{'publicClient' . $repositoryid});
     if (empty($publicClient)) {
         $options = repository::get_instance($repositoryid)->options;
         $publicClient = self::getPublicClient($options['hwsurl']);
     }
     $SESSION->{'publicClient' . $repositoryid} = serialize($publicClient);
     return $publicClient;
 }
Beispiel #2
0
 /**
  * Create an instance for this plug-in
  *
  * @static
  * @param string $type the type of the repository
  * @param int $userid the user id
  * @param stdClass $context the context
  * @param array $params the options for this instance
  * @param int $readonly whether to create it readonly or not (defaults to not)
  * @return mixed
  */
 public static function create($type, $userid, $context, $params, $readonly = 0)
 {
     global $CFG, $DB;
     $params = (array) $params;
     require_once $CFG->dirroot . '/repository/' . $type . '/lib.php';
     $classname = 'repository_' . $type;
     if ($repo = $DB->get_record('repository', array('type' => $type))) {
         $record = new stdClass();
         $record->name = $params['name'];
         $record->typeid = $repo->id;
         $record->timecreated = time();
         $record->timemodified = time();
         $record->contextid = $context->id;
         $record->readonly = $readonly;
         $record->userid = $userid;
         $id = $DB->insert_record('repository_instances', $record);
         cache::make('core', 'repositories')->purge();
         $options = array();
         $configs = call_user_func($classname . '::get_instance_option_names');
         if (!empty($configs)) {
             foreach ($configs as $config) {
                 if (isset($params[$config])) {
                     $options[$config] = $params[$config];
                 } else {
                     $options[$config] = null;
                 }
             }
         }
         if (!empty($id)) {
             unset($options['name']);
             $instance = repository::get_instance($id);
             $instance->set_option($options);
             return $id;
         } else {
             return null;
         }
     } else {
         return null;
     }
 }
Beispiel #3
0
            echo $OUTPUT->header();
            echo $OUTPUT->heading(get_string('configplugin', 'repository_' . $plugin));
            echo $OUTPUT->box_start();
            $mform->display();
            echo $OUTPUT->box_end();
            $return = false;
        }
    }
} else {
    if (!empty($hide)) {
        $instance = repository::get_type_by_typename($hide);
        $instance->hide();
        $return = true;
    } else {
        if (!empty($delete)) {
            $instance = repository::get_instance($delete);
            //if you try to delete an instance set as readonly, display an error message
            if ($instance->readonly) {
                throw new repository_exception('readonlyinstance', 'repository');
            }
            if ($sure) {
                if ($instance->delete($downloadcontents)) {
                    $deletedstr = get_string('instancedeleted', 'repository');
                    redirect($parenturl, $deletedstr, 3);
                } else {
                    print_error('instancenotdeleted', 'repository', $parenturl);
                }
                exit;
            }
            echo $OUTPUT->header();
            echo $OUTPUT->box_start('generalbox', 'notice');
Beispiel #4
0
<?php

require_once '../../config.php';
require_once $CFG->dirroot . '/repository/lib.php';
global $PAGE, $USER;
//this doesnt seem to work here. So had to put an echo "...embed-comressed.jpg" code below
//$PAGE->requires->js(new moodle_url($CFG->httpswwwroot . '/filter/poodll/flash/embed-compressed.js'),true);
// we get the request parameters:
// the repository ID controls where the file will be added
$repo_id = required_param('repo_id', PARAM_INT);
// repository ID
$filename = optional_param('filename', '', PARAM_TEXT);
// filename
// load the repository
$repo = repository::get_instance($repo_id);
if (empty($repo)) {
    die;
}
// we output a simple HTML page with the poodll recorder code in it
//$PAGE->set_generaltype('popup');
//we meed to do something like this to get a progress bar in the repo for html5
//$PAGE->requires->css(new moodle_url($CFG->httpswwwroot . '/filter/poodll/styles.css'));
echo "<link rel=\"stylesheet\" href=\"{$CFG->wwwroot}/filter/poodll/styles.css\" />";
$PAGE->set_context(context_user::instance($USER->id));
$PAGE->set_url($CFG->wwwroot . '/repository/poodll/record.php', array('repo_id' => $repo_id));
//print_header(null, get_string('recordnew', 'repository_poodll'),null, null, null, false);
?>

<div style="text-align: center;">
<?php 
if ($filename == '') {
 /**
  * Updates all files that are referencing this file with the new contenthash
  * and filesize
  *
  * @param stored_file $storedfile
  */
 public function update_references_to_storedfile(stored_file $storedfile)
 {
     global $CFG, $DB;
     $params = array();
     $params['contextid'] = $storedfile->get_contextid();
     $params['component'] = $storedfile->get_component();
     $params['filearea'] = $storedfile->get_filearea();
     $params['itemid'] = $storedfile->get_itemid();
     $params['filename'] = $storedfile->get_filename();
     $params['filepath'] = $storedfile->get_filepath();
     $reference = self::pack_reference($params);
     $referencehash = sha1($reference);
     $sql = "SELECT repositoryid, id FROM {files_reference}\n                 WHERE referencehash = ? and reference = ?";
     $rs = $DB->get_recordset_sql($sql, array($referencehash, $reference));
     $now = time();
     foreach ($rs as $record) {
         require_once $CFG->dirroot . '/repository/lib.php';
         $repo = repository::get_instance($record->repositoryid);
         $lifetime = $repo->get_reference_file_lifetime($reference);
         $this->update_references($record->id, $now, $lifetime, $storedfile->get_contenthash(), $storedfile->get_filesize(), 0);
     }
     $rs->close();
 }