Ejemplo n.º 1
0
 /**
  * Get the LTI data connector
  *
  * @return \LTI_Data_Connector
  */
 public function getLtiDataConnector()
 {
     if (!$this->exists('res.lti.connector')) {
         $this->set('res.lti.connector', \LTI_Data_Connector::getDataConnector(new \LTI_Data_Connector_PDO($this->getDb())));
     }
     return $this->get('res.lti.connector');
 }
Ejemplo n.º 2
0
 /**
  * Initialize the extension
  */
 public function init()
 {
     Yii::import('application.vendors.*');
     require_once 'lti_tool_provider/LTI_Tool_Provider.php';
     $this->defaults();
     $this->data_connector = LTI_Data_Connector::getDataConnector($this->table_prefix, $this->db);
     $this->tool = new $this->lti_tool_provider_name($this->data_connector);
     echo $this->lti_tool_provider_name;
     // TODO: create database, if tables not exist...
 }
Ejemplo n.º 3
0
function lti_parse_request($wp)
{
    if (is_basic_lti_request()) {
        global $wpdb;
        /*$secret = lti_get_secret_from_consumer_key();
        		$consumer_key = $_POST[ 'oauth_consumer_key' ] ;*/
        //$db_connector = LTI_Data_Connector::getDataConnector('', 'none');
        get_lti_hash();
        // initialise the remote login hash
        // oritgigo: These two lines made it possible to connect to the database
        mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
        mysql_select_db(DB_NAME);
        $db_connector = LTI_Data_Connector::getDataConnector($wpdb->base_prefix);
        $consumer = new LTI_Tool_Consumer($consumer_key, $db_connector);
        $tool = new LTI_Tool_Provider('lti_do_actions', $db_connector);
        $tool->execute();
    }
}
Ejemplo n.º 4
0
<?php

require_once 'common.inc.php';
/* clear any existing session data */
if (session_status() === PHP_SESSION_NONE) {
    session_start();
}
$_SESSION = array();
session_destroy();
session_start();
/* set up a Tool Provider (TP) object to process the LTI request */
$toolProvider = new CanvasAPIviaLTI(LTI_Data_Connector::getDataConnector($sql));
$toolProvider->setParameterConstraint('oauth_consumer_key', TRUE, 50);
$toolProvider->setParameterConstraint('resource_link_id', TRUE, 50, array('basic-lti-launch-request'));
$toolProvider->setParameterConstraint('user_id', TRUE, 50, array('basic-lti-launch-request'));
$toolProvider->setParameterConstraint('roles', TRUE, NULL, array('basic-lti-launch-request'));
$_SESSION['toolProvider'] = $toolProvider;
/* process the LTI request from the Tool Consumer (TC) */
$toolProvider->handle_request();
 public function User_delete($user)
 {
     $sql = sprintf("DELETE FROM {$this->dbTableNamePrefix}" . LTI_Data_Connector::USER_TABLE_NAME . ' ' . 'WHERE (consumer_key = %s) AND (context_id = %s) AND (user_id = %s)', LTI_Data_Connector::quoted($user->getResourceLink()->getKey()), LTI_Data_Connector::quoted($user->getResourceLink()->getId()), LTI_Data_Connector::quoted($user->getId(LTI_Tool_Provider::ID_SCOPE_ID_ONLY)));
     $ok = mysql_query($sql);
     if ($ok) {
         $user->initialise();
     }
     return $ok;
 }
