Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JI-5127 revert ch reverts #149

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions h5p.classes.php
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,13 @@ public function getContentHubMetadataChecked($lang = 'en');
* @return bool True if successful
*/
public function setContentHubMetadataChecked($time, $lang = 'en');

/**
* Callback for reset hub data
*
* @return void
*/
public function resetHubOrganizationData();
}

/**
Expand Down Expand Up @@ -3962,6 +3969,12 @@ public function hubAccountInfo() {
return false;
}

if ($accountInfo['status'] === 403) {
// Unauthenticated, cannot find site uuid
$this->h5pF->resetHubOrganizationData();
return false;
}

if ($accountInfo['status'] !== 200) {
$this->h5pF->setErrorMessage($this->h5pF->t('Unable to retrieve HUB account information. Please contact support.'));
return false;
Expand Down Expand Up @@ -4000,7 +4013,7 @@ public function hubRegisterAccount($formData, $logo) {
$headers = [];
$endpoint = H5PHubEndpoints::REGISTER;
// Update if already registered
$hasRegistered = $this->h5pF->getOption('hub_secret');
$hasRegistered = $this->hubAccountInfo() ? true : false;
if ($hasRegistered) {
$endpoint .= "/{$uuid}";
$formData['_method'] = 'PUT';
Expand Down Expand Up @@ -4092,8 +4105,7 @@ public function getHubContentStatus($hubContentId, $syncStatus) {
null, true, null, true, $headers);

if (isset($response['status']) && $response['status'] === 403) {
$msg = $this->h5pF->t('The request for content status was unauthorized. This could be because the content belongs to a different account, or your account is not setup properly.');
$this->h5pF->setErrorMessage($msg);
$this->h5pF->resetHubOrganizationData();
return false;
}
if (empty($response) || $response['status'] !== 200) {
Expand Down