Skip to content

Commit

Permalink
pkp#229 Added missing namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasraoni committed Apr 15, 2023
1 parent 89d344f commit b8b0205
Showing 1 changed file with 18 additions and 36 deletions.
54 changes: 18 additions & 36 deletions OrcidProfilePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@
use APP\plugins\generic\orcidProfile\classes\OrcidValidator;
use APP\plugins\generic\orcidProfile\mailables\OrcidCollectAuthorId;
use APP\plugins\generic\orcidProfile\mailables\OrcidRequestAuthorAuthorization;
use APP\plugins\generic\orcidProfile\OrcidProfileHanlder;
use APP\submission\Submission;
use APP\template\TemplateManager;
use Carbon\Carbon;
use Exception;
use GuzzleHttp\Exception\ClientException;
use Illuminate\Support\Facades\Mail;
use PKP\components\forms\FieldOptions;
Expand All @@ -60,6 +60,7 @@
use PKP\core\PKPApplication;
use PKP\db\DAORegistry;
use PKP\form\Form;
use PKP\install\Installer;
use PKP\linkAction\LinkAction;
use PKP\linkAction\request\AjaxModal;
use PKP\plugins\GenericPlugin;
Expand All @@ -76,7 +77,6 @@ class OrcidProfilePlugin extends GenericPlugin
public const PUBID_TO_ORCID_EXT_ID = ['doi' => 'doi', 'other::urn' => 'urn'];
public const USER_GROUP_TO_ORCID_ROLE = ['Author' => 'AUTHOR', 'Translator' => 'CHAIR_OR_TRANSLATOR', 'Journal manager' => 'AUTHOR'];

private $submissionIdToBePublished;
private $currentContextId;

/**
Expand Down Expand Up @@ -266,10 +266,8 @@ public function getSetting($contextId, $name)
* @param Form $form
* @return bool
*/
function addOrcidFormFields($hookName, $form): bool

