]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-12886 untested amf server
authorPetr Skoda <skodak@moodle.org>
Mon, 26 Oct 2009 19:30:12 +0000 (19:30 +0000)
committerPetr Skoda <skodak@moodle.org>
Mon, 26 Oct 2009 19:30:12 +0000 (19:30 +0000)
lang/en_utf8/webservice_amf.php
webservice/amf/db/access.php [new file with mode: 0644]
webservice/amf/lib.php [deleted file]
webservice/amf/locallib.php [new file with mode: 0644]
webservice/amf/server.php
webservice/amf/simpleserver.php [new file with mode: 0644]
webservice/amf/testclient/index.php
webservice/amf/version.php [new file with mode: 0644]
webservice/testclient.php

index f51fe76cb83dccd1485ae73c1c089bb491b91208..e3cf1d66d7528233346b44e3714459876047b838 100644 (file)
@@ -1,4 +1,3 @@
 <?php
 
-$string['amfdebug'] = 'AMF server debug mode';
 $string['pluginname'] = 'AMF protocok';
diff --git a/webservice/amf/db/access.php b/webservice/amf/db/access.php
new file mode 100644 (file)
index 0000000..c2397fc
--- /dev/null
@@ -0,0 +1,12 @@
+<?php
+
+$webservice_amf_capabilities = array(
+
+    'webservice/amf:use' => array(
+        'captype' => 'read', // in fact this may be considered read and write at the same time
+        'contextlevel' => CONTEXT_COURSE, // the context level should be probably CONTEXT_MODULE
+        'legacy' => array(
+        ),
+    ),
+
+);
diff --git a/webservice/amf/lib.php b/webservice/amf/lib.php
deleted file mode 100644 (file)
index 4e5fb0d..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-<?php
-/**
- * Moodle - Modular Object-Oriented Dynamic Learning Environment
- *         http://moodle.com
- *
- * LICENSE
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details:
- *
- *         http://www.gnu.org/copyleft/gpl.html
- *
- * @category  Moodle
- * @package   webservice
- * @copyright Copyright (c) 1999 onwards Martin Dougiamas     http://dougiamas.com
- * @license   http://www.gnu.org/copyleft/gpl.html     GNU GPL License
- */
-
-
-require_once($CFG->dirroot.'/webservice/lib.php');
-
-/*
- * AMF server class
- */
-final class amf_server extends webservice_server {
-
-
-    public function __construct() {
-        //set web service proctol name
-        $this->set_protocolname("Amf");
-        $this->set_protocolid("amf");
-    }
-
-    /**
-     * Run the AMF server
-     */
-    public function run() {
-        $enable = $this->get_enable();
-        if (empty($enable)) {
-            die;
-        }
-        include "Zend/Loader.php";
-        Zend_Loader::registerAutoload();
-
-        //retrieve the api name
-        $classpath = optional_param('classpath','user',PARAM_ALPHA);
-        require_once(dirname(__FILE__) . '/../../'.$classpath.'/external.php');
-
-        /// run the Zend AMF server
-        $server = new Zend_Amf_Server();
-        $debugmode = get_config($this->get_protocolid(),'debug');
-        if (!empty($debugmode)) {
-            $server->setProduction(false);
-        } else {
-            $server->setProduction(true);
-        }
-        $server->setClass($classpath."_external");
-        $response = $server->handle();
-        echo $response;
-    }
-
-    /**
-     * Names of the server settings
-     * @return array
-     */
-    public static function get_setting_names() {
-        return array('debug');
-    }
-
-    public function settings_form(&$mform) {
-        $debug = get_config($this->get_protocolid(), 'debug');
-        $debug = true;
-        if (empty($debug)) {
-            $debug = false;
-        }
-        $mform->addElement('checkbox', 'debug', get_string('amfdebug', 'webservice'));
-    }
-}
-
-?>
diff --git a/webservice/amf/locallib.php b/webservice/amf/locallib.php
new file mode 100644 (file)
index 0000000..1a86ca6
--- /dev/null
@@ -0,0 +1,53 @@
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * AMF web service implementation classes and methods.
+ *
+ * @package   webservice
+ * @copyright 2009 Moodle Pty Ltd (http://moodle.com)
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+require_once("$CFG->dirroot/webservice/lib.php");
+
+/**
+ * AMF service server implementation.
+ * @author Petr Skoda (skodak)
+ */
+class webservice_amf_server extends webservice_zend_server {
+    /**
+     * Contructor
+     * @param bool $simple use simple authentication
+     */
+    public function __construct($simple) {
+        require_once 'Zend/Amf/Server.php';
+        parent::__construct($simple, 'Zend_Amf_Server');
+        $this->wsname = 'amf';
+    }
+
+    /**
+     * Set up zend service class
+     * @return void
+     */
+    protected function init_zend_server() {
+        parent::init_zend_server();
+        // TODO: add some exception handling
+    }
+}
+
+// TODO: implement AMF test client somehow, maybe we could use moodle form to feed the data to the flash app somehow
index eeb9cf9f9723840bc9ecd0a207ee3f1b5ee87407..e25f11e76737626b6273648cfce07d2595c0c7fc 100644 (file)
@@ -1,39 +1,38 @@
 <?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
 /**
- * Moodle - Modular Object-Oriented Dynamic Learning Environment
- *         http://moodle.com
- *
- * LICENSE
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details:
+ * AMF web service entry point. The authentication is done via tokens.
  *
- *         http://www.gnu.org/copyleft/gpl.html
- *
- * @category  Moodle
  * @package   webservice
- * @copyright Copyright (c) 1999 onwards Martin Dougiamas     http://dougiamas.com
- * @license   http://www.gnu.org/copyleft/gpl.html     GNU GPL License
+ * @copyright 2009 Moodle Pty Ltd (http://moodle.com)
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
-/**
- * Moodle AMF server
- */
-require_once(dirname(__FILE__) . '/../../config.php');
-require_once('lib.php');
+define('NO_MOODLE_COOKIES', true);
+
+require('../../config.php');
+require_once("$CFG->dirroot/webservice/amf/locallib.php");
 
-if (empty($CFG->enablewebservices)) {
+if (!webservice_protocol_is_enabled('amf')) {
     die;
 }
 
-$server = new amf_server();
+$server = new webservice_amf_server(true);
 $server->run();
+die;
 
-?>
\ No newline at end of file
diff --git a/webservice/amf/simpleserver.php b/webservice/amf/simpleserver.php
new file mode 100644 (file)
index 0000000..2e89df7
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * AMF web service entry point. The authentication is done via tokens.
+ *
+ * @package   webservice
+ * @copyright 2009 Moodle Pty Ltd (http://moodle.com)
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+define('NO_MOODLE_COOKIES', true);
+
+require('../../config.php');
+require_once("$CFG->dirroot/webservice/amf/locallib.php");
+
+//ob_start();
+
+//TODO: for now disable all mess in xml
+ini_set('display_errors', '0');
+ini_set('log_errors', '1');
+$CFG->debugdisplay = false;
+
+if (!webservice_protocol_is_enabled('amf')) {
+    die;
+}
+
+$server = new webservice_amf_server(true);
+$server->run();
+die;
+
+
index c14d0fdd9aa2a5cb8707f669ec95a6b6e9d72828..6097e64904f1bfa14554976b0110a97f875d80c9 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 require "../../../config.php";
 
+die('TODO');
 
 $args['movie'] = $CFG->wwwroot.'/webservice/amf/testclient/moodleclient.swf';
 $args['width'] = '100%';
diff --git a/webservice/amf/version.php b/webservice/amf/version.php
new file mode 100644 (file)
index 0000000..f15e31b
--- /dev/null
@@ -0,0 +1,3 @@
+<?php
+
+$plugin->version = 2009101900;
index 6035ce43ee84641bd21f770f5f89a89c166811fd..22126378abbd75cebd3026f9b1d6ef8a0c009bbc 100644 (file)
@@ -52,6 +52,11 @@ foreach ($active_protocols as $p) {
     if (empty($available_protocols[$p])) {
         continue;
     }
+    include_once($available_protocols[$p].'/locallib.php');
+    if (!class_exists('webservice_'.$p.'_test_client')) {
+        // test client support not implemented
+        continue;
+    }
     $protocols[$p] = get_string('pluginname', 'webservice_'.$p);
 }
 if (!isset($protocols[$protocol])) { // whitelisting security