first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-06-08 17:09:23 -04:00
commit df3a033196
17887 changed files with 8637778 additions and 0 deletions
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
/**
* @file classes/observers/events/BatchMetadataChanged.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class BatchMetadataChanged
*
* @ingroup core
*
* @brief Event fired when metadata changes batch as called
*/
namespace PKP\observers\events;
use Illuminate\Foundation\Events\Dispatchable;
class BatchMetadataChanged
{
use Dispatchable;
/** @var array $submissionIds Submission ids associated */
public $submissionIds;
public function __construct(array $submissionIds = [])
{
$this->submissionIds = $submissionIds;
}
}
@@ -0,0 +1,66 @@
<?php
/**
* @file classes/observers/events/DecisionAdded.php
*
* Copyright (c) 2014-2022 Simon Fraser University
* Copyright (c) 2000-2022 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class DecisionAdded
*
* @ingroup observers_events
*
* @brief An event fired when an editorial decision is recorded.
*/
namespace PKP\observers\events;
use APP\decision\Decision;
use APP\submission\Submission;
use Illuminate\Foundation\Events\Dispatchable;
use PKP\context\Context;
use PKP\decision\DecisionType;
use PKP\user\User;
class DecisionAdded
{
use Dispatchable;
/** The decision that was recorded */
public Decision $decision;
/** The type of decision that was recorded */
public DecisionType $decisionType;
/** The journal, press or preprint server this decision was recorded in */
public Context $context;
/** The submission for which this decision was recorded */
public Submission $submission;
/** The editor who recorded the decision */
public User $editor;
/**
* Any additional actions that were requested when this
* decision was recorded.
*
* Actions include emails sent, files promoted, and other form
* data submitted when the decision was recorded. Each decision
* supports different actions. See the REST API documentation
* for more information about what actions to expect with each
* decision.
*/
public array $actions;
public function __construct(Decision $decision, DecisionType $decisionType, Submission $submission, User $editor, Context $context, array $actions)
{
$this->actions = $actions;
$this->context = $context;
$this->decision = $decision;
$this->decisionType = $decisionType;
$this->editor = $editor;
$this->submission = $submission;
}
}
@@ -0,0 +1,32 @@
<?php
/**
* @file classes/observers/events/MessageSendingFromContext.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class MessageSendingFromContext
*
* @ingroup observers_events
*
* @brief overrides Illuminate event which is fired just before sending email message from the journal/press
*/
namespace PKP\observers\events;
use Illuminate\Mail\Events\MessageSending as IlluminateMessageSending;
use PKP\context\Context;
use Symfony\Component\Mime\Email as SymfonyEmail;
class MessageSendingFromContext extends IlluminateMessageSending
{
public Context $context;
public function __construct(Context $context, SymfonyEmail $message, array $data = [])
{
parent::__construct($message, $data);
$this->context = $context;
}
}
@@ -0,0 +1,32 @@
<?php
/**
* @file classes/observers/events/MessageSendingFromSite.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class MessageSendingFromSite
*
* @ingroup observers_events
*
* @brief overrides Illuminate event which is fired just before sending email message from the site
*/
namespace PKP\observers\events;
use Illuminate\Mail\Events\MessageSending as IlluminateMessageSending;
use PKP\site\Site;
use Symfony\Component\Mime\Email as SymfonyEmail;
class MessageSendingFromSite extends IlluminateMessageSending
{
public Site $site;
public function __construct(Site $site, SymfonyEmail $message, array $data = [])
{
parent::__construct($message, $data);
$this->site = $site;
}
}
@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
/**
* @file classes/observers/events/MetadataChanged.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class MetadataChanged
*
* @ingroup core
*
* @brief Event fired when metadata changed
*/
namespace PKP\observers\events;
use Illuminate\Foundation\Events\Dispatchable;
use PKP\submission\PKPSubmission;
class MetadataChanged
{
use Dispatchable;
/** @var PKPSubmission $submission Submission associated */
public $submission;
public function __construct(PKPSubmission $submission)
{
$this->submission = $submission;
}
}
@@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
/**
* @file classes/observers/events/PluginSettingChanged.php
*
* Copyright (c) 2014-2022 Simon Fraser University
* Copyright (c) 2000-2022 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class PluginSettingChanged
*
* @ingroup observers_events
*
* @brief Event fired when a plugin's setting is changed, including whether
* it is enabled or disabled.
*/
namespace PKP\observers\events;
use Illuminate\Foundation\Events\Dispatchable;
use PKP\plugins\Plugin;
class PluginSettingChanged
{
use Dispatchable;
public Plugin $plugin;
public string $settingName;
public mixed $newValue;
public ?int $contextId;
public function __construct(
Plugin $plugin,
string $settingName,
$newValue,
?int $contextId = null
) {
$this->plugin = $plugin;
$this->settingName = $settingName;
$this->newValue = $newValue;
$this->contextId = $contextId;
}
}
@@ -0,0 +1,57 @@
<?php
declare(strict_types=1);
/**
* @file classes/observers/events/PublicationPublished.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class PublicationPublished
*
* @ingroup observers_events
*
* @brief Event fired when publication is published
*/
namespace PKP\observers\events;
use APP\publication\Publication;
use APP\submission\Submission;
use Illuminate\Foundation\Events\Dispatchable;
use PKP\context\Context;
class PublicationPublished
{
use Dispatchable;
/** @var Publication $publication The publication that was published */
public Publication $publication;
/** @var Publication $publication The publication before it was published */
public Publication $oldPublication;
public Submission $submission;
public Context $context;
/**
* Class construct
*
* @param Publication $publication The publication that was published
* @param Publication $oldPublication The publication before it was published
*/
public function __construct(
Publication $publication,
Publication $oldPublication,
Submission $submission,
Context $context
) {
$this->publication = $publication;
$this->oldPublication = $oldPublication;
$this->submission = $submission;
$this->context = $context;
}
}
@@ -0,0 +1,57 @@
<?php
declare(strict_types=1);
/**
* @file classes/observers/events/PublicationUnpublished.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class PublicationUnpublished
*
* @ingroup core
*
* @brief Event fired when publication is being unpublished
*/
namespace PKP\observers\events;
use APP\publication\Publication;
use APP\submission\Submission;
use Illuminate\Foundation\Events\Dispatchable;
use PKP\context\Context;
class PublicationUnpublished
{
use Dispatchable;
/** @var Publication $publication The publication that was unpublished */
public Publication $publication;
/** @var Publication $publication The publication before it was unpublished */
public Publication $oldPublication;
public Submission $submission;
public Context $context;
/**
* Class construct
*
* @param Publication $publication The publication that was unpublished
* @param Publication $oldPublication The publication before it was unpublished
*/
public function __construct(
Publication $publication,
Publication $oldPublication,
Submission $submission,
Context $context
) {
$this->publication = $publication;
$this->oldPublication = $oldPublication;
$this->submission = $submission;
$this->context = $context;
}
}
@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
/**
* @file classes/observers/events/SubmissionDeleted.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class SubmissionDeleted
*
* @ingroup core
*
* @brief Event fired when submission's deleted
*/
namespace PKP\observers\events;
use Illuminate\Foundation\Events\Dispatchable;
class SubmissionDeleted
{
use Dispatchable;
/**
* The submission id of the targeted submission to delete
*/
public int $submissionId;
public function __construct(int $submissionId)
{
$this->submissionId = $submissionId;
}
}
@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
/**
* @file classes/observers/events/SubmissionFileDeleted.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class SubmissionFileDeleted
*
* @ingroup core
*
* @brief Event fired when submission's deleted
*/
namespace PKP\observers\events;
use Illuminate\Foundation\Events\Dispatchable;
class SubmissionFileDeleted
{
use Dispatchable;
/**
* The submission id of the targeted submission
*/
public int $submissionId;
/**
* The submission file id of the targeted submission file to delete
*/
public int $submissionFileId;
public function __construct(int $submissionId, int $submissionFileId)
{
$this->submissionId = $submissionId;
$this->submissionFileId = $submissionFileId;
}
}
@@ -0,0 +1,31 @@
<?php
/**
* @file classes/observers/events/SubmissionSubmitted.php
*
* Copyright (c) 2014-2022 Simon Fraser University
* Copyright (c) 2000-2022 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class SubmissionSubmitted
*
* @ingroup observers_events
*
* @brief Event fired when a submission is submitted.
*/
namespace PKP\observers\events;
use APP\submission\Submission;
use PKP\context\Context;
class SubmissionSubmitted
{
public Context $context;
public Submission $submission;
public function __construct(Submission $submission, Context $context)
{
$this->context = $context;
$this->submission = $submission;
}
}
@@ -0,0 +1,180 @@
<?php
/**
* @file classes/observers/events/UsageEvent.php
*
* Copyright (c) 2022 Simon Fraser University
* Copyright (c) 2022 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class UsageEvent
*
* @ingroup observers_events
*
* @brief Base class for the usage event used to record usage logs.
*/
namespace PKP\observers\events;
use APP\core\Application;
use APP\core\PageRouter;
use APP\core\Request;
use APP\submission\Submission;
use Exception;
use Illuminate\Foundation\Events\Dispatchable;
use PKP\config\Config;
use PKP\context\Context;
use PKP\core\Core;
use PKP\core\Registry;
use PKP\submission\Representation;
use PKP\submissionFile\SubmissionFile;
abstract class UsageEvent
{
use Dispatchable;
/** Current time */
public string $time;
/** Viewed/downloaded object, one of the Application::ASSOC_TYPE_... constants */
public int $assocType;
/** Canonical URL for the pub object */
public string $canonicalUrl;
public Request $request;
public Context $context;
public ?Submission $submission;
/** Representation (galley or publication format) */
public ?Representation $representation;
public ?SubmissionFile $submissionFile;
/** Application's complete version string */
public string $version;
/**
* Create a new usage event instance.
*/
public function __construct(
int $assocType,
Context $context,
Submission $submission = null,
Representation $representation = null,
SubmissionFile $submissionFile = null
) {
$this->time = Core::getCurrentDate();
$this->assocType = $assocType;
$this->context = $context;
$this->submission = $submission;
$this->representation = $representation;
$this->submissionFile = $submissionFile;
$this->version = Registry::get('appVersion');
$this->request = Application::get()->getRequest();
$this->canonicalUrl = $this->getCanonicalUrl();
}
/**
* Get the canonical URL for the usage object
*
* @throws Exception
*/
protected function getCanonicalUrl(): string
{
$canonicalUrlPage = $canonicalUrlOp = null;
$canonicalUrlParams = [];
switch ($this->assocType) {
case Application::ASSOC_TYPE_SUBMISSION_FILE_COUNTER_OTHER:
case Application::ASSOC_TYPE_SUBMISSION_FILE:
$canonicalUrlOp = 'download';
$canonicalUrlParams = [$this->submission->getId()];
$router = $this->request->getRouter(); /** @var PageRouter $router */
$op = $router->getRequestedOp($this->request);
$args = $router->getRequestedArgs($this->request);
if ($op == 'download' && count($args) > 1) {
if ($args[1] == 'version' && count($args) == 5) {
$publicationId = (int) $args[2];
$canonicalUrlParams[] = 'version';
$canonicalUrlParams[] = $publicationId;
}
}
$canonicalUrlParams[] = $this->representation->getId();
$canonicalUrlParams[] = $this->submissionFile->getId();
break;
case Application::ASSOC_TYPE_SUBMISSION:
$canonicalUrlOp = 'view';
if (Application::get()->getName() == 'omp') {
$canonicalUrlOp = 'book';
}
$canonicalUrlParams = [$this->submission->getId()];
$router = $this->request->getRouter(); /** @var PageRouter $router */
$op = $router->getRequestedOp($this->request);
$args = $router->getRequestedArgs($this->request);
if ($op == $canonicalUrlOp && count($args) > 1) {
if ($args[1] == 'version' && count($args) == 3) {
$publicationId = (int) $args[2];
$canonicalUrlParams[] = 'version';
$canonicalUrlParams[] = $publicationId;
}
}
break;
case Application::getContextAssocType():
$canonicalUrlOp = '';
$canonicalUrlPage = 'index';
break;
default:
throw new Exception('Not recognized assoc type that we can create the canonical URL for.');
}
$canonicalUrl = $this->getRouterCanonicalUrl($this->request, $canonicalUrlPage, $canonicalUrlOp, $canonicalUrlParams);
return $canonicalUrl;
}
/**
* Construct the URL from page, op, and params
*/
protected function getRouterCanonicalUrl(Request $request, string $canonicalUrlPage = null, string $canonicalUrlOp = null, array $canonicalUrlParams = null): string
{
$router = $request->getRouter(); /** @var PageRouter $router */
$context = $router->getContext($request);
if (!isset($canonicalUrlPage)) {
$canonicalUrlPage = $router->getRequestedPage($request);
}
if (!isset($canonicalUrlOp)) {
$canonicalUrlOp = $router->getRequestedOp($request);
}
if (!isset($canonicalUrlParams)) {
$canonicalUrlParams = $router->getRequestedArgs($request);
}
$canonicalUrl = $router->url(
$request,
null,
$canonicalUrlPage,
$canonicalUrlOp,
$canonicalUrlParams
);
// Make sure we log the server name and not aliases.
$configBaseUrl = Config::getVar('general', 'base_url');
$requestBaseUrl = $request->getBaseUrl();
if ($requestBaseUrl !== $configBaseUrl) {
// Make sure it's not an url override (no alias on that case).
if (!in_array($requestBaseUrl, Config::getContextBaseUrls()) &&
$requestBaseUrl !== Config::getVar('general', 'base_url[index]')) {
// Alias found, replace it by base_url from config file.
// Make sure we use the correct base url override value for the context, if any.
$baseUrlReplacement = Config::getVar('general', 'base_url[' . $context->getPath() . ']');
if (!$baseUrlReplacement) {
$baseUrlReplacement = $configBaseUrl;
}
$canonicalUrl = str_replace($requestBaseUrl, $baseUrlReplacement, $canonicalUrl);
}
}
return $canonicalUrl;
}
}
@@ -0,0 +1,36 @@
<?php
/**
* @file classes/observers/events/UserRegisteredContext.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class UserRegisteredContext
*
* @ingroup observers_events
*
* @brief An event fired when a user registers with a context
*/
namespace PKP\observers\events;
use Illuminate\Foundation\Events\Dispatchable;
use PKP\context\Context;
use PKP\user\User;
class UserRegisteredContext
{
use Dispatchable;
public User $recipient;
public Context $context;
public function __construct(User $recipient, Context $context)
{
$this->recipient = $recipient;
$this->context = $context;
}
}
@@ -0,0 +1,36 @@
<?php
/**
* @file classes/observers/events/UserRegisteredSite.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class UserRegisteredSite
*
* @ingroup observers_events
*
* @brief An event fired when a user registers from the site-wide registration form
*/
namespace PKP\observers\events;
use Illuminate\Foundation\Events\Dispatchable;
use PKP\site\Site;
use PKP\user\User;
class UserRegisteredSite
{
use Dispatchable;
public User $recipient;
public Site $site;
public function __construct(User $recipient, Site $site)
{
$this->recipient = $recipient;
$this->site = $site;
}
}