Skip to content

Commit

Permalink
The big move to REST URLs.
Browse files Browse the repository at this point in the history
  • Loading branch information
csev committed May 17, 2017
1 parent 04e3d25 commit f9ab595
Show file tree
Hide file tree
Showing 50 changed files with 322 additions and 116 deletions.
8 changes: 4 additions & 4 deletions about-dev.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
define('COOKIE_SESSION', true);
if ( ! defined('COOKIE_SESSION') ) define('COOKIE_SESSION', true);
require_once("config.php");
$OUTPUT->header();
$OUTPUT->bodyStart();
Expand All @@ -16,9 +16,9 @@
It allows you to change any LTI lauch parameter and switch
between a sets of fake user account data.
</p>
<?php if ( $CFG->DEVELOPER ) { ?>
<a class="btn btn-primary" href="dev.php" role="button">Back</a>
<?php if ( false && $CFG->DEVELOPER ) { ?>
<a class="btn btn-primary" href="dev" role="button">Back</a>
<?php } else { ?>
<a class="btn btn-primary" href="<?= $CFG->apphome ?>/index.php" role="button">Back</a>
<a class="btn btn-primary" href="<?= $CFG->apphome ?>" role="button">Back</a>
<?php }
$OUTPUT->footer();
4 changes: 2 additions & 2 deletions about.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
define('COOKIE_SESSION', true);
if ( ! defined('COOKIE_SESSION') ) define('COOKIE_SESSION', true);
require_once("config.php");
$OUTPUT->header();
?>
Expand Down Expand Up @@ -31,7 +31,7 @@
trademark of <a href="http://www.imsglobal.org/" target="_blank">IMS Global Learning Consortium, Inc.</a>
in the United States and/or other countries.
</p>
<a class="btn btn-primary" href="index.php" role="button">Back</a>
<a class="btn btn-primary" href="<?= $CFG->wwwroot ?>" role="button">Back</a>
</div>
</div>
</body>
15 changes: 15 additions & 0 deletions admin/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^ - [E=protossl]
RewriteCond %{HTTPS} on
RewriteRule ^ - [E=protossl:s]
RewriteRule "(^|/)\." - [F]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ route.php [L]
</IfModule>

<IfModule !mod_rewrite.c>
FallbackResource route.php
</IfModule>
15 changes: 15 additions & 0 deletions admin/context/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^ - [E=protossl]
RewriteCond %{HTTPS} on
RewriteRule ^ - [E=protossl:s]
RewriteRule "(^|/)\." - [F]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ route.php [L]
</IfModule>

<IfModule !mod_rewrite.c>
FallbackResource route.php
</IfModule>
7 changes: 4 additions & 3 deletions admin/context/index.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
<?php
// In the top frame, we use cookies for session.
define('COOKIE_SESSION', true);
if (!defined('COOKIE_SESSION')) define('COOKIE_SESSION', true);
require_once("../../config.php");
require_once("../../admin/admin_util.php");

use \Tsugi\UI\Table;
use \Tsugi\Core\LTIX;

\Tsugi\Core\LTIX::getConnection();

header('Content-Type: text/html; charset=utf-8');
session_start();

if ( ! isAdmin() ) {
$_SESSION['login_return'] = $CFG->getUrlFull(__FILE__) . "/index.php";
$_SESSION['login_return'] = LTIX::curPageUrlFolder();
header('Location: '.$CFG->wwwroot.'/login.php');
return;
}
Expand All @@ -39,7 +40,7 @@
$OUTPUT->topNav();
$OUTPUT->flashMessages();

Table::pagedTable($newrows, $searchfields, $orderfields, "membership.php");
Table::pagedTable($newrows, $searchfields, $orderfields, "membership");

$OUTPUT->footer();

7 changes: 4 additions & 3 deletions admin/context/membership.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
<?php
// In the top frame, we use cookies for session.
define('COOKIE_SESSION', true);
if (!defined('COOKIE_SESSION')) define('COOKIE_SESSION', true);
require_once("../../config.php");
require_once("../../admin/admin_util.php");

use \Tsugi\UI\Table;
use \Tsugi\Core\LTIX;

\Tsugi\Core\LTIX::getConnection();

header('Content-Type: text/html; charset=utf-8');
session_start();

if ( ! isAdmin() ) {
$_SESSION['login_return'] = $CFG->getUrlFull(__FILE__) . "/index.php";
$_SESSION['login_return'] = LTIX::curPageUrlFolder();
header('Location: '.$CFG->wwwroot.'/login.php');
return;
}
Expand Down Expand Up @@ -50,7 +51,7 @@
$OUTPUT->flashMessages();
?>
<p>
<a href="index.php" class="btn btn-default">View Contexts</a>
<a href="<?= LTIX::curPageUrlFolder() ?>" class="btn btn-default">View Contexts</a>
</p>
<?php

Expand Down
20 changes: 20 additions & 0 deletions admin/context/route.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

define('COOKIE_SESSION', true);
require_once('../../config.php');

// Make PHP paths pretty .../install => install.php
$router = new Tsugi\Util\FileRouter();
$file = $router->fileCheck();
if ( $file ) {
require_once($file);
return;
}

// Add 404 Handling
http_response_code(404);
$OUTPUT->header();
$OUTPUT->bodyStart();
$OUTPUT->topNav();
echo("<h2>Page not found.</h2>\n");
$OUTPUT->footer();
14 changes: 7 additions & 7 deletions admin/index.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
define('COOKIE_SESSION', true);
if ( ! defined('COOKIE_SESSION') ) define('COOKIE_SESSION', true);
require_once("../config.php");
session_start();
require_once("gate.php");
Expand All @@ -21,25 +21,25 @@
<h1>Welcome Adminstrator</h1>
<ul>
<li>
<a href="upgrade.php" title="Upgrade Database" target="iframe-frame"
<a href="upgrade" title="Upgrade Database" target="iframe-frame"
onclick="showModalIframe(this.title, 'iframe-dialog', 'iframe-frame', _TSUGI.spinnerUrl, true);" >
Ugrade Database
</a>
<li>
<a href="nonce.php" title="Check Nonces" target="iframe-frame"
<a href="nonce" title="Check Nonces" target="iframe-frame"
onclick="showModalIframe(this.title, 'iframe-dialog', 'iframe-frame', _TSUGI.spinnerUrl);" >
Check Nonces
</a></li>
<li>
<a href="recent.php" title="Recent Logins" target="iframe-frame"
<a href="recent" title="Recent Logins" target="iframe-frame"
onclick="showModalIframe(this.title, 'iframe-dialog', 'iframe-frame', _TSUGI.spinnerUrl);" >
Recent Logins
</a></li>
<li><a href="context/index.php">View Contexts</a></li>
<li><a href="context/">View Contexts</a></li>
<?php if ( $CFG->providekeys ) { ?>
<li><a href="key/index.php">Manage Access Keys</a></li>
<li><a href="key">Manage Access Keys</a></li>
<?php } ?>
<li><a href="install/index.php">Manage Installed Modules</a></li>
<li><a href="install">Manage Installed Modules</a></li>
</ul>
<?php

Expand Down
2 changes: 1 addition & 1 deletion admin/install/git.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use \Tsugi\Util\LTI;
use \Tsugi\Core\Cache;

define('COOKIE_SESSION', true);
if (!defined('COOKIE_SESSION')) define('COOKIE_SESSION', true);
require_once("../../config.php");
session_start();
if ( ! isset($_SESSION["admin"]) ) {
Expand Down
2 changes: 1 addition & 1 deletion admin/install/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use \Tsugi\Core\LTIX;
use \Tsugi\Util\Git;

define('COOKIE_SESSION', true);
if (!defined('COOKIE_SESSION')) define('COOKIE_SESSION', true);
require_once("../../config.php");
session_start();
require_once("../gate.php");
Expand Down
2 changes: 1 addition & 1 deletion admin/install/repos_json.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use \Tsugi\Core\Cache;
use \Tsugi\UI\Lessons;

define('COOKIE_SESSION', true);
if (!defined('COOKIE_SESSION')) define('COOKIE_SESSION', true);
require_once("../../config.php");
session_start();
if ( ! isset($_SESSION["admin"]) ) {
Expand Down
15 changes: 15 additions & 0 deletions admin/key/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^ - [E=protossl]
RewriteCond %{HTTPS} on
RewriteRule ^ - [E=protossl:s]
RewriteRule "(^|/)\." - [F]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ route.php [L]
</IfModule>

<IfModule !mod_rewrite.c>
FallbackResource route.php
</IfModule>
6 changes: 3 additions & 3 deletions admin/key/approve-key.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
// In the top frame, we use cookies for session.
define('COOKIE_SESSION', true);
if (!defined('COOKIE_SESSION')) define('COOKIE_SESSION', true);
require_once("../../config.php");
require_once("../../admin/admin_util.php");

Expand All @@ -20,7 +20,7 @@
die("request_id required");
}

$from_location = "request-detail.php?request_id=".$_REQUEST['request_id'];
$from_location = "request-detail?request_id=".$_REQUEST['request_id'];

$row = $PDOX->rowDie(
"SELECT request_id, title, notes, admin, state, lti, R.created_at, R.updated_at, R.user_id, displayname, email
Expand Down Expand Up @@ -98,7 +98,7 @@
error_log("New LTI 1.x Key Inserted: $oauth_consumer_key User: ".$row['email']);
} else {
$message .= "\nThe URL for LTI 2.x Registration is at\n\n";
$message .= $CFG->wwwroot . "/lti/register.php\n\n";
$message .= $CFG->wwwroot . "/lti/register\n\n";
error_log("LTI 2.x Key Approved request_id=".$_REQUEST['request_id']." User: ".$row['email']);
}

Expand Down
19 changes: 10 additions & 9 deletions admin/key/index.php
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
<?php
// In the top frame, we use cookies for session.
define('COOKIE_SESSION', true);
if ( ! defined('COOKIE_SESSION') ) define('COOKIE_SESSION', true);
require_once("../../config.php");
require_once("../../admin/admin_util.php");

use \Tsugi\UI\Table;
use \Tsugi\Core\Mail;
use \Tsugi\Core\LTIX;

\Tsugi\Core\LTIX::getConnection();

if ( $CFG->providekeys === false || $CFG->owneremail === false ) {
$_SESSION['error'] = _m("This service does not accept instructor requests for keys");
header('Location: '.$CFG->wwwroot.'/index.php');
header('Location: '.$CFG->wwwroot);
return;
}

header('Content-Type: text/html; charset=utf-8');
session_start();

if ( ! ( isset($_SESSION['id']) || isAdmin() ) ) {
$_SESSION['login_return'] = $CFG->getUrlFull(__FILE__) . "/index.php";
header('Location: '.$CFG->wwwroot.'/login.php');
$_SESSION['login_return'] = LTIX::curPageUrlFolder();
header('Location: '.$CFG->wwwroot.'/login');
return;
}

Expand All @@ -31,13 +32,13 @@
isset($_POST['title']) && isset($_POST['notes']) ) {
if ( strlen($_POST['title']) < 1 ) {
$_SESSION['error'] = _m("Requests must have titles");
header("Location: index.php");
header("Location: ".LTIX::curPageUrl());
return;
}
$version = $_POST['lti']+0;
if ( $version != 1 && $version != 2 ) {
$_SESSION['error'] = _m("LTI Version muse be 1 or 2");
header("Location: index.php");
header("Location: ".LTIX::curPageUrlFolder());
return;
}
$stmt = $PDOX->queryDie(
Expand All @@ -59,7 +60,7 @@
$retval = Mail::send($to, $subject, $message, $user_id, $token);
}
$_SESSION['success'] = "Record inserted";
header("Location: index.php");
header("Location: ".LTIX::curPageUrlFolder());
return;
}

Expand Down Expand Up @@ -98,7 +99,7 @@
?>
<h1>LTI Key Requests</h1>
<p>
<a href="keys.php" class="btn btn-default">View Keys</a>
<a href="keys" class="btn btn-default">View Keys</a>
<a href="#" class="btn btn-default" onclick="
showModal('Using this key', 'about-div');
return false;
Expand Down Expand Up @@ -235,7 +236,7 @@
to request access to this service.
</p>
<?php } else {
Table::pagedTable($newrows, $searchfields, false, "request-detail.php");
Table::pagedTable($newrows, $searchfields, false, "request-detail");
}
if ( $goodsession ) { ?>
<p>
Expand Down
4 changes: 2 additions & 2 deletions admin/key/key-add.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
// In the top frame, we use cookies for session.
define('COOKIE_SESSION', true);
if (!defined('COOKIE_SESSION')) define('COOKIE_SESSION', true);
require_once("../../config.php");
require_once("../../admin/admin_util.php");

Expand All @@ -15,7 +15,7 @@
die('Must be logged in or admin');
}

$from_location = "keys.php";
$from_location = "keys";
$tablename = "{$CFG->dbprefix}lti_key";
if ( isAdmin() ) {
$fields = array("key_key", "key_sha256", "secret", "created_at", "updated_at", "user_id");
Expand Down
4 changes: 2 additions & 2 deletions admin/key/key-detail.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
// In the top frame, we use cookies for session.
define('COOKIE_SESSION', true);
if (!defined('COOKIE_SESSION')) define('COOKIE_SESSION', true);
require_once("../../config.php");
require_once("../../admin/admin_util.php");

Expand All @@ -17,7 +17,7 @@

$tablename = "{$CFG->dbprefix}lti_key";
$current = $CFG->getCurrentFileUrl(__FILE__);
$from_location = "keys.php";
$from_location = "keys";
$allow_delete = true;
$allow_edit = true;
$where_clause = '';
Expand Down
Loading

0 comments on commit f9ab595

Please sign in to comment.