Beispiel #1
0
function LTI_update_consumer($tool_guid, $name, $consumer_name, $url, $enable, $instance_guid, $secret, $state)
{
    // Deleting the instance allows us to update the key (if required)
    $consumerInstance = new LTI_Tool_Consumer_Instance(elgg_get_config('dbprefix'), $tool_guid);
    // Update consumer
    $consumer = new LTI_Tool_Consumer($tool_guid, elgg_get_config('dbprefix'));
    $consumer->name = $name;
    $consumer->consumer_name = $consumer_name;
    $consumer->profile_url = $url;
    $consumer->enabled = $enable == 'yes' ? true : false;
    $consumer->updated = time();
    $consumer->save();
    // Create new consumer instance
    $consumerInstance = new LTI_Tool_Consumer_Instance($instance_guid, elgg_get_config('dbprefix'));
    $consumerInstance->secret = $secret;
    $consumerInstance->state = $state;
    $consumerInstance->save();
    return;
}
Beispiel #2
0
<?php

/*-------------------------------------------------------------------
 * Elgg LTI
 *
 * This is called when administrator removes a consumer
 ------------------------------------------------------------------*/
// Must be logged in as admin to use this page
admin_gatekeeper();
// Sort out what is to go
$consumer_instance = new LTI_Tool_Consumer_Instance(get_input('LTIconsumerguid'), elgg_get_config('dbprefix'));
$consumer_tool = new LTI_Tool_Consumer($consumer_instance->consumer_guid, elgg_get_config('dbprefix'));
// Check we have right sort of object
if ($consumer_instance) {
    $consumer_instance->state = 'removed';
    $consumer_instance->save();
    if ($consumer_instance->state == 'removed') {
        system_message(sprintf(elgg_echo('LTI:remove:success'), $consumer_tool->name));
    } else {
        system_message(sprintf(elgg_echo('LTI:restore:success'), $consumer_tool->name));
    }
} else {
    register_error(sprintf(elgg_echo('LTI:remove:fail'), $consumer_tool->name));
}
forward($_SERVER['HTTP_REFERER']);