refactor: add strict types declaration before each file and fix activitypub issues

fix some style issues
This commit is contained in:
Yassine Doghri 2021-06-08 09:52:11 +00:00
parent 76afc0cfa2
commit c72f4be6d8
No known key found for this signature in database
GPG Key ID: 3E7F89498B960C9F
291 changed files with 8724 additions and 7354 deletions

View File

@ -7,10 +7,10 @@ or shared hosting, you can install it on most PHP-MySQL compatible web servers.
- [Install instructions](#install-instructions)
- [0. Pre-requisites](#0-pre-requisites)
- [1. Install Wizard](#1-install-wizard)
- [1-alt Manual configuration](#1-alt-manual-configuration)
- [(recommended) Install Wizard](#recommended-install-wizard)
- [(alternative) Manual configuration](#alternative-manual-configuration)
- [Web Server Requirements](#web-server-requirements)
- [PHP v8.0 or higher](#php-v73-or-higher)
- [PHP v8.0 or higher](#php-v80-or-higher)
- [MySQL compatible database](#mysql-compatible-database)
- [Privileges](#privileges)
- [(Optional) Other recommendations](#optional-other-recommendations)
@ -39,17 +39,20 @@ or shared hosting, you can install it on most PHP-MySQL compatible web servers.
> ⚠️ Social features will not work properly if you do not set the task. It is
> used to broadcast social activities to the fediverse.
### 1. Install Wizard
### (recommended) Install Wizard
1. Run the Castopod Host install script by going to the install wizard page
(`https://your_domain_name.com/cp-install`) in your favorite web browser.
2. Follow the instructions on your screen.
3. Start podcasting!
### 1-alt Manual configuration
> **Note:**
>
> The install script writes a `.env` file in the package root. If you cannot go
> through the install wizard, you can
> [create and update the `.env` file manually](#alternative-manual-configuration).
The install script writes a `.env` file in the package root. If you cannot go
through the install wizard, you can create and update the `.env` file yourself:
### (alternative) Manual configuration
1. Rename the `.env.example` file to `.env` and update the default values with
your own.

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Authorization;
use Myth\Auth\Authorization\FlatAuthorization as MythAuthFlatAuthorization;
@ -26,7 +28,7 @@ class FlatAuthorization extends MythAuthFlatAuthorization
return false;
}
return $this->permissionModel->doesGroupHavePermission($groupId, $permissionId,);
return $this->permissionModel->doesGroupHavePermission($groupId, $permissionId);
}
/**

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Authorization;
use Myth\Auth\Authorization\GroupModel as MythAuthGroupModel;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Authorization;
use Myth\Auth\Authorization\PermissionModel as MythAuthPermissionModel;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* The goal of this file is to allow developers a location where they can overwrite core procedural functions and
* replace them with their own. This file is loaded during the bootstrap process and is called during the frameworks

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Config;
use ActivityPub\Config\ActivityPub as ActivityPubBase;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Config;
use Analytics\Config\Analytics as AnalyticsBase;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Config;
use CodeIgniter\Config\BaseConfig;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Config;
use Myth\Auth\Config\Auth as MythAuthConfig;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Config;
use CodeIgniter\Config\AutoloadConfig;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* --------------------------------------------------------------------------
* ERROR DISPLAY

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* --------------------------------------------------------------------------
* ERROR DISPLAY
@ -8,7 +10,7 @@
* it and display a generic error message.
*/
ini_set('display_errors', '0');
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED,);
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
/**
* --------------------------------------------------------------------------

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* --------------------------------------------------------------------------
* ERROR DISPLAY

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Config;
use CodeIgniter\Cache\Handlers\DummyHandler;
@ -74,6 +76,19 @@ class Cache extends BaseConfig
*/
public string $prefix = '';
/**
* --------------------------------------------------------------------------
* Default TTL
* --------------------------------------------------------------------------
*
* The default number of seconds to save items when none is specified.
*
* WARNING: This is not used by framework handlers where 60 seconds is
* hard-coded, but may be useful to projects and modules. This will replace
* the hard-coded value in a future release.
*/
public int $ttl = 60;
/**
* --------------------------------------------------------------------------
* File settings

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/*
| --------------------------------------------------------------------
| Castopod Version

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Config;
use CodeIgniter\Config\BaseConfig;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Config;
use CodeIgniter\Config\BaseConfig;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Config;
use CodeIgniter\Database\Config;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Config;
class DocTypes

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Config;
use CodeIgniter\Config\BaseConfig;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Config;
use CodeIgniter\Config\BaseConfig;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Config;
use App\Entities\Actor;
@ -50,7 +52,7 @@ Events::on('pre_system', function () {
* @phpstan-ignore-next-line
*/
if (CI_DEBUG && ! is_cli()) {
Events::on('DBQuery', 'CodeIgniter\Debug\Toolbar\Collectors\Database::collect',);
Events::on('DBQuery', 'CodeIgniter\Debug\Toolbar\Collectors\Database::collect');
Services::toolbar()->respond();
}
});
@ -76,47 +78,109 @@ Events::on('logout', function (User $user): void {
* --------------------------------------------------------------------
* ActivityPub events
* --------------------------------------------------------------------
* Update episode metadata counts
*/
Events::on('on_note_add', function (Note $note): void {
/**
* @param Actor $actor
* @param Actor $targetActor
*/
Events::on('on_follow', function ($actor, $targetActor): void {
if ($actor->is_podcast) {
cache()
->deleteMatching("podcast#{$actor->podcast->id}*");
cache()
->deleteMatching("page_podcast#{$actor->podcast->id}*");
}
if ($targetActor->is_podcast) {
cache()
->deleteMatching("podcast#{$targetActor->podcast->id}*");
cache()
->deleteMatching("page_podcast#{$targetActor->podcast->id}*");
}
});
/**
* @param Actor $actor
* @param Actor $targetActor
*/
Events::on('on_undo_follow', function ($actor, $targetActor): void {
if ($actor->is_podcast) {
cache()
->deleteMatching("podcast#{$actor->podcast->id}*");
cache()
->deleteMatching("page_podcast#{$actor->podcast->id}*");
}
if ($targetActor->is_podcast) {
cache()
->deleteMatching("podcast#{$targetActor->podcast->id}*");
cache()
->deleteMatching("page_podcast#{$targetActor->podcast->id}*");
}
});
/**
* @param Note $note
*/
Events::on('on_note_add', function ($note): void {
if ($note->is_reply) {
$note = $note->reply_to_note;
}
if ($note->episode_id) {
model('EpisodeModel')
->where('id', $note->episode_id)
->increment('notes_total');
}
// Removing all of the podcast pages is a bit overkill, but works perfectly
// same for other events below
cache()
->deleteMatching("page_podcast#{$note->actor->podcast->id}*");
cache()
->deleteMatching("podcast#{$note->actor->podcast->id}*");
if ($note->actor->is_podcast) {
// Removing all of the podcast pages is a bit overkill, but works to avoid caching bugs
// same for other events below
cache()
->deleteMatching("podcast#{$note->actor->podcast->id}*");
cache()
->deleteMatching("page_podcast#{$note->actor->podcast->id}*");
}
});
Events::on('on_note_remove', function (Note $note): void {
if ($note->episode_id) {
/**
* @param Note $note
*/
Events::on('on_note_remove', function ($note): void {
if ($note->is_reply) {
Events::trigger('on_note_remove', $note->reply_to_note);
}
if ($episodeId = $note->episode_id) {
model('EpisodeModel')
->where('id', $note->episode_id)
->where('id', $episodeId)
->decrement('notes_total', 1 + $note->reblogs_count);
model('EpisodeModel')
->where('id', $note->episode_id)
->where('id', $episodeId)
->decrement('reblogs_total', $note->reblogs_count);
model('EpisodeModel')
->where('id', $note->episode_id)
->where('id', $episodeId)
->decrement('favourites_total', $note->favourites_count);
}
cache()
->deleteMatching("page_podcast#{$note->actor->podcast->id}*");
cache()
->deleteMatching("podcast#{$note->actor->podcast->id}*");
if ($note->actor->is_podcast) {
cache()
->deleteMatching("podcast#{$note->actor->podcast->id}*");
cache()
->deleteMatching("page_podcast#{$note->actor->podcast->id}*");
}
cache()
->deleteMatching("page_note#{$note->id}*");
});
Events::on('on_note_reblog', function (Actor $actor, Note $note): void {
/**
* @param Actor $actor
* @param Note $note
*/
Events::on('on_note_reblog', function ($actor, $note): void {
if ($episodeId = $note->episode_id) {
model('EpisodeModel')
->where('id', $episodeId)
@ -127,19 +191,31 @@ Events::on('on_note_reblog', function (Actor $actor, Note $note): void {
->increment('notes_total');
}
cache()
->deleteMatching("page_podcast#{$note->actor->podcast->id}*");
cache()
->deleteMatching("podcast#{$note->actor->podcast->id}*");
if ($note->actor->is_podcast) {
cache()
->deleteMatching("podcast#{$note->actor->podcast->id}*");
cache()
->deleteMatching("page_podcast#{$note->actor->podcast->id}*");
}
if ($actor->is_podcast) {
cache()->deleteMatching("podcast#{$actor->podcast->id}*");
cache()
->deleteMatching("page_podcast#{$actor->podcast->id}*");
}
cache()
->deleteMatching("page_note#{$note->id}*");
if ($actor->is_podcast) {
cache()->deleteMatching("page_podcast#{$actor->podcast->id}*");
if ($note->is_reply) {
cache()->deleteMatching("page_note#{$note->in_reply_to_id}");
}
});
Events::on('on_note_undo_reblog', function (Note $reblogNote): void {
/**
* @param Note $reblogNote
*/
Events::on('on_note_undo_reblog', function ($reblogNote): void {
$note = $reblogNote->reblog_of_note;
if ($episodeId = $note->episode_id) {
model('EpisodeModel')
@ -151,74 +227,128 @@ Events::on('on_note_undo_reblog', function (Note $reblogNote): void {
->decrement('notes_total');
}
cache()
->deleteMatching("page_podcast#{$note->actor->podcast->id}*");
cache()
->deleteMatching("podcast#{$note->actor->podcast->id}*");
if ($note->actor->is_podcast) {
cache()
->deleteMatching("podcast#{$note->actor->podcast->id}*");
cache()
->deleteMatching("page_podcast#{$note->actor->podcast->id}*");
}
cache()
->deleteMatching("page_note#{$note->id}*");
cache()
->deleteMatching("page_note#{$reblogNote->id}*");
if ($note->is_reply) {
cache()->deleteMatching("page_note#{$note->in_reply_to_id}");
}
if ($reblogNote->actor->is_podcast) {
cache()->deleteMatching("page_podcast#{$reblogNote->actor->podcast->id}*",);
cache()
->deleteMatching("podcast#{$reblogNote->actor->podcast->id}*");
cache()
->deleteMatching("page_podcast#{$reblogNote->actor->podcast->id}*");
}
});
Events::on('on_note_reply', function (Note $reply): void {
/**
* @param Note $reply
*/
Events::on('on_note_reply', function ($reply): void {
$note = $reply->reply_to_note;
cache()
->deleteMatching("page_podcast#{$note->actor->podcast->id}*");
if ($note->actor->is_podcast) {
cache()
->deleteMatching("podcast#{$note->actor->podcast->id}*");
cache()
->deleteMatching("page_podcast#{$note->actor->podcast->id}*");
}
cache()
->deleteMatching("page_note#{$note->id}*");
});
Events::on('on_reply_remove', function (Note $reply): void {
/**
* @param Note $reply
*/
Events::on('on_reply_remove', function ($reply): void {
$note = $reply->reply_to_note;
cache()
->deleteMatching("page_podcast#{$note->actor->podcast->id}*");
cache()
->deleteMatching("podcast#{$note->actor->podcast->id}*");
if ($note->actor->is_podcast) {
cache()
->deleteMatching("page_podcast#{$note->actor->podcast->id}*");
cache()
->deleteMatching("podcast#{$note->actor->podcast->id}*");
}
cache()
->deleteMatching("page_note#{$note->id}*");
cache()
->deleteMatching("page_note#{$reply->id}*");
});
Events::on('on_note_favourite', function (Actor $actor, Note $note): void {
/**
* @param Actor $actor
* @param Note $note
*/
Events::on('on_note_favourite', function ($actor, $note): void {
if ($note->episode_id) {
model('EpisodeModel')
->where('id', $note->episode_id)
->increment('favourites_total');
}
cache()
->deleteMatching("page_podcast#{$actor->podcast->id}*");
cache()
->deleteMatching("podcast#{$actor->podcast->id}*");
if ($note->actor->is_podcast) {
cache()
->deleteMatching("podcast#{$note->actor->podcast->id}*");
cache()
->deleteMatching("page_podcast#{$note->actor->podcast->id}*");
}
cache()
->deleteMatching("page_note#{$note->id}*");
if ($note->in_reply_to_id) {
if ($note->is_reply) {
cache()->deleteMatching("page_note#{$note->in_reply_to_id}*");
}
if ($actor->is_podcast) {
cache()->deleteMatching("podcast#{$actor->podcast->id}*");
cache()
->deleteMatching("page_podcast#{$actor->podcast->id}*");
}
});
Events::on('on_note_undo_favourite', function (Actor $actor, Note $note): void {
/**
* @param Actor $actor
* @param Note $note
*/
Events::on('on_note_undo_favourite', function ($actor, $note): void {
if ($note->episode_id) {
model('EpisodeModel')
->where('id', $note->episode_id)
->decrement('favourites_total');
}
cache()
->deleteMatching("page_podcast#{$actor->podcast->id}*");
cache()
->deleteMatching("podcast#{$actor->podcast->id}*");
if ($note->actor->is_podcast) {
cache()
->deleteMatching("podcast#{$note->actor->podcast->id}*");
cache()
->deleteMatching("page_podcast#{$note->actor->podcast->id}*");
}
cache()
->deleteMatching("page_note#{$note->id}*");
if ($note->in_reply_to_id) {
if ($note->is_reply) {
cache()->deleteMatching("page_note#{$note->in_reply_to_id}*");
}
if ($actor->is_podcast) {
cache()->deleteMatching("podcast#{$actor->podcast->id}*");
cache()
->deleteMatching("page_podcast#{$actor->podcast->id}*");
}
});
Events::on('on_block_actor', function (int $actorId): void {

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Config;
use CodeIgniter\Config\BaseConfig;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Config;
use ActivityPub\Filters\ActivityPubFilter;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Config;
use CodeIgniter\Config\ForeignCharacters as BaseForeignCharacters;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Config;
use CodeIgniter\Config\BaseConfig;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Config;
use CodeIgniter\Config\BaseConfig;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Config;
use CodeIgniter\Config\BaseConfig;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Config;
use CodeIgniter\Config\BaseConfig;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Config;
use CodeIgniter\Config\BaseConfig;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Config;
use CodeIgniter\Config\BaseConfig;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Config;
use CodeIgniter\Config\BaseConfig;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Config;
/**

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Config;
use CodeIgniter\Modules\Modules as BaseModules;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Config;
use CodeIgniter\Config\BaseConfig;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Config;
/**

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Config;
// Create a new instance of our RouteCollection class.
@ -34,7 +36,7 @@ $routes->addPlaceholder('slug', '[a-zA-Z0-9\-]{1,191}');
$routes->addPlaceholder('base64', '[A-Za-z0-9\.\_]+\-{0,2}');
$routes->addPlaceholder('platformType', '\bpodcasting|\bsocial|\bfunding');
$routes->addPlaceholder('noteAction', '\bfavourite|\breblog|\breply');
$routes->addPlaceholder('embeddablePlayerTheme', '\blight|\bdark|\blight-transparent|\bdark-transparent',);
$routes->addPlaceholder('embeddablePlayerTheme', '\blight|\bdark|\blight-transparent|\bdark-transparent');
$routes->addPlaceholder(
'uuid',
'[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-4[0-9A-Fa-f]{3}-[89ABab][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}',
@ -59,10 +61,10 @@ $routes->group(config('App')->installGateway, function ($routes): void {
]);
$routes->post('instance-config', 'InstallController::attemptInstanceConfig', [
'as' => 'instance-config',
],);
]);
$routes->post('database-config', 'InstallController::attemptDatabaseConfig', [
'as' => 'database-config',
],);
]);
$routes->post('cache-config', 'InstallController::attemptCacheConfig', [
'as' => 'cache-config',
]);
@ -626,7 +628,7 @@ $routes->group(
'as' => 'change-password',
],
);
$routes->post('change-password', 'MyAccountController::attemptChange/$1',);
$routes->post('change-password', 'MyAccountController::attemptChange/$1');
});
},
);

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Config;
use CodeIgniter\Config\BaseConfig;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Config;
use App\Authorization\FlatAuthorization;
@ -76,7 +78,7 @@ class Services extends BaseService
bool $getShared = true
) {
if ($getShared) {
return self::getSharedInstance('authentication', $lib, $userModel, $loginModel,);
return self::getSharedInstance('authentication', $lib, $userModel, $loginModel);
}
// config() checks first in app/Config
@ -108,7 +110,7 @@ class Services extends BaseService
bool $getShared = true
) {
if ($getShared) {
return self::getSharedInstance('authorization', $groupModel, $permissionModel, $userModel,);
return self::getSharedInstance('authorization', $groupModel, $permissionModel, $userModel);
}
if ($groupModel === null) {

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Config;
use CodeIgniter\Config\BaseConfig;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Config;
use CodeIgniter\Config\BaseConfig;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Config;
use App\Validation\FileRules as AppFileRules;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Config;
use CodeIgniter\Config\View as BaseView;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -24,6 +26,7 @@ class ActorController extends ActivityPubActorController
{
// Prevent analytics hit when authenticated
if (! can_user_interact()) {
// @phpstan-ignore-next-line
$this->registerPodcastWebpageHit($this->actor->podcast->id);
}

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Controllers\Admin;
use CodeIgniter\Controller;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -161,7 +163,7 @@ class EpisodeController extends BaseController
) {
$newEpisode->transcript_file = $transcriptFile;
} elseif ($transcriptChoice === 'remote-url') {
$newEpisode->transcript_file_remote_url = $this->request->getPost('transcript_file_remote_url',);
$newEpisode->transcript_file_remote_url = $this->request->getPost('transcript_file_remote_url');
}
$chaptersChoice = $this->request->getPost('chapters-choice');
@ -171,7 +173,7 @@ class EpisodeController extends BaseController
) {
$newEpisode->chapters_file = $chaptersFile;
} elseif ($chaptersChoice === 'remote-url') {
$newEpisode->chapters_file_remote_url = $this->request->getPost('chapters_file_remote_url',);
$newEpisode->chapters_file_remote_url = $this->request->getPost('chapters_file_remote_url');
}
$episodeModel = new EpisodeModel();
@ -187,7 +189,7 @@ class EpisodeController extends BaseController
$podcastModel = new PodcastModel();
if ($this->podcast->hasChanged('episode_description_footer_markdown')) {
$this->podcast->episode_description_footer_markdown = $this->request->getPost('description_footer',);
$this->podcast->episode_description_footer_markdown = $this->request->getPost('description_footer');
if (! $podcastModel->update($this->podcast->id, $this->podcast)) {
return redirect()
@ -237,8 +239,8 @@ class EpisodeController extends BaseController
$this->episode->title = $this->request->getPost('title');
$this->episode->slug = $this->request->getPost('slug');
$this->episode->description_markdown = $this->request->getPost('description',);
$this->episode->location = new Location($this->request->getPost('location_name'),);
$this->episode->description_markdown = $this->request->getPost('description');
$this->episode->location = new Location($this->request->getPost('location_name'));
$this->episode->parental_advisory =
$this->request->getPost('parental_advisory') !== 'undefined'
? $this->request->getPost('parental_advisory')
@ -251,7 +253,7 @@ class EpisodeController extends BaseController
: null;
$this->episode->type = $this->request->getPost('type');
$this->episode->is_blocked = $this->request->getPost('block') === 'yes';
$this->episode->custom_rss_string = $this->request->getPost('custom_rss',);
$this->episode->custom_rss_string = $this->request->getPost('custom_rss');
$this->episode->updated_by = (int) user_id();
@ -278,7 +280,7 @@ class EpisodeController extends BaseController
(($transcriptFile = $this->episode->transcript_file) &&
$transcriptFile !== null)
) {
unlink($transcriptFile);
unlink((string) $transcriptFile);
$this->episode->transcript_file_path = null;
}
$this->episode->transcript_file_remote_url = $transcriptFileRemoteUrl;
@ -297,7 +299,7 @@ class EpisodeController extends BaseController
(($chaptersFile = $this->episode->chapters_file) &&
$chaptersFile !== null)
) {
unlink($chaptersFile);
unlink((string) $chaptersFile);
$this->episode->chapters_file_path = null;
}
$this->episode->chapters_file_remote_url = $chaptersFileRemoteUrl;
@ -313,7 +315,7 @@ class EpisodeController extends BaseController
}
// update podcast's episode_description_footer_markdown if changed
$this->podcast->episode_description_footer_markdown = $this->request->getPost('description_footer',);
$this->podcast->episode_description_footer_markdown = $this->request->getPost('description_footer');
if ($this->podcast->hasChanged('episode_description_footer_markdown')) {
$podcastModel = new PodcastModel();
@ -330,7 +332,7 @@ class EpisodeController extends BaseController
public function transcriptDelete(): RedirectResponse
{
unlink($this->episode->transcript_file);
unlink((string) $this->episode->transcript_file);
$this->episode->transcript_file_path = null;
$episodeModel = new EpisodeModel();
@ -347,7 +349,7 @@ class EpisodeController extends BaseController
public function chaptersDelete(): RedirectResponse
{
unlink($this->episode->chapters_file);
unlink((string) $this->episode->chapters_file);
$this->episode->chapters_file_path = null;
$episodeModel = new EpisodeModel();
@ -409,7 +411,7 @@ class EpisodeController extends BaseController
$publishMethod = $this->request->getPost('publication_method');
if ($publishMethod === 'schedule') {
$scheduledPublicationDate = $this->request->getPost('scheduled_publication_date',);
$scheduledPublicationDate = $this->request->getPost('scheduled_publication_date');
if ($scheduledPublicationDate) {
$this->episode->published_at = Time::createFromFormat(
'Y-m-d H:i',
@ -498,7 +500,7 @@ class EpisodeController extends BaseController
$publishMethod = $this->request->getPost('publication_method');
if ($publishMethod === 'schedule') {
$scheduledPublicationDate = $this->request->getPost('scheduled_publication_date',);
$scheduledPublicationDate = $this->request->getPost('scheduled_publication_date');
if ($scheduledPublicationDate) {
$this->episode->published_at = Time::createFromFormat(
'Y-m-d H:i',
@ -516,7 +518,7 @@ class EpisodeController extends BaseController
$this->episode->published_at = Time::now();
}
$note = (new NoteModel())->getNoteById($this->request->getPost('note_id'),);
$note = (new NoteModel())->getNoteById($this->request->getPost('note_id'));
if ($note !== null) {
$note->message = $this->request->getPost('message');
@ -688,7 +690,7 @@ class EpisodeController extends BaseController
public function soundbiteDelete(int $soundbiteId): RedirectResponse
{
(new SoundbiteModel())->deleteSoundbite($this->podcast->id, $this->episode->id, $soundbiteId,);
(new SoundbiteModel())->deleteSoundbite($this->podcast->id, $this->episode->id, $soundbiteId);
return redirect()->route('soundbites-edit', [$this->podcast->id, $this->episode->id]);
}

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -88,7 +90,7 @@ class EpisodePersonController extends BaseController
public function remove(int $personId): RedirectResponse
{
(new PersonModel())->removePersonFromEpisode($this->podcast->id, $this->episode->id, $personId,);
(new PersonModel())->removePersonFromEpisode($this->podcast->id, $this->episode->id, $personId);
return redirect()->back();
}

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -74,7 +76,7 @@ class PageController extends BaseController
->route('page-list')
->with('message', lang('Page.messages.createSuccess', [
'pageTitle' => $page->title,
]),);
]));
}
public function edit(): string

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @copyright 2021 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -126,7 +128,7 @@ class PersonController extends BaseController
$this->person->full_name = $this->request->getPost('full_name');
$this->person->unique_name = $this->request->getPost('unique_name');
$this->person->information_url = $this->request->getPost('information_url',);
$this->person->information_url = $this->request->getPost('information_url');
$imageFile = $this->request->getFile('image');
if ($imageFile !== null && $imageFile->isValid()) {
$this->person->image = new Image($imageFile);

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -225,7 +227,7 @@ class PodcastController extends BaseController
$authorize = Services::authorization();
$podcastAdminGroup = $authorize->group('podcast_admin');
$podcastModel->addPodcastContributor(user_id(), $newPodcastId, $podcastAdminGroup->id,);
$podcastModel->addPodcastContributor(user_id(), $newPodcastId, $podcastAdminGroup->id);
// set Podcast categories
(new CategoryModel())->setPodcastCategories(
@ -276,7 +278,7 @@ class PodcastController extends BaseController
}
$this->podcast->title = $this->request->getPost('title');
$this->podcast->description_markdown = $this->request->getPost('description',);
$this->podcast->description_markdown = $this->request->getPost('description');
$image = $this->request->getFile('image');
if ($image !== null && $image->isValid()) {
@ -293,12 +295,12 @@ class PodcastController extends BaseController
$this->podcast->owner_email = $this->request->getPost('owner_email');
$this->podcast->type = $this->request->getPost('type');
$this->podcast->copyright = $this->request->getPost('copyright');
$this->podcast->location = new Location($this->request->getPost('location_name'),);
$this->podcast->payment_pointer = $this->request->getPost('payment_pointer',);
$this->podcast->custom_rss_string = $this->request->getPost('custom_rss',);
$this->podcast->location = new Location($this->request->getPost('location_name'));
$this->podcast->payment_pointer = $this->request->getPost('payment_pointer');
$this->podcast->custom_rss_string = $this->request->getPost('custom_rss');
$this->podcast->partner_id = $this->request->getPost('partner_id');
$this->podcast->partner_link_url = $this->request->getPost('partner_link_url',);
$this->podcast->partner_image_url = $this->request->getPost('partner_image_url',);
$this->podcast->partner_link_url = $this->request->getPost('partner_link_url');
$this->podcast->partner_image_url = $this->request->getPost('partner_image_url');
$this->podcast->is_blocked = $this->request->getPost('block') === 'yes';
$this->podcast->is_completed =
$this->request->getPost('complete') === 'yes';

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -78,7 +80,7 @@ class PodcastImportController extends BaseController
}
try {
ini_set('user_agent', 'Castopod/' . CP_VERSION);
$feed = simplexml_load_file($this->request->getPost('imported_feed_url'),);
$feed = simplexml_load_file($this->request->getPost('imported_feed_url'));
} catch (ErrorException $errorException) {
return redirect()
->back()
@ -92,11 +94,11 @@ class PodcastImportController extends BaseController
' ⎋</a>',
]);
}
$nsItunes = $feed->channel[0]->children('http://www.itunes.com/dtds/podcast-1.0.dtd',);
$nsItunes = $feed->channel[0]->children('http://www.itunes.com/dtds/podcast-1.0.dtd');
$nsPodcast = $feed->channel[0]->children(
'https://github.com/Podcastindex-org/podcast-namespace/blob/main/docs/1.0.md',
);
$nsContent = $feed->channel[0]->children('http://purl.org/rss/1.0/modules/content/',);
$nsContent = $feed->channel[0]->children('http://purl.org/rss/1.0/modules/content/');
if ((string) $nsPodcast->locked === 'yes') {
return redirect()
@ -114,9 +116,9 @@ class PodcastImportController extends BaseController
property_exists($nsItunes, 'image') && $nsItunes->image !== null &&
$nsItunes->image->attributes()['href'] !== null
) {
$imageFile = download_file((string) $nsItunes->image->attributes()['href'],);
$imageFile = download_file((string) $nsItunes->image->attributes()['href']);
} else {
$imageFile = download_file((string) $feed->channel[0]->image->url,);
$imageFile = download_file((string) $feed->channel[0]->image->url);
}
$location = null;
@ -195,7 +197,7 @@ class PodcastImportController extends BaseController
$authorize = Services::authorization();
$podcastAdminGroup = $authorize->group('podcast_admin');
$podcastModel->addPodcastContributor(user_id(), $newPodcastId, $podcastAdminGroup->id,);
$podcastModel->addPodcastContributor(user_id(), $newPodcastId, $podcastAdminGroup->id);
$podcastsPlatformsData = [];
$platformTypes = [
@ -230,7 +232,7 @@ class PodcastImportController extends BaseController
}
if (count($podcastsPlatformsData) > 1) {
$platformModel->createPodcastPlatforms($newPodcastId, $podcastsPlatformsData,);
$platformModel->createPodcastPlatforms($newPodcastId, $podcastsPlatformsData);
}
foreach ($nsPodcast->person as $podcastPerson) {
@ -291,11 +293,11 @@ class PodcastImportController extends BaseController
for ($itemNumber = 1; $itemNumber <= $lastItem; ++$itemNumber) {
$item = $feed->channel[0]->item[$numberItems - $itemNumber];
$nsItunes = $item->children('http://www.itunes.com/dtds/podcast-1.0.dtd',);
$nsItunes = $item->children('http://www.itunes.com/dtds/podcast-1.0.dtd');
$nsPodcast = $item->children(
'https://github.com/Podcastindex-org/podcast-namespace/blob/main/docs/1.0.md',
);
$nsContent = $item->children('http://purl.org/rss/1.0/modules/content/',);
$nsContent = $item->children('http://purl.org/rss/1.0/modules/content/');
$slug = slugify(
$this->request->getPost('slug_field') === 'title'
@ -321,7 +323,7 @@ class PodcastImportController extends BaseController
property_exists($nsItunes, 'image') && $nsItunes->image !== null &&
$nsItunes->image->attributes()['href'] !== null
) {
$episodeImage = new Image(download_file((string) $nsItunes->image->attributes()['href'],),);
$episodeImage = new Image(download_file((string) $nsItunes->image->attributes()['href'],));
} else {
$episodeImage = null;
}

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -74,7 +76,7 @@ class PodcastPersonController extends BaseController
public function remove(int $personId): RedirectResponse
{
(new PersonModel())->removePersonFromPodcast($this->podcast->id, $personId,);
(new PersonModel())->removePersonFromPodcast($this->podcast->id, $personId);
return redirect()->back();
}

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -93,7 +95,7 @@ class PodcastPlatformController extends BaseController
->with('message', lang('Platforms.messages.updateSuccess'));
}
$platformModel->savePodcastPlatforms($this->podcast->id, $platformType, $podcastsPlatformsData,);
$platformModel->savePodcastPlatforms($this->podcast->id, $platformType, $podcastsPlatformsData);
return redirect()
->back()
@ -102,7 +104,7 @@ class PodcastPlatformController extends BaseController
public function removePodcastPlatform(string $platformSlug): RedirectResponse
{
(new PlatformModel())->removePodcastPlatform($this->podcast->id, $platformSlug,);
(new PlatformModel())->removePodcastPlatform($this->podcast->id, $platformSlug);
return redirect()
->back()

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -108,7 +110,7 @@ class UserController extends BaseController
->route('user-list')
->with('message', lang('User.messages.createSuccess', [
'username' => $user->username,
]),);
]));
}
public function edit(): string
@ -148,7 +150,7 @@ class UserController extends BaseController
->route('user-list')
->with('message', lang('User.messages.rolesEditSuccess', [
'username' => $this->user->username,
]),);
]));
}
public function forcePassReset(): RedirectResponse
@ -200,7 +202,7 @@ class UserController extends BaseController
->route('user-list')
->with('message', lang('User.messages.banSuccess', [
'username' => $this->user->username,
]),);
]));
}
public function unBan(): RedirectResponse
@ -218,7 +220,7 @@ class UserController extends BaseController
->route('user-list')
->with('message', lang('User.messages.unbanSuccess', [
'username' => $this->user->username,
]),);
]));
}
public function delete(): RedirectResponse
@ -240,6 +242,6 @@ class UserController extends BaseController
->back()
->with('message', lang('User.messages.deleteSuccess', [
'username' => $this->user->username,
]),);
]));
}
}

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -53,7 +55,7 @@ class AuthController extends MythAuthController
}
// Save the user
$allowedPostFields = array_merge(['password'], $this->config->validFields, $this->config->personalFields,);
$allowedPostFields = array_merge(['password'], $this->config->validFields, $this->config->personalFields);
$user = new User($this->request->getPost($allowedPostFields));
$this->config->requireActivation === null
@ -80,7 +82,7 @@ class AuthController extends MythAuthController
return redirect()
->back()
->withInput()
->with('error', $activator->error() ?? lang('Auth.unknownError'),);
->with('error', $activator->error() ?? lang('Auth.unknownError'));
}
// Success!

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Controllers;
use CodeIgniter\Controller;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -100,7 +102,7 @@ class EpisodeController extends BaseController
$session = Services::session();
$session->start();
if (isset($_SERVER['HTTP_REFERER'])) {
$session->set('embeddable_player_domain', parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST),);
$session->set('embeddable_player_domain', parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST));
}
$locale = service('request')
@ -159,7 +161,7 @@ class EpisodeController extends BaseController
public function oembedXML(): ResponseInterface
{
$oembed = new SimpleXMLElement("<?xml version='1.0' encoding='utf-8' standalone='yes'?><oembed></oembed>",);
$oembed = new SimpleXMLElement("<?xml version='1.0' encoding='utf-8' standalone='yes'?><oembed></oembed>");
$oembed->addChild('type', 'rich');
$oembed->addChild('version', '1.0');
@ -182,6 +184,6 @@ class EpisodeController extends BaseController
$oembed->addChild('width', '600');
$oembed->addChild('height', '200');
return $this->response->setXML($oembed);
return $this->response->setXML((string) $oembed);
}
}

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -33,10 +35,10 @@ class FeedController extends Controller
$service = UserAgentsRSS::find($_SERVER['HTTP_USER_AGENT']);
} catch (Exception $exception) {
// If things go wrong the show must go on and the user must be able to download the file
log_message('critical', $exception);
log_message('critical', $exception->getMessage());
}
$serviceSlug = null;
$serviceSlug = '';
if ($service) {
$serviceSlug = $service['slug'];
}

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -123,7 +125,7 @@ class InstallController extends Controller
// Could not connect to the database
// show database config view to fix value
session()
->setFlashdata('error', lang('Install.messages.databaseConnectError'),);
->setFlashdata('error', lang('Install.messages.databaseConnectError'));
return view('install/database_config');
}
@ -171,7 +173,7 @@ class InstallController extends Controller
helper('text');
// redirect to full install url with new baseUrl input
return redirect()->to(reduce_double_slashes($baseUrl . '/' . config('App')->installGateway,),);
return redirect()->to(reduce_double_slashes($baseUrl . '/' . config('App')->installGateway,));
}
public function databaseConfig(): string

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -15,6 +17,7 @@ use App\Entities\Actor;
use App\Entities\Note as CastopodNote;
use App\Entities\Podcast;
use App\Models\EpisodeModel;
use App\Models\NoteModel;
use App\Models\PodcastModel;
use CodeIgniter\Exceptions\PageNotFoundException;
use CodeIgniter\HTTP\RedirectResponse;
@ -46,7 +49,7 @@ class NoteController extends ActivityPubNoteController
if (
count($params) > 1 &&
! ($this->note = model('NoteModel')->getNoteById($params[1]))
! ($this->note = (new NoteModel())->getNoteById($params[1]))
) {
throw PageNotFoundException::forPageNotFound();
}
@ -129,14 +132,15 @@ class NoteController extends ActivityPubNoteController
$newNote->message = $message;
$noteModel = new NoteModel();
if (
! model('NoteModel')
! $noteModel
->addNote($newNote, ! (bool) $newNote->episode_id, true,)
) {
return redirect()
->back()
->withInput()
->with('errors', model('NoteModel')->errors());
->with('errors', $noteModel->errors());
}
// Note has been successfully created
@ -164,11 +168,12 @@ class NoteController extends ActivityPubNoteController
'created_by' => user_id(),
]);
if (! model('NoteModel')->addReply($newNote)) {
$noteModel = new NoteModel();
if (! $noteModel->addReply($newNote)) {
return redirect()
->back()
->withInput()
->with('errors', model('NoteModel')->errors());
->with('errors', $noteModel->errors());
}
// Reply note without preview card has been successfully created
@ -177,14 +182,14 @@ class NoteController extends ActivityPubNoteController
public function attemptFavourite(): RedirectResponse
{
model('FavouriteModel')->toggleFavourite(interact_as_actor(), $this->note,);
model('FavouriteModel')->toggleFavourite(interact_as_actor(), $this->note);
return redirect()->back();
}
public function attemptReblog(): RedirectResponse
{
model('NoteModel')->toggleReblog(interact_as_actor(), $this->note);
(new NoteModel())->toggleReblog(interact_as_actor(), $this->note);
return redirect()->back();
}

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -94,7 +96,7 @@ class PodcastController extends BaseController
$seasonQuery = $this->request->getGet('season');
if (! $yearQuery && ! $seasonQuery) {
$defaultQuery = (new PodcastModel())->getDefaultQuery($this->podcast->id,);
$defaultQuery = (new PodcastModel())->getDefaultQuery($this->podcast->id);
if ($defaultQuery) {
if ($defaultQuery['type'] === 'season') {
$seasonQuery = $defaultQuery['data']['season_number'];

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* Class AddAddPodcastsPlatforms Creates podcasts_platforms table in database
*

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* Class AddCategories Creates categories table in database
*

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* Class AddLanguages Creates languages table in database
*

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* Class AddPodcasts Creates podcasts table in database
*
@ -189,7 +191,7 @@ class AddPodcasts extends Migration
// TODO: remove name in favor of username from actor
$this->forge->addUniqueKey('name');
$this->forge->addUniqueKey('actor_id');
$this->forge->addForeignKey('actor_id', 'activitypub_actors', 'id', '', 'CASCADE',);
$this->forge->addForeignKey('actor_id', 'activitypub_actors', 'id', '', 'CASCADE');
$this->forge->addForeignKey('category_id', 'categories', 'id');
$this->forge->addForeignKey('language_code', 'languages', 'code');
$this->forge->addForeignKey('created_by', 'users', 'id');

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* Class AddEpisodes Creates episodes table in database
*
@ -185,7 +187,7 @@ class AddEpisodes extends Migration
]);
$this->forge->addPrimaryKey('id');
$this->forge->addUniqueKey(['podcast_id', 'slug']);
$this->forge->addForeignKey('podcast_id', 'podcasts', 'id', '', 'CASCADE',);
$this->forge->addForeignKey('podcast_id', 'podcasts', 'id', '', 'CASCADE');
$this->forge->addForeignKey('created_by', 'users', 'id');
$this->forge->addForeignKey('updated_by', 'users', 'id');
$this->forge->createTable('episodes');

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* Class AddSoundbites Creates soundbites table in database
*
@ -63,8 +65,8 @@ class AddSoundbites extends Migration
]);
$this->forge->addKey('id', true);
$this->forge->addUniqueKey(['episode_id', 'start_time', 'duration']);
$this->forge->addForeignKey('podcast_id', 'podcasts', 'id', '', 'CASCADE',);
$this->forge->addForeignKey('episode_id', 'episodes', 'id', '', 'CASCADE',);
$this->forge->addForeignKey('podcast_id', 'podcasts', 'id', '', 'CASCADE');
$this->forge->addForeignKey('episode_id', 'episodes', 'id', '', 'CASCADE');
$this->forge->addForeignKey('created_by', 'users', 'id');
$this->forge->addForeignKey('updated_by', 'users', 'id');
$this->forge->createTable('soundbites');

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* Class AddPlatforms Creates platforms table in database
*
@ -41,7 +43,7 @@ class AddPlatforms extends Migration
],
]);
$this->forge->addField('`created_at` timestamp NOT NULL DEFAULT NOW()');
$this->forge->addField('`updated_at` timestamp NOT NULL DEFAULT NOW() ON UPDATE NOW()',);
$this->forge->addField('`updated_at` timestamp NOT NULL DEFAULT NOW() ON UPDATE NOW()');
$this->forge->addPrimaryKey('slug');
$this->forge->createTable('platforms');
}

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* Class AddPodcastUsers Creates podcast_users table in database
*
@ -32,8 +34,8 @@ class AddPodcastsUsers extends Migration
]);
$this->forge->addPrimaryKey(['user_id', 'podcast_id']);
$this->forge->addForeignKey('user_id', 'users', 'id', '', 'CASCADE');
$this->forge->addForeignKey('podcast_id', 'podcasts', 'id', '', 'CASCADE',);
$this->forge->addForeignKey('group_id', 'auth_groups', 'id', '', 'CASCADE',);
$this->forge->addForeignKey('podcast_id', 'podcasts', 'id', '', 'CASCADE');
$this->forge->addForeignKey('group_id', 'auth_groups', 'id', '', 'CASCADE');
$this->forge->createTable('podcasts_users');
}

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* Class AddPages Creates pages table in database
*

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* Class AddPodcastsCategories Creates podcasts_categories table in database
*
@ -27,8 +29,8 @@ class AddPodcastsCategories extends Migration
],
]);
$this->forge->addPrimaryKey(['podcast_id', 'category_id']);
$this->forge->addForeignKey('podcast_id', 'podcasts', 'id', '', 'CASCADE',);
$this->forge->addForeignKey('category_id', 'categories', 'id', '', 'CASCADE',);
$this->forge->addForeignKey('podcast_id', 'podcasts', 'id', '', 'CASCADE');
$this->forge->addForeignKey('category_id', 'categories', 'id', '', 'CASCADE');
$this->forge->createTable('podcasts_categories');
}

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* Class Persons Creates persons table in database
*

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* Class AddPodcastsPersons Creates podcasts_persons table in database
*
@ -41,8 +43,8 @@ class AddPodcastsPersons extends Migration
]);
$this->forge->addKey('id', true);
$this->forge->addUniqueKey(['podcast_id', 'person_id', 'person_group', 'person_role']);
$this->forge->addForeignKey('podcast_id', 'podcasts', 'id', '', 'CASCADE',);
$this->forge->addForeignKey('person_id', 'persons', 'id', '', 'CASCADE',);
$this->forge->addForeignKey('podcast_id', 'podcasts', 'id', '', 'CASCADE');
$this->forge->addForeignKey('person_id', 'persons', 'id', '', 'CASCADE');
$this->forge->createTable('podcasts_persons');
}

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* Class AddEpisodesPersons Creates episodes_persons table in database
*
@ -45,9 +47,9 @@ class AddEpisodesPersons extends Migration
]);
$this->forge->addPrimaryKey('id');
$this->forge->addUniqueKey(['podcast_id', 'episode_id', 'person_id', 'person_group', 'person_role']);
$this->forge->addForeignKey('podcast_id', 'podcasts', 'id', '', 'CASCADE',);
$this->forge->addForeignKey('episode_id', 'episodes', 'id', '', 'CASCADE',);
$this->forge->addForeignKey('person_id', 'persons', 'id', '', 'CASCADE',);
$this->forge->addForeignKey('podcast_id', 'podcasts', 'id', '', 'CASCADE');
$this->forge->addForeignKey('episode_id', 'episodes', 'id', '', 'CASCADE');
$this->forge->addForeignKey('person_id', 'persons', 'id', '', 'CASCADE');
$this->forge->createTable('episodes_persons');
}

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* Class AddCreditView Creates Credit View in database
*

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* Class AddEpisodeIdToNotes Adds episode_id field to activitypub_notes table in database
*
@ -28,7 +30,7 @@ class AddEpisodeIdToNotes extends Migration
public function down(): void
{
$this->forge->dropForeignKey('activitypub_notes', 'activitypub_notes_episode_id_foreign',);
$this->forge->dropForeignKey('activitypub_notes', 'activitypub_notes_episode_id_foreign');
$this->forge->dropColumn('activitypub_notes', 'episode_id');
}
}

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* Class AddCreatedByToNotes Adds created_by field to activitypub_notes table in database
*
@ -28,7 +30,7 @@ class AddCreatedByToNotes extends Migration
public function down(): void
{
$this->forge->dropForeignKey('activitypub_notes', 'activitypub_notes_created_by_foreign',);
$this->forge->dropForeignKey('activitypub_notes', 'activitypub_notes_created_by_foreign');
$this->forge->dropColumn('activitypub_notes', 'created_by');
}
}

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* Class AppSeeder Calls all required seeders for castopod to work properly
*

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* Class PermissionSeeder Inserts permissions
*

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* Class CategorySeeder Inserts values in categories table in database
*

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* Class FakePodcastsAnalyticsSeeder Inserts Fake Analytics in the database
*
@ -61,7 +63,7 @@ class FakePodcastsAnalyticsSeeder extends Seeder
->where('`published_at` <= NOW()', null, false)
->findAll();
foreach ($episodes as $episode) {
$age = floor(($date - strtotime($episode->published_at)) / 86400,);
$age = floor(($date - strtotime($episode->published_at)) / 86400);
$probability1 = (int) floor(exp(3 - $age / 40)) + 1;
for (
@ -95,7 +97,7 @@ class FakePodcastsAnalyticsSeeder extends Seeder
'.' .
rand(0, 255);
$cityReader = new Reader(WRITEPATH . 'uploads/GeoLite2-City/GeoLite2-City.mmdb',);
$cityReader = new Reader(WRITEPATH . 'uploads/GeoLite2-City/GeoLite2-City.mmdb');
$countryCode = 'N/A';
$regionCode = 'N/A';

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* Class FakeWebsiteAnalyticsSeeder Inserts Fake Analytics in the database
*
@ -200,7 +202,7 @@ class FakeWebsiteAnalyticsSeeder extends Seeder
->where('`published_at` <= NOW()', null, false)
->findAll();
foreach ($episodes as $episode) {
$age = floor(($date - strtotime($episode->published_at)) / 86400,);
$age = floor(($date - strtotime($episode->published_at)) / 86400);
$probability1 = (int) floor(exp(3 - $age / 40)) + 1;
for (

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* Class LanguageSeeder Inserts values in languages table in database
*

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* Class PlatformsSeeder Inserts values in platforms table in database
*

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* Class TestSeeder Inserts a superadmin user in the database
*

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -20,21 +22,21 @@ class Actor extends ActivityPubActor
{
protected ?Podcast $podcast = null;
protected bool $is_podcast;
protected bool $is_podcast = false;
public function getIsPodcast(): bool
{
return $this->podcast !== null;
return $this->getPodcast() !== null;
}
public function getPodcast(): ?Podcast
{
if ($this->id === null) {
throw new RuntimeException('Podcast id must be set before getting associated podcast.',);
throw new RuntimeException('Podcast id must be set before getting associated podcast.');
}
if ($this->podcast === null) {
$this->podcast = (new PodcastModel())->getPodcastByActorId($this->id,);
$this->podcast = (new PodcastModel())->getPodcastByActorId($this->id);
}
return $this->podcast;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -54,11 +56,11 @@ class Credit extends Entity
public function getPerson(): ?Person
{
if ($this->person_id === null) {
throw new RuntimeException('Credit must have person_id before getting person.',);
throw new RuntimeException('Credit must have person_id before getting person.');
}
if ($this->person === null) {
$this->person = (new PersonModel())->getPersonById($this->person_id,);
$this->person = (new PersonModel())->getPersonById($this->person_id);
}
return $this->person;
@ -67,11 +69,11 @@ class Credit extends Entity
public function getPodcast(): ?Podcast
{
if ($this->podcast_id === null) {
throw new RuntimeException('Credit must have podcast_id before getting podcast.',);
throw new RuntimeException('Credit must have podcast_id before getting podcast.');
}
if ($this->podcast === null) {
$this->podcast = (new PodcastModel())->getPodcastById($this->podcast_id,);
$this->podcast = (new PodcastModel())->getPodcastById($this->podcast_id);
}
return $this->podcast;
@ -80,11 +82,11 @@ class Credit extends Entity
public function getEpisode(): ?Episode
{
if ($this->episode_id === null) {
throw new RuntimeException('Credit must have episode_id before getting episode.',);
throw new RuntimeException('Credit must have episode_id before getting episode.');
}
if ($this->episode === null) {
$this->episode = (new EpisodeModel())->getPublishedEpisodeById($this->podcast_id, $this->episode_id,);
$this->episode = (new EpisodeModel())->getPublishedEpisodeById($this->podcast_id, $this->episode_id);
}
return $this->episode;
@ -109,6 +111,6 @@ class Credit extends Entity
return '';
}
return lang("PersonsTaxonomy.persons.{$this->person_group}.roles.{$this->person_role}.label",);
return lang("PersonsTaxonomy.persons.{$this->person_group}.roles.{$this->person_role}.label");
}
}

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -178,7 +180,7 @@ class Episode extends Entity
}
// Save image
$image->saveImage('podcasts/' . $this->getPodcast()->name, $this->attributes['slug'],);
$image->saveImage('podcasts/' . $this->getPodcast()->name, $this->attributes['slug']);
$this->attributes['image_mimetype'] = $image->mimetype;
$this->attributes['image_path'] = $image->path;
@ -189,7 +191,7 @@ class Episode extends Entity
public function getImage(): Image
{
if ($imagePath = $this->attributes['image_path']) {
return new Image(null, $imagePath, $this->attributes['image_mimetype'],);
return new Image(null, $imagePath, $this->attributes['image_mimetype']);
}
return $this->getPodcast()
@ -266,7 +268,7 @@ class Episode extends Entity
if ($this->attributes['transcript_file_path']) {
helper('media');
return new File(media_path($this->attributes['transcript_file_path']),);
return new File(media_path($this->attributes['transcript_file_path']));
}
return null;
@ -277,7 +279,7 @@ class Episode extends Entity
if ($this->attributes['chapters_file_path']) {
helper('media');
return new File(media_path($this->attributes['chapters_file_path']),);
return new File(media_path($this->attributes['chapters_file_path']));
}
return null;
@ -348,11 +350,11 @@ class Episode extends Entity
public function getPersons(): array
{
if ($this->id === null) {
throw new RuntimeException('Episode must be created before getting persons.',);
throw new RuntimeException('Episode must be created before getting persons.');
}
if ($this->persons === null) {
$this->persons = (new PersonModel())->getEpisodePersons($this->podcast_id, $this->id,);
$this->persons = (new PersonModel())->getEpisodePersons($this->podcast_id, $this->id);
}
return $this->persons;
@ -366,11 +368,11 @@ class Episode extends Entity
public function getSoundbites(): array
{
if ($this->id === null) {
throw new RuntimeException('Episode must be created before getting soundbites.',);
throw new RuntimeException('Episode must be created before getting soundbites.');
}
if ($this->soundbites === null) {
$this->soundbites = (new SoundbiteModel())->getEpisodeSoundbites($this->getPodcast() ->id, $this->id,);
$this->soundbites = (new SoundbiteModel())->getEpisodeSoundbites($this->getPodcast() ->id, $this->id);
}
return $this->soundbites;
@ -382,7 +384,7 @@ class Episode extends Entity
public function getNotes(): array
{
if ($this->id === null) {
throw new RuntimeException('Episode must be created before getting soundbites.',);
throw new RuntimeException('Episode must be created before getting soundbites.');
}
if ($this->notes === null) {
@ -394,7 +396,7 @@ class Episode extends Entity
public function getLink(): string
{
return base_url(route_to('episode', $this->getPodcast() ->name, $this->attributes['slug'],),);
return base_url(route_to('episode', $this->getPodcast() ->name, $this->attributes['slug'],));
}
public function getEmbeddablePlayerUrl(string $theme = null): string
@ -421,7 +423,7 @@ class Episode extends Entity
public function getPodcast(): ?Podcast
{
return (new PodcastModel())->getPodcastById($this->attributes['podcast_id'],);
return (new PodcastModel())->getPodcastById($this->podcast_id);
}
public function setDescriptionMarkdown(string $descriptionMarkdown): static
@ -432,7 +434,7 @@ class Episode extends Entity
]);
$this->attributes['description_markdown'] = $descriptionMarkdown;
$this->attributes['description_html'] = $converter->convertToHtml($descriptionMarkdown,);
$this->attributes['description_html'] = $converter->convertToHtml($descriptionMarkdown);
return $this;
}
@ -525,7 +527,7 @@ class Episode extends Entity
}
if ($this->location === null) {
$this->location = new Location($this->location_name, $this->location_geo, $this->location_osm,);
$this->location = new Location($this->location_name, $this->location_geo, $this->location_osm);
}
return $this->location;
@ -549,7 +551,7 @@ class Episode extends Entity
->addChild('item');
array_to_rss([
'elements' => $this->custom_rss,
], $xmlNode,);
], $xmlNode);
return str_replace(['<item>', '</item>'], '', $xmlNode->asXML());
}
@ -573,7 +575,7 @@ class Episode extends Entity
)['elements'][0]['elements'][0];
if (array_key_exists('elements', $customRssArray)) {
$this->attributes['custom_rss'] = json_encode($customRssArray['elements'],);
$this->attributes['custom_rss'] = json_encode($customRssArray['elements']);
} else {
$this->attributes['custom_rss'] = null;
}

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @copyright 2021 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -48,7 +50,7 @@ class Image extends Entity
public function __construct(?File $file, string $path = '', string $mimetype = '')
{
if ($file === null && $path === '') {
throw new RuntimeException('File or path must be set to create an Image.',);
throw new RuntimeException('File or path must be set to create an Image.');
}
$this->config = config('Images');

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* @copyright 2021 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -84,7 +86,7 @@ class Location extends Entity
],
);
$places = json_decode($response->getBody(), false, 512, JSON_THROW_ON_ERROR,);
$places = json_decode($response->getBody(), false, 512, JSON_THROW_ON_ERROR);
if ($places === []) {
return $this;

Some files were not shown because too many files have changed in this diff Show More