Example #1
0
<?php

/*-------------------------------------------------------------------
 * Elgg LTI
 *
 * List the sharing contexts
 ------------------------------------------------------------------*/
elgg_set_context('groups');
// Must be logged in to use this page
gatekeeper();
// Get group details
$group_guid = (int) get_input('group_guid');
$group = get_entity($group_guid);
elgg_set_page_owner_guid($group_guid);
// Sort out which consumer to get membership from
$consumer_instance = new LTI_Tool_Consumer_Instance($group->consumer_key, elgg_get_config('dbprefix'));
$context = new LTI_Context($consumer_instance, $group->context_id);
$list_of_shares = $context->getShares();
$area2 = elgg_view_title(elgg_echo('LTI:share:manage'));
if (!empty($list_of_shares)) {
    $text = '';
    foreach ($list_of_shares as $share) {
        $text .= elgg_view('object/shares', array('shares' => $share, 'group' => $group_guid));
    }
    $area2 .= $text;
} else {
    $area2 .= elgg_view('page/elements/body', array('body' => elgg_echo('LTI:share:noshared')));
}
$body = elgg_view_layout('two_column_left_sidebar', array('title' => '', 'content' => $area2));
// Finally draw the page
echo elgg_view_page($title, $body);
Example #2
0
$group = get_entity($group_guid);
set_page_owner($group_guid);
// Update synchronisation time
$contexts = array();
// Get logged in user
$cur_user = elgg_get_logged_in_user_entity();
$consumer_instance = new LTI_Tool_Consumer_Instance($cur_user->consumer_key, elgg_get_config('dbprefix'));
$context = new LTI_Context($consumer_instance, $cur_user->context_id);
// Add this context as must be used
$contexts[] = $context;
if ($cur_user->consumer_key == $group->consumer_key) {
    // add the shared contexts --- get all the contexts
    $shares = $context->getShares();
    foreach ($shares as $share) {
        $consumer_instance = new LTI_Tool_Consumer_Instance($share->consumer_instance_guid, elgg_get_config('dbprefix'));
        $context = new LTI_Context($consumer_instance, $share->context_id);
        $contexts[] = $context;
    }
}
foreach ($contexts as $context) {
    // First check that we have a membership service. Strictly speaking we shouldn't end up here unless
    // there is a service as the Sync option shouldn't appear
    if ($context->hasMembershipsService() && $context->hasSettingService()) {
        // Lets try and write back the current time
        $context->doSettingService(LTI_Context::EXT_WRITE, date('d-M-Y H:i'));
    }
}
$deletions = get_input('delete');
$delete = $deletions == 'yes' ? true : false;
$added_members = unserialize($_SESSION['added_members']);
if ($delete) {
Example #3
0
<?php

/*-------------------------------------------------------------------
 * Elgg LTI
 *
 * Create new share key
 ------------------------------------------------------------------*/
$group = get_entity(get_input('group_guid'));
$life = get_input('life');
$preapprove = get_input('preapprove');
$approve = $preapprove == 0 ? true : false;
$consumer_instance = new LTI_Tool_Consumer_Instance($group->consumer_key, elgg_get_config('dbprefix'));
$context = new LTI_Context($consumer_instance, $group->context_id);
forward('/' . elgg_get_config('ltiname') . '/shareinfo/' . group_guid . '/' . $context->getNewShareKey($life, $approve, 20));
Example #4
0
gatekeeper();
// Get group details
$group_guid = (int) get_input('group_guid');
$group = get_entity($group_guid);
elgg_set_page_owner_guid($group_guid);
// Get logged in user
$cur_user = elgg_get_logged_in_user_entity();
$consumer_instance = new LTI_Tool_Consumer_Instance($cur_user->consumer_key, elgg_get_config('dbprefix'));
$context = new LTI_Context($consumer_instance, $cur_user->context_id);
$contexts[] = $context;
if ($cur_user->consumer_key == $group->consumer_key) {
    // add the shared contexts --- get all the contexts
    $shares = $context->getShares();
    foreach ($shares as $share) {
        $consumer_instance = new LTI_Tool_Consumer_Instance($share->consumer_instance_guid, elgg_get_config('dbprefix'));
        $context = new LTI_Context($consumer_instance, $share->context_id);
        $contexts[] = $context;
    }
}
// Title
$area2 = elgg_view_title(elgg_echo('LTI:members:label'));
// Main text
$formbody = elgg_echo('LTI:members:explain');
// Read back the last sync time
if (sizeof($contexts) == 1 && $context->hasSettingService()) {
    $last_sync = $context->doSettingService(LTI_Context::EXT_READ, NULL);
    if (!empty($last_sync)) {
        $formbody .= sprintf(elgg_echo('LTI:members:explain:lastsync'), $last_sync);
    }
} else {
    $formbody .= sprintf(elgg_echo('LTI:members:explain:lastsync:share'));
Example #5
0
 // Get logged in user
 $cur_user = elgg_get_logged_in_user_entity();
 $consumer_instance = new LTI_Tool_Consumer_Instance($cur_user->consumer_key, elgg_get_config('dbprefix'));
 $context = new LTI_Context($consumer_instance, $cur_user->context_id);
 // Add this context as must be used
 $contexts[] = $context;
 // Check how synchronisation is to be done. If this instructor
 // is from primary context then synchronise across all contexts.
 // If the instructor is from a shared context than just
 // synchronise that context --- which is already set up
 if ($cur_user->consumer_key == $group->consumer_key) {
     // add the shared contexts --- get all the contexts
     $shares = $context->getShares();
     foreach ($shares as $share) {
         $consumer_instance = new LTI_Tool_Consumer_Instance($share->consumer_instance_guid, elgg_get_config('dbprefix'));
         $context = new LTI_Context($consumer_instance, $share->context_id);
         $contexts[] = $context;
     }
 }
 foreach ($contexts as $context) {
     $added_members = array();
     $user_provision = array();
     $membershipFromConsumer = array();
     // First check that we have a membership service. Strictly speaking we shouldn't end up here unless
     // there is a service as the Sync option shouldn't appear
     if ($context->hasMembershipsService()) {
         // Get array of membership from consumer
         $members = $context->doMembershipsService();
         // Failure and single context --- abandon with error message
         if (!$members && sizeof(contexts) == 1) {
             register_error(sprintf(elgg_echo('LTI:members:error:noservice'), $context->consumer_instance->guid));
Example #6
0
<?php

require_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php";
require_once 'BasicLTI_Tool_Provider.php';
$consumer_guid = $_GET['consumer_guid'];
$context_id = $_GET['context_id'];
$email = $_GET['email'];
$fromemail = $_GET['fromemail'];
$consumer_instance = new LTI_Tool_Consumer_Instance($consumer_guid, elgg_get_config('dbprefix'));
$context = new LTI_Context($consumer_instance, $context_id);
$life = $_GET['life'];
$param = $_GET['auto_approve'];
$auto_approve = !empty($param);
$key = $context->getNewShareKey($life, $auto_approve, SHARE_KEY_LENGTH);
if ($auto_approve) {
    $message = sprintf(elgg_echo('LTI:share:emailmsg:pre'), $key, $key, $life);
} else {
    $message = sprintf(elgg_echo('LTI:share:emailmsg'), $key, $key, $life);
}
$headers = 'From:' . $fromemail . "\r\n";
$headers .= "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$result = mail($email, elgg_echo('LTI:share:subject'), $message, $headers);
if ($result) {
    $premessage = sprintf(elgg_echo('LTI:share:email'), $email);
} else {
    $premessage = sprintf(elgg_echo('LTI:share:noemail'), $email);
}
echo $premessage . $message;
Example #7
0
<?php

/*-------------------------------------------------------------------
 * Elgg LTI
 *
 * Approve/Suspend share
 ------------------------------------------------------------------*/
elgg_set_context('groups');
// Must be logged in to use this page
gatekeeper();
$group_guid = (int) get_input('group');
$group = get_entity($group_guid);
set_page_owner($group_guid);
$consumer_instance = new LTI_Tool_Consumer_Instance(get_input('guid'), elgg_get_config('dbprefix'));
$context = new LTI_Context($consumer_instance, get_input('id'));
$approve = $context->share_approved ? false : true;
$primary_guid = $context->primary_consumer_instance_guid;
$consumer_instance = new LTI_Tool_Consumer_Instance($primary_guid, elgg_get_config('dbprefix'));
$context = new LTI_Context($consumer_instance, $context->primary_context_id);
$context->doApproveShare(get_input('guid'), get_input('id'), $approve);
forward(elgg_get_config('wwwroot') . elgg_get_config('ltiname') . '/sharemanage/' . $primary_guid . '/' . $group_guid);
Example #8
0
 *
 * Create a share key --- includes all the workflow text
 ------------------------------------------------------------------*/
elgg_set_context('groups');
// Must be logged in to use this page
gatekeeper();
// Get group details
$group_guid = (int) get_input('group_guid');
$group = get_entity($group_guid);
elgg_set_page_owner_guid($group_guid);
$area2 = elgg_view_title(elgg_echo('LTI:share:key'));
$area2 .= elgg_view('page/elements/body', array('body' => elgg_echo('LTI:share:explain')));
$area2 .= elgg_view('page/elements/body', array('body' => elgg_echo('LTI:share:workflow')));
// Is this context shared?
$consumer_instance = new LTI_Tool_Consumer_Instance(get_input('LTIconsumerguid'), elgg_get_config('dbprefix'));
$context = new LTI_Context($consumer_instance, $group->context_id);
$shares = $context->getShares();
if (!empty($shares)) {
    $area2 .= elgg_view('page/elements/body', array('body' => elgg_echo('LTI:share:shared')));
} else {
    $area2 .= elgg_view('page/elements/body', array('body' => elgg_echo('LTI:share:notshared')));
}
// Life dropdown
$formbody = '<div id="LTI_formarea"><table><tr><td>';
$formbody .= elgg_echo('LTI:share:life');
$formbody .= elgg_view('input/select', array('name' => 'life', 'options_values' => array('1' => '1 hr', '2' => '2 hr', '12' => '12 hr', '24' => '1 day', '48' => '2 day', '72' => '3 day', '96' => '4 day', '120' => '5 day', '168' => '1 week'), 'value' => '1 hr'));
$formbody .= '</td><td>&nbsp;</td><td>';
// Pre-approve Checkbox
$formbody .= elgg_echo('LTI:share:preapprove');
$formbody .= '</td><td>';
$formbody .= elgg_view('input/checkboxes', array('name' => 'auto_approve', 'options' => array('' => 'yes')));
Example #9
0
function LTI_Group_Delete($event, $object_type, $group)
{
    // Check we have LTI group (i.e. it has a context and consumer_key) and the delete
    // event is occurring
    if (!empty($group->context_id) && !empty($group->consumer_key) && $event == 'delete') {
        $consumer_instance = new LTI_Tool_Consumer_Instance($group->consumer_key, elgg_get_config('dbprefix'));
        $context = new LTI_Context($consumer_instance, $group->context_id);
        if (elgg_is_active_plugin('notifications')) {
            if ($context->hasMembershipsService()) {
                // Inform all instructors that group is being deleted using
                // membership list from consumer
                InformInstructorsViaLTIMembership($group, $context, $consumer_instance->guid);
            } else {
                // No Membership service, so use group members
                InformInstructorsViaGroupMembership($group);
            }
        }
        $context->delete();
    }
    return true;
}