Skip to content

Commit

Permalink
Updates for PHP 8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
spvickers committed Jul 31, 2023
1 parent 9ef831a commit 3e015a0
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 46 deletions.
15 changes: 8 additions & 7 deletions src/admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use ceLTIc\LTI\Tool;
use ceLTIc\LTI\DataConnector\DataConnector;
use ceLTIc\LTI\Util;
use ceLTIc\LTI\Enum\LtiVersion;

/**
* This page manages the definition of LTI platform records. A platform record is required to
Expand Down Expand Up @@ -44,7 +45,7 @@
if (!empty($id) || !empty($_POST['name'])) {
if (empty($id)) {
$updatePlatform = new Platform($dataConnector);
$updatePlatform->ltiVersion = Util::LTI_VERSION1;
$updatePlatform->ltiVersion = LtiVersion::V1;
} else {
$updatePlatform = Platform::fromRecordId($id, $dataConnector);
}
Expand Down Expand Up @@ -102,8 +103,8 @@
$updatePlatform->jku = null;
}
if (!empty($_POST['ltiversion'])) {
$updatePlatform->ltiVersion = $_POST['ltiversion'];
if ($updatePlatform->ltiVersion === Util::LTI_VERSION1P3) {
$updatePlatform->ltiVersion = LtiVersion::tryFrom($_POST['ltiversion']);
if ($updatePlatform->ltiVersion === LtiVersion::V1P3) {
$updatePlatform->signatureMethod = 'RS256';
}
}
Expand Down Expand Up @@ -379,7 +380,7 @@ function doOnLoad() {
} else {
$mode = 'Update';
$update = ' disabled="disabled"';
if ($updatePlatform->ltiVersion === Util::LTI_VERSION2) {
if ($updatePlatform->ltiVersion === LtiVersion::V2) {
$lti2 = ' disabled="disabled"';
}
}
Expand Down Expand Up @@ -424,11 +425,11 @@ function doOnLoad() {
} else {
$debug = '';
}
$v1 = Util::LTI_VERSION1;
$v1p3 = Util::LTI_VERSION1P3;
$v1 = LtiVersion::V1->value;
$v1p3 = LtiVersion::V1P3->value;
$v1Selected = ' selected';
$v1p3Selected = '';
if ($updatePlatform->ltiVersion === $v1p3) {
if ($updatePlatform->ltiVersion === LtiVersion::V1P3) {
$v1Selected = '';
$v1p3Selected = ' selected';
}
Expand Down
7 changes: 4 additions & 3 deletions src/composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "celtic/rating",
"version": "4.2.0",
"version": "5.0.0",
"type": "project",
"license": "GPL-3.0-or-later",
"authors": [
Expand All @@ -10,9 +10,10 @@
}
],
"support": {
"docs": "http://www.spvsoftwareproducts.com/php/rating/"
"docs": "https://github.com/celtic-project/Rating-PHP/wiki"
},
"require": {
"celtic/lti": "^4.7.2"
"php": ">=8.1",
"celtic/lti": "^5.0.0"
}
}
3 changes: 2 additions & 1 deletion src/config-dist.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

use ceLTIc\LTI\Util;
use ceLTIc\LTI\Enum\LogLevel;

/**
* This page contains the configuration settings for the application.
Expand All @@ -15,7 +16,7 @@
// Uncomment the next line to log all PHP messages
// error_reporting(E_ALL);
// Set the application logging level
Util::$logLevel = Util::LOGLEVEL_ERROR;
Util::$logLevel = LogLevel::Error;

// Specify a prefix (starting with '/') when the REQUEST_URI server variable is missing the first part of the real path
define('REQUEST_URI_PREFIX', '');
Expand Down
4 changes: 2 additions & 2 deletions src/css/rateit.css
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
}

.rateit .rateit-preset-rtl {
background: url(star.gif) left -48px;
background: url(star.gif) right -48px;
}

.rateit button.rateit-reset {
Expand Down Expand Up @@ -108,7 +108,7 @@
color: #ccc;
}

.rateit-font .rateit-range > div {
.rateit-font .rateit-range > div, .rateit-font .rateit-range > span {
background: none;
overflow: hidden;
cursor: default;
Expand Down
31 changes: 16 additions & 15 deletions src/db.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use ceLTIc\LTI\DataConnector;
use ceLTIc\LTI\Util;
use ceLTIc\LTI\Enum\LogLevel;

/**
* This page provides functions for accessing the database.
Expand All @@ -13,7 +14,7 @@
require_once('vendor/autoload.php');

// Set the default application logging level
Util::$logLevel = Util::LOGLEVEL_ERROR;
Util::$logLevel = LogLevel::Error;

require_once('config.php');

Expand Down Expand Up @@ -65,8 +66,8 @@ function init_db($db)
$ok = true;
$prefix = DB_TABLENAME_PREFIX;

if (!tableExists($db, $prefix . DataConnector\DataConnector::CONSUMER_TABLE_NAME)) {
$sql = "CREATE TABLE {$prefix}" . DataConnector\DataConnector::CONSUMER_TABLE_NAME . ' (' .
if (!tableExists($db, $prefix . DataConnector\DataConnector::PLATFORM_TABLE_NAME)) {
$sql = "CREATE TABLE {$prefix}" . DataConnector\DataConnector::PLATFORM_TABLE_NAME . ' (' .
'consumer_pk int(11) NOT NULL AUTO_INCREMENT, ' .
'name varchar(50) NOT NULL, ' .
'consumer_key varchar(256) DEFAULT NULL, ' .
Expand Down Expand Up @@ -94,14 +95,14 @@ function init_db($db)
') ENGINE=InnoDB DEFAULT CHARSET=utf8';
$ok = $db->exec($sql) !== false;
if ($ok) {
$sql = "ALTER TABLE {$prefix}" . DataConnector\DataConnector::CONSUMER_TABLE_NAME . ' ' .
"ADD UNIQUE INDEX {$prefix}" . DataConnector\DataConnector::CONSUMER_TABLE_NAME . '_' .
$sql = "ALTER TABLE {$prefix}" . DataConnector\DataConnector::PLATFORM_TABLE_NAME . ' ' .
"ADD UNIQUE INDEX {$prefix}" . DataConnector\DataConnector::PLATFORM_TABLE_NAME . '_' .
'consumer_key_UNIQUE (consumer_key ASC)';
$ok = $db->exec($sql) !== false;
}
if ($ok) {
$sql = "ALTER TABLE {$prefix}" . DataConnector\DataConnector::CONSUMER_TABLE_NAME . ' ' .
"ADD UNIQUE INDEX {$prefix}" . DataConnector\DataConnector::CONSUMER_TABLE_NAME . '_' .
$sql = "ALTER TABLE {$prefix}" . DataConnector\DataConnector::PLATFORM_TABLE_NAME . ' ' .
"ADD UNIQUE INDEX {$prefix}" . DataConnector\DataConnector::PLATFORM_TABLE_NAME . '_' .
'platform_UNIQUE (platform_id ASC, client_id ASC, deployment_id ASC)';
$ok = $db->exec($sql) !== false;
}
Expand All @@ -118,8 +119,8 @@ function init_db($db)
if ($ok) {
$sql = "ALTER TABLE {$prefix}" . DataConnector\DataConnector::NONCE_TABLE_NAME . ' ' .
"ADD CONSTRAINT {$prefix}" . DataConnector\DataConnector::NONCE_TABLE_NAME . '_' .
DataConnector\DataConnector::CONSUMER_TABLE_NAME . '_FK1 FOREIGN KEY (consumer_pk) ' .
"REFERENCES {$prefix}" . DataConnector\DataConnector::CONSUMER_TABLE_NAME . ' (consumer_pk)';
DataConnector\DataConnector::PLATFORM_TABLE_NAME . '_FK1 FOREIGN KEY (consumer_pk) ' .
"REFERENCES {$prefix}" . DataConnector\DataConnector::PLATFORM_TABLE_NAME . ' (consumer_pk)';
$ok = $db->exec($sql) !== false;
}
}
Expand All @@ -138,8 +139,8 @@ function init_db($db)
if ($ok) {
$sql = "ALTER TABLE {$prefix}" . DataConnector\DataConnector::ACCESS_TOKEN_TABLE_NAME . ' ' .
"ADD CONSTRAINT {$prefix}" . DataConnector\DataConnector::ACCESS_TOKEN_TABLE_NAME . '_' .
DataConnector\DataConnector::CONSUMER_TABLE_NAME . '_FK1 FOREIGN KEY (consumer_pk) ' .
"REFERENCES {$prefix}" . DataConnector\DataConnector::CONSUMER_TABLE_NAME . ' (consumer_pk)';
DataConnector\DataConnector::PLATFORM_TABLE_NAME . '_FK1 FOREIGN KEY (consumer_pk) ' .
"REFERENCES {$prefix}" . DataConnector\DataConnector::PLATFORM_TABLE_NAME . ' (consumer_pk)';
$ok = $db->exec($sql) !== false;
}
}
Expand All @@ -160,8 +161,8 @@ function init_db($db)
if ($ok) {
$sql = "ALTER TABLE {$prefix}" . DataConnector\DataConnector::CONTEXT_TABLE_NAME . ' ' .
"ADD CONSTRAINT {$prefix}" . DataConnector\DataConnector::CONTEXT_TABLE_NAME . '_' .
DataConnector\DataConnector::CONSUMER_TABLE_NAME . '_FK1 FOREIGN KEY (consumer_pk) ' .
"REFERENCES {$prefix}" . DataConnector\DataConnector::CONSUMER_TABLE_NAME . ' (consumer_pk)';
DataConnector\DataConnector::PLATFORM_TABLE_NAME . '_FK1 FOREIGN KEY (consumer_pk) ' .
"REFERENCES {$prefix}" . DataConnector\DataConnector::PLATFORM_TABLE_NAME . ' (consumer_pk)';
$ok = $db->exec($sql) !== false;
}
if ($ok) {
Expand Down Expand Up @@ -190,8 +191,8 @@ function init_db($db)
if ($ok) {
$sql = "ALTER TABLE {$prefix}" . DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . ' ' .
"ADD CONSTRAINT {$prefix}" . DataConnector\DataConnector::RESOURCE_LINK_TABLE_NAME . '_' .
DataConnector\DataConnector::CONSUMER_TABLE_NAME . '_FK1 FOREIGN KEY (consumer_pk) ' .
"REFERENCES {$prefix}" . DataConnector\DataConnector::CONSUMER_TABLE_NAME . ' (consumer_pk)';
DataConnector\DataConnector::PLATFORM_TABLE_NAME . '_FK1 FOREIGN KEY (consumer_pk) ' .
"REFERENCES {$prefix}" . DataConnector\DataConnector::PLATFORM_TABLE_NAME . ' (consumer_pk)';
$ok = $db->exec($sql) !== false;
}
if ($ok) {
Expand Down
2 changes: 1 addition & 1 deletion src/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>{$here(APP_NAME)}</title>
<link href="css/rateit.css" media="screen" rel="stylesheet" type="text/css" />
<script src="js/jquery-3.3.1.min.js" type="text/javascript"></script>
<script src="js/jquery-3.7.0.min.js" type="text/javascript"></script>
<script src="js/jquery.rateit.min.js" type="text/javascript"></script>
<script src="js/rating.js?v={$here(APP_VERSION)}" type="text/javascript"></script>
<link href="css/rating.css?v={$here(APP_VERSION)}" media="screen" rel="stylesheet" type="text/css" />
Expand Down
2 changes: 0 additions & 2 deletions src/js/jquery-3.3.1.min.js

This file was deleted.

2 changes: 2 additions & 0 deletions src/js/jquery-3.7.0.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/js/jquery-3.7.0.min.map

Large diffs are not rendered by default.

Loading

0 comments on commit 3e015a0

Please sign in to comment.