Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

first commit

  • Loading branch information...
commit 6d1ff191c64d0724f2ed3053cd2c1dbadc5c9755 0 parents
@pgogy authored
38 activitystreams/db/services.php
@@ -0,0 +1,38 @@
+<?php
+
+// 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/>.
+
+/**
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+// We defined the web service functions to install.
+$functions = array(
+ 'local_activitystreams_get_streams' => array(
+ 'classname' => 'local_activitystreams_external',
+ 'methodname' => 'get_streams',
+ 'classpath' => 'local/activitystreams/externallib.php',
+ 'description' => 'Gets ActivityStrea.ms from Moodle\'s URL table',
+ 'type' => 'read',
+ )
+);
+
+// We define the services to install as pre-build services. A pre-build service is not editable by administrator.
+$services = array(
+ 'Activity Streams' => array(
+ 'functions' => array ('local_activitystreams_get_streams'),
+ 'restrictedusers' => 1,
+ 'enabled'=>1,
+ )
+);
84 activitystreams/externallib.php
@@ -0,0 +1,84 @@
+<?php
+
+// 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/>.
+
+/**
+ * Activity Streams Template
+ */
+require_once($CFG->libdir . "/externallib.php");
+
+class local_activitystreams_external extends external_api {
+
+ /**
+ * Returns description of method parameters
+ * @return external_function_parameters
+ */
+ public static function get_streams_parameters() {
+ return new external_function_parameters(
+ array('since' => new external_value(PARAM_INT, 'Unix Timestamp to return from', VALUE_DEFAULT, (time()-(86400*7))))
+ );
+ }
+
+ /**
+ * Returns welcome message
+ * @return string welcome message
+ */
+ public static function get_streams($since = 0) {
+ global $DB;
+
+ $params = self::validate_parameters(self::get_streams_parameters(), array('since'=>$time));
+
+ $sql_params = array($since);
+
+ $items = array();
+
+ $items['items'] = array();
+
+ $sql = "SELECT f.externalurl, f.timemodified FROM {url} f where f.timemodified > ?";
+
+ $records = $DB->get_records_sql($sql, $sql_params);
+
+ foreach($records as $record){
+
+ $data = array();
+
+ $data['published'] = $record->timemodified;
+ $data['actor'] = '';
+ $data['verb'] = 'Shared';
+
+ $url = array();
+
+ $url['url'] = str_replace("\\","",$record->externalurl);
+
+ $data['object'] = $url;
+
+ array_push($items['items'],$data);
+
+ }
+
+ return str_replace("\/","",json_encode($items));
+
+ }
+
+ /**
+ * Returns description of method result value
+ * @return external_description
+ */
+ public static function get_streams_returns() {
+ return new external_value(PARAM_TEXT, 'ActivityStrea.ms data from the URL table');
+ }
+
+
+
+}
21 activitystreams/lang/en/local_activitystreams.php
@@ -0,0 +1,21 @@
+<?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/>.
+
+/**
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+$string['pluginname'] = 'Activity Streams';
19 activitystreams/version.php
@@ -0,0 +1,19 @@
+<?php
+// 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/>.
+
+$plugin->version = 2011101245;
+$plugin->requires = 2010112400;
+$plugin->cron = 0;
+$plugin->release = '1.0 (Build: 2011101210)';
+$plugin->maturity = MATURITY_STABLE;
20 clients/client-rest.php
@@ -0,0 +1,20 @@
+<?php
+
+/// SETUP - NEED TO BE CHANGED
+$token = 'SET ME';
+$domainname = 'AND ME';
+$functionname = 'local_activitystreams_get_streams';
+
+// REST RETURNED VALUES FORMAT
+$restformat = 'xml'; //Also possible in Moodle 2.2 and later: 'json'
+ //Setting it to 'json' will fail all calls on earlier Moodle version
+
+/// REST CALL
+$params = array('since' => 0);
+
+header('Content-Type: text/plain');
+$serverurl = $domainname . '/webservice/rest/server.php'. '?wstoken=' . $token . '&wsfunction='.$functionname;
+require_once('./curl.php');
+$curl = new curl;
+$resp = $curl->post($serverurl, $params);
+print_r($resp);
41 clients/client-xmlrpc.php
@@ -0,0 +1,41 @@
+<?php
+// This client for local_wstemplate 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.
+//
+
+/**
+ * XMLRPC client for Moodle 2 - local_wstemplate
+ *
+ * This script does not depend of any Moodle code,
+ * and it can be called from a browser.
+ *
+ * @authorr Jerome Mouneyrac
+ */
+
+/// MOODLE ADMINISTRATION SETUP STEPS
+// 1- Install the plugin
+// 2- Enable web service advance feature (Admin > Advanced features)
+// 3- Enable XMLRPC protocol (Admin > Plugins > Web services > Manage protocols)
+// 4- Create a token for a specific user and for the service 'My service' (Admin > Plugins > Web services > Manage tokens)
+// 5- Run this script directly from your browser: you should see 'Hello, FIRSTNAME'
+
+/// SETUP - NEED TO BE CHANGED
+$token = 'ad991d354e363b250c038462dc8718c5';
+$domainname = 'http://localhost/moodle';
+
+/// FUNCTION NAME
+$functionname = 'local_activitystreams_get_streams';
+
+/// PARAMETERS
+$since = 0;
+
+///// XML-RPC CALL
+header('Content-Type: text/plain');
+$serverurl = $domainname . '/webservice/xmlrpc/server.php'. '?wstoken=' . $token;
+require_once('./curl.php');
+$curl = new curl;
+$post = xmlrpc_encode_request($functionname, array($since));
+$resp = xmlrpc_decode($curl->post($serverurl, $post));
+print_r($resp);
Please sign in to comment.
Something went wrong with that request. Please try again.