Skip to content

Commit

Permalink
Merge pull request #333 from ucfopen/dev/v2-3-1
Browse files Browse the repository at this point in the history
version 2.3.1 release
  • Loading branch information
bagofarms authored Feb 15, 2018
2 parents 6f255c9 + e345c89 commit 8076437
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 24 deletions.
2 changes: 1 addition & 1 deletion config/localConfig.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
$doc_length = '1500';

/* Unscannable Suggestion */
$unscannable_suggestion = 'Consider converting these documents to Pages, since they are easier to update and generally more accessible.';
$unscannable_suggestion = 'Consider converting these documents to Pages, since they are easier to update, easier to view on mobile devices, and generally more accessible.';
$unscannable_suggestion_on = true;

/* Tool name for display in Canvas Navigation */
Expand Down
4 changes: 2 additions & 2 deletions config/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
define('ENV_TEST', 'test');
define('ENV_PROD', 'prod');
define('ENV_DEV', 'dev');
define('UDOIT_VERSION', '2.3.0');
define('UDOIT_VERSION', '2.3.1');

// SET UP AUTOLOADER (uses autoload rules from composer)
require_once(__DIR__.'/../vendor/autoload.php');
Expand Down Expand Up @@ -32,7 +32,7 @@
isset($UDOIT_ENV) || $UDOIT_ENV = ENV_PROD; // !! override in your localConfig.php

// SET UP OAUTH
UdoitUtils::setupOauth($oauth2_id, $oauth2_key, $oauth2_id, $consumer_key, $shared_secret);
UdoitUtils::setupOauth($oauth2_id, $oauth2_key, $oauth2_uri, $consumer_key, $shared_secret);

// SET UP DATABASE
UdoitDB::setup($db_type, $dsn, $db_user, $db_password);
Expand Down
12 changes: 10 additions & 2 deletions lib/UdoitJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,10 @@ protected static function finalizeReport($job_group, $job_data)

