$toolbox->lti_authenticate(); exit; } /* if authenticated LTI launch, head off to app.php */ if (!empty($_SESSION[ToolProvider::class]['canvas'])) { header("Location: control-panel.php"); exit; /* if not authenticated, default to showing credentials */ } else { $action = empty($action) ? ACTION_CONFIG : $action; } /* process any actions */ switch ($action) { /* reset cached install data from config file */ case ACTION_INSTALL: $_SESSION['toolbox'] = Toolbox::fromConfiguration(CONFIG_FILE, true); $toolbox =& $_SESSION['toolbox']; /* test to see if we can connect to the API */ try { $toolbox->getAPI(); } catch (ConfigurationException $e) { /* if there isn't an API token in config.xml, are there OAuth credentials? */ if ($e->getCode() === ConfigurationException::CANVAS_API_INCORRECT) { $toolbox->interactiveGetAccessToken(); exit; } else { /* no (understandable) API credentials available -- doh! */ throw $e; } } /* finish by opening consumers control panel */
<?php require_once __DIR__ . '/vendor/autoload.php'; use smtech\CanvasHack\Toolbox; use smtech\ReflexiveCanvasLTI\LTI\ToolProvider; use Battis\DataUtilities; define('CONFIG_FILE', __DIR__ . '/config.xml'); define('CANVAS_INSTANCE_URL', 'canvasInstanceUrl'); @session_start(); // TODO I don't feel good about suppressing warnings /* prepare the toolbox */ if (empty($_SESSION[Toolbox::class])) { $_SESSION[Toolbox::class] =& Toolbox::fromConfiguration(CONFIG_FILE); } $toolbox =& $_SESSION[Toolbox::class]; if (php_sapi_name() !== 'cli') { $toolbox->smarty_prependTemplateDir(__DIR__ . '/templates', basename(__DIR__)); $toolbox->smarty_assign(['category' => DataUtilities::titleCase(preg_replace('/[\\-_]+/', ' ', basename(__DIR__)))]); $smarty =& $toolbox->getSmarty(); // FIXME } /* * FIXME convience variables until plugins are all updated */ $api =& $toolbox->getAPI(); $sql =& $toolbox->getMySQL(); $customPrefs =& $toolbox->getCustomPrefs(); /* set the Tool Consumer's instance URL, if present */ if (empty($_SESSION[CANVAS_INSTANCE_URL])) { if (!empty($_SESSION[ToolProvider::class]['canvas']['api_domain'])) { $_SESSION[CANVAS_INSTANCE_URL] = 'https://' . $_SESSION[ToolProvider::class]['canvas']['api_domain'];