Ejemplo n.º 1
0
 */

// disable moodle specific debug messages and any errors in output
define('NO_DEBUG_DISPLAY', true);
define('NO_MOODLE_COOKIES', true);

require('../../config.php');
require_once("$CFG->dirroot/webservice/rest/locallib.php");

if (!webservice_protocol_is_enabled('rest')) {
    die;
}

$restformat = optional_param('moodlewsrestformat', 'xml', PARAM_ALPHA);
//remove the alt from the request
if (isset($_REQUEST['moodlewsrestformat'])) {
    unset($_REQUEST['moodlewsrestformat']);
}
if (isset($_GET['moodlewsrestformat'])) {
    unset($_GET['moodlewsrestformat']);
}
if (isset($_POST['moodlewsrestformat'])) {
    unset($_POST['moodlewsrestformat']);
}

$server = new webservice_rest_server(WEBSERVICE_AUTHMETHOD_USERNAME);
$server->run();
die;


Ejemplo n.º 2
0
 /**
  * Get user information for online users
  *
  * @return array An array of arrays describing an atom feed
  */
 public static function get_online_users()
 {
     global $USER;
     // last 10 active users
     $users = get_onlineusers();
     // now format ready for atom
     $results = array('id' => sha1($_SERVER['HTTP_HOST'] . 'get_online_users' . time()), 'link' => get_config('wwwroot'), 'email' => $USER->get('email'), 'uri' => get_config('wwwroot'), 'title' => 'Get Online Users by ' . $USER->username . ' at ' . webservice_rest_server::format_rfc3339_date(time()), 'name' => 'mahara_user_external_get_online_users', 'updated' => webservice_rest_server::format_rfc3339_date(time()), 'entries' => array());
     foreach ($users['data'] as $user) {
         $user = get_record('usr', 'id', $user);
         if (empty($user)) {
             continue;
         }
         $results['entries'][] = array('id' => get_config('wwwroot') . 'user/view.php?id=' . $user->id, 'link' => get_config('wwwroot') . 'user/view.php?id=' . $user->id, 'email' => $user->email, 'name' => display_name($user), 'updated' => webservice_rest_server::format_rfc3339_date(strtotime($user->lastaccess)), 'published' => webservice_rest_server::format_rfc3339_date(time()), 'title' => 'last_access');
     }
     return $results;
 }