Ejemplo n.º 6
0
    if ($valid) {
        $consumer = new LTI_Tool_Consumer($_key, LTI_Data_Connector::getDataConnector($sql));
        $consumer->name = $_name;
        $consumer->secret = $_REQUEST['secret'];
        $consumer->enabled = isset($_REQUEST['enabled']);
        if (!$consumer->save()) {
            $valid = false;
            $message = "<strong>Consumer could not be saved.</strong> {$sql->error}";
        }
    }
    if (!$valid) {
        $smarty->addMessage('Required information missing', $message, NotificationMessage::ERROR);
    }
    /* look up consumer to edit, if requested */
} elseif (isset($_REQUEST['consumer_key'])) {
    $consumer = new LTI_Tool_Consumer($_REQUEST['consumer_key'], LTI_Data_Connector::getDataConnector($sql));
    if (isset($_REQUEST['action'])) {
        switch ($_REQUEST['action']) {
            case 'delete':
                $consumer->delete();
                break;
            case 'select':
                $name = $consumer->name;
                $key = $consumer->getKey();
                $secret = $consumer->secret;
                $enabled = $consumer->enabled;
                break;
            case 'update':
            case 'insert':
            default:
                // leave default form values set
 /**
  * Save the resource link share key to the database.
  *
  * @return boolean True if the share key was successfully saved
  */
 public function save()
 {
     if (empty($this->life)) {
         $this->life = self::DEFAULT_SHARE_KEY_LIFE;
     } else {
         $this->life = max(min($this->life, self::MAX_SHARE_KEY_LIFE), 0);
     }
     $this->expires = time() + $this->life * 60 * 60;
     if (empty($this->id)) {
         if (empty($this->length) || !is_numeric($this->length)) {
             $this->length = self::MAX_SHARE_KEY_LENGTH;
         } else {
             $this->length = max(min($this->length, self::MAX_SHARE_KEY_LENGTH), self::MIN_SHARE_KEY_LENGTH);
         }
         $this->id = LTI_Data_Connector::getRandomString($this->length);
     }
     return $this->data_connector->Resource_Link_Share_Key_save($this);
 }
Ejemplo n.º 8
0
require_once 'lib.php';
class Ndar_LTI_Tool_Provider extends LTI_Tool_Provider
{
    function onLaunch()
    {
        global $db;
        echo 'IN LAUNCH';
        //        $ndarBase = 'http://test.newdealartregistry.org';
        //        $roleString = implode('|', $this->user->roles);
        //        if (stripos($roleString, "Instructor")) {
        //            $location = $ndarBase . '/adminLogin?email=ltiuser@kinexis.com&password=lticlass';
        //        }
        //        header("Location: " . $location);
        //        die();
        exit;
    }
    function onError()
    {
        var_export($this->details);
        var_export($_POST);
        exit;
    }
}
openlog('php', LOG_CONS | LOG_NDELAY | LOG_PID, LOG_USER | LOG_PERROR);
// Initialise database
$db = NULL;
if (init($db)) {
    $data_connector = LTI_Data_Connector::getDataConnector(DB_TABLENAME_PREFIX, $db);
    $tool = new Ndar_LTI_Tool_Provider($data_connector);
    $tool->handle_request();
}
Ejemplo n.º 9
0
            return var_dump($env);
            break;
        case 'info':
            return phpinfo();
            break;
        default:
            echo "undefined function_type";
    }
}
# mainline
require_once 'LTI_Tool_Provider.php';
openlog('php', LOG_CONS | LOG_NDELAY | LOG_PID, LOG_USER | LOG_PERROR);
//syslog(LOG_WARNING, 'starting TP');
$configs = (include 'config.php');
$db = new mysqli($configs['db_server'], $configs['db_user'], $configs['db_password'], $configs['db_schema']);
$db_connector = LTI_Data_Connector::getDataConnector('', $db);
$consumer = new LTI_Tool_Consumer('testing.edu', $db_connector);
$consumer->name = '12345';
$consumer->secret = 'secret';
$consumer->save();
# enable tool consumer
if (!is_null($consumer->created)) {
    $consumer->enabled = TRUE;
    $consumer->save();
}
//var_dump($consumer);
$full_path = $_SERVER['REQUEST_URI'];
$paths = explode('/', $full_path);
if (count($paths) >= 2) {
    $path = $paths[1];
} else {
Ejemplo n.º 10
0
<?php

/* clear any existing session data */
if (session_status() === PHP_SESSION_ACTIVE) {
    session_destroy();
}
define('LAUNCHING_LTI', true);
require_once 'common.inc.php';
use smcs\language_lab\LanguageLabLTI;
/* set up a Tool Provider (TP) object to process the LTI request */
$toolProvider = new LanguageLabLTI(LTI_Data_Connector::getDataConnector($sql));
$toolProvider->setParameterConstraint('oauth_consumer_key', TRUE, 50);
$toolProvider->setParameterConstraint('resource_link_id', TRUE, 50, array('basic-lti-launch-request'));
$toolProvider->setParameterConstraint('user_id', TRUE, 50, array('basic-lti-launch-request'));
$toolProvider->setParameterConstraint('roles', TRUE, NULL, array('basic-lti-launch-request'));
/* process the LTI request from the Tool Consumer (TC) */
$toolProvider->handle_request();
exit;
Ejemplo n.º 11
0
/*
 *  wordpress-lti - WordPress module to add LTI support
 *  Copyright (C) 2013  Simon Booth, Stephen P Vickers
 *
 *  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.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 *  Contact: s.p.booth@stir.ac.uk
 *
 *  Version history:
 *    1.0.00  18-Apr-13  Initial release
 */
/** Load WordPress Administration Bootstrap */
require_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . DIRECTORY_SEPARATOR . 'wp-admin' . DIRECTORY_SEPARATOR . 'admin.php';
// include the library
require_once 'lib.php';
header('Content-type: application/json');
echo '{"Key": "' . lti_get_guid() . '","Secret": "' . LTI_Data_Connector::getRandomString(32) . '"}';
Ejemplo n.º 12
0
function lti_get_guid()
{
    $lti_scope = 3;
    if (isset($_GET['lti_scope'])) {
        $lti_scope = $_GET['lti_scope'];
    }
    $str = strtoupper(LTI_Data_Connector::getRandomString(6));
    return 'WP' . $lti_scope . '-' . $str;
}