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; }
} if (empty($_key = trim($_REQUEST['key']))) { $valid = false; $message .= 'Consumer key must not be empty. '; } if (empty(trim($_REQUEST['secret']))) { // secret may contain intentional whitespace -- leave untrimmed $valid = false; $message .= 'Shared secret must not be empty. '; } 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;
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 { echo $full_path; return; } switch ($path) {
/** * Demo function. Creates new LTI Consumer * @param string $key * @param string $name * @param string $secret * @param bool $enabled */ public function createConsumer($key = 'jisc.ac.uk', $name = 'ceLTIc', $secret = 'secret', $enabled = TRUE) { $consumer = new LTI_Tool_Consumer($key, $this->data_connector); if (is_null($consumer->created)) { $consumer->name = $name; $consumer->secret = $secret; $consumer->enabled = $enabled; return $consumer->save(); } return false; }
function lti_set_enable($key, $enable) { global $wpdb; $consumer = new LTI_Tool_Consumer($key, array($wpdb->prefix)); $consumer->enabled = $enable; $consumer->save(); }
<?php /*------------------------------------------------------------------- * Elgg LTI * * Enable/Disable consumer ------------------------------------------------------------------*/ // Must be logged in as admin to use this page admin_gatekeeper(); $consumer_instance = new LTI_Tool_Consumer_Instance(get_input('guid'), elgg_get_config('dbprefix')); $consumer_tool = new LTI_Tool_Consumer($consumer_instance->consumer_guid, elgg_get_config('dbprefix')); $consumer_tool->enabled = $consumer_instance->isEnabled() ? False : True; $consumer_tool->save(); forward(REFERRER);