protected static function combineJobResults($job_group)
{
global $logger;
$totals = ['errors' => 0, 'warnings' => 0, 'suggestions' => 0];
$unscannables_items = [];
$content = [];
$unscannables_items = array();
$content = array();

// combine the data from each job's results
$sql = "SELECT * FROM job_queue WHERE job_group = '{$job_group}'";
Expand All @@ -182,12 +183,19 @@ protected static function combineJobResults($job_group)
$totals['warnings'] += $results['total_results']['warnings'];
$totals['suggestions'] += $results['total_results']['suggestions'];

// if the scan results array is empty for some reason,
// make sure it's an empty array and continue.
if (empty($results['scan_results'])) {
$results['scan_results'] = array();
}

// if unscannables are found, collect them
if (!empty($results['scan_results']['unscannable'])) {
$unscannables_items = array_merge($unscannables_items, $results['scan_results']['unscannable']);
unset($results['scan_results']['unscannable']);
}


// merge the scan results
$content = array_merge($content, $results['scan_results']);
}
Expand Down
16 changes: 11 additions & 5 deletions lib/UdoitUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,14 @@ public function getLocalApiKey($user_id)
$sth = UdoitDB::prepare("SELECT api_key, canvas_url FROM {$db_user_table} WHERE id = :userid LIMIT 1");
$sth->bindValue(':userid', $user_id, PDO::PARAM_INT);
$sth->execute();
if ($result = $sth->fetchObject()) {
self::$canvas_base_url = $result->canvas_url;

return $result->api_key;
if ($result = $sth->fetchObject()) {
if (empty($result->canvas_url)) {
return false;
} else {
self::$canvas_base_url = $result->canvas_url;
return $result->api_key;
}
}

return false;
Expand Down Expand Up @@ -209,11 +213,13 @@ public function createOrUpdateUser($user_id, $api_key, $refresh_token, $canvas_u
{
global $db_user_table;

$sth = UdoitDB::prepare("SELECT * FROM {$db_user_table} WHERE id = :userid AND canvas_url = :canvas_url LIMIT 1");
// Try to find the user first
// Note: We're not looking for a matching Canvas URL because the id field is unique
$sth = UdoitDB::prepare("SELECT * FROM {$db_user_table} WHERE id = :userid LIMIT 1");
$sth->bindValue(':userid', $user_id, PDO::PARAM_INT);
$sth->bindValue(':canvas_url', $canvas_url, PDO::PARAM_STR);
$sth->execute();

// If we found the user, update them. Otherwise, insert a new one.
if ($result = $sth->fetchObject()) {
$sth = UdoitDB::prepare("UPDATE {$db_user_table} SET api_key = :api_key, refresh_token = :refresh_token, canvas_url = :canvas_url WHERE id = :userid");
} else {
Expand Down
14 changes: 8 additions & 6 deletions lib/quail/quail/common/accessibility_tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -5724,12 +5724,14 @@ function check()
foreach ($table->childNodes as $child) {
if ($this->propertyIsEqual($child, 'tagName', 'tbody') || $this->propertyIsEqual($child, 'tagName', 'thead')) {
foreach ($child->childNodes as $tr) {
foreach ($tr->childNodes as $th) {
if ($this->propertyIsEqual($th, 'tagName', 'th')) {
break 3;
} else {
$this->addReport($table);
break 3;
if (!is_null($tr->childNodes)) {
foreach ($tr->childNodes as $th) {
if ($this->propertyIsEqual($th, 'tagName', 'th')) {
break 3;
} else {
$this->addReport($table);
break 3;
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions migrations/000_db_create_tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

if ('pgsql' === $db_type) {
// POSTGRESQL
echo("Setting up tables in PostgreSQL\r\n");
$tables = [
'
CREATE TABLE IF NOT EXISTS reports (
Expand All @@ -55,6 +56,7 @@

if ('mysql' === $db_type) {
// MYSQL
echo("Setting up tables in MySQL\r\n");
$tables = [
'
CREATE TABLE IF NOT EXISTS `reports` (
Expand Down
22 changes: 15 additions & 7 deletions migrations/001_move_reports_to_db.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,36 @@
// if 'file_path' col is missing, there's nothing to do
if (!$check_for_column($db_reports_table, 'file_path')) {
if (!getenv('UNITTEST')) {
echo("It looks like this script doesnt need to be run");
echo("No need to migrate old reports, continuing...\r\n");
}

return;
}

// add the column if it's missing
if ($check_for_column($db_reports_table, $col_to_add)) {
if (!$check_for_column($db_reports_table, $col_to_add)) {
// Quick hack to add report column since we dont have migrations yet
echo("Adding report_json column.\r\n");
$column_type = $db_type == 'mysql' ? 'MEDIUMTEXT' : 'TEXT';
$dbh->query("ALTER TABLE {$db_reports_table} ADD {$col_to_add} {$column_type}");
UdoitDB::query("ALTER TABLE {$db_reports_table} ADD {$col_to_add} {$column_type}");
}

// exit with warning if the column is still missing
if (!check_for_column($dbh, $db_reports_table, $col_to_add)) {
if (!getenv('UNITTEST')) {
echo("The migration script failed to create a ${col_to_add} column");
echo("The migration script failed to create a ${col_to_add} column\r\n");
}

return;
}

echo("Migrating old reports from disk to database.\r\n");

// Grab all rows from the reports table
if ($rows = UdoidDB::query('SELECT * FROM reports')) {
$rows = $rows->fetchAll();
}

// now move the reports from the report files into the database
$sth = UdoitDB::prepare("UPDATE {$db_reports_table} set {$col_to_add} = :report_json WHERE id = :id");
$count_moved = 0;
Expand All @@ -77,7 +85,7 @@

$file = __DIR__.'/'.$row['file_path'];
if (!file_exists($file)) {
echo("Json file not found {$file} for report id: {$row['id']}\n");
echo("Json file not found {$file} for report id: {$row['id']}\r\n");
continue;
}

Expand All @@ -93,12 +101,12 @@

if (!$res) {
print_r($sth->errorInfo());
echo("Failed inserting report for {$row['id']}\n");
echo("Failed inserting report for {$row['id']}\r\n");
continue;
}

$count_moved++;
}

UdoitDB::query("ALTER TABLE {$db_reports_table} DROP COLUMN file_path");
echo("Moved {$count_moved} reports from disk to the database. Feel free to delete the reports directory\n");
echo("Moved {$count_moved} reports from disk to the database. Feel free to delete the reports directory\r\n");
4 changes: 3 additions & 1 deletion migrations/002_add_background_queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

if ('pgsql' === $db_type) {
// POSTGRESQL
echo("Creating job_queue in PostgreSQL\r\n");
$queries = [
'
CREATE TABLE IF NOT EXISTS job_queue (
Expand All @@ -44,6 +45,7 @@

if ('mysql' === $db_type) {
// MYSQL
echo("Creating job_queue in MySQL\r\n");
$queries = [
'
CREATE TABLE IF NOT EXISTS `job_queue` (
Expand All @@ -52,7 +54,7 @@
`user_id` int(10) unsigned NOT NULL,
`job_type` varchar(255) NOT NULL,
`data` text,
`results` text,
`results` mediumtext,
`status` varchar(255) NOT NULL DEFAULT "new",
`date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`date_completed` timestamp,
Expand Down
2 changes: 2 additions & 0 deletions migrations/003_add_refresh_token_to_users.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

if ('pgsql' === $db_type) {
// POSTGRESQL
echo("Adding refresh_token and canvas_url fields in PostgreSQL\r\n");
$queries = [
[
'isRequired' => !$check_for_column('users', 'refresh_token'),
Expand All @@ -55,6 +56,7 @@

if ('mysql' === $db_type) {
// MYSQL
echo("Adding refresh_token and canvas_url fields in MySQL\r\n");
$queries = [
[
'isRequired' => !$check_for_column('users', 'refresh_token'),
Expand Down

0 comments on commit 8076437

Please sign in to comment.