refactor: add php_codesniffer to define castopod's coding style based on psr-1
- add .editorconfig file - format all files to comply with castopod's coding style - switch parsedown dependency with commonmark library to better follow commonmark spec for markdown - add prettier command to format all project files at once closes #16
This commit is contained in:
parent
58364bfed1
commit
ed6e953010
|
@ -9,6 +9,7 @@
|
|||
"[php]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
},
|
||||
"phpSniffer.autoDetect": true,
|
||||
"color-highlight.markerType": "dot-before"
|
||||
},
|
||||
"extensions": [
|
||||
|
@ -22,6 +23,7 @@
|
|||
"bradlc.vscode-tailwindcss",
|
||||
"jamesbirtles.svelte-vscode",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"stylelint.vscode-stylelint"
|
||||
"stylelint.vscode-stylelint",
|
||||
"wongjn.php-sniffer"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
; top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
; Unix-style newlines
|
||||
[*]
|
||||
end_of_line = lf
|
||||
|
||||
[*.php]
|
||||
indent_style = spaces
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0"?>
|
||||
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Castopod">
|
||||
<description>Castopod's coding standard based on the PSR-1 standard.</description>
|
||||
|
||||
<!-- Include the whole PSR-1 standard -->
|
||||
<rule ref="PSR1"/>
|
||||
</ruleset>
|
|
@ -5,8 +5,7 @@
|
|||
"files": "*.php",
|
||||
"options": {
|
||||
"phpVersion": "7.2",
|
||||
"singleQuote": true,
|
||||
"trailingCommaPHP": true
|
||||
"singleQuote": true
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
@ -10,7 +10,7 @@ PHP Dependencies:
|
|||
- [GeoIP2 PHP API](https://github.com/maxmind/GeoIP2-php) ([Apache License 2.0](https://github.com/maxmind/GeoIP2-php/blob/master/LICENSE))
|
||||
- [getID3](https://github.com/JamesHeinrich/getID3) ([GNU General Public License v3](https://github.com/JamesHeinrich/getID3/blob/2.0/licenses/license.gpl-30.txt))
|
||||
- [myth-auth](https://github.com/lonnieezell/myth-auth) ([MIT license](https://github.com/lonnieezell/myth-auth/blob/develop/LICENSE.md))
|
||||
- [parsedown](https://github.com/erusev/parsedown) ([MIT license](https://github.com/erusev/parsedown/blob/master/LICENSE.txt))
|
||||
- [commonmark](https://commonmark.thephpleague.com/) ([BSD 3-Clause "New" or "Revised" License](https://github.com/thephpleague/commonmark/blob/latest/LICENSE))
|
||||
|
||||
Javascript dependencies:
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace App\Authorization;
|
||||
<?php
|
||||
|
||||
namespace App\Authorization;
|
||||
|
||||
class FlatAuthorization extends \Myth\Auth\Authorization\FlatAuthorization
|
||||
{
|
||||
|
@ -49,26 +51,26 @@ class FlatAuthorization extends \Myth\Auth\Authorization\FlatAuthorization
|
|||
/**
|
||||
* Makes a member a part of multiple groups.
|
||||
*
|
||||
* @param $user_id
|
||||
* @param $userId
|
||||
* @param array|null $groups // Either collection of ID or names
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function setUserGroups(int $user_id, $groups)
|
||||
public function setUserGroups(int $userId, $groups)
|
||||
{
|
||||
if (empty($user_id) || !is_numeric($user_id)) {
|
||||
if (empty($userId) || !is_numeric($userId)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// remove user from all groups before resetting it in new groups
|
||||
$this->groupModel->removeUserFromAllGroups($user_id);
|
||||
$this->groupModel->removeUserFromAllGroups($userId);
|
||||
|
||||
if (empty($groups)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach ($groups as $group) {
|
||||
$this->addUserToGroup($user_id, $group);
|
||||
$this->addUserToGroup($userId, $group);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace App\Authorization;
|
||||
<?php
|
||||
|
||||
namespace App\Authorization;
|
||||
|
||||
class GroupModel extends \Myth\Auth\Authorization\GroupModel
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace App\Authorization;
|
||||
<?php
|
||||
|
||||
namespace App\Authorization;
|
||||
|
||||
class PermissionModel extends \Myth\Auth\Authorization\PermissionModel
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ERROR DISPLAY
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Config;
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Config;
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
/**
|
||||
* Database Configuration
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Config;
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
/**
|
||||
* DocTypes
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Config;
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Events\Events;
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Config;
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
/**
|
||||
* Setup how the exception handler works.
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Config;
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Config;
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
class ForeignCharacters extends \CodeIgniter\Config\ForeignCharacters
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Config;
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Config;
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Config;
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Config;
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
use Kint\Renderer\Renderer;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Config;
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Config;
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Config;
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
/*
|
||||
| -------------------------------------------------------------------
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Config;
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
// Cannot extend BaseConfig or looping resources occurs.
|
||||
class Modules
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Config;
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Config;
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
/**
|
||||
* Holds the paths that are used by the system to
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Config;
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\Services as CoreServices;
|
||||
use CodeIgniter\Model;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Config;
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Config;
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Config;
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
class Validation
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Config;
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
class View extends \CodeIgniter\Config\View
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @copyright 2020 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
|
@ -66,7 +67,9 @@ class Contributor extends BaseController
|
|||
return redirect()
|
||||
->back()
|
||||
->withInput()
|
||||
->with('errors', [lang('Contributor.alreadyAddedError')]);
|
||||
->with('errors', [
|
||||
lang('Contributor.messages.alreadyAddedError'),
|
||||
]);
|
||||
}
|
||||
|
||||
return redirect()->route('contributor_list', [$this->podcast->id]);
|
||||
|
@ -77,7 +80,7 @@ class Contributor extends BaseController
|
|||
$data = [
|
||||
'podcast' => $this->podcast,
|
||||
'user' => $this->user,
|
||||
'contributor_group_id' => (new PodcastModel())->getContributorGroupId(
|
||||
'contributorGroupId' => (new PodcastModel())->getContributorGroupId(
|
||||
$this->user->id,
|
||||
$this->podcast->id
|
||||
),
|
||||
|
@ -104,27 +107,27 @@ class Contributor extends BaseController
|
|||
return redirect()
|
||||
->back()
|
||||
->with('errors', [
|
||||
lang('Contributor.removeOwnerContributorError'),
|
||||
lang('Contributor.messages.removeOwnerContributorError'),
|
||||
]);
|
||||
}
|
||||
|
||||
$podcast_model = new PodcastModel();
|
||||
$podcastModel = new PodcastModel();
|
||||
if (
|
||||
!$podcast_model->removePodcastContributor(
|
||||
!$podcastModel->removePodcastContributor(
|
||||
$this->user->id,
|
||||
$this->podcast->id
|
||||
)
|
||||
) {
|
||||
return redirect()
|
||||
->back()
|
||||
->with('errors', $podcast_model->errors());
|
||||
->with('errors', $podcastModel->errors());
|
||||
}
|
||||
|
||||
return redirect()
|
||||
->back()
|
||||
->with(
|
||||
'message',
|
||||
lang('Contributor.removeContributorSuccess', [
|
||||
lang('Contributor.messages.removeContributorSuccess', [
|
||||
'username' => $this->user->username,
|
||||
'podcastTitle' => $this->podcast->title,
|
||||
])
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @copyright 2020 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
|
@ -20,9 +21,8 @@ class Episode extends BaseController
|
|||
$this->podcast = (new PodcastModel())->find($params[0]);
|
||||
|
||||
if (count($params) > 1) {
|
||||
$episode_model = new EpisodeModel();
|
||||
if (
|
||||
!($this->episode = $episode_model
|
||||
!($this->episode = (new EpisodeModel())
|
||||
->where([
|
||||
'id' => $params[1],
|
||||
'podcast_id' => $params[0],
|
||||
|
@ -78,7 +78,7 @@ class Episode extends BaseController
|
|||
->with('errors', $this->validator->getErrors());
|
||||
}
|
||||
|
||||
$new_episode = new \App\Entities\Episode([
|
||||
$newEpisode = new \App\Entities\Episode([
|
||||
'podcast_id' => $this->podcast->id,
|
||||
'title' => $this->request->getPost('title'),
|
||||
'slug' => $this->request->getPost('slug'),
|
||||
|
@ -95,13 +95,13 @@ class Episode extends BaseController
|
|||
'block' => (bool) $this->request->getPost('block'),
|
||||
]);
|
||||
|
||||
$episode_model = new EpisodeModel();
|
||||
$episodeModel = new EpisodeModel();
|
||||
|
||||
if (!$episode_model->save($new_episode)) {
|
||||
if (!$episodeModel->save($newEpisode)) {
|
||||
return redirect()
|
||||
->back()
|
||||
->withInput()
|
||||
->with('errors', $episode_model->errors());
|
||||
->with('errors', $episodeModel->errors());
|
||||
}
|
||||
|
||||
return redirect()->route('episode_list', [$this->podcast->id]);
|
||||
|
@ -112,7 +112,6 @@ class Episode extends BaseController
|
|||
helper(['form']);
|
||||
|
||||
$data = [
|
||||
'podcast' => $this->podcast,
|
||||
'episode' => $this->episode,
|
||||
];
|
||||
|
||||
|
@ -158,13 +157,13 @@ class Episode extends BaseController
|
|||
$this->episode->image = $image;
|
||||
}
|
||||
|
||||
$episode_model = new EpisodeModel();
|
||||
$episodeModel = new EpisodeModel();
|
||||
|
||||
if (!$episode_model->save($this->episode)) {
|
||||
if (!$episodeModel->save($this->episode)) {
|
||||
return redirect()
|
||||
->back()
|
||||
->withInput()
|
||||
->with('errors', $episode_model->errors());
|
||||
->with('errors', $episodeModel->errors());
|
||||
}
|
||||
|
||||
return redirect()->route('episode_list', [$this->podcast->id]);
|
||||
|
@ -172,8 +171,7 @@ class Episode extends BaseController
|
|||
|
||||
public function delete()
|
||||
{
|
||||
$episode_model = new EpisodeModel();
|
||||
$episode_model->delete($this->episode->id);
|
||||
(new EpisodeModel())->delete($this->episode->id);
|
||||
|
||||
return redirect()->route('episode_list', [$this->podcast->id]);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @copyright 2020 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @copyright 2020 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
|
@ -25,7 +26,7 @@ class Myaccount extends BaseController
|
|||
public function attemptChange()
|
||||
{
|
||||
$auth = Services::authentication();
|
||||
$user_model = new UserModel();
|
||||
$userModel = new UserModel();
|
||||
|
||||
// Validate here first, since some things,
|
||||
// like the password, can only be validated properly here.
|
||||
|
@ -40,7 +41,7 @@ class Myaccount extends BaseController
|
|||
return redirect()
|
||||
->back()
|
||||
->withInput()
|
||||
->with('errors', $user_model->errors());
|
||||
->with('errors', $userModel->errors());
|
||||
}
|
||||
|
||||
$credentials = [
|
||||
|
@ -52,22 +53,22 @@ class Myaccount extends BaseController
|
|||
return redirect()
|
||||
->back()
|
||||
->withInput()
|
||||
->with('errors', $user_model->errors());
|
||||
->with('errors', $userModel->errors());
|
||||
}
|
||||
|
||||
user()->password = $this->request->getPost('new_password');
|
||||
$user_model->save(user());
|
||||
$userModel->save(user());
|
||||
|
||||
if (!$user_model->save(user())) {
|
||||
if (!$userModel->save(user())) {
|
||||
return redirect()
|
||||
->back()
|
||||
->withInput()
|
||||
->with('errors', $user_model->errors());
|
||||
->with('errors', $userModel->errors());
|
||||
}
|
||||
|
||||
// Success!
|
||||
return redirect()
|
||||
->route('myAccount')
|
||||
->with('message', lang('MyAccount.passwordChangeSuccess'));
|
||||
->with('message', lang('MyAccount.messages.passwordChangeSuccess'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @copyright 2020 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
* @link https://castopod.org/
|
||||
*/
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Models\CategoryModel;
|
||||
|
@ -29,7 +31,7 @@ class Podcast extends BaseController
|
|||
public function myPodcasts()
|
||||
{
|
||||
$data = [
|
||||
'all_podcasts' => (new PodcastModel())->getUserPodcasts(user()->id),
|
||||
'podcasts' => (new PodcastModel())->getUserPodcasts(user()->id),
|
||||
];
|
||||
|
||||
return view('admin/podcast/list', $data);
|
||||
|
@ -41,7 +43,7 @@ class Podcast extends BaseController
|
|||
return redirect()->route('my_podcasts');
|
||||
}
|
||||
|
||||
$data = ['all_podcasts' => (new PodcastModel())->findAll()];
|
||||
$data = ['podcasts' => (new PodcastModel())->findAll()];
|
||||
|
||||
return view('admin/podcast/list', $data);
|
||||
}
|
||||
|
@ -62,7 +64,7 @@ class Podcast extends BaseController
|
|||
$data = [
|
||||
'languages' => $languageModel->findAll(),
|
||||
'categories' => $categoryModel->findAll(),
|
||||
'browser_lang' => get_browser_language(
|
||||
'browserLang' => get_browser_language(
|
||||
$this->request->getServer('HTTP_ACCEPT_LANGUAGE')
|
||||
),
|
||||
];
|
||||
|
@ -106,26 +108,26 @@ class Podcast extends BaseController
|
|||
'custom_html_head' => $this->request->getPost('custom_html_head'),
|
||||
]);
|
||||
|
||||
$podcast_model = new PodcastModel();
|
||||
$podcastModel = new PodcastModel();
|
||||
$db = \Config\Database::connect();
|
||||
|
||||
$db->transStart();
|
||||
|
||||
if (!($new_podcast_id = $podcast_model->insert($podcast, true))) {
|
||||
if (!($newPodcastId = $podcastModel->insert($podcast, true))) {
|
||||
$db->transComplete();
|
||||
return redirect()
|
||||
->back()
|
||||
->withInput()
|
||||
->with('errors', $podcast_model->errors());
|
||||
->with('errors', $podcastModel->errors());
|
||||
}
|
||||
|
||||
$authorize = Services::authorization();
|
||||
$podcast_admin_group = $authorize->group('podcast_admin');
|
||||
$podcastAdminGroup = $authorize->group('podcast_admin');
|
||||
|
||||
$podcast_model->addPodcastContributor(
|
||||
$podcastModel->addPodcastContributor(
|
||||
user()->id,
|
||||
$new_podcast_id,
|
||||
$podcast_admin_group->id
|
||||
$newPodcastId,
|
||||
$podcastAdminGroup->id
|
||||
);
|
||||
|
||||
$db->transComplete();
|
||||
|
@ -137,12 +139,10 @@ class Podcast extends BaseController
|
|||
{
|
||||
helper('form');
|
||||
|
||||
$languageModel = new LanguageModel();
|
||||
$categoryModel = new CategoryModel();
|
||||
$data = [
|
||||
'podcast' => $this->podcast,
|
||||
'languages' => $languageModel->findAll(),
|
||||
'categories' => $categoryModel->findAll(),
|
||||
'languages' => (new LanguageModel())->findAll(),
|
||||
'categories' => (new CategoryModel())->findAll(),
|
||||
];
|
||||
|
||||
echo view('admin/podcast/edit', $data);
|
||||
|
@ -188,13 +188,13 @@ class Podcast extends BaseController
|
|||
'custom_html_head'
|
||||
);
|
||||
|
||||
$podcast_model = new PodcastModel();
|
||||
$podcastModel = new PodcastModel();
|
||||
|
||||
if (!$podcast_model->save($this->podcast)) {
|
||||
if (!$podcastModel->save($this->podcast)) {
|
||||
return redirect()
|
||||
->back()
|
||||
->withInput()
|
||||
->with('errors', $podcast_model->errors());
|
||||
->with('errors', $podcastModel->errors());
|
||||
}
|
||||
|
||||
return redirect()->route('podcast_list');
|
||||
|
@ -202,8 +202,7 @@ class Podcast extends BaseController
|
|||
|
||||
public function delete()
|
||||
{
|
||||
$podcast_model = new PodcastModel();
|
||||
$podcast_model->delete($this->podcast->id);
|
||||
(new PodcastModel())->delete($this->podcast->id);
|
||||
|
||||
return redirect()->route('podcast_list');
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @copyright 2020 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
|
@ -18,8 +19,7 @@ class User extends BaseController
|
|||
public function _remap($method, ...$params)
|
||||
{
|
||||
if (count($params) > 0) {
|
||||
$user_model = new UserModel();
|
||||
if (!($this->user = $user_model->find($params[0]))) {
|
||||
if (!($this->user = (new UserModel())->find($params[0]))) {
|
||||
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ class User extends BaseController
|
|||
|
||||
public function list()
|
||||
{
|
||||
$data = ['all_users' => (new UserModel())->findAll()];
|
||||
$data = ['users' => (new UserModel())->findAll()];
|
||||
|
||||
return view('admin/user/list', $data);
|
||||
}
|
||||
|
@ -45,12 +45,12 @@ class User extends BaseController
|
|||
|
||||
public function attemptCreate()
|
||||
{
|
||||
$user_model = new UserModel();
|
||||
$userModel = new UserModel();
|
||||
|
||||
// Validate here first, since some things,
|
||||
// like the password, can only be validated properly here.
|
||||
$rules = array_merge(
|
||||
$user_model->getValidationRules(['only' => ['username']]),
|
||||
$userModel->getValidationRules(['only' => ['username']]),
|
||||
[
|
||||
'email' => 'required|valid_email|is_unique[users.email]',
|
||||
'password' => 'required|strong_password',
|
||||
|
@ -74,11 +74,11 @@ class User extends BaseController
|
|||
// Force user to reset his password on first connection
|
||||
$user->forcePasswordReset();
|
||||
|
||||
if (!$user_model->save($user)) {
|
||||
if (!$userModel->save($user)) {
|
||||
return redirect()
|
||||
->back()
|
||||
->withInput()
|
||||
->with('errors', $user_model->errors());
|
||||
->with('errors', $userModel->errors());
|
||||
}
|
||||
|
||||
// Success!
|
||||
|
@ -86,7 +86,7 @@ class User extends BaseController
|
|||
->route('user_list')
|
||||
->with(
|
||||
'message',
|
||||
lang('User.createSuccess', [
|
||||
lang('User.messages.createSuccess', [
|
||||
'username' => $user->username,
|
||||
])
|
||||
);
|
||||
|
@ -114,7 +114,7 @@ class User extends BaseController
|
|||
->route('user_list')
|
||||
->with(
|
||||
'message',
|
||||
lang('User.rolesEditSuccess', [
|
||||
lang('User.messages.rolesEditSuccess', [
|
||||
'username' => $this->user->username,
|
||||
])
|
||||
);
|
||||
|
@ -122,13 +122,13 @@ class User extends BaseController
|
|||
|
||||
public function forcePassReset()
|
||||
{
|
||||
$user_model = new UserModel();
|
||||
$userModel = new UserModel();
|
||||
$this->user->forcePasswordReset();
|
||||
|
||||
if (!$user_model->save($this->user)) {
|
||||
if (!$userModel->save($this->user)) {
|
||||
return redirect()
|
||||
->back()
|
||||
->with('errors', $user_model->errors());
|
||||
->with('errors', $userModel->errors());
|
||||
}
|
||||
|
||||
// Success!
|
||||
|
@ -136,7 +136,7 @@ class User extends BaseController
|
|||
->route('user_list')
|
||||
->with(
|
||||
'message',
|
||||
lang('User.forcePassResetSuccess', [
|
||||
lang('User.messages.forcePassResetSuccess', [
|
||||
'username' => $this->user->username,
|
||||
])
|
||||
);
|
||||
|
@ -149,27 +149,27 @@ class User extends BaseController
|
|||
return redirect()
|
||||
->back()
|
||||
->with('errors', [
|
||||
lang('User.banSuperAdminError', [
|
||||
lang('User.messages.banSuperAdminError', [
|
||||
'username' => $this->user->username,
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
$user_model = new UserModel();
|
||||
$userModel = new UserModel();
|
||||
// TODO: add ban reason?
|
||||
$this->user->ban('');
|
||||
|
||||
if (!$user_model->save($this->user)) {
|
||||
if (!$userModel->save($this->user)) {
|
||||
return redirect()
|
||||
->back()
|
||||
->with('errors', $user_model->errors());
|
||||
->with('errors', $userModel->errors());
|
||||
}
|
||||
|
||||
return redirect()
|
||||
->route('user_list')
|
||||
->with(
|
||||
'message',
|
||||
lang('User.banSuccess', [
|
||||
lang('User.messages.banSuccess', [
|
||||
'username' => $this->user->username,
|
||||
])
|
||||
);
|
||||
|
@ -177,20 +177,20 @@ class User extends BaseController
|
|||
|
||||
public function unBan()
|
||||
{
|
||||
$user_model = new UserModel();
|
||||
$userModel = new UserModel();
|
||||
$this->user->unBan();
|
||||
|
||||
if (!$user_model->save($this->user)) {
|
||||
if (!$userModel->save($this->user)) {
|
||||
return redirect()
|
||||
->back()
|
||||
->with('errors', $user_model->errors());
|
||||
->with('errors', $userModel->errors());
|
||||
}
|
||||
|
||||
return redirect()
|
||||
->route('user_list')
|
||||
->with(
|
||||
'message',
|
||||
lang('User.unbanSuccess', [
|
||||
lang('User.messages.unbanSuccess', [
|
||||
'username' => $this->user->username,
|
||||
])
|
||||
);
|
||||
|
@ -203,20 +203,19 @@ class User extends BaseController
|
|||
return redirect()
|
||||
->back()
|
||||
->with('errors', [
|
||||
lang('User.deleteSuperAdminError', [
|
||||
lang('User.messages.deleteSuperAdminError', [
|
||||
'username' => $this->user->username,
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
$user_model = new UserModel();
|
||||
$user_model->delete($this->user->id);
|
||||
(new UserModel())->delete($this->user->id);
|
||||
|
||||
return redirect()
|
||||
->back()
|
||||
->with(
|
||||
'message',
|
||||
lang('User.deleteSuccess', [
|
||||
lang('User.messages.deleteSuccess', [
|
||||
'username' => $this->user->username,
|
||||
])
|
||||
);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class Analytics
|
||||
* Creates Analytics controller
|
||||
|
@ -44,9 +45,9 @@ class Analytics extends Controller
|
|||
}
|
||||
|
||||
// Add one hit to this episode:
|
||||
public function hit($p_podcast_id, $p_episode_id, ...$filename)
|
||||
public function hit($p_podcastId, $p_episodeId, ...$filename)
|
||||
{
|
||||
podcast_hit($p_podcast_id, $p_episode_id);
|
||||
podcast_hit($p_podcastId, $p_episodeId);
|
||||
return redirect()->to(media_url(implode('/', $filename)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,8 +50,8 @@ class BaseController extends Controller
|
|||
set_user_session_referer();
|
||||
}
|
||||
|
||||
protected static function triggerWebpageHit($postcast_id)
|
||||
protected static function triggerWebpageHit($podcastId)
|
||||
{
|
||||
webpage_hit($postcast_id);
|
||||
webpage_hit($podcastId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @copyright 2020 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
|
@ -17,14 +18,13 @@ class Episode extends BaseController
|
|||
|
||||
public function _remap($method, ...$params)
|
||||
{
|
||||
$podcast_model = new PodcastModel();
|
||||
$this->podcast = (new PodcastModel())
|
||||
->where('name', $params[0])
|
||||
->first();
|
||||
|
||||
$this->podcast = $podcast_model->where('name', $params[0])->first();
|
||||
|
||||
if (count($params) > 1) {
|
||||
$episode_model = new EpisodeModel();
|
||||
if (
|
||||
!($this->episode = $episode_model
|
||||
count($params) > 1 &&
|
||||
!($this->episode = (new EpisodeModel())
|
||||
->where([
|
||||
'podcast_id' => $this->podcast->id,
|
||||
'slug' => $params[1],
|
||||
|
@ -33,7 +33,6 @@ class Episode extends BaseController
|
|||
) {
|
||||
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
}
|
||||
|
||||
return $this->$method();
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @copyright 2020 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
|
@ -12,16 +13,15 @@ use CodeIgniter\Controller;
|
|||
|
||||
class Feed extends Controller
|
||||
{
|
||||
public function index($podcast_name)
|
||||
public function index($podcastName)
|
||||
{
|
||||
helper('rss');
|
||||
|
||||
$podcast_model = new PodcastModel();
|
||||
$podcast = $podcast_model->where('name', $podcast_name)->first();
|
||||
|
||||
// The page cache is set to a decade so it is deleted manually upon podcast update
|
||||
$this->cachePage(DECADE);
|
||||
|
||||
helper('rss');
|
||||
|
||||
$podcast = (new PodcastModel())->where('name', $podcastName)->first();
|
||||
|
||||
return $this->response->setXML(get_rss_feed($podcast));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @copyright 2020 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
|
@ -15,15 +16,15 @@ class Home extends BaseController
|
|||
{
|
||||
$model = new PodcastModel();
|
||||
|
||||
$all_podcasts = $model->findAll();
|
||||
$allPodcasts = $model->findAll();
|
||||
|
||||
// check if there's only one podcast to redirect user to it
|
||||
if (count($all_podcasts) == 1) {
|
||||
return redirect()->route('podcast', [$all_podcasts[0]->name]);
|
||||
if (count($allPodcasts) == 1) {
|
||||
return redirect()->route('podcast', [$allPodcasts[0]->name]);
|
||||
}
|
||||
|
||||
// default behavior: list all podcasts on home page
|
||||
$data = ['podcasts' => $all_podcasts];
|
||||
$data = ['podcasts' => $allPodcasts];
|
||||
return view('home', $data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @copyright 2020 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @copyright 2020 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
* @link https://castopod.org/
|
||||
*/
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\PodcastModel;
|
||||
|
@ -15,9 +17,8 @@ class Podcast extends BaseController
|
|||
public function _remap($method, ...$params)
|
||||
{
|
||||
if (count($params) > 0) {
|
||||
$podcast_model = new PodcastModel();
|
||||
if (
|
||||
!($this->podcast = $podcast_model
|
||||
!($this->podcast = (new PodcastModel())
|
||||
->where('name', $params[0])
|
||||
->first())
|
||||
) {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @copyright 2020 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
|
@ -6,14 +7,15 @@
|
|||
*/
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use CodeIgniter\Controller;
|
||||
|
||||
class UnknownUserAgents extends Controller
|
||||
{
|
||||
public function index($last_known_id = 0)
|
||||
public function index($lastKnownId = 0)
|
||||
{
|
||||
$model = new \App\Models\UnknownUserAgentsModel();
|
||||
|
||||
return $this->response->setJSON($model->getUserAgents($last_known_id));
|
||||
return $this->response->setJSON($model->getUserAgents($lastKnownId));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class AddCategories
|
||||
* Creates categories table in database
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class AddLanguages
|
||||
* Creates languages table in database
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class AddPodcasts
|
||||
* Creates podcasts table in database
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class AddEpisodes
|
||||
* Creates episodes table in database
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class AddPlatforms
|
||||
* Creates platforms table in database
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class AddPlatformsLinks
|
||||
* Creates platform_links table in database
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class AddAnalyticsEpisodesByCountry
|
||||
* Creates analytics_episodes_by_country table in database
|
||||
|
@ -6,6 +7,7 @@
|
|||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
* @link https://castopod.org/
|
||||
*/
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class AddAnalyticsEpisodesByPlayer
|
||||
* Creates analytics_episodes_by_player table in database
|
||||
|
@ -6,6 +7,7 @@
|
|||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
* @link https://castopod.org/
|
||||
*/
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class AddAnalyticsPodcastsByCountry
|
||||
* Creates analytics_podcasts_by_country table in database
|
||||
|
@ -6,6 +7,7 @@
|
|||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
* @link https://castopod.org/
|
||||
*/
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class AddAnalyticsPodcastsByPlayer
|
||||
* Creates analytics_podcasts_by_player table in database
|
||||
|
@ -6,6 +7,7 @@
|
|||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
* @link https://castopod.org/
|
||||
*/
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class AddAnalyticsUnknownUseragents
|
||||
* Creates analytics_unknown_useragents table in database
|
||||
|
@ -6,6 +7,7 @@
|
|||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
* @link https://castopod.org/
|
||||
*/
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class AddAnalyticsWebsiteByBrowser
|
||||
* Creates analytics_website_by_browser table in database
|
||||
|
@ -6,6 +7,7 @@
|
|||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
* @link https://castopod.org/
|
||||
*/
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class AddAnalyticsWebsiteByCountry
|
||||
* Creates analytics_website_by_country table in database
|
||||
|
@ -6,6 +7,7 @@
|
|||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
* @link https://castopod.org/
|
||||
*/
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class AddAnalyticsWebsiteByReferer
|
||||
* Creates analytics_website_by_referer table in database
|
||||
|
@ -6,6 +7,7 @@
|
|||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
* @link https://castopod.org/
|
||||
*/
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class AddAnalyticsPodcastsStoredProcedure
|
||||
* Creates analytics_podcasts stored procedure in database
|
||||
|
@ -6,6 +7,7 @@
|
|||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
* @link https://castopod.org/
|
||||
*/
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class AddAnalyticsUnknownUseragentsStoredProcedure
|
||||
* Creates analytics_unknown_useragents stored procedure in database
|
||||
|
@ -6,6 +7,7 @@
|
|||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
* @link https://castopod.org/
|
||||
*/
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class AddAnalyticsWebsiteStoredProcedure
|
||||
* Creates analytics_website stored procedure in database
|
||||
|
@ -6,6 +7,7 @@
|
|||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
* @link https://castopod.org/
|
||||
*/
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class AddLanguages
|
||||
* Creates languages table in database
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class PermissionSeeder
|
||||
* Inserts permissions
|
||||
|
@ -224,9 +225,9 @@ class AuthSeeder extends Seeder
|
|||
],
|
||||
];
|
||||
|
||||
static function getGroupIdByName($name, $data_groups)
|
||||
static function getGroupIdByName($name, $dataGroups)
|
||||
{
|
||||
foreach ($data_groups as $group) {
|
||||
foreach ($dataGroups as $group) {
|
||||
if ($group['name'] === $name) {
|
||||
return $group['id'];
|
||||
}
|
||||
|
@ -236,45 +237,45 @@ class AuthSeeder extends Seeder
|
|||
|
||||
public function run()
|
||||
{
|
||||
$group_id = 0;
|
||||
$data_groups = [];
|
||||
$groupId = 0;
|
||||
$dataGroups = [];
|
||||
foreach ($this->groups as $group) {
|
||||
array_push($data_groups, [
|
||||
'id' => ++$group_id,
|
||||
array_push($dataGroups, [
|
||||
'id' => ++$groupId,
|
||||
'name' => $group['name'],
|
||||
'description' => $group['description'],
|
||||
]);
|
||||
}
|
||||
|
||||
// Map permissions to a format the `auth_permissions` table expects
|
||||
$data_permissions = [];
|
||||
$data_groups_permissions = [];
|
||||
$permission_id = 0;
|
||||
$dataPermissions = [];
|
||||
$dataGroupsPermissions = [];
|
||||
$permissionId = 0;
|
||||
foreach ($this->permissions as $context => $actions) {
|
||||
foreach ($actions as $action) {
|
||||
array_push($data_permissions, [
|
||||
'id' => ++$permission_id,
|
||||
array_push($dataPermissions, [
|
||||
'id' => ++$permissionId,
|
||||
'name' => $context . '-' . $action['name'],
|
||||
'description' => $action['description'],
|
||||
]);
|
||||
|
||||
foreach ($action['has_permission'] as $role) {
|
||||
// link permission to specified groups
|
||||
array_push($data_groups_permissions, [
|
||||
array_push($dataGroupsPermissions, [
|
||||
'group_id' => $this->getGroupIdByName(
|
||||
$role,
|
||||
$data_groups
|
||||
$dataGroups
|
||||
),
|
||||
'permission_id' => $permission_id,
|
||||
'permission_id' => $permissionId,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->table('auth_permissions')->insertBatch($data_permissions);
|
||||
$this->db->table('auth_groups')->insertBatch($data_groups);
|
||||
$this->db->table('auth_permissions')->insertBatch($dataPermissions);
|
||||
$this->db->table('auth_groups')->insertBatch($dataGroups);
|
||||
$this->db
|
||||
->table('auth_groups_permissions')
|
||||
->insertBatch($data_groups_permissions);
|
||||
->insertBatch($dataGroupsPermissions);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class CategorySeeder
|
||||
* Inserts values in categories table in database
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class LanguageSeeder
|
||||
* Inserts values in languages table in database
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class PlatformsSeeder
|
||||
* Inserts values in platforms table in database
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class TestSeeder
|
||||
* Inserts a superadmin user in the database
|
||||
|
@ -23,7 +24,7 @@ class TestSeeder extends Seeder
|
|||
$this->db->table('users')->insert([
|
||||
'id' => 1,
|
||||
'username' => 'admin',
|
||||
'email' => 'admin@castopod.com',
|
||||
'email' => 'admin@example.com',
|
||||
'password_hash' =>
|
||||
'$2y$10$TXJEHX/djW8jtzgpDVf7dOOCGo5rv1uqtAYWdwwwkttQcDkAeB2.6',
|
||||
'active' => 1,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class AnalyticsEpisodesByCountry
|
||||
* Entity for AnalyticsEpisodesByCountry
|
||||
|
@ -6,6 +7,7 @@
|
|||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
* @link https://castopod.org/
|
||||
*/
|
||||
|
||||
namespace App\Entities;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class AnalyticsEpisodesByPlayer
|
||||
* Entity for AnalyticsEpisodesByPlayer
|
||||
|
@ -6,6 +7,7 @@
|
|||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
* @link https://castopod.org/
|
||||
*/
|
||||
|
||||
namespace App\Entities;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class AnalyticsPodcastsByCountry
|
||||
* Entity for AnalyticsPodcastsByCountry
|
||||
|
@ -6,6 +7,7 @@
|
|||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
* @link https://castopod.org/
|
||||
*/
|
||||
|
||||
namespace App\Entities;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class AnalyticsPodcastsByPlayer
|
||||
* Entity for AnalyticsPodcastsByPlayer
|
||||
|
@ -6,6 +7,7 @@
|
|||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
* @link https://castopod.org/
|
||||
*/
|
||||
|
||||
namespace App\Entities;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class AnalyticsUnknownUseragents
|
||||
* Entity for AnalyticsUnknownUseragents
|
||||
|
@ -6,6 +7,7 @@
|
|||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
* @link https://castopod.org/
|
||||
*/
|
||||
|
||||
namespace App\Entities;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class AnalyticsWebsiteByBrowser
|
||||
* Entity for AnalyticsWebsiteByBrowser
|
||||
|
@ -6,6 +7,7 @@
|
|||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
* @link https://castopod.org/
|
||||
*/
|
||||
|
||||
namespace App\Entities;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class AnalyticsWebsiteByCountry
|
||||
* Entity for AnalyticsWebsiteByCountry
|
||||
|
@ -6,6 +7,7 @@
|
|||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
* @link https://castopod.org/
|
||||
*/
|
||||
|
||||
namespace App\Entities;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class class AnalyticsWebsiteByReferer
|
||||
* Entity for AnalyticsWebsiteByReferer
|
||||
|
@ -6,6 +7,7 @@
|
|||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
* @link https://castopod.org/
|
||||
*/
|
||||
|
||||
namespace App\Entities;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @copyright 2020 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
|
@ -23,11 +24,10 @@ class Category extends Entity
|
|||
|
||||
public function getParent()
|
||||
{
|
||||
$category_model = new CategoryModel();
|
||||
$parent_id = $this->attributes['parent_id'];
|
||||
$parentId = $this->attributes['parent_id'];
|
||||
|
||||
return $parent_id != 0
|
||||
? $category_model->find($this->attributes['parent_id'])
|
||||
return $parentId != 0
|
||||
? (new CategoryModel())->findParent($parentId)
|
||||
: null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @copyright 2020 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
|
@ -9,7 +10,7 @@ namespace App\Entities;
|
|||
|
||||
use App\Models\PodcastModel;
|
||||
use CodeIgniter\Entity;
|
||||
use Parsedown;
|
||||
use League\CommonMark\CommonMarkConverter;
|
||||
|
||||
class Episode extends Entity
|
||||
{
|
||||
|
@ -43,7 +44,7 @@ class Episode extends Entity
|
|||
|
||||
public function setImage(?\CodeIgniter\HTTP\Files\UploadedFile $image)
|
||||
{
|
||||
if ($image->isValid()) {
|
||||
if (!empty($image) && $image->isValid()) {
|
||||
// check whether the user has inputted an image and store it
|
||||
$this->attributes['image_uri'] = save_podcast_media(
|
||||
$image,
|
||||
|
@ -68,17 +69,17 @@ class Episode extends Entity
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getImage()
|
||||
public function getImage(): \CodeIgniter\Files\File
|
||||
{
|
||||
return new \CodeIgniter\Files\File($this->getImageMediaPath());
|
||||
}
|
||||
|
||||
public function getImageMediaPath()
|
||||
public function getImageMediaPath(): string
|
||||
{
|
||||
return media_path($this->attributes['image_uri']);
|
||||
}
|
||||
|
||||
public function getImageUrl()
|
||||
public function getImageUrl(): string
|
||||
{
|
||||
if ($image_uri = $this->attributes['image_uri']) {
|
||||
return media_url($image_uri);
|
||||
|
@ -89,7 +90,7 @@ class Episode extends Entity
|
|||
public function setEnclosure(
|
||||
\CodeIgniter\HTTP\Files\UploadedFile $enclosure = null
|
||||
) {
|
||||
if ($enclosure->isValid()) {
|
||||
if (!empty($enclosure) && $enclosure->isValid()) {
|
||||
helper('media');
|
||||
|
||||
$this->attributes['enclosure_uri'] = save_podcast_media(
|
||||
|
@ -151,26 +152,25 @@ class Episode extends Entity
|
|||
|
||||
public function getPodcast()
|
||||
{
|
||||
$podcast_model = new PodcastModel();
|
||||
|
||||
return $podcast_model->find($this->attributes['podcast_id']);
|
||||
return (new PodcastModel())->find($this->attributes['podcast_id']);
|
||||
}
|
||||
|
||||
public function getDescriptionHtml()
|
||||
{
|
||||
$converter = new Parsedown();
|
||||
$converter->setBreaksEnabled(true);
|
||||
$converter = new CommonMarkConverter([
|
||||
'html_input' => 'strip',
|
||||
'allow_unsafe_links' => false,
|
||||
]);
|
||||
|
||||
if (
|
||||
$description_footer = $this->getPodcast()
|
||||
->episode_description_footer
|
||||
$descriptionFooter = $this->getPodcast()->episode_description_footer
|
||||
) {
|
||||
return $converter->text($this->attributes['description']) .
|
||||
return $converter->convertToHtml($this->attributes['description']) .
|
||||
'<footer>' .
|
||||
$converter->text($description_footer) .
|
||||
$converter->convertToHtml($descriptionFooter) .
|
||||
'</footer>';
|
||||
}
|
||||
|
||||
return $converter->text($this->attributes['description']);
|
||||
return $converter->convertToHtml($this->attributes['description']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @copyright 2020 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @copyright 2020 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
|
@ -10,7 +11,7 @@ namespace App\Entities;
|
|||
use App\Models\EpisodeModel;
|
||||
use CodeIgniter\Entity;
|
||||
use App\Models\UserModel;
|
||||
use Parsedown;
|
||||
use League\CommonMark\CommonMarkConverter;
|
||||
|
||||
class Podcast extends Entity
|
||||
{
|
||||
|
@ -158,9 +159,11 @@ class Podcast extends Entity
|
|||
|
||||
public function getDescriptionHtml()
|
||||
{
|
||||
$converter = new Parsedown();
|
||||
$converter->setBreaksEnabled(true);
|
||||
$converter = new CommonMarkConverter([
|
||||
'html_input' => 'strip',
|
||||
'allow_unsafe_links' => false,
|
||||
]);
|
||||
|
||||
return $converter->text($this->attributes['description']);
|
||||
return $converter->convertToHtml($this->attributes['description']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace App\Entities;
|
||||
<?php
|
||||
|
||||
namespace App\Entities;
|
||||
|
||||
use App\Models\PodcastModel;
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace App\Filters;
|
||||
<?php
|
||||
|
||||
namespace App\Filters;
|
||||
|
||||
use App\Models\PodcastModel;
|
||||
use Config\Services;
|
||||
|
@ -57,14 +59,12 @@ class Permission implements FilterInterface
|
|||
count($routerParams) > 0
|
||||
) {
|
||||
if (
|
||||
$group_id = (new PodcastModel())->getContributorGroupId(
|
||||
$groupId = (new PodcastModel())->getContributorGroupId(
|
||||
$authenticate->id(),
|
||||
$routerParams[0]
|
||||
)
|
||||
) {
|
||||
if (
|
||||
$authorize->groupHasPermission($permission, $group_id)
|
||||
) {
|
||||
if ($authorize->groupHasPermission($permission, $groupId)) {
|
||||
$result = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @copyright 2020 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
|
@ -187,4 +187,3 @@ function podcast_hit($p_podcast_id, $p_episode_id)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @copyright 2020 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @copyright 2020 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @copyright 2020 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @copyright 2020 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @copyright 2020 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
* @link https://castopod.org/
|
||||
*/
|
||||
|
||||
use App\Libraries\SimpleRSSElement;
|
||||
use App\Models\CategoryModel;
|
||||
use CodeIgniter\I18n\Time;
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @copyright 2020 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
<?
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @copyright 2020 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
* @link https://castopod.org/
|
||||
*/
|
||||
|
||||
return [
|
||||
return [
|
||||
'dashboard' => 'Dashboard',
|
||||
'podcasts' => 'Podcasts',
|
||||
'users' => 'Users',
|
||||
|
@ -15,5 +16,5 @@
|
|||
'podcast_create' => 'New podcast',
|
||||
'user_list' => 'All users',
|
||||
'user_create' => 'New user',
|
||||
'go_to_website' => 'Go to website'
|
||||
];
|
||||
'go_to_website' => 'Go to website',
|
||||
];
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @copyright 2020 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
|
@ -6,9 +7,6 @@
|
|||
*/
|
||||
|
||||
return [
|
||||
'removeOwnerContributorError' => 'You can\'t remove the podcast owner!',
|
||||
'removeContributorSuccess' => 'You have successfully removed {username} from {podcastTitle}',
|
||||
'alreadyAddedError' => 'The contributor you\'re trying to add has already been added!',
|
||||
'podcast_contributors' => 'Podcast contributors',
|
||||
'add' => 'Add contributor',
|
||||
'add_contributor' => 'Add a contributor for {0}',
|
||||
|
@ -19,6 +17,13 @@ return [
|
|||
'user' => 'User',
|
||||
'role' => 'Role',
|
||||
'submit_add' => 'Add contributor',
|
||||
'submit_edit' => 'Update role'
|
||||
]
|
||||
'submit_edit' => 'Update role',
|
||||
],
|
||||
'messages' => [
|
||||
'removeOwnerContributorError' => 'You can\'t remove the podcast owner!',
|
||||
'removeContributorSuccess' =>
|
||||
'You have successfully removed {username} from {podcastTitle}',
|
||||
'alreadyAddedError' =>
|
||||
'The contributor you\'re trying to add has already been added!',
|
||||
],
|
||||
];
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ISO 3166 country codes
|
||||
* @copyright 2020 Podlibre
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @copyright 2020 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
|
@ -10,7 +11,7 @@ return [
|
|||
'back_to_podcast' => 'Go back to podcast',
|
||||
'edit' => 'Edit',
|
||||
'delete' => 'Delete',
|
||||
'goto_page' => 'Go to page',
|
||||
'go_to_page' => 'Go to page',
|
||||
'create' => 'Add an episode',
|
||||
'form' => [
|
||||
'file' => 'Audio file',
|
||||
|
@ -33,5 +34,5 @@ return [
|
|||
'block' => 'Block',
|
||||
'submit_create' => 'Create episode',
|
||||
'submit_edit' => 'Save episode',
|
||||
]
|
||||
],
|
||||
];
|
|
@ -1,4 +1,5 @@
|
|||
<?
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @copyright 2020 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @copyright 2020 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
|
@ -6,7 +7,9 @@
|
|||
*/
|
||||
|
||||
return [
|
||||
'info' => 'My account info',
|
||||
'messages' => [
|
||||
'passwordChangeSuccess' => 'Password has been successfully changed!',
|
||||
'changePassword' => 'Change my password',
|
||||
'info' => 'My account info'
|
||||
],
|
||||
];
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @copyright 2020 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
|
@ -16,7 +17,7 @@ return [
|
|||
'delete' => 'Delete podcast',
|
||||
'see_episodes' => 'See episodes',
|
||||
'see_contributors' => 'See contributors',
|
||||
'goto_page' => 'Go to page',
|
||||
'go_to_page' => 'Go to page',
|
||||
'form' => [
|
||||
'title' => 'Title',
|
||||
'name' => 'Name',
|
||||
|
@ -156,5 +157,5 @@ return [
|
|||
'tv_reviews' => 'TV Reviews',
|
||||
],
|
||||
'list_of_episodes' => 'List of episodes',
|
||||
'no_episode' => 'No episode found'
|
||||
'no_episode' => 'No episode found',
|
||||
];
|
|
@ -1,4 +1,5 @@
|
|||
<?
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @copyright 2020 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
|
@ -6,14 +7,6 @@
|
|||
*/
|
||||
|
||||
return [
|
||||
'createSuccess' => 'User created successfully! {username} will be prompted with a password reset upon first authentication.',
|
||||
'rolesEditSuccess' => '{username}\'s roles have been successfully updated.',
|
||||
'forcePassResetSuccess' => '{username} will be prompted with a password reset upon next visit.',
|
||||
'banSuccess' => '{username} has been banned.',
|
||||
'unbanSuccess' => '{username} has been unbanned.',
|
||||
'banSuperAdminError' => '{username} is a superadmin, one does not simply ban a superadmin…',
|
||||
'deleteSuperAdminError' => '{username} is a superadmin, one does not simply delete a superadmin…',
|
||||
'deleteSuccess' => '{username} has been deleted.',
|
||||
'edit_roles' => 'Edit {username}\'s roles',
|
||||
'forcePassReset' => 'Force pass reset',
|
||||
'ban' => 'Ban',
|
||||
|
@ -31,5 +24,20 @@ return [
|
|||
'roles' => 'Roles',
|
||||
'submit_create' => 'Create user',
|
||||
'submit_edit' => 'Save',
|
||||
]
|
||||
],
|
||||
'messages' => [
|
||||
'createSuccess' =>
|
||||
'User created successfully! {username} will be prompted with a password reset upon first authentication.',
|
||||
'rolesEditSuccess' =>
|
||||
'{username}\'s roles have been successfully updated.',
|
||||
'forcePassResetSuccess' =>
|
||||
'{username} will be prompted with a password reset upon next visit.',
|
||||
'banSuccess' => '{username} has been banned.',
|
||||
'unbanSuccess' => '{username} has been unbanned.',
|
||||
'banSuperAdminError' =>
|
||||
'{username} is a superadmin, one does not simply ban a superadmin…',
|
||||
'deleteSuperAdminError' =>
|
||||
'{username} is a superadmin, one does not simply delete a superadmin…',
|
||||
'deleteSuccess' => '{username} has been deleted.',
|
||||
],
|
||||
];
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ISO 3166 country codes
|
||||
* @copyright 2020 Podlibre
|
||||
|
@ -6,7 +7,8 @@
|
|||
* @link https://castopod.org/
|
||||
*/
|
||||
|
||||
return ['AF ' => 'Afghanistan',
|
||||
return [
|
||||
'AF ' => 'Afghanistan',
|
||||
'ZA ' => 'Afrique Du Sud',
|
||||
'AX ' => 'Åland, Îles',
|
||||
'AL ' => 'Albanie',
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue