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:
Yassine Doghri 2020-08-04 11:25:22 +00:00
parent 58364bfed1
commit ed6e953010
153 changed files with 2292 additions and 1854 deletions

View File

@ -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"
]
}

12
.editorconfig Normal file
View File

@ -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

7
.phpcs.xml Normal file
View File

@ -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>

View File

@ -5,8 +5,7 @@
"files": "*.php",
"options": {
"phpVersion": "7.2",
"singleQuote": true,
"trailingCommaPHP": true
"singleQuote": true
}
}
]

View File

@ -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:

View File

@ -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;

View File

@ -1,4 +1,6 @@
<?php namespace App\Authorization;
<?php
namespace App\Authorization;
class GroupModel extends \Myth\Auth\Authorization\GroupModel
{

View File

@ -1,4 +1,6 @@
<?php namespace App\Authorization;
<?php
namespace App\Authorization;
class PermissionModel extends \Myth\Auth\Authorization\PermissionModel
{

View File

@ -7,181 +7,181 @@ use CodeIgniter\Config\BaseConfig;
class App extends BaseConfig
{
/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
| http://example.com/
|
| If this is not set then CodeIgniter will try guess the protocol, domain
| and path to your installation. However, you should always configure this
| explicitly and never rely on auto-guessing, especially in production
| environments.
|
*/
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
| http://example.com/
|
| If this is not set then CodeIgniter will try guess the protocol, domain
| and path to your installation. However, you should always configure this
| explicitly and never rely on auto-guessing, especially in production
| environments.
|
*/
public $baseURL = 'http://localhost:8080/';
/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
public $indexPage = 'index.php';
/*
|--------------------------------------------------------------------------
| URI PROTOCOL
|--------------------------------------------------------------------------
|
| This item determines which getServer global should be used to retrieve the
| URI string. The default setting of 'REQUEST_URI' works for most servers.
| If your links do not seem to work, try one of the other delicious flavors:
|
| 'REQUEST_URI' Uses $_SERVER['REQUEST_URI']
| 'QUERY_STRING' Uses $_SERVER['QUERY_STRING']
| 'PATH_INFO' Uses $_SERVER['PATH_INFO']
|
| WARNING: If you set this to 'PATH_INFO', URIs will always be URL-decoded!
*/
|--------------------------------------------------------------------------
| URI PROTOCOL
|--------------------------------------------------------------------------
|
| This item determines which getServer global should be used to retrieve the
| URI string. The default setting of 'REQUEST_URI' works for most servers.
| If your links do not seem to work, try one of the other delicious flavors:
|
| 'REQUEST_URI' Uses $_SERVER['REQUEST_URI']
| 'QUERY_STRING' Uses $_SERVER['QUERY_STRING']
| 'PATH_INFO' Uses $_SERVER['PATH_INFO']
|
| WARNING: If you set this to 'PATH_INFO', URIs will always be URL-decoded!
*/
public $uriProtocol = 'REQUEST_URI';
/*
|--------------------------------------------------------------------------
| Default Locale
|--------------------------------------------------------------------------
|
| The Locale roughly represents the language and location that your visitor
| is viewing the site from. It affects the language strings and other
| strings (like currency markers, numbers, etc), that your program
| should run under for this request.
|
*/
|--------------------------------------------------------------------------
| Default Locale
|--------------------------------------------------------------------------
|
| The Locale roughly represents the language and location that your visitor
| is viewing the site from. It affects the language strings and other
| strings (like currency markers, numbers, etc), that your program
| should run under for this request.
|
*/
public $defaultLocale = 'en';
/*
|--------------------------------------------------------------------------
| Negotiate Locale
|--------------------------------------------------------------------------
|
| If true, the current Request object will automatically determine the
| language to use based on the value of the Accept-Language header.
|
| If false, no automatic detection will be performed.
|
*/
|--------------------------------------------------------------------------
| Negotiate Locale
|--------------------------------------------------------------------------
|
| If true, the current Request object will automatically determine the
| language to use based on the value of the Accept-Language header.
|
| If false, no automatic detection will be performed.
|
*/
public $negotiateLocale = true;
/*
|--------------------------------------------------------------------------
| Supported Locales
|--------------------------------------------------------------------------
|
| If $negotiateLocale is true, this array lists the locales supported
| by the application in descending order of priority. If no match is
| found, the first locale will be used.
|
*/
|--------------------------------------------------------------------------
| Supported Locales
|--------------------------------------------------------------------------
|
| If $negotiateLocale is true, this array lists the locales supported
| by the application in descending order of priority. If no match is
| found, the first locale will be used.
|
*/
public $supportedLocales = ['en'];
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| The default timezone that will be used in your application to display
| dates with the date helper, and can be retrieved through app_timezone()
|
*/
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| The default timezone that will be used in your application to display
| dates with the date helper, and can be retrieved through app_timezone()
|
*/
public $appTimezone = 'UTC';
/*
|--------------------------------------------------------------------------
| Default Character Set
|--------------------------------------------------------------------------
|
| This determines which character set is used by default in various methods
| that require a character set to be provided.
|
| See http://php.net/htmlspecialchars for a list of supported charsets.
|
*/
|--------------------------------------------------------------------------
| Default Character Set
|--------------------------------------------------------------------------
|
| This determines which character set is used by default in various methods
| that require a character set to be provided.
|
| See http://php.net/htmlspecialchars for a list of supported charsets.
|
*/
public $charset = 'UTF-8';
/*
|--------------------------------------------------------------------------
| URI PROTOCOL
|--------------------------------------------------------------------------
|
| If true, this will force every request made to this application to be
| made via a secure connection (HTTPS). If the incoming request is not
| secure, the user will be redirected to a secure version of the page
| and the HTTP Strict Transport Security header will be set.
*/
|--------------------------------------------------------------------------
| URI PROTOCOL
|--------------------------------------------------------------------------
|
| If true, this will force every request made to this application to be
| made via a secure connection (HTTPS). If the incoming request is not
| secure, the user will be redirected to a secure version of the page
| and the HTTP Strict Transport Security header will be set.
*/
public $forceGlobalSecureRequests = false;
/*
|--------------------------------------------------------------------------
| Session Variables
|--------------------------------------------------------------------------
|
| 'sessionDriver'
|
| The storage driver to use: files, database, redis, memcached
| - CodeIgniter\Session\Handlers\FileHandler
| - CodeIgniter\Session\Handlers\DatabaseHandler
| - CodeIgniter\Session\Handlers\MemcachedHandler
| - CodeIgniter\Session\Handlers\RedisHandler
|
| 'sessionCookieName'
|
| The session cookie name, must contain only [0-9a-z_-] characters
|
| 'sessionExpiration'
|
| The number of SECONDS you want the session to last.
| Setting to 0 (zero) means expire when the browser is closed.
|
| 'sessionSavePath'
|
| The location to save sessions to, driver dependent.
|
| For the 'files' driver, it's a path to a writable directory.
| WARNING: Only absolute paths are supported!
|
| For the 'database' driver, it's a table name.
| Please read up the manual for the format with other session drivers.
|
| IMPORTANT: You are REQUIRED to set a valid save path!
|
| 'sessionMatchIP'
|
| Whether to match the user's IP address when reading the session data.
|
| WARNING: If you're using the database driver, don't forget to update
| your session table's PRIMARY KEY when changing this setting.
|
| 'sessionTimeToUpdate'
|
| How many seconds between CI regenerating the session ID.
|
| 'sessionRegenerateDestroy'
|
| Whether to destroy session data associated with the old session ID
| when auto-regenerating the session ID. When set to FALSE, the data
| will be later deleted by the garbage collector.
|
| Other session cookie settings are shared with the rest of the application,
| except for 'cookie_prefix' and 'cookie_httponly', which are ignored here.
|
*/
|--------------------------------------------------------------------------
| Session Variables
|--------------------------------------------------------------------------
|
| 'sessionDriver'
|
| The storage driver to use: files, database, redis, memcached
| - CodeIgniter\Session\Handlers\FileHandler
| - CodeIgniter\Session\Handlers\DatabaseHandler
| - CodeIgniter\Session\Handlers\MemcachedHandler
| - CodeIgniter\Session\Handlers\RedisHandler
|
| 'sessionCookieName'
|
| The session cookie name, must contain only [0-9a-z_-] characters
|
| 'sessionExpiration'
|
| The number of SECONDS you want the session to last.
| Setting to 0 (zero) means expire when the browser is closed.
|
| 'sessionSavePath'
|
| The location to save sessions to, driver dependent.
|
| For the 'files' driver, it's a path to a writable directory.
| WARNING: Only absolute paths are supported!
|
| For the 'database' driver, it's a table name.
| Please read up the manual for the format with other session drivers.
|
| IMPORTANT: You are REQUIRED to set a valid save path!
|
| 'sessionMatchIP'
|
| Whether to match the user's IP address when reading the session data.
|
| WARNING: If you're using the database driver, don't forget to update
| your session table's PRIMARY KEY when changing this setting.
|
| 'sessionTimeToUpdate'
|
| How many seconds between CI regenerating the session ID.
|
| 'sessionRegenerateDestroy'
|
| Whether to destroy session data associated with the old session ID
| when auto-regenerating the session ID. When set to FALSE, the data
| will be later deleted by the garbage collector.
|
| Other session cookie settings are shared with the rest of the application,
| except for 'cookie_prefix' and 'cookie_httponly', which are ignored here.
|
*/
public $sessionDriver = 'CodeIgniter\Session\Handlers\FileHandler';
public $sessionCookieName = 'ci_session';
public $sessionExpiration = 7200;
@ -191,20 +191,20 @@ class App extends BaseConfig
public $sessionRegenerateDestroy = false;
/*
|--------------------------------------------------------------------------
| Cookie Related Variables
|--------------------------------------------------------------------------
|
| 'cookiePrefix' = Set a cookie name prefix if you need to avoid collisions
| 'cookieDomain' = Set to .your-domain.com for site-wide cookies
| 'cookiePath' = Typically will be a forward slash
| 'cookieSecure' = Cookie will only be set if a secure HTTPS connection exists.
| 'cookieHTTPOnly' = Cookie will only be accessible via HTTP(S) (no javascript)
|
| Note: These settings (with the exception of 'cookie_prefix' and
| 'cookie_httponly') will also affect sessions.
|
*/
|--------------------------------------------------------------------------
| Cookie Related Variables
|--------------------------------------------------------------------------
|
| 'cookiePrefix' = Set a cookie name prefix if you need to avoid collisions
| 'cookieDomain' = Set to .your-domain.com for site-wide cookies
| 'cookiePath' = Typically will be a forward slash
| 'cookieSecure' = Cookie will only be set if a secure HTTPS connection exists.
| 'cookieHTTPOnly' = Cookie will only be accessible via HTTP(S) (no javascript)
|
| Note: These settings (with the exception of 'cookie_prefix' and
| 'cookie_httponly') will also affect sessions.
|
*/
public $cookiePrefix = '';
public $cookieDomain = '';
public $cookiePath = '/';
@ -212,38 +212,38 @@ class App extends BaseConfig
public $cookieHTTPOnly = false;
/*
|--------------------------------------------------------------------------
| Reverse Proxy IPs
|--------------------------------------------------------------------------
|
| If your server is behind a reverse proxy, you must whitelist the proxy
| IP addresses from which CodeIgniter should trust headers such as
| HTTP_X_FORWARDED_FOR and HTTP_CLIENT_IP in order to properly identify
| the visitor's IP address.
|
| You can use both an array or a comma-separated list of proxy addresses,
| as well as specifying whole subnets. Here are a few examples:
|
| Comma-separated: '10.0.1.200,192.168.5.0/24'
| Array: array('10.0.1.200', '192.168.5.0/24')
*/
|--------------------------------------------------------------------------
| Reverse Proxy IPs
|--------------------------------------------------------------------------
|
| If your server is behind a reverse proxy, you must whitelist the proxy
| IP addresses from which CodeIgniter should trust headers such as
| HTTP_X_FORWARDED_FOR and HTTP_CLIENT_IP in order to properly identify
| the visitor's IP address.
|
| You can use both an array or a comma-separated list of proxy addresses,
| as well as specifying whole subnets. Here are a few examples:
|
| Comma-separated: '10.0.1.200,192.168.5.0/24'
| Array: array('10.0.1.200', '192.168.5.0/24')
*/
public $proxyIPs = '';
/*
|--------------------------------------------------------------------------
| Cross Site Request Forgery
|--------------------------------------------------------------------------
| Enables a CSRF cookie token to be set. When set to TRUE, token will be
| checked on a submitted form. If you are accepting user data, it is strongly
| recommended CSRF protection be enabled.
|
| CSRFTokenName = The token name
| CSRFHeaderName = The header name
| CSRFCookieName = The cookie name
| CSRFExpire = The number in seconds the token should expire.
| CSRFRegenerate = Regenerate token on every submission
| CSRFRedirect = Redirect to previous page with error on failure
*/
|--------------------------------------------------------------------------
| Cross Site Request Forgery
|--------------------------------------------------------------------------
| Enables a CSRF cookie token to be set. When set to TRUE, token will be
| checked on a submitted form. If you are accepting user data, it is strongly
| recommended CSRF protection be enabled.
|
| CSRFTokenName = The token name
| CSRFHeaderName = The header name
| CSRFCookieName = The cookie name
| CSRFExpire = The number in seconds the token should expire.
| CSRFRegenerate = Regenerate token on every submission
| CSRFRedirect = Redirect to previous page with error on failure
*/
public $CSRFTokenName = 'csrf_test_name';
public $CSRFHeaderName = 'X-CSRF-TOKEN';
public $CSRFCookieName = 'csrf_cookie_name';
@ -252,42 +252,42 @@ class App extends BaseConfig
public $CSRFRedirect = true;
/*
|--------------------------------------------------------------------------
| Content Security Policy
|--------------------------------------------------------------------------
| Enables the Response's Content Secure Policy to restrict the sources that
| can be used for images, scripts, CSS files, audio, video, etc. If enabled,
| the Response object will populate default values for the policy from the
| ContentSecurityPolicy.php file. Controllers can always add to those
| restrictions at run time.
|
| For a better understanding of CSP, see these documents:
| - http://www.html5rocks.com/en/tutorials/security/content-security-policy/
| - http://www.w3.org/TR/CSP/
*/
|--------------------------------------------------------------------------
| Content Security Policy
|--------------------------------------------------------------------------
| Enables the Response's Content Secure Policy to restrict the sources that
| can be used for images, scripts, CSS files, audio, video, etc. If enabled,
| the Response object will populate default values for the policy from the
| ContentSecurityPolicy.php file. Controllers can always add to those
| restrictions at run time.
|
| For a better understanding of CSP, see these documents:
| - http://www.html5rocks.com/en/tutorials/security/content-security-policy/
| - http://www.w3.org/TR/CSP/
*/
public $CSPEnabled = false;
/*
|--------------------------------------------------------------------------
| Media root folder
|--------------------------------------------------------------------------
| Defines the root folder for media files storage
*/
|--------------------------------------------------------------------------
| Media root folder
|--------------------------------------------------------------------------
| Defines the root folder for media files storage
*/
public $mediaRoot = 'media';
/*
|--------------------------------------------------------------------------
| Admin gateway
|--------------------------------------------------------------------------
| Defines a base route for all admin pages
*/
|--------------------------------------------------------------------------
| Admin gateway
|--------------------------------------------------------------------------
| Defines a base route for all admin pages
*/
public $adminGateway = 'admin';
/*
|--------------------------------------------------------------------------
| Auth gateway
|--------------------------------------------------------------------------
| Defines a base route for all authentication related pages
*/
|--------------------------------------------------------------------------
| Auth gateway
|--------------------------------------------------------------------------
| Defines a base route for all authentication related pages
*/
public $authGateway = 'auth';
}

View File

@ -1,4 +1,5 @@
<?php
/*
|--------------------------------------------------------------------------
| ERROR DISPLAY

View File

@ -7,78 +7,78 @@ use CodeIgniter\Config\BaseConfig;
class Cache extends BaseConfig
{
/*
|--------------------------------------------------------------------------
| Primary Handler
|--------------------------------------------------------------------------
|
| The name of the preferred handler that should be used. If for some reason
| it is not available, the $backupHandler will be used in its place.
|
*/
|--------------------------------------------------------------------------
| Primary Handler
|--------------------------------------------------------------------------
|
| The name of the preferred handler that should be used. If for some reason
| it is not available, the $backupHandler will be used in its place.
|
*/
public $handler = 'file';
/*
|--------------------------------------------------------------------------
| Backup Handler
|--------------------------------------------------------------------------
|
| The name of the handler that will be used in case the first one is
| unreachable. Often, 'file' is used here since the filesystem is
| always available, though that's not always practical for the app.
|
*/
|--------------------------------------------------------------------------
| Backup Handler
|--------------------------------------------------------------------------
|
| The name of the handler that will be used in case the first one is
| unreachable. Often, 'file' is used here since the filesystem is
| always available, though that's not always practical for the app.
|
*/
public $backupHandler = 'dummy';
/*
|--------------------------------------------------------------------------
| Cache Directory Path
|--------------------------------------------------------------------------
|
| The path to where cache files should be stored, if using a file-based
| system.
|
*/
|--------------------------------------------------------------------------
| Cache Directory Path
|--------------------------------------------------------------------------
|
| The path to where cache files should be stored, if using a file-based
| system.
|
*/
public $storePath = WRITEPATH . 'cache/';
/*
|--------------------------------------------------------------------------
| Cache Include Query String
|--------------------------------------------------------------------------
|
| Whether to take the URL query string into consideration when generating
| output cache files. Valid options are:
|
| false = Disabled
| true = Enabled, take all query parameters into account.
| Please be aware that this may result in numerous cache
| files generated for the same page over and over again.
| array('q') = Enabled, but only take into account the specified list
| of query parameters.
|
*/
|--------------------------------------------------------------------------
| Cache Include Query String
|--------------------------------------------------------------------------
|
| Whether to take the URL query string into consideration when generating
| output cache files. Valid options are:
|
| false = Disabled
| true = Enabled, take all query parameters into account.
| Please be aware that this may result in numerous cache
| files generated for the same page over and over again.
| array('q') = Enabled, but only take into account the specified list
| of query parameters.
|
*/
public $cacheQueryString = false;
/*
|--------------------------------------------------------------------------
| Key Prefix
|--------------------------------------------------------------------------
|
| This string is added to all cache item names to help avoid collisions
| if you run multiple applications with the same cache engine.
|
*/
|--------------------------------------------------------------------------
| Key Prefix
|--------------------------------------------------------------------------
|
| This string is added to all cache item names to help avoid collisions
| if you run multiple applications with the same cache engine.
|
*/
public $prefix = '';
/*
| -------------------------------------------------------------------------
| Memcached settings
| -------------------------------------------------------------------------
| Your Memcached servers can be specified below, if you are using
| the Memcached drivers.
|
| See: https://codeigniter.com/user_guide/libraries/caching.html#memcached
|
*/
| -------------------------------------------------------------------------
| Memcached settings
| -------------------------------------------------------------------------
| Your Memcached servers can be specified below, if you are using
| the Memcached drivers.
|
| See: https://codeigniter.com/user_guide/libraries/caching.html#memcached
|
*/
public $memcached = [
'host' => '127.0.0.1',
'port' => 11211,
@ -87,13 +87,13 @@ class Cache extends BaseConfig
];
/*
| -------------------------------------------------------------------------
| Redis settings
| -------------------------------------------------------------------------
| Your Redis server can be specified below, if you are using
| the Redis or Predis drivers.
|
*/
| -------------------------------------------------------------------------
| Redis settings
| -------------------------------------------------------------------------
| Your Redis server can be specified below, if you are using
| the Redis or Predis drivers.
|
*/
public $redis = [
'host' => '127.0.0.1',
'password' => null,
@ -103,14 +103,14 @@ class Cache extends BaseConfig
];
/*
|--------------------------------------------------------------------------
| Available Cache Handlers
|--------------------------------------------------------------------------
|
| This is an array of cache engine alias' and class names. Only engines
| that are listed here are allowed to be used.
|
*/
|--------------------------------------------------------------------------
| Available Cache Handlers
|--------------------------------------------------------------------------
|
| This is an array of cache engine alias' and class names. Only engines
| that are listed here are allowed to be used.
|
*/
public $validHandlers = [
'dummy' => \CodeIgniter\Cache\Handlers\DummyHandler::class,
'file' => \CodeIgniter\Cache\Handlers\FileHandler::class,

View File

@ -1,4 +1,6 @@
<?php namespace Config;
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;

View File

@ -1,4 +1,6 @@
<?php namespace Config;
<?php
namespace Config;
/**
* Database Configuration

View File

@ -1,4 +1,6 @@
<?php namespace Config;
<?php
namespace Config;
/**
* DocTypes

View File

@ -1,4 +1,5 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;

View File

@ -1,4 +1,5 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
@ -12,24 +13,24 @@ use CodeIgniter\Config\BaseConfig;
class Encryption extends BaseConfig
{
/*
|--------------------------------------------------------------------------
| Encryption Key Starter
|--------------------------------------------------------------------------
|
| If you use the Encryption class you must set an encryption key (seed).
| You need to ensure it is long enough for the cipher and mode you plan to use.
| See the user guide for more info.
*/
|--------------------------------------------------------------------------
| Encryption Key Starter
|--------------------------------------------------------------------------
|
| If you use the Encryption class you must set an encryption key (seed).
| You need to ensure it is long enough for the cipher and mode you plan to use.
| See the user guide for more info.
*/
public $key = '';
/*
|--------------------------------------------------------------------------
| Encryption driver to use
|--------------------------------------------------------------------------
|
| One of the supported drivers, eg 'OpenSSL' or 'Sodium'.
| The default driver, if you don't specify one, is 'OpenSSL'.
*/
|--------------------------------------------------------------------------
| Encryption driver to use
|--------------------------------------------------------------------------
|
| One of the supported drivers, eg 'OpenSSL' or 'Sodium'.
| The default driver, if you don't specify one, is 'OpenSSL'.
*/
public $driver = 'OpenSSL';
}

View File

@ -1,4 +1,6 @@
<?php namespace Config;
<?php
namespace Config;
use CodeIgniter\Events\Events;

View File

@ -1,4 +1,6 @@
<?php namespace Config;
<?php
namespace Config;
/**
* Setup how the exception handler works.
@ -9,33 +11,33 @@
class Exceptions
{
/*
|--------------------------------------------------------------------------
| LOG EXCEPTIONS?
|--------------------------------------------------------------------------
| If true, then exceptions will be logged
| through Services::Log.
|
| Default: true
*/
|--------------------------------------------------------------------------
| LOG EXCEPTIONS?
|--------------------------------------------------------------------------
| If true, then exceptions will be logged
| through Services::Log.
|
| Default: true
*/
public $log = true;
/*
|--------------------------------------------------------------------------
| DO NOT LOG STATUS CODES
|--------------------------------------------------------------------------
| Any status codes here will NOT be logged if logging is turned on.
| By default, only 404 (Page Not Found) exceptions are ignored.
*/
|--------------------------------------------------------------------------
| DO NOT LOG STATUS CODES
|--------------------------------------------------------------------------
| Any status codes here will NOT be logged if logging is turned on.
| By default, only 404 (Page Not Found) exceptions are ignored.
*/
public $ignoreCodes = [404];
/*
|--------------------------------------------------------------------------
| Error Views Path
|--------------------------------------------------------------------------
| This is the path to the directory that contains the 'cli' and 'html'
| directories that hold the views used to generate errors.
|
| Default: APPPATH.'Views/errors'
*/
|--------------------------------------------------------------------------
| Error Views Path
|--------------------------------------------------------------------------
| This is the path to the directory that contains the 'cli' and 'html'
| directories that hold the views used to generate errors.
|
| Default: APPPATH.'Views/errors'
*/
public $errorViewPath = APPPATH . 'Views/errors';
}

View File

@ -1,4 +1,6 @@
<?php namespace Config;
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;

View File

@ -1,4 +1,6 @@
<?php namespace Config;
<?php
namespace Config;
class ForeignCharacters extends \CodeIgniter\Config\ForeignCharacters
{

View File

@ -1,23 +1,25 @@
<?php namespace Config;
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
class Format extends BaseConfig
{
/*
|--------------------------------------------------------------------------
| Available Response Formats
|--------------------------------------------------------------------------
|
| When you perform content negotiation with the request, these are the
| available formats that your application supports. This is currently
| only used with the API\ResponseTrait. A valid Formatter must exist
| for the specified format.
|
| These formats are only checked when the data passed to the respond()
| method is an array.
|
*/
|--------------------------------------------------------------------------
| Available Response Formats
|--------------------------------------------------------------------------
|
| When you perform content negotiation with the request, these are the
| available formats that your application supports. This is currently
| only used with the API\ResponseTrait. A valid Formatter must exist
| for the specified format.
|
| These formats are only checked when the data passed to the respond()
| method is an array.
|
*/
public $supportedResponseFormats = [
'application/json',
'application/xml', // machine-readable XML
@ -25,15 +27,15 @@ class Format extends BaseConfig
];
/*
|--------------------------------------------------------------------------
| Formatters
|--------------------------------------------------------------------------
|
| Lists the class to use to format responses with of a particular type.
| For each mime type, list the class that should be used. Formatters
| can be retrieved through the getFormatter() method.
|
*/
|--------------------------------------------------------------------------
| Formatters
|--------------------------------------------------------------------------
|
| Lists the class to use to format responses with of a particular type.
| For each mime type, list the class that should be used. Formatters
| can be retrieved through the getFormatter() method.
|
*/
public $formatters = [
'application/json' => \CodeIgniter\Format\JSONFormatter::class,
'application/xml' => \CodeIgniter\Format\XMLFormatter::class,

View File

@ -1,4 +1,6 @@
<?php namespace Config;
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;

View File

@ -1,4 +1,6 @@
<?php namespace Config;
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;

View File

@ -1,4 +1,6 @@
<?php namespace Config;
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
use Kint\Renderer\Renderer;
@ -6,23 +8,23 @@ use Kint\Renderer\Renderer;
class Kint extends BaseConfig
{
/*
|--------------------------------------------------------------------------
| Kint
|--------------------------------------------------------------------------
|
| We use Kint's RichRenderer and CLIRenderer. This area contains options
| that you can set to customize how Kint works for you.
|
| For details on these settings, see Kint's docs:
| https://kint-php.github.io/kint/
|
*/
|--------------------------------------------------------------------------
| Kint
|--------------------------------------------------------------------------
|
| We use Kint's RichRenderer and CLIRenderer. This area contains options
| that you can set to customize how Kint works for you.
|
| For details on these settings, see Kint's docs:
| https://kint-php.github.io/kint/
|
*/
/*
|--------------------------------------------------------------------------
| Global Settings
|--------------------------------------------------------------------------
*/
|--------------------------------------------------------------------------
| Global Settings
|--------------------------------------------------------------------------
*/
public $plugins = null;
@ -33,10 +35,10 @@ class Kint extends BaseConfig
public $expanded = false;
/*
|--------------------------------------------------------------------------
| RichRenderer Settings
|--------------------------------------------------------------------------
*/
|--------------------------------------------------------------------------
| RichRenderer Settings
|--------------------------------------------------------------------------
*/
public $richTheme = 'aante-light.css';
public $richFolder = false;
@ -48,10 +50,10 @@ class Kint extends BaseConfig
public $richTabPlugins = null;
/*
|--------------------------------------------------------------------------
| CLI Settings
|--------------------------------------------------------------------------
*/
|--------------------------------------------------------------------------
| CLI Settings
|--------------------------------------------------------------------------
*/
public $cliColors = true;
public $cliForceUTF8 = false;

View File

@ -1,74 +1,76 @@
<?php namespace Config;
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
class Logger extends BaseConfig
{
/*
|--------------------------------------------------------------------------
| Error Logging Threshold
|--------------------------------------------------------------------------
|
| You can enable error logging by setting a threshold over zero. The
| threshold determines what gets logged. Any values below or equal to the
| threshold will be logged. Threshold options are:
|
| 0 = Disables logging, Error logging TURNED OFF
| 1 = Emergency Messages - System is unusable
| 2 = Alert Messages - Action Must Be Taken Immediately
| 3 = Critical Messages - Application component unavailable, unexpected exception.
| 4 = Runtime Errors - Don't need immediate action, but should be monitored.
| 5 = Warnings - Exceptional occurrences that are not errors.
| 6 = Notices - Normal but significant events.
| 7 = Info - Interesting events, like user logging in, etc.
| 8 = Debug - Detailed debug information.
| 9 = All Messages
|
| You can also pass an array with threshold levels to show individual error types
|
| array(1, 2, 3, 8) = Emergency, Alert, Critical, and Debug messages
|
| For a live site you'll usually enable Critical or higher (3) to be logged otherwise
| your log files will fill up very fast.
|
*/
|--------------------------------------------------------------------------
| Error Logging Threshold
|--------------------------------------------------------------------------
|
| You can enable error logging by setting a threshold over zero. The
| threshold determines what gets logged. Any values below or equal to the
| threshold will be logged. Threshold options are:
|
| 0 = Disables logging, Error logging TURNED OFF
| 1 = Emergency Messages - System is unusable
| 2 = Alert Messages - Action Must Be Taken Immediately
| 3 = Critical Messages - Application component unavailable, unexpected exception.
| 4 = Runtime Errors - Don't need immediate action, but should be monitored.
| 5 = Warnings - Exceptional occurrences that are not errors.
| 6 = Notices - Normal but significant events.
| 7 = Info - Interesting events, like user logging in, etc.
| 8 = Debug - Detailed debug information.
| 9 = All Messages
|
| You can also pass an array with threshold levels to show individual error types
|
| array(1, 2, 3, 8) = Emergency, Alert, Critical, and Debug messages
|
| For a live site you'll usually enable Critical or higher (3) to be logged otherwise
| your log files will fill up very fast.
|
*/
public $threshold = 3;
/*
|--------------------------------------------------------------------------
| Date Format for Logs
|--------------------------------------------------------------------------
|
| Each item that is logged has an associated date. You can use PHP date
| codes to set your own date formatting
|
*/
|--------------------------------------------------------------------------
| Date Format for Logs
|--------------------------------------------------------------------------
|
| Each item that is logged has an associated date. You can use PHP date
| codes to set your own date formatting
|
*/
public $dateFormat = 'Y-m-d H:i:s';
/*
|--------------------------------------------------------------------------
| Log Handlers
|--------------------------------------------------------------------------
|
| The logging system supports multiple actions to be taken when something
| is logged. This is done by allowing for multiple Handlers, special classes
| designed to write the log to their chosen destinations, whether that is
| a file on the getServer, a cloud-based service, or even taking actions such
| as emailing the dev team.
|
| Each handler is defined by the class name used for that handler, and it
| MUST implement the CodeIgniter\Log\Handlers\HandlerInterface interface.
|
| The value of each key is an array of configuration items that are sent
| to the constructor of each handler. The only required configuration item
| is the 'handles' element, which must be an array of integer log levels.
| This is most easily handled by using the constants defined in the
| Psr\Log\LogLevel class.
|
| Handlers are executed in the order defined in this array, starting with
| the handler on top and continuing down.
|
*/
|--------------------------------------------------------------------------
| Log Handlers
|--------------------------------------------------------------------------
|
| The logging system supports multiple actions to be taken when something
| is logged. This is done by allowing for multiple Handlers, special classes
| designed to write the log to their chosen destinations, whether that is
| a file on the getServer, a cloud-based service, or even taking actions such
| as emailing the dev team.
|
| Each handler is defined by the class name used for that handler, and it
| MUST implement the CodeIgniter\Log\Handlers\HandlerInterface interface.
|
| The value of each key is an array of configuration items that are sent
| to the constructor of each handler. The only required configuration item
| is the 'handles' element, which must be an array of integer log levels.
| This is most easily handled by using the constants defined in the
| Psr\Log\LogLevel class.
|
| Handlers are executed in the order defined in this array, starting with
| the handler on top and continuing down.
|
*/
public $handlers = [
//--------------------------------------------------------------------
// File Handler

View File

@ -1,49 +1,51 @@
<?php namespace Config;
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
class Migrations extends BaseConfig
{
/*
|--------------------------------------------------------------------------
| Enable/Disable Migrations
|--------------------------------------------------------------------------
|
| Migrations are enabled by default for security reasons.
| You should enable migrations whenever you intend to do a schema migration
| and disable it back when you're done.
|
*/
|--------------------------------------------------------------------------
| Enable/Disable Migrations
|--------------------------------------------------------------------------
|
| Migrations are enabled by default for security reasons.
| You should enable migrations whenever you intend to do a schema migration
| and disable it back when you're done.
|
*/
public $enabled = true;
/*
|--------------------------------------------------------------------------
| Migrations table
|--------------------------------------------------------------------------
|
| This is the name of the table that will store the current migrations state.
| When migrations runs it will store in a database table which migration
| level the system is at. It then compares the migration level in this
| table to the $config['migration_version'] if they are not the same it
| will migrate up. This must be set.
|
*/
|--------------------------------------------------------------------------
| Migrations table
|--------------------------------------------------------------------------
|
| This is the name of the table that will store the current migrations state.
| When migrations runs it will store in a database table which migration
| level the system is at. It then compares the migration level in this
| table to the $config['migration_version'] if they are not the same it
| will migrate up. This must be set.
|
*/
public $table = 'migrations';
/*
|--------------------------------------------------------------------------
| Timestamp Format
|--------------------------------------------------------------------------
|
| This is the format that will be used when creating new migrations
| using the cli command:
| > php spark migrate:create
|
| Typical formats:
| YmdHis_
| Y-m-d-His_
| Y_m_d_His_
|
*/
|--------------------------------------------------------------------------
| Timestamp Format
|--------------------------------------------------------------------------
|
| This is the format that will be used when creating new migrations
| using the cli command:
| > php spark migrate:create
|
| Typical formats:
| YmdHis_
| Y-m-d-His_
| Y_m_d_His_
|
*/
public $timestampFormat = 'Y-m-d-His_';
}

View File

@ -1,4 +1,6 @@
<?php namespace Config;
<?php
namespace Config;
/*
| -------------------------------------------------------------------

View File

@ -1,38 +1,40 @@
<?php namespace Config;
<?php
namespace Config;
// Cannot extend BaseConfig or looping resources occurs.
class Modules
{
/*
|--------------------------------------------------------------------------
| Auto-Discovery Enabled?
|--------------------------------------------------------------------------
|
| If true, then auto-discovery will happen across all elements listed in
| $activeExplorers below. If false, no auto-discovery will happen at all,
| giving a slight performance boost.
*/
|--------------------------------------------------------------------------
| Auto-Discovery Enabled?
|--------------------------------------------------------------------------
|
| If true, then auto-discovery will happen across all elements listed in
| $activeExplorers below. If false, no auto-discovery will happen at all,
| giving a slight performance boost.
*/
public $enabled = true;
/*
|--------------------------------------------------------------------------
| Auto-Discovery Within Composer Packages Enabled?
|--------------------------------------------------------------------------
|
| If true, then auto-discovery will happen across all namespaces loaded
| by Composer, as well as the namespaces configured locally.
*/
|--------------------------------------------------------------------------
| Auto-Discovery Within Composer Packages Enabled?
|--------------------------------------------------------------------------
|
| If true, then auto-discovery will happen across all namespaces loaded
| by Composer, as well as the namespaces configured locally.
*/
public $discoverInComposer = true;
/*
|--------------------------------------------------------------------------
| Auto-discover Rules
|--------------------------------------------------------------------------
|
| Lists the aliases of all discovery classes that will be active
| and used during the current application request. If it is not
| listed here, only the base application elements will be used.
*/
|--------------------------------------------------------------------------
| Auto-discover Rules
|--------------------------------------------------------------------------
|
| Lists the aliases of all discovery classes that will be active
| and used during the current application request. If it is not
| listed here, only the base application elements will be used.
*/
public $activeExplorers = ['events', 'registrars', 'routes', 'services'];
/**

View File

@ -1,22 +1,24 @@
<?php namespace Config;
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
class Pager extends BaseConfig
{
/*
|--------------------------------------------------------------------------
| Templates
|--------------------------------------------------------------------------
|
| Pagination links are rendered out using views to configure their
| appearance. This array contains aliases and the view names to
| use when rendering the links.
|
| Within each view, the Pager object will be available as $pager,
| and the desired group as $pagerGroup;
|
*/
|--------------------------------------------------------------------------
| Templates
|--------------------------------------------------------------------------
|
| Pagination links are rendered out using views to configure their
| appearance. This array contains aliases and the view names to
| use when rendering the links.
|
| Within each view, the Pager object will be available as $pager,
| and the desired group as $pagerGroup;
|
*/
public $templates = [
'default_full' => 'CodeIgniter\Pager\Views\default_full',
'default_simple' => 'CodeIgniter\Pager\Views\default_simple',
@ -24,12 +26,12 @@ class Pager extends BaseConfig
];
/*
|--------------------------------------------------------------------------
| Items Per Page
|--------------------------------------------------------------------------
|
| The default number of results shown in a single page.
|
*/
|--------------------------------------------------------------------------
| Items Per Page
|--------------------------------------------------------------------------
|
| The default number of results shown in a single page.
|
*/
public $perPage = 20;
}

View File

@ -1,4 +1,6 @@
<?php namespace Config;
<?php
namespace Config;
/**
* Holds the paths that are used by the system to

View File

@ -1,4 +1,6 @@
<?php namespace Config;
<?php
namespace Config;
use CodeIgniter\Config\Services as CoreServices;
use CodeIgniter\Model;

View File

@ -1,21 +1,23 @@
<?php namespace Config;
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
class Toolbar extends BaseConfig
{
/*
|--------------------------------------------------------------------------
| Debug Toolbar
|--------------------------------------------------------------------------
| The Debug Toolbar provides a way to see information about the performance
| and state of your application during that page display. By default it will
| NOT be displayed under production environments, and will only display if
| CI_DEBUG is true, since if it's not, there's not much to display anyway.
|
| toolbarMaxHistory = Number of history files, 0 for none or -1 for unlimited
|
*/
|--------------------------------------------------------------------------
| Debug Toolbar
|--------------------------------------------------------------------------
| The Debug Toolbar provides a way to see information about the performance
| and state of your application during that page display. By default it will
| NOT be displayed under production environments, and will only display if
| CI_DEBUG is true, since if it's not, there's not much to display anyway.
|
| toolbarMaxHistory = Number of history files, 0 for none or -1 for unlimited
|
*/
public $collectors = [
\CodeIgniter\Debug\Toolbar\Collectors\Timers::class,
\CodeIgniter\Debug\Toolbar\Collectors\Database::class,
@ -29,41 +31,41 @@ class Toolbar extends BaseConfig
];
/*
|--------------------------------------------------------------------------
| Max History
|--------------------------------------------------------------------------
| The Toolbar allows you to view recent requests that have been made to
| the application while the toolbar is active. This allows you to quickly
| view and compare multiple requests.
|
| $maxHistory sets a limit on the number of past requests that are stored,
| helping to conserve file space used to store them. You can set it to
| 0 (zero) to not have any history stored, or -1 for unlimited history.
|
*/
|--------------------------------------------------------------------------
| Max History
|--------------------------------------------------------------------------
| The Toolbar allows you to view recent requests that have been made to
| the application while the toolbar is active. This allows you to quickly
| view and compare multiple requests.
|
| $maxHistory sets a limit on the number of past requests that are stored,
| helping to conserve file space used to store them. You can set it to
| 0 (zero) to not have any history stored, or -1 for unlimited history.
|
*/
public $maxHistory = 20;
/*
|--------------------------------------------------------------------------
| Toolbar Views Path
|--------------------------------------------------------------------------
| The full path to the the views that are used by the toolbar.
| MUST have a trailing slash.
|
*/
|--------------------------------------------------------------------------
| Toolbar Views Path
|--------------------------------------------------------------------------
| The full path to the the views that are used by the toolbar.
| MUST have a trailing slash.
|
*/
public $viewsPath = SYSTEMPATH . 'Debug/Toolbar/Views/';
/*
|--------------------------------------------------------------------------
| Max Queries
|--------------------------------------------------------------------------
| If the Database Collector is enabled, it will log every query that the
| the system generates so they can be displayed on the toolbar's timeline
| and in the query log. This can lead to memory issues in some instances
| with hundreds of queries.
|
| $maxQueries defines the maximum amount of queries that will be stored.
|
*/
|--------------------------------------------------------------------------
| Max Queries
|--------------------------------------------------------------------------
| If the Database Collector is enabled, it will log every query that the
| the system generates so they can be displayed on the toolbar's timeline
| and in the query log. This can lead to memory issues in some instances
| with hundreds of queries.
|
| $maxQueries defines the maximum amount of queries that will be stored.
|
*/
public $maxQueries = 100;
}

View File

@ -1,18 +1,20 @@
<?php namespace Config;
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
class UserAgents extends BaseConfig
{
/*
| -------------------------------------------------------------------
| USER AGENT TYPES
| -------------------------------------------------------------------
| This file contains four arrays of user agent data. It is used by the
| User Agent Class to help identify browser, platform, robot, and
| mobile device data. The array keys are used to identify the device
| and the array values are used to set the actual name of the item.
*/
| -------------------------------------------------------------------
| USER AGENT TYPES
| -------------------------------------------------------------------
| This file contains four arrays of user agent data. It is used by the
| User Agent Class to help identify browser, platform, robot, and
| mobile device data. The array keys are used to identify the device
| and the array values are used to set the actual name of the item.
*/
public $platforms = [
'windows nt 10.0' => 'Windows 10',
'windows nt 6.3' => 'Windows 8.1',

View File

@ -1,4 +1,6 @@
<?php namespace Config;
<?php
namespace Config;
class Validation
{

View File

@ -1,4 +1,6 @@
<?php namespace Config;
<?php
namespace Config;
class View extends \CodeIgniter\Config\View
{

View File

@ -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,
])

View File

@ -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]);
}

View File

@ -1,4 +1,5 @@
<?php
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3

View File

@ -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'));
}
}

View File

@ -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');
}

View File

@ -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,
])
);

