From bb3c7a057c0129efbb974540ffe34476d9b3f1b2 Mon Sep 17 00:00:00 2001 From: Dongsheng Cai Date: Fri, 11 Jun 2010 08:37:33 +0000 Subject: [PATCH] MDL-15352, remove remotemoodle plugin from head --- repository/remotemoodle/db/access.php | 16 - repository/remotemoodle/db/mnet.php | 46 --- repository/remotemoodle/db/upgrade.php | 20 -- repository/remotemoodle/icon.png | Bin 582 -> 0 bytes .../lang/en/repository_remotemoodle.php | 41 --- repository/remotemoodle/repository.class.php | 321 ------------------ repository/remotemoodle/version.php | 18 - 7 files changed, 462 deletions(-) delete mode 100644 repository/remotemoodle/db/access.php delete mode 100644 repository/remotemoodle/db/mnet.php delete mode 100644 repository/remotemoodle/db/upgrade.php delete mode 100644 repository/remotemoodle/icon.png delete mode 100644 repository/remotemoodle/lang/en/repository_remotemoodle.php delete mode 100644 repository/remotemoodle/repository.class.php delete mode 100644 repository/remotemoodle/version.php diff --git a/repository/remotemoodle/db/access.php b/repository/remotemoodle/db/access.php deleted file mode 100644 index 8a9bb22c458..00000000000 --- a/repository/remotemoodle/db/access.php +++ /dev/null @@ -1,16 +0,0 @@ - array( - 'captype' => 'read', - 'contextlevel' => CONTEXT_SYSTEM, - 'archetypes' => array( - 'user' => CAP_ALLOW, - 'student' => CAP_ALLOW, - 'teacher' => CAP_ALLOW, - 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) - ) -); diff --git a/repository/remotemoodle/db/mnet.php b/repository/remotemoodle/db/mnet.php deleted file mode 100644 index dbcb5efbfac..00000000000 --- a/repository/remotemoodle/db/mnet.php +++ /dev/null @@ -1,46 +0,0 @@ -. - - -/** - * This file contains the mnet services for the remotemoodle repository plugin - * - * @since 2.0 - * @package moodlecore - * @subpackage repository - * @copyright 2010 Penny Leach - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -$publishes = array( - 'remoterep' => array( - 'apiversion' => 1, - 'classname' => 'repository_remotemoodle', - 'filename' => 'repository.class.php', - 'methods' => array( - 'getFileList', - 'retrieveFile', - ), - ), -); -$subscribes = array( - 'remoterep' => array( - 'getFileList' => 'repository/remotemoodle/repository.class.php/getFileList', - 'retrieveFile' => 'repository/remotemoodle/repository.class.php/retrieveFile', - - ), -); diff --git a/repository/remotemoodle/db/upgrade.php b/repository/remotemoodle/db/upgrade.php deleted file mode 100644 index 7dc6808a953..00000000000 --- a/repository/remotemoodle/db/upgrade.php +++ /dev/null @@ -1,20 +0,0 @@ -get_manager(); - $result = true; - -/// And upgrade begins here. For each one, you'll need one -/// block of code similar to the next one. Please, delete -/// this comment lines once this file start handling proper -/// upgrade code. - -/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php -/// $result = result of database_manager methods -/// } - - return $result; -} diff --git a/repository/remotemoodle/icon.png b/repository/remotemoodle/icon.png deleted file mode 100644 index 5131cf3de1da9a246a7ea410df97a56454f75901..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 582 zcmV-M0=fN(P)sc!?Oa|W?(3ZQitt8@U9a!$t!d={vG7L$Qdv3nt_fEurUGPi#$jEje}jwZZ~A-j((jg^X( zl8wZYFT;>M>zM`7ol4uBKkA+h=AI_*pa|xkFQ==ts;sB`qXGV)3jd!L-lt0cqYP)Ps~P{Q8U3pp{Hz)Ktr`EVA^xr<`m!SbvKarcBf7o9 z|F}c{zD51NNdLZ0_rg&6!b|VJfB(Qz{=!oA#bN%!VEx2h{l{DX$5!ITuKvhg|JjBA z=)jY8&gcLD00DGTPE!Ct=GbNc0004EOGiWihy@);0001~Nkl$KDDbS|FmcAAr?t&acy0W$yqz~S6bU0DR+w!S1?U9<-vDvl~^OABWG{l0ud*r=$g zDNKzl-<@qQ&L9};Y$$KuI$oWcUR#+Ucsgol{j!za^EQI7ok^Zgd-=HOCivVR. - -/** - * Strings for component 'repository_remotemoodle', language 'en', branch 'MOODLE_20_STABLE' - * - * @package repository_remotemoodle - * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -$string['configplugin'] = 'Configuration for remote Moodle file repository'; -$string['connectionfailure'] = 'Failed to retrieve file listing - The host moodle has either a version older than 2.0, either its Moodle Remote Repository service hasn\'t been activated'; -$string['emptyfilelist'] = 'There are no files to show'; -$string['failtoretrievelist'] = 'List could not be retrieved or is empty'; -$string['hostnotfound'] = 'Cannot find the remote Moodle into the database - contact your system administrator'; -$string['nopeer'] = 'Please setup some Moodle peers for your Moodle site.'; -$string['notitle'] = 'notitle'; -$string['peer'] = 'Peer'; -$string['remember'] = 'Remember me'; -$string['remotemoodle:view'] = 'View remote moodle repository'; -$string['remoterep_description'] = 'Allow the service to be discovered'; -$string['remoterep_name'] = 'Remote Moodle site'; -$string['repositorydesc'] = 'Files on a remote Moodle server'; -$string['repositoryname'] = 'Remote Moodle site'; -$string['usercannotaccess'] = 'You ({$a}) cannot access to this file'; -$string['usernotfound'] = 'The user {$a} is not registered into the remote Moodle'; diff --git a/repository/remotemoodle/repository.class.php b/repository/remotemoodle/repository.class.php deleted file mode 100644 index 02dcfdf7edb..00000000000 --- a/repository/remotemoodle/repository.class.php +++ /dev/null @@ -1,321 +0,0 @@ -. - -/** - * repository_remotemoodle class - * This plugin allowed to connect a retrieve a file from another Moodle site - * This is a subclass of repository class - * - * @since 2.0 - * @package moodlecore - * @subpackage repository - * @copyright 2009 Jerome Mouneyrac - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -require_once($CFG->dirroot.'/repository/lib.php'); - - -class repository_remotemoodle extends repository { - - /** - * Constructor of remotemoodle plugin, used to setup mnet environment - * @global object $SESSION - * @global object $CFG - * @param int $repositoryid - * @param object $context - * @param array $options - */ - public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array()) { - global $SESSION, $CFG; - parent::__construct($repositoryid, $context, $options); - $this->mnet = get_mnet_environment(); - } - - /** - * Retrieve a file for a user of the Moodle client calling this function - * The file is encoded in base64 - * @global object $DB - * @global object $USER - * @param string $username - * @param string $source - * @return array - */ - public function retrieveFile($username, $source) { - global $DB, $USER; - - $remoteclient = get_mnet_remote_client(); - - ///check the the user is known - ///he has to be previously connected to the server site in order to be in the database - //TODO: MDL-21318 this looks problematic, because global $USER would need to be set back after this, - // also is the user allowed to roam? - $USER = $DB->get_record('user',array('username' => $username, 'mnethostid' => $remoteclient->id)); - if (empty($USER)) { - throw new mnet_server_exception(9012, 'usernotfound', 'repository_remotemoodle', $username); - } - - $file = unserialize(base64_decode($source)); - $contextid = $file[0]; - $filearea = $file[1]; - $itemid = $file[2]; - $filepath = $file[3]; - $filename = $file[4]; - - ///check that the user has read permission on this file - $browser = get_file_browser(); - $fileinfo = $browser->get_file_info(get_context_instance_by_id($contextid), $filearea, $itemid, $filepath, $filename); - if (empty($fileinfo)) { - throw new mnet_server_exception(9013, 'usercannotaccess', 'repository_remotemoodle', $file); - } - - ///retrieve the file with file API functions and return it encoded in base64 - $fs = get_file_storage(); - $sf = $fs->get_file($contextid, $filearea, $itemid, $filepath, $filename); - $contents = base64_encode($sf->get_content()); - return array($contents, $sf->get_filename()); - } - - /** - * Retrieve file list for a user of the Moodle client calling this function - * @global object $DB - * @global object $USER - * @global object $CFG - * @param string $username - * @param string $search - * @return array - */ - public function getFileList($username, $search) { - global $DB, $USER, $CFG; - - $remoteclient = get_mnet_remote_client(); - ///check the the user is known - ///he has to be previously connected to the server site in order to be in the database - //TODO: MDL-21318 this looks problematic, because global $USER would need to be set back after this, - // also is the user allowed to roam? - $USER = $DB->get_record('user',array('username' => $username, 'mnethostid' => $remoteclient->id)); - if (empty($USER)) { - throw new mnet_server_exception(9012, 'usernotfound', 'repository_remotemoodle', $username); - } - - try { - return repository::get_user_file_tree($search); - } - catch (Exception $e) { - throw new mnet_server_exception(9014, 'failtoretrievelist', 'repository_remotemoodle'); - } - } - - /** - * Display the file listing - no login required - * @return array - */ - public function print_login() { - return $this->get_listing(); - } - - /** - * Display the file listing for the search term - * @param string $search_text - * @return array - */ - public function search($search_text) { - return $this->get_listing('', '', $search_text); - } - - /** - * Retrieve the file listing - file picker function - * @global object $CFG - * @global object $DB - * @global object $USER - * @param string $encodedpath - * @param int $page - * @param string $search - * @return array - */ - public function get_listing($encodedpath = '', $page = '', $search = '') { - global $CFG, $DB, $USER; - - ///check that the host has a version >2.0 - ///for that we check that the host has the getFileList() method implemented - ///We also check that this method has been activated (if it is not - ///the method will not be returned by the system method system/listMethods) - require_once($CFG->dirroot . '/mnet/xmlrpc/client.php'); - - ///check that the peer has been setup - if (!array_key_exists('peer',$this->options)) { - echo json_encode(array('e'=>get_string('error').' 9010: '.get_string('hostnotfound','repository_remotemoodle'))); - exit; - } - - $host = $DB->get_record('mnet_host',array('id' => $this->options['peer'])); //need to retrieve the host url - - ///check that the peer host exists into the database - if (empty($host)) { - echo json_encode(array('e'=>get_string('error').' 9011: '.get_string('hostnotfound','repository_remotemoodle'))); - exit; - } - - $mnet_peer = new mnet_peer(); - $mnet_peer->set_wwwroot($host->wwwroot); - $client = new mnet_xmlrpc_client(); - $client->set_method('system/listMethods'); - $client->send($mnet_peer); - $services = $client->response; - if (array_search('repository/remotemoodle/repository.class.php/getFileList', $services) === false) { - echo json_encode(array('e'=>get_string('connectionfailure','repository_remotemoodle'))); - exit; - } - - ///connect to the remote moodle and retrieve the list of files - $client->set_method('repository/remotemoodle/repository.class.php/getFileList'); - $client->add_param($USER->username); - $client->add_param($search); - - ///call the method and manage host error - if (!$client->send($mnet_peer)) { - $message =" "; - foreach ($client->error as $errormessage) { - $message .= "ERROR: $errormessage . "; - } - echo json_encode(array('e'=>$message)); //display all error messages - exit; - } - - $services = $client->response; - ///display error message if we could retrieve the list or if nothing were returned - if (empty($services)) { - echo json_encode(array('e'=>get_string('failtoretrievelist','repository_remotemoodle'))); - exit; - } - - return $services; - } - - - - /** - * Download a file - * @global object $CFG - * @param string $url the url of file - * @param string $file save location - * @return string the location of the file - * @see curl package - */ - public function get_file($url, $file = '') { - global $CFG, $DB, $USER; - - ///set mnet environment and set the mnet host - require_once($CFG->dirroot . '/mnet/xmlrpc/client.php'); - $host = $DB->get_record('mnet_host',array('id' => $this->options['peer'])); //retrieve the host url - $mnet_peer = new mnet_peer(); - $mnet_peer->set_wwwroot($host->wwwroot); - - ///create the client and set the method to call - $client = new mnet_xmlrpc_client(); - $client->set_method('repository/remotemoodle/repository.class.php/retrieveFile'); - $client->add_param($USER->username); - $client->add_param($url); - - ///call the method and manage host error - if (!$client->send($mnet_peer)) { - $message =" "; - foreach ($client->error as $errormessage) { - $message .= "ERROR: $errormessage . "; - } - echo json_encode(array('e'=>$message)); - exit; - } - - $services = $client->response; //service contains the file content in the first case of the array, - //and the filename in the second - - //the content has been encoded in base64, need to decode it - $content = base64_decode($services[0]); - $file = $services[1]; //filename - - ///create a temporary folder with a file - $path = $this->prepare_file($file); - ///fill the file with the content - $fp = fopen($path, 'w'); - fwrite($fp,$content); - fclose($fp); - - return array('path'=>$path); - - } - - /** - * Add Instance settings input to Moodle form - * @global object $CFG - * @global object $DB - * @param object $mform - */ - public function instance_config_form($mform) { - global $CFG, $DB; - - //retrieve only Moodle peers - $hosts = $DB->get_records_sql(' SELECT - h.id, - h.wwwroot, - h.ip_address, - h.name, - h.public_key, - h.public_key_expires, - h.transport, - h.portno, - h.last_connect_time, - h.last_log_id, - h.applicationid, - a.name as app_name, - a.display_name as app_display_name, - a.xmlrpc_server_url - FROM {mnet_host} h - JOIN {mnet_application} a ON h.applicationid=a.id - WHERE - h.id <> ? AND - h.deleted = 0 AND - a.name = ? AND - h.name <> ?', - array($CFG->mnet_localhost_id, 'moodle', 'All Hosts')); - $peers = array(); - foreach($hosts as $host) { - $peers[$host->id] = $host->name; - } - - - $mform->addElement('select', 'peer', get_string('peer', 'repository_remotemoodle'),$peers); - $mform->addRule('peer', get_string('required'), 'required', null, 'client'); - - if (empty($peers)) { - $mform->addElement('static', null, '', get_string('nopeer','repository_remotemoodle')); - } - } - - /** - * Names of the instance settings - * @return array - */ - public static function get_instance_option_names() { - ///the administrator just need to set a peer - return array('peer'); - } - public function supported_returntypes() { - return FILE_INTERNAL; - } -} - diff --git a/repository/remotemoodle/version.php b/repository/remotemoodle/version.php deleted file mode 100644 index 8254b62b5a8..00000000000 --- a/repository/remotemoodle/version.php +++ /dev/null @@ -1,18 +0,0 @@ -. - -$plugin->version = 2010021801;