public function addOrcidFormFields($hookName, $form): bool
{

if (!$form instanceof ContributorForm) return Hook::CONTINUE;

$form->removeField('orcid');
Expand Down Expand Up @@ -311,7 +309,7 @@ function addOrcidFormFields($hookName, $form): bool
* @param string $hookName
* @param array $args
*/
function handleThankReviewer($hookName, $args)
public function handleThankReviewer($hookName, $args)
{
$request = PKPApplication::get()->getRequest();
$context = $request->getContext();
Expand Down Expand Up @@ -371,7 +369,6 @@ public function publishReviewerWorkToOrcid(Submission $submission, Request $requ
'Authorization' => 'Bearer ' . $reviewer->getData("orcidAccessToken")
];
$httpClient = Application::get()->getHttpClient();
$requestsSuccess = [];

try {
$response = $httpClient->request(
Expand Down Expand Up @@ -421,10 +418,8 @@ public function buildOrcidReview($submission, $review, $request, $issue = null)
$supportedSubmissionLocales = $context->getSupportedSubmissionLocales();

if (!empty($review->getData('dateCompleted')) && $context->getData('onlineIssn')) {
$publicationPublishDate = Carbon::parse($submission->getData('datePublished'));
$reviewCompletionDate = Carbon::parse($review->getData('dateCompleted'));


$orcidReview = [
'reviewer-role' => 'reviewer',
'review-type' => 'review',
Expand Down Expand Up @@ -478,7 +473,6 @@ public function buildOrcidReview($submission, $review, $request, $issue = null)
];
$orcidReview['subject-external-identifier'] = $externalIds;
}

}

$translatedTitleAvailable = false;
Expand All @@ -491,8 +485,6 @@ public function buildOrcidReview($submission, $review, $request, $issue = null)
$translatedTitleAvailable = true;
}
}


}
return $orcidReview;
}
Expand Down Expand Up @@ -554,7 +546,7 @@ public function setupCallbackHandler($hookName, $params)
{
$page = $params[0];
if ($this->getEnabled() && $page == 'orcidapi') {
define('HANDLER_CLASS', 'APP\plugins\generic\orcidProfile\OrcidProfileHandler');
define('HANDLER_CLASS', OrcidProfileHandler::class);
return true;
}
return false;
Expand All @@ -564,7 +556,7 @@ public function setupCallbackHandler($hookName, $params)
* Check if there exist a valid orcid configuration section in the global config.inc.php of OJS.
* @return boolean True, if the config file has api_url, client_id and client_secret set in an [orcid] section
*/
function isGloballyConfigured()
public function isGloballyConfigured()
{
$apiUrl = Config::getVar('orcid', 'api_url');
$clientId = Config::getVar('orcid', 'client_id');
Expand Down Expand Up @@ -654,17 +646,15 @@ public function handleTemplateDisplay($hookName, $args)
*
* @return string
*/
function getStyleSheet()
public function getStyleSheet()
{
return $this->getPluginPath() . '/css/orcidProfile.css';
}

public function isSandbox()
{

$apiUrl = $this->getSetting($this->getCurrentContextId(), 'orcidProfileAPIPath');
return ($apiUrl == ORCID_API_URL_MEMBER_SANDBOX);

}

/**
Expand All @@ -680,9 +670,6 @@ public function registrationFilter($output, $templateMgr)
if (preg_match('/<form[^>]+id="register"[^>]+>/', $output, $matches, PREG_OFFSET_CAPTURE)) {
$match = $matches[0][0];
$offset = $matches[0][1];
$request = Application::get()->getRequest();
$context = $request->getContext();
$contextId = ($context == null) ? 0 : $context->getId();
$targetOp = 'register';
$templateMgr->assign([
'targetOp' => $targetOp,
Expand Down Expand Up @@ -770,7 +757,7 @@ public function getOauthPath()
*
* @return string
*/
function getIcon()
public function getIcon()
{
$path = Core::getBaseDir() . '/' . $this->getPluginPath() . '/templates/images/orcid.svg';
return file_exists($path) ? file_get_contents($path) : '';
Expand All @@ -789,7 +776,6 @@ function getIcon()
*/
public function handleUserPublicProfileDisplay($hookName, $params)
{

$templateMgr = &$params[1];
$output = &$params[2];
$request = Application::get()->getRequest();
Expand All @@ -814,7 +800,7 @@ public function handleUserPublicProfileDisplay($hookName, $params)
}

/**
* handleAuthorFormexecute sends an e-mail to the author if a specific checkbox was ticked in the author form.
* handleAuthorFormExecute sends an e-mail to the author if a specific checkbox was ticked in the author form.
*
* @param string $hookname
* @param AuthorForm[] $args
Expand Down Expand Up @@ -1053,7 +1039,7 @@ public function getActions($request, $actionArgs)
),
new LinkAction(
'status',
new AjaxModal($router->url($request, null, null, 'manage', null, array('verb' => 'status', 'plugin' => $this->getName(), 'category' => 'generic')), $this->getDisplayName()),
new AjaxModal($router->url($request, null, null, 'manage', null, ['verb' => 'status', 'plugin' => $this->getName(), 'category' => 'generic']), $this->getDisplayName()),
__('common.status'),
null
)
Expand All @@ -1065,12 +1051,12 @@ public function getActions($request, $actionArgs)
/**
* @see Plugin::manage()
*/
function getDisplayName()
public function getDisplayName()
{
return __('plugins.generic.orcidProfile.displayName');
}

function setEnabled($enabled)
public function setEnabled($enabled)
{
$contextId = $this->getCurrentContextId();
$request = Application::get()->getRequest();
Expand Down Expand Up @@ -1114,7 +1100,7 @@ public function manage($args, $request)
]);

$isoCodes = new IsoCodesFactory();
$countries = array();
$countries = [];
foreach ($isoCodes->getCountries() as $country) {
$countries[$country->getAlpha2()] = $country->getLocalName();
}
Expand Down Expand Up @@ -1156,12 +1142,8 @@ public function manage($args, $request)
*/
public function handlePublicationStatusChange($hookName, $args)
{
$newPublication = &$args[0];
/** @var Publication $newPublication */
$publication = &$args[1];
/** @var Publication $publication */
$submission = &$args[2];
/** @var Submission $submission */
$newPublication = &$args[0];

$request = Application::get()->getRequest();

Expand Down Expand Up @@ -1231,7 +1213,7 @@ public function sendSubmissionToOrcid($publication, $request)
}

$orcidWork = $this->buildOrcidWork($publication, $context, $authors, $request, $issue);
$this::logInfo('Request body (without put-code): ' . json_encode($orcidWork));
$this->logInfo('Request body (without put-code): ' . json_encode($orcidWork));

$requestsSuccess = [];
foreach ($authorsWithOrcid as $orcid => $author) {
Expand Down Expand Up @@ -1677,13 +1659,14 @@ public function updateSchema($hookName, $args)
$result = false;
}
}
/**

/**
* Pre-publication checks
* @param $hookName
* @param $args
* @return false
*/
function validate($hookName, $args)
public function validate($hookName, $args)
{
$errors =& $args[0];
$publication = $args[1];
Expand All @@ -1702,5 +1685,4 @@ function validate($hookName, $args)

return false;
}

}

0 comments on commit b8b0205

Please sign in to comment.