View File

@ -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)));
}
}

View File

@ -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);
}
}

View File

@ -1,4 +1,5 @@
<?php
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
@ -17,22 +18,20 @@ 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
->where([
'podcast_id' => $this->podcast->id,
'slug' => $params[1],
])
->first())
) {
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
}
if (
count($params) > 1 &&
!($this->episode = (new EpisodeModel())
->where([
'podcast_id' => $this->podcast->id,
'slug' => $params[1],
])
->first())
) {
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
}
return $this->$method();

View File

@ -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));
}
}

View File

@ -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);
}
}

View File

@ -1,4 +1,5 @@
<?php
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3

View File

@ -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())
) {

View File

@ -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));
}
}

View File

@ -1,4 +1,5 @@
<?php
/**
* Class AddCategories
* Creates categories table in database

View File

@ -1,4 +1,5 @@
<?php
/**
* Class AddLanguages
* Creates languages table in database

View File

@ -1,4 +1,5 @@
<?php
/**
* Class AddPodcasts
* Creates podcasts table in database

View File

@ -1,4 +1,5 @@
<?php
/**
* Class AddEpisodes
* Creates episodes table in database

View File

@ -1,4 +1,5 @@
<?php
/**
* Class AddPlatforms
* Creates platforms table in database

View File

@ -1,4 +1,5 @@
<?php
/**
* Class AddPlatformsLinks
* Creates platform_links table in database

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -1,4 +1,5 @@
<?php
/**
* Class AddLanguages
* Creates languages table in database

View File

@ -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);
}
}

View File

@ -1,4 +1,5 @@
<?php
/**
* Class CategorySeeder
* Inserts values in categories table in database

View File

@ -1,4 +1,5 @@
<?php
/**
* Class LanguageSeeder
* Inserts values in languages table in database

View File

@ -1,4 +1,5 @@
<?php
/**
* Class PlatformsSeeder
* Inserts values in platforms table in database

View File

@ -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,

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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']);
}
}

View File

@ -1,4 +1,5 @@
<?php
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3

View File

@ -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']);
}
}

View File

@ -1,4 +1,6 @@
<?php namespace App\Entities;
<?php
namespace App\Entities;
use App\Models\PodcastModel;

View File

@ -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;
}

View File

@ -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)
}
}
}

View File

@ -1,4 +1,5 @@
<?php
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3

View File

@ -1,4 +1,5 @@
<?php
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3

View File

@ -1,4 +1,5 @@
<?php
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3

View File

@ -1,4 +1,5 @@
<?php
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3

View File

@ -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;

View File

@ -1,4 +1,5 @@
<?php
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3

View File

@ -1,19 +1,20 @@
<?
<?php
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
return [
'dashboard' => 'Dashboard',
'podcasts' => 'Podcasts',
'users' => 'Users',
'admin_home' => 'Home',
'my_podcasts' => 'My podcasts',
'podcast_list' => 'All podcasts',
'podcast_create' => 'New podcast',
'user_list' => 'All users',
'user_create' => 'New user',
'go_to_website' => 'Go to website'
];
return [
'dashboard' => 'Dashboard',
'podcasts' => 'Podcasts',
'users' => 'Users',
'admin_home' => 'Home',
'my_podcasts' => 'My podcasts',
'podcast_list' => 'All podcasts',
'podcast_create' => 'New podcast',
'user_list' => 'All users',
'user_create' => 'New user',
'go_to_website' => 'Go to website',
];

View File

@ -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!',
],
];

View File

@ -1,4 +1,5 @@
<?
<?php
/**
* ISO 3166 country codes
* @copyright 2020 Podlibre

View File

@ -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',
]
],
];

View File

@ -1,4 +1,5 @@
<?
<?php
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3

View File

@ -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 [
'passwordChangeSuccess' => 'Password has been successfully changed!',
'changePassword' => 'Change my password',
'info' => 'My account info'
'info' => 'My account info',
'messages' => [
'passwordChangeSuccess' => 'Password has been successfully changed!',
'changePassword' => 'Change my password',
],
];

View File

@ -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',
];

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