Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • adaures/castopod
  • mkljczk/castopod-host
  • spaetz/castopod-host
  • PatrykMis/castopod
  • jonas/castopod
  • ajeremias/castopod
  • misuzu/castopod
  • KrzysztofDomanczyk/castopod
  • Behel/castopod
  • nebulon/castopod
  • ewen/castopod
  • NeoluxConsulting/castopod
  • nateritter/castopod-og
  • prcutler/castopod
14 results
Show changes
Showing
with 1341 additions and 773 deletions
<?php
declare(strict_types=1);
/**
* Class AddEpisodesPersons Creates episodes_persons table in database
*
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Migrations;
use Override;
class AddEpisodesPersons extends BaseMigration
{
#[Override]
public function up(): void
{
$this->forge->addField([
'id' => [
'type' => 'INT',
'unsigned' => true,
'auto_increment' => true,
],
'podcast_id' => [
'type' => 'INT',
'unsigned' => true,
],
'episode_id' => [
'type' => 'INT',
'unsigned' => true,
],
'person_id' => [
'type' => 'INT',
'unsigned' => true,
],
'person_group' => [
'type' => 'VARCHAR',
'constraint' => 32,
],
'person_role' => [
'type' => 'VARCHAR',
'constraint' => 32,
],
]);
$this->forge->addPrimaryKey('id');
$this->forge->addUniqueKey(['podcast_id', 'episode_id', 'person_id', 'person_group', 'person_role']);
$this->forge->addForeignKey('podcast_id', 'podcasts', 'id', '', 'CASCADE');
$this->forge->addForeignKey('episode_id', 'episodes', 'id', '', 'CASCADE');
$this->forge->addForeignKey('person_id', 'persons', 'id', '', 'CASCADE');
$this->forge->createTable('episodes_persons');
}
#[Override]
public function down(): void
{
$this->forge->dropTable('episodes_persons');
}
}
<?php
declare(strict_types=1);
/**
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Migrations;
use Override;
class AddCreditsView extends BaseMigration
{
#[Override]
public function up(): void
{
// Creates View for credit UNION query
$viewName = $this->db->prefixTable('credits');
$personsTable = $this->db->prefixTable('persons');
$podcastPersonsTable = $this->db->prefixTable('podcasts_persons');
$episodePersonsTable = $this->db->prefixTable('episodes_persons');
$episodesTable = $this->db->prefixTable('episodes');
$createQuery = <<<SQL
CREATE VIEW `{$viewName}` AS
SELECT `person_group`, `person_id`, `full_name`, `person_role`, `podcast_id`, NULL AS `episode_id` FROM `{$podcastPersonsTable}`
INNER JOIN `{$personsTable}`
ON (`person_id`=`{$personsTable}`.`id`)
UNION
SELECT `person_group`, `person_id`, `full_name`, `person_role`, {$episodePersonsTable}.`podcast_id`, `episode_id` FROM `{$episodePersonsTable}`
INNER JOIN `{$personsTable}`
ON (`person_id`=`{$personsTable}`.`id`)
INNER JOIN `{$episodesTable}`
ON (`episode_id`=`{$episodesTable}`.`id`)
WHERE `{$episodesTable}`.published_at <= UTC_TIMESTAMP()
ORDER BY `person_group`, `full_name`, `person_role`, `podcast_id`, `episode_id`;
SQL;
$this->db->query($createQuery);
}
#[Override]
public function down(): void
{
$viewName = $this->db->prefixTable('credits');
$this->db->query("DROP VIEW IF EXISTS `{$viewName}`");
}
}
<?php
declare(strict_types=1);
/**
* Class AddEpisodeIdToPosts Adds episode_id field to posts table in database
*
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Migrations;
use Override;
class AddEpisodeIdToPosts extends BaseMigration
{
#[Override]
public function up(): void
{
$prefix = $this->db->getPrefix();
$this->forge->addColumn('fediverse_posts', [
'episode_id' => [
'type' => 'INT',
'unsigned' => true,
'null' => true,
'after' => 'replies_count',
],
]);
$this->forge->addForeignKey(
'episode_id',
'episodes',
'id',
'',
'CASCADE',
$prefix . 'fediverse_posts_episode_id_foreign',
);
$this->forge->processIndexes('fediverse_posts');
}
#[Override]
public function down(): void
{
$prefix = $this->db->getPrefix();
$this->forge->dropForeignKey('fediverse_posts', $prefix . 'fediverse_posts_episode_id_foreign');
$this->forge->dropColumn('fediverse_posts', 'episode_id');
}
}
<?php
declare(strict_types=1);
/**
* Class AddCreatedByToPosts Adds created_by field to posts table in database
*
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Migrations;
use Override;
class AddCreatedByToPosts extends BaseMigration
{
#[Override]
public function up(): void
{
$prefix = $this->db->getPrefix();
$this->forge->addColumn('fediverse_posts', [
'created_by' => [
'type' => 'INT',
'unsigned' => true,
'null' => true,
'after' => 'episode_id',
],
]);
$this->forge->addForeignKey(
'created_by',
'users',
'id',
'',
'CASCADE',
$prefix . 'fediverse_posts_created_by_foreign',
);
$this->forge->processIndexes('fediverse_posts');
}
#[Override]
public function down(): void
{
$prefix = $this->db->getPrefix();
$this->forge->dropForeignKey('fediverse_posts', $prefix . 'fediverse_posts_created_by_foreign');
$this->forge->dropColumn('fediverse_posts', 'created_by');
}
}
<?php
declare(strict_types=1);
namespace App\Database\Migrations;
use Override;
class AddFullTextSearchIndexes extends BaseMigration
{
#[Override]
public function up(): void
{
$prefix = $this->db->getPrefix();
$createQuery = <<<SQL
ALTER TABLE {$prefix}episodes DROP INDEX title;
SQL;
$this->db->query($createQuery);
$createQuery = <<<SQL
ALTER TABLE {$prefix}episodes
ADD FULLTEXT episodes_search (title, description_markdown, slug, location_name);
SQL;
$this->db->query($createQuery);
$createQuery = <<<SQL
ALTER TABLE {$prefix}podcasts
ADD FULLTEXT podcasts_search (title, description_markdown, handle, location_name);
SQL;
$this->db->query($createQuery);
}
#[Override]
public function down(): void
{
$prefix = $this->db->getPrefix();
$createQuery = <<<SQL
ALTER TABLE {$prefix}episodes
DROP INDEX episodes_search;
SQL;
$this->db->query($createQuery);
$createQuery = <<<SQL
ALTER TABLE {$prefix}podcasts
DROP INDEX podcasts_search;
SQL;
$this->db->query($createQuery);
}
}
<?php
declare(strict_types=1);
namespace App\Database\Migrations;
use Override;
class AddEpisodePreviewId extends BaseMigration
{
#[Override]
public function up(): void
{
$fields = [
'preview_id' => [
'type' => 'BINARY',
'constraint' => 16,
'after' => 'podcast_id',
],
];
$this->forge->addColumn('episodes', $fields);
// set preview_id as unique key
$prefix = $this->db->getPrefix();
$uniquePreviewId = <<<CODE_SAMPLE
ALTER TABLE `{$prefix}episodes`
ADD CONSTRAINT `preview_id` UNIQUE (`preview_id`);
CODE_SAMPLE;
$this->db->query($uniquePreviewId);
}
#[Override]
public function down(): void
{
$fields = ['preview_id'];
$this->forge->dropColumn('episodes', $fields);
}
}
<?php
declare(strict_types=1);
/**
* Class AddPodcastsOwnerEmailRemovedFromFeed adds is_owner_email_removed_from_feed field to podcast table in database
*
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Migrations;
use Override;
class AddPodcastsOwnerEmailRemovedFromFeed extends BaseMigration
{
#[Override]
public function up(): void
{
$fields = [
'is_owner_email_removed_from_feed' => [
'type' => 'BOOLEAN',
'null' => false,
'default' => 0,
'after' => 'owner_email',
],
];
$this->forge->addColumn('podcasts', $fields);
}
#[Override]
public function down(): void
{
$fields = ['is_owner_email_removed_from_feed'];
$this->forge->dropColumn('podcasts', $fields);
}
}
<?php
declare(strict_types=1);
/**
* Class AddPodcastsMediumField adds medium field to podcast table in database
*
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Migrations;
use Override;
class AddPodcastsMediumField extends BaseMigration
{
#[Override]
public function up(): void
{
$fields = [
'medium' => [
'type' => "ENUM('podcast','music','audiobook')",
'null' => false,
'default' => 'podcast',
'after' => 'type',
],
];
$this->forge->addColumn('podcasts', $fields);
}
#[Override]
public function down(): void
{
$fields = ['medium'];
$this->forge->dropColumn('podcasts', $fields);
}
}
<?php
declare(strict_types=1);
/**
* Class AddPodcastsVerifyTxtField adds 1 field to podcast table in database to support podcast:txt tag
*
* @copyright 2024 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Migrations;
use Override;
class AddPodcastsVerifyTxtField extends BaseMigration
{
#[Override]
public function up(): void
{
$fields = [
'verify_txt' => [
'type' => 'TEXT',
'null' => true,
'after' => 'location_osm',
],
];
$this->forge->addColumn('podcasts', $fields);
}
#[Override]
public function down(): void
{
$this->forge->dropColumn('podcasts', 'verify_txt');
}
}
<?php
declare(strict_types=1);
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Override;
class RefactorPlatforms extends Migration
{
#[Override]
public function up(): void
{
$this->forge->addField([
'id' => [
'type' => 'INT',
'unsigned' => true,
'auto_increment' => true,
],
'podcast_id' => [
'type' => 'INT',
'unsigned' => true,
],
'type' => [
'type' => 'ENUM',
'constraint' => ['podcasting', 'social', 'funding'],
'after' => 'podcast_id',
],
'slug' => [
'type' => 'VARCHAR',
'constraint' => 32,
],
'link_url' => [
'type' => 'VARCHAR',
'constraint' => 512,
],
'account_id' => [
'type' => 'VARCHAR',
'constraint' => 128,
'null' => true,
],
'is_visible' => [
'type' => 'TINYINT',
'constraint' => 1,
'default' => 0,
],
]);
$this->forge->addPrimaryKey('id');
$this->forge->addForeignKey('podcast_id', 'podcasts', 'id', '', 'CASCADE', 'platforms_podcast_id_foreign');
$this->forge->addUniqueKey(['podcast_id', 'type', 'slug']);
$this->forge->createTable('platforms_temp');
$platformsData = $this->db->table('podcasts_platforms')
->select('podcasts_platforms.*, type')
->join('platforms', 'platforms.slug = podcasts_platforms.platform_slug')
->get()
->getResultArray();
$data = [];
foreach ($platformsData as $platformData) {
$data[] = [
'podcast_id' => $platformData['podcast_id'],
'type' => $platformData['type'],
'slug' => $platformData['platform_slug'],
'link_url' => $platformData['link_url'],
'account_id' => $platformData['account_id'],
'is_visible' => $platformData['is_visible'],
];
}
if ($data !== []) {
$this->db->table('platforms_temp')
->insertBatch($data);
}
$this->forge->dropTable('platforms');
$this->forge->dropTable('podcasts_platforms');
$this->forge->renameTable('platforms_temp', 'platforms');
}
#[Override]
public function down(): void
{
// delete platforms
$this->forge->dropTable('platforms');
// recreate platforms and podcasts_platforms tables
$this->forge->addField([
'slug' => [
'type' => 'VARCHAR',
'constraint' => 32,
],
'type' => [
'type' => 'ENUM',
'constraint' => ['podcasting', 'social', 'funding'],
],
'label' => [
'type' => 'VARCHAR',
'constraint' => 32,
],
'home_url' => [
'type' => 'VARCHAR',
'constraint' => 255,
],
'submit_url' => [
'type' => 'VARCHAR',
'constraint' => 512,
'null' => true,
],
]);
$this->forge->addField('`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP()');
$this->forge->addField(
'`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP() ON UPDATE CURRENT_TIMESTAMP()',
);
$this->forge->addPrimaryKey('slug');
$this->forge->createTable('platforms');
$this->forge->addField([
'podcast_id' => [
'type' => 'INT',
'unsigned' => true,
],
'platform_slug' => [
'type' => 'VARCHAR',
'constraint' => 32,
],
'link_url' => [
'type' => 'VARCHAR',
'constraint' => 512,
],
'account_id' => [
'type' => 'VARCHAR',
'constraint' => 128,
'null' => true,
],
'is_visible' => [
'type' => 'TINYINT',
'constraint' => 1,
'default' => 0,
],
'is_on_embed' => [
'type' => 'TINYINT',
'constraint' => 1,
'default' => 0,
],
]);
$this->forge->addPrimaryKey(['podcast_id', 'platform_slug']);
$this->forge->addForeignKey('podcast_id', 'podcasts', 'id', '', 'CASCADE');
$this->forge->addForeignKey('platform_slug', 'platforms', 'slug', 'CASCADE');
$this->forge->createTable('podcasts_platforms');
}
}
<?php
declare(strict_types=1);
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Override;
/**
* CodeIgniter 4.5.1 introduces new DataCaster class that breaks deserialization of import queue tasks.
* This just removes them altogether.
*/
class ClearImportQueue extends Migration
{
#[Override]
public function up(): void
{
service('settings')->forget('Import.queue');
}
#[Override]
public function down(): void
{
// nothing
}
}
<?php
declare(strict_types=1);
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class AddEpisodeDownloadsCount extends Migration
{
public function up(): void
{
$fields = [
'downloads_count' => [
'type' => 'INT',
'unsigned' => true,
'default' => 0,
'after' => 'is_published_on_hubs',
],
];
$this->forge->addColumn('episodes', $fields);
}
public function down(): void
{
$this->forge->dropColumn('episodes', 'downloads_count');
}
}
<?php
declare(strict_types=1);
/**
* Class AddPodcastsMediumField adds medium field to podcast table in database
*
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Migrations;
use Override;
class DropDeprecatedPodcastsFields extends BaseMigration
{
#[Override]
public function up(): void
{
// TODO: migrate data
$this->forge->dropColumn(
'podcasts',
'episode_description_footer_markdown,episode_description_footer_html,is_owner_email_removed_from_feed,medium,payment_pointer,verify_txt,custom_rss,partner_id,partner_link_url,partner_image_url',
);
}
#[Override]
public function down(): void
{
$fields = [
'episode_description_footer_markdown' => [
'type' => 'TEXT',
'null' => true,
],
'episode_description_footer_html' => [
'type' => 'TEXT',
'null' => true,
],
'is_owner_email_removed_from_feed' => [
'type' => 'BOOLEAN',
'null' => false,
'default' => 0,
'after' => 'owner_email',
],
'medium' => [
'type' => "ENUM('podcast','music','audiobook')",
'null' => false,
'default' => 'podcast',
'after' => 'type',
],
'payment_pointer' => [
'type' => 'VARCHAR',
'constraint' => 128,
'comment' => 'Wallet address for Web Monetization payments',
'null' => true,
],
'verify_txt' => [
'type' => 'TEXT',
'null' => true,
'after' => 'location_osm',
],
'custom_rss' => [
'type' => 'JSON',
'null' => true,
],
'partner_id' => [
'type' => 'VARCHAR',
'constraint' => 32,
'null' => true,
],
'partner_link_url' => [
'type' => 'VARCHAR',
'constraint' => 512,
'null' => true,
],
'partner_image_url' => [
'type' => 'VARCHAR',
'constraint' => 512,
'null' => true,
],
];
$this->forge->addColumn('podcasts', $fields);
}
}
<?php
declare(strict_types=1);
/**
* Class AddPodcastsMediumField adds medium field to podcast table in database
*
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Migrations;
use Override;
class DropDeprecatedEpisodesFields extends BaseMigration
{
#[Override]
public function up(): void
{
$this->forge->dropColumn('episodes', 'custom_rss');
}
#[Override]
public function down(): void
{
$fields = [
'custom_rss' => [
'type' => 'JSON',
'null' => true,
],
];
$this->forge->addColumn('episodes', $fields);
}
}
<?php
declare(strict_types=1);
/**
* Class AddCreatedByToPosts Adds created_by field to posts table in database
*
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Migrations;
use CodeIgniter\Database\BaseConnection;
use CodeIgniter\Database\Migration;
use Override;
class BaseMigration extends Migration
{
/**
* Database Connection instance
*
* @var BaseConnection
*/
protected $db;
#[Override]
public function up(): void
{
}
#[Override]
public function down(): void
{
}
}
<?php
declare(strict_types=1);
/**
* Class AppSeeder
* Calls all required seeders for castopod to work properly
* Class AppSeeder Calls all required seeders for castopod to work properly
*
* @copyright 2020 Podlibre
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
......@@ -12,14 +13,14 @@
namespace App\Database\Seeds;
use CodeIgniter\Database\Seeder;
use Override;
class AppSeeder extends Seeder
{
public function run()
#[Override]
public function run(): void
{
$this->call('AuthSeeder');
$this->call('CategorySeeder');
$this->call('LanguageSeeder');
$this->call('PlatformSeeder');
}
}
<?php
/**
* Class PermissionSeeder
* Inserts permissions
*
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Seeds;
use CodeIgniter\Database\Seeder;
class AuthSeeder extends Seeder
{
protected $groups = [
[
'name' => 'superadmin',
'description' =>
'Somebody who has access to all the castopod instance features',
],
[
'name' => 'podcast_admin',
'description' =>
'Somebody who has access to all the features within a given podcast',
],
];
/** Build permissions array as a list of:
*
* ```
* context => [
* [action, description],
* [action, description],
* ...
* ]
* ```
*/
protected $permissions = [
'users' => [
[
'name' => 'create',
'description' => 'Create a user',
'has_permission' => ['superadmin'],
],
[
'name' => 'list',
'description' => 'List all users',
'has_permission' => ['superadmin'],
],
[
'name' => 'view',
'description' => 'View any user info',
'has_permission' => ['superadmin'],
],
[
'name' => 'manage_authorizations',
'description' => 'Add or remove roles/permissions to a user',
'has_permission' => ['superadmin'],
],
[
'name' => 'manage_bans',
'description' => 'Ban / unban a user',
'has_permission' => ['superadmin'],
],
[
'name' => 'force_pass_reset',
'description' =>
'Force a user to update his password upon next login',
'has_permission' => ['superadmin'],
],
[
'name' => 'delete',
'description' =>
'Delete user without removing him from database',
'has_permission' => ['superadmin'],
],
[
'name' => 'delete_permanently',
'description' =>
'Delete all occurrences of a user from the database',
'has_permission' => ['superadmin'],
],
],
'pages' => [
[
'name' => 'manage',
'description' => 'List / create / edit / delete pages',
'has_permission' => ['superadmin'],
],
],
'podcasts' => [
[
'name' => 'create',
'description' => 'Add a new podcast',
'has_permission' => ['superadmin'],
],
[
'name' => 'import',
'description' => 'Import a new podcast from an external feed',
'has_permission' => ['superadmin'],
],
[
'name' => 'list',
'description' => 'List all podcasts and their episodes',
'has_permission' => ['superadmin'],
],
[
'name' => 'view',
'description' => 'View any podcast and their contributors list',
'has_permission' => ['superadmin'],
],
[
'name' => 'delete',
'description' =>
'Delete a podcast without removing it from database',
'has_permission' => ['superadmin'],
],
[
'name' => 'delete_permanently',
'description' => 'Delete any podcast from the database',
'has_permission' => ['superadmin'],
],
],
'episodes' => [
[
'name' => 'list',
'description' => 'List all episodes of any podcast',
'has_permission' => ['superadmin'],
],
[
'name' => 'view',
'description' => 'View any episode of any podcast',
'has_permission' => ['superadmin'],
],
],
'podcast' => [
[
'name' => 'view',
'description' => 'View a podcast',
'has_permission' => ['podcast_admin'],
],
[
'name' => 'edit',
'description' => 'Edit a podcast',
'has_permission' => ['podcast_admin'],
],
[
'name' => 'manage_contributors',
'description' =>
'Add / remove contributors to a podcast and edit their roles',
'has_permission' => ['podcast_admin'],
],
[
'name' => 'manage_platforms',
'description' => 'Set / remove platform links of a podcast',
'has_permission' => ['podcast_admin'],
],
[
'name' => 'manage_publications',
'description' =>
'Publish / unpublish episodes & notes of a podcast',
'has_permission' => ['podcast_admin'],
],
[
'name' => 'interact_as',
'description' =>
'Interact as the podcast to favourite / share or reply to notes.',
'has_permission' => ['podcast_admin'],
],
],
'podcast_episodes' => [
[
'name' => 'list',
'description' => 'List all episodes of a podcast',
'has_permission' => ['podcast_admin'],
],
[
'name' => 'view',
'description' => 'View any episode of a podcast',
'has_permission' => ['podcast_admin'],
],
[
'name' => 'create',
'description' => 'Add new episodes for a podcast',
'has_permission' => ['podcast_admin'],
],
[
'name' => 'edit',
'description' => 'Edit an episode of a podcast',
'has_permission' => ['podcast_admin'],
],
[
'name' => 'delete',
'description' =>
'Delete an episode of a podcast without removing it from the database',
'has_permission' => ['podcast_admin'],
],
[
'name' => 'delete_permanently',
'description' =>
'Delete all occurrences of an episode of a podcast from the database',
'has_permission' => ['podcast_admin'],
],
],
'person' => [
[
'name' => 'create',
'description' => 'Add a new person',
'has_permission' => ['superadmin'],
],
[
'name' => 'list',
'description' => 'List all persons',
'has_permission' => ['superadmin'],
],
[
'name' => 'view',
'description' => 'View any person',
'has_permission' => ['superadmin'],
],
[
'name' => 'edit',
'description' => 'Edit a person',
'has_permission' => ['superadmin'],
],
[
'name' => 'delete',
'description' =>
'Delete permanently any person from the database',
'has_permission' => ['superadmin'],
],
],
'fediverse' => [
[
'name' => 'block_actors',
'description' =>
'Block an activitypub actors from interacting with the instance.',
'has_permission' => ['superadmin'],
],
[
'name' => 'block_domains',
'description' =>
'Block an activitypub domains from interacting with the instance.',
'has_permission' => ['superadmin'],
],
],
];
static function getGroupIdByName($name, $dataGroups)
{
foreach ($dataGroups as $group) {
if ($group['name'] === $name) {
return $group['id'];
}
}
return null;
}
public function run()
{
$groupId = 0;
$dataGroups = [];
foreach ($this->groups as $group) {
array_push($dataGroups, [
'id' => ++$groupId,
'name' => $group['name'],
'description' => $group['description'],
]);
}
// Map permissions to a format the `auth_permissions` table expects
$dataPermissions = [];
$dataGroupsPermissions = [];
$permissionId = 0;
foreach ($this->permissions as $context => $actions) {
foreach ($actions as $action) {
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($dataGroupsPermissions, [
'group_id' => $this->getGroupIdByName(
$role,
$dataGroups,
),
'permission_id' => $permissionId,
]);
}
}
}
$this->db
->table('auth_permissions')
->ignore(true)
->insertBatch($dataPermissions);
$this->db
->table('auth_groups')
->ignore(true)
->insertBatch($dataGroups);
$this->db
->table('auth_groups_permissions')
->ignore(true)
->insertBatch($dataGroupsPermissions);
}
}
<?php
declare(strict_types=1);
/**
* Class CategorySeeder
* Inserts values in categories table in database
* Class CategorySeeder Inserts values in categories table in database
*
* @copyright 2020 Podlibre
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
......@@ -12,794 +13,791 @@
namespace App\Database\Seeds;
use CodeIgniter\Database\Seeder;
use Override;
class CategorySeeder extends Seeder
{
public function run()
#[Override]
public function run(): void
{
$data = [
[
'parent_id' => 0,
'id' => 0,
'code' => 'uncategorized',
'apple_category' => 'uncategorized',
'google_category' => 'uncategorized',
],
[
'parent_id' => 0,
'id' => 1,
'code' => 'arts',
'apple_category' => 'Arts',
'id' => 1,
'parent_id' => null,
'code' => 'arts',
'apple_category' => 'Arts',
'google_category' => 'Arts',
],
[
'parent_id' => 0,
'id' => 2,
'code' => 'business',
'apple_category' => 'Business',
'id' => 2,
'parent_id' => null,
'code' => 'business',
'apple_category' => 'Business',
'google_category' => 'Business',
],
[
'parent_id' => 0,
'id' => 3,
'code' => 'comedy',
'apple_category' => 'Comedy',
'id' => 3,
'parent_id' => null,
'code' => 'comedy',
'apple_category' => 'Comedy',
'google_category' => 'Comedy',
],
[
'parent_id' => 0,
'id' => 4,
'code' => 'education',
'apple_category' => 'Education',
'id' => 4,
'parent_id' => null,
'code' => 'education',
'apple_category' => 'Education',
'google_category' => 'Education',
],
[
'parent_id' => 0,
'id' => 5,
'code' => 'fiction',
'apple_category' => 'Fiction',
'id' => 5,
'parent_id' => null,
'code' => 'fiction',
'apple_category' => 'Fiction',
'google_category' => '',
],
[
'parent_id' => 0,
'id' => 6,
'code' => 'government',
'apple_category' => 'Government',
'id' => 6,
'parent_id' => null,
'code' => 'government',
'apple_category' => 'Government',
'google_category' => 'Government & Organizations',
],
[
'parent_id' => 0,
'id' => 7,
'code' => 'health_and_fitness',
'apple_category' => 'Health & Fitness',
'id' => 7,
'parent_id' => null,
'code' => 'health_and_fitness',
'apple_category' => 'Health & Fitness',
'google_category' => 'Health',
],
[
'parent_id' => 0,
'id' => 8,
'code' => 'history',
'apple_category' => 'History',
'id' => 8,
'parent_id' => null,
'code' => 'history',
'apple_category' => 'History',
'google_category' => '',
],
[
'parent_id' => 0,
'id' => 9,
'code' => 'kids_and_family',
'apple_category' => 'Kids & Family',
'id' => 9,
'parent_id' => null,
'code' => 'kids_and_family',
'apple_category' => 'Kids & Family',
'google_category' => 'Kids & Family',
],
[
'parent_id' => 0,
'id' => 10,
'code' => 'leisure',
'apple_category' => 'Leisure',
'id' => 10,
'parent_id' => null,
'code' => 'leisure',
'apple_category' => 'Leisure',
'google_category' => 'Games & Hobbies',
],
[
'parent_id' => 0,
'id' => 11,
'code' => 'music',
'apple_category' => 'Music',
'id' => 11,
'parent_id' => null,
'code' => 'music',
'apple_category' => 'Music',
'google_category' => 'Music',
],
[
'parent_id' => 0,
'id' => 12,
'code' => 'news',
'apple_category' => 'News',
'id' => 12,
'parent_id' => null,
'code' => 'news',
'apple_category' => 'News',
'google_category' => 'News & Politics',
],
[
'parent_id' => 0,
'id' => 13,
'code' => 'religion_and_spirituality',
'apple_category' => 'Religion & Spirituality',
'id' => 13,
'parent_id' => null,
'code' => 'religion_and_spirituality',
'apple_category' => 'Religion & Spirituality',
'google_category' => 'Religion & Spirituality',
],
[
'parent_id' => 0,
'id' => 14,
'code' => 'science',
'apple_category' => 'Science',
'id' => 14,
'parent_id' => null,
'code' => 'science',
'apple_category' => 'Science',
'google_category' => 'Science & Medicine',
],
[
'parent_id' => 0,
'id' => 15,
'code' => 'society_and_culture',
'apple_category' => 'Society & Culture',
'id' => 15,
'parent_id' => null,
'code' => 'society_and_culture',
'apple_category' => 'Society & Culture',
'google_category' => 'Society & Culture',
],
[
'parent_id' => 0,
'id' => 16,
'code' => 'sports',
'apple_category' => 'Sports',
'id' => 16,
'parent_id' => null,
'code' => 'sports',
'apple_category' => 'Sports',
'google_category' => 'Sports & Recreation',
],
[
'parent_id' => 0,
'id' => 17,
'code' => 'technology',
'apple_category' => 'Technology',
'id' => 17,
'parent_id' => null,
'code' => 'technology',
'apple_category' => 'Technology',
'google_category' => 'Technology',
],
[
'parent_id' => 0,
'id' => 18,
'code' => 'true_crime',
'apple_category' => 'True Crime',
'id' => 18,
'parent_id' => null,
'code' => 'true_crime',
'apple_category' => 'True Crime',
'google_category' => '',
],
[
'parent_id' => 0,
'id' => 19,
'code' => 'tv_and_film',
'apple_category' => 'TV & Film',
'id' => 19,
'parent_id' => null,
'code' => 'tv_and_film',
'apple_category' => 'TV & Film',
'google_category' => 'TV & Film',
],
[
'parent_id' => 1,
'id' => 20,
'code' => 'books',
'apple_category' => 'Books',
'id' => 20,
'parent_id' => 1,
'code' => 'books',
'apple_category' => 'Books',
'google_category' => '',
],
[
'parent_id' => 1,
'id' => 21,
'code' => 'design',
'apple_category' => 'Design',
'id' => 21,
'parent_id' => 1,
'code' => 'design',
'apple_category' => 'Design',
'google_category' => '',
],
[
'parent_id' => 1,
'id' => 22,
'code' => 'fashion_and_beauty',
'apple_category' => 'Fashion & Beauty',
'id' => 22,
'parent_id' => 1,
'code' => 'fashion_and_beauty',
'apple_category' => 'Fashion & Beauty',
'google_category' => '',
],
[
'parent_id' => 1,
'id' => 23,
'code' => 'food',
'apple_category' => 'Food',
'id' => 23,
'parent_id' => 1,
'code' => 'food',
'apple_category' => 'Food',
'google_category' => '',
],
[
'parent_id' => 1,
'id' => 24,
'code' => 'performing_arts',
'apple_category' => 'Performing Arts',
'id' => 24,
'parent_id' => 1,
'code' => 'performing_arts',
'apple_category' => 'Performing Arts',
'google_category' => '',
],
[
'parent_id' => 1,
'id' => 25,
'code' => 'visual_arts',
'apple_category' => 'Visual Arts',
'id' => 25,
'parent_id' => 1,
'code' => 'visual_arts',
'apple_category' => 'Visual Arts',
'google_category' => '',
],
[
'parent_id' => 2,
'id' => 26,
'code' => 'careers',
'apple_category' => 'Careers',
'id' => 26,
'parent_id' => 2,
'code' => 'careers',
'apple_category' => 'Careers',
'google_category' => '',
],
[
'parent_id' => 2,
'id' => 27,
'code' => 'entrepreneurship',
'apple_category' => 'Entrepreneurship',
'id' => 27,
'parent_id' => 2,
'code' => 'entrepreneurship',
'apple_category' => 'Entrepreneurship',
'google_category' => '',
],
[
'parent_id' => 2,
'id' => 28,
'code' => 'investing',
'apple_category' => 'Investing',
'id' => 28,
'parent_id' => 2,
'code' => 'investing',
'apple_category' => 'Investing',
'google_category' => '',
],
[
'parent_id' => 2,
'id' => 29,
'code' => 'management',
'apple_category' => 'Management',
'id' => 29,
'parent_id' => 2,
'code' => 'management',
'apple_category' => 'Management',
'google_category' => '',
],
[
'parent_id' => 2,
'id' => 30,
'code' => 'marketing',
'apple_category' => 'Marketing',
'id' => 30,
'parent_id' => 2,
'code' => 'marketing',
'apple_category' => 'Marketing',
'google_category' => '',
],
[
'parent_id' => 2,
'id' => 31,
'code' => 'non_profit',
'apple_category' => 'Non-Profit',
'id' => 31,
'parent_id' => 2,
'code' => 'non_profit',
'apple_category' => 'Non-Profit',
'google_category' => '',
],
[
'parent_id' => 3,
'id' => 32,
'code' => 'comedy_interviews',
'apple_category' => 'Comedy Interviews',
'id' => 32,
'parent_id' => 3,
'code' => 'comedy_interviews',
'apple_category' => 'Comedy Interviews',
'google_category' => '',
],
[
'parent_id' => 3,
'id' => 33,
'code' => 'improv',
'apple_category' => 'Improv',
'id' => 33,
'parent_id' => 3,
'code' => 'improv',
'apple_category' => 'Improv',
'google_category' => '',
],
[
'parent_id' => 3,
'id' => 34,
'code' => 'stand_up',
'apple_category' => 'Stand-Up',
'id' => 34,
'parent_id' => 3,
'code' => 'stand_up',
'apple_category' => 'Stand-Up',
'google_category' => '',
],
[
'parent_id' => 4,
'id' => 35,
'code' => 'courses',
'apple_category' => 'Courses',
'id' => 35,
'parent_id' => 4,
'code' => 'courses',
'apple_category' => 'Courses',
'google_category' => '',
],
[
'parent_id' => 4,
'id' => 36,
'code' => 'how_to',
'apple_category' => 'How To',
'id' => 36,
'parent_id' => 4,
'code' => 'how_to',
'apple_category' => 'How To',
'google_category' => '',
],
[
'parent_id' => 4,
'id' => 37,
'code' => 'language_learning',
'apple_category' => 'Language Learning',
'id' => 37,
'parent_id' => 4,
'code' => 'language_learning',
'apple_category' => 'Language Learning',
'google_category' => '',
],
[
'parent_id' => 4,
'id' => 38,
'code' => 'self_improvement',
'apple_category' => 'Self-Improvement',
'id' => 38,
'parent_id' => 4,
'code' => 'self_improvement',
'apple_category' => 'Self-Improvement',
'google_category' => '',
],
[
'parent_id' => 5,
'id' => 39,
'code' => 'comedy_fiction',
'apple_category' => 'Comedy Fiction',
'id' => 39,
'parent_id' => 5,
'code' => 'comedy_fiction',
'apple_category' => 'Comedy Fiction',
'google_category' => '',
],
[
'parent_id' => 5,
'id' => 40,
'code' => 'drama',
'apple_category' => 'Drama',
'id' => 40,
'parent_id' => 5,
'code' => 'drama',
'apple_category' => 'Drama',
'google_category' => '',
],
[
'parent_id' => 5,
'id' => 41,
'code' => 'science_fiction',
'apple_category' => 'Science Fiction',
'id' => 41,
'parent_id' => 5,
'code' => 'science_fiction',
'apple_category' => 'Science Fiction',
'google_category' => '',
],
[
'parent_id' => 7,
'id' => 42,
'code' => 'alternative_health',
'apple_category' => 'Alternative Health',
'id' => 42,
'parent_id' => 7,
'code' => 'alternative_health',
'apple_category' => 'Alternative Health',
'google_category' => '',
],
[
'parent_id' => 7,
'id' => 43,
'code' => 'fitness',
'apple_category' => 'Fitness',
'id' => 43,
'parent_id' => 7,
'code' => 'fitness',
'apple_category' => 'Fitness',
'google_category' => '',
],
[
'parent_id' => 7,
'id' => 44,
'code' => 'medicine',
'apple_category' => 'Medicine',
'id' => 44,
'parent_id' => 7,
'code' => 'medicine',
'apple_category' => 'Medicine',
'google_category' => '',
],
[
'parent_id' => 7,
'id' => 45,
'code' => 'mental_health',
'apple_category' => 'Mental Health',
'id' => 45,
'parent_id' => 7,
'code' => 'mental_health',
'apple_category' => 'Mental Health',
'google_category' => '',
],
[
'parent_id' => 7,
'id' => 46,
'code' => 'nutrition',
'apple_category' => 'Nutrition',
'id' => 46,
'parent_id' => 7,
'code' => 'nutrition',
'apple_category' => 'Nutrition',
'google_category' => '',
],
[
'parent_id' => 7,
'id' => 47,
'code' => 'sexuality',
'apple_category' => 'Sexuality',
'id' => 47,
'parent_id' => 7,
'code' => 'sexuality',
'apple_category' => 'Sexuality',
'google_category' => '',
],
[
'parent_id' => 9,
'id' => 48,
'code' => 'education_for_kids',
'apple_category' => 'Education for Kids',
'id' => 48,
'parent_id' => 9,
'code' => 'education_for_kids',
'apple_category' => 'Education for Kids',
'google_category' => '',
],
[
'parent_id' => 9,
'id' => 49,
'code' => 'parenting',
'apple_category' => 'Parenting',
'id' => 49,
'parent_id' => 9,
'code' => 'parenting',
'apple_category' => 'Parenting',
'google_category' => '',
],
[
'parent_id' => 9,
'id' => 50,
'code' => 'pets_and_animals',
'apple_category' => 'Pets & Animals',
'id' => 50,
'parent_id' => 9,
'code' => 'pets_and_animals',
'apple_category' => 'Pets & Animals',
'google_category' => '',
],
[
'parent_id' => 9,
'id' => 51,
'code' => 'stories_for_kids',
'apple_category' => 'Stories for Kids',
'id' => 51,
'parent_id' => 9,
'code' => 'stories_for_kids',
'apple_category' => 'Stories for Kids',
'google_category' => '',
],
[
'parent_id' => 10,
'id' => 52,
'code' => 'animation_and_manga',
'apple_category' => 'Animation & Manga',
'id' => 52,
'parent_id' => 10,
'code' => 'animation_and_manga',
'apple_category' => 'Animation & Manga',
'google_category' => '',
],
[
'parent_id' => 10,
'id' => 53,
'code' => 'automotive',
'apple_category' => 'Automotive',
'id' => 53,
'parent_id' => 10,
'code' => 'automotive',
'apple_category' => 'Automotive',
'google_category' => '',
],
[
'parent_id' => 10,
'id' => 54,
'code' => 'aviation',
'apple_category' => 'Aviation',
'id' => 54,
'parent_id' => 10,
'code' => 'aviation',
'apple_category' => 'Aviation',
'google_category' => '',
],
[
'parent_id' => 10,
'id' => 55,
'code' => 'crafts',
'apple_category' => 'Crafts',
'id' => 55,
'parent_id' => 10,
'code' => 'crafts',
'apple_category' => 'Crafts',
'google_category' => '',
],
[
'parent_id' => 10,
'id' => 56,
'code' => 'games',
'apple_category' => 'Games',
'id' => 56,
'parent_id' => 10,
'code' => 'games',
'apple_category' => 'Games',
'google_category' => '',
],
[
'parent_id' => 10,
'id' => 57,
'code' => 'hobbies',
'apple_category' => 'Hobbies',
'id' => 57,
'parent_id' => 10,
'code' => 'hobbies',
'apple_category' => 'Hobbies',
'google_category' => '',
],
[
'parent_id' => 10,
'id' => 58,
'code' => 'home_and_garden',
'apple_category' => 'Home & Garden',
'id' => 58,
'parent_id' => 10,
'code' => 'home_and_garden',
'apple_category' => 'Home & Garden',
'google_category' => '',
],
[
'parent_id' => 10,
'id' => 59,
'code' => 'video_games',
'apple_category' => 'Video Games',
'id' => 59,
'parent_id' => 10,
'code' => 'video_games',
'apple_category' => 'Video Games',
'google_category' => '',
],
[
'parent_id' => 11,
'id' => 60,
'code' => 'music_commentary',
'apple_category' => 'Music Commentary',
'id' => 60,
'parent_id' => 11,
'code' => 'music_commentary',
'apple_category' => 'Music Commentary',
'google_category' => '',
],
[
'parent_id' => 11,
'id' => 61,
'code' => 'music_history',
'apple_category' => 'Music History',
'id' => 61,
'parent_id' => 11,
'code' => 'music_history',
'apple_category' => 'Music History',
'google_category' => '',
],
[
'parent_id' => 11,
'id' => 62,
'code' => 'music_interviews',
'apple_category' => 'Music Interviews',
'id' => 62,
'parent_id' => 11,
'code' => 'music_interviews',
'apple_category' => 'Music Interviews',
'google_category' => '',
],
[
'parent_id' => 12,
'id' => 63,
'code' => 'business_news',
'apple_category' => 'Business News',
'id' => 63,
'parent_id' => 12,
'code' => 'business_news',
'apple_category' => 'Business News',
'google_category' => '',
],
[
'parent_id' => 12,
'id' => 64,
'code' => 'daily_news',
'apple_category' => 'Daily News',
'id' => 64,
'parent_id' => 12,
'code' => 'daily_news',
'apple_category' => 'Daily News',
'google_category' => '',
],
[
'parent_id' => 12,
'id' => 65,
'code' => 'entertainment_news',
'apple_category' => 'Entertainment News',
'id' => 65,
'parent_id' => 12,
'code' => 'entertainment_news',
'apple_category' => 'Entertainment News',
'google_category' => '',
],
[
'parent_id' => 12,
'id' => 66,
'code' => 'news_commentary',
'apple_category' => 'News Commentary',
'id' => 66,
'parent_id' => 12,
'code' => 'news_commentary',
'apple_category' => 'News Commentary',
'google_category' => '',
],
[
'parent_id' => 12,
'id' => 67,
'code' => 'politics',
'apple_category' => 'Politics',
'id' => 67,
'parent_id' => 12,
'code' => 'politics',
'apple_category' => 'Politics',
'google_category' => '',
],
[
'parent_id' => 12,
'id' => 68,
'code' => 'sports_news',
'apple_category' => 'Sports News',
'id' => 68,
'parent_id' => 12,
'code' => 'sports_news',
'apple_category' => 'Sports News',
'google_category' => '',
],
[
'parent_id' => 12,
'id' => 69,
'code' => 'tech_news',
'apple_category' => 'Tech News',
'id' => 69,
'parent_id' => 12,
'code' => 'tech_news',
'apple_category' => 'Tech News',
'google_category' => '',
],
[
'parent_id' => 13,
'id' => 70,
'code' => 'buddhism',
'apple_category' => 'Buddhism',
'id' => 70,
'parent_id' => 13,
'code' => 'buddhism',
'apple_category' => 'Buddhism',
'google_category' => '',
],
[
'parent_id' => 13,
'id' => 71,
'code' => 'christianity',
'apple_category' => 'Christianity',
'id' => 71,
'parent_id' => 13,
'code' => 'christianity',
'apple_category' => 'Christianity',
'google_category' => '',
],
[
'parent_id' => 13,
'id' => 72,
'code' => 'hinduism',
'apple_category' => 'Hinduism',
'id' => 72,
'parent_id' => 13,
'code' => 'hinduism',
'apple_category' => 'Hinduism',
'google_category' => '',
],
[
'parent_id' => 13,
'id' => 73,
'code' => 'islam',
'apple_category' => 'Islam',
'id' => 73,
'parent_id' => 13,
'code' => 'islam',
'apple_category' => 'Islam',
'google_category' => '',
],
[
'parent_id' => 13,
'id' => 74,
'code' => 'judaism',
'apple_category' => 'Judaism',
'id' => 74,
'parent_id' => 13,
'code' => 'judaism',
'apple_category' => 'Judaism',
'google_category' => '',
],
[
'parent_id' => 13,
'id' => 75,
'code' => 'religion',
'apple_category' => 'Religion',
'id' => 75,
'parent_id' => 13,
'code' => 'religion',
'apple_category' => 'Religion',
'google_category' => '',
],
[
'parent_id' => 13,
'id' => 76,
'code' => 'spirituality',
'apple_category' => 'Spirituality',
'id' => 76,
'parent_id' => 13,
'code' => 'spirituality',
'apple_category' => 'Spirituality',
'google_category' => '',
],
[
'parent_id' => 14,
'id' => 77,
'code' => 'astronomy',
'apple_category' => 'Astronomy',
'id' => 77,
'parent_id' => 14,
'code' => 'astronomy',
'apple_category' => 'Astronomy',
'google_category' => '',
],
[
'parent_id' => 14,
'id' => 78,
'code' => 'chemistry',
'apple_category' => 'Chemistry',
'id' => 78,
'parent_id' => 14,
'code' => 'chemistry',
'apple_category' => 'Chemistry',
'google_category' => '',
],
[
'parent_id' => 14,
'id' => 79,
'code' => 'earth_sciences',
'apple_category' => 'Earth Sciences',
'id' => 79,
'parent_id' => 14,
'code' => 'earth_sciences',
'apple_category' => 'Earth Sciences',
'google_category' => '',
],
[
'parent_id' => 14,
'id' => 80,
'code' => 'life_sciences',
'apple_category' => 'Life Sciences',
'id' => 80,
'parent_id' => 14,
'code' => 'life_sciences',
'apple_category' => 'Life Sciences',
'google_category' => '',
],
[
'parent_id' => 14,
'id' => 81,
'code' => 'mathematics',
'apple_category' => 'Mathematics',
'id' => 81,
'parent_id' => 14,
'code' => 'mathematics',
'apple_category' => 'Mathematics',
'google_category' => '',
],
[
'parent_id' => 14,
'id' => 82,
'code' => 'natural_sciences',
'apple_category' => 'Natural Sciences',
'id' => 82,
'parent_id' => 14,
'code' => 'natural_sciences',
'apple_category' => 'Natural Sciences',
'google_category' => '',
],
[
'parent_id' => 14,
'id' => 83,
'code' => 'nature',
'apple_category' => 'Nature',
'id' => 83,
'parent_id' => 14,
'code' => 'nature',
'apple_category' => 'Nature',
'google_category' => '',
],
[
'parent_id' => 14,
'id' => 84,
'code' => 'physics',
'apple_category' => 'Physics',
'id' => 84,
'parent_id' => 14,
'code' => 'physics',
'apple_category' => 'Physics',
'google_category' => '',
],
[
'parent_id' => 14,
'id' => 85,
'code' => 'social_sciences',
'apple_category' => 'Social Sciences',
'id' => 85,
'parent_id' => 14,
'code' => 'social_sciences',
'apple_category' => 'Social Sciences',
'google_category' => '',
],
[
'parent_id' => 15,
'id' => 86,
'code' => 'documentary',
'apple_category' => 'Documentary',
'id' => 86,
'parent_id' => 15,
'code' => 'documentary',
'apple_category' => 'Documentary',
'google_category' => '',
],
[
'parent_id' => 15,
'id' => 87,
'code' => 'personal_journals',
'apple_category' => 'Personal Journals',
'id' => 87,
'parent_id' => 15,
'code' => 'personal_journals',
'apple_category' => 'Personal Journals',
'google_category' => '',
],
[
'parent_id' => 15,
'id' => 88,
'code' => 'philosophy',
'apple_category' => 'Philosophy',
'id' => 88,
'parent_id' => 15,
'code' => 'philosophy',
'apple_category' => 'Philosophy',
'google_category' => '',
],
[
'parent_id' => 15,
'id' => 89,
'code' => 'places_and_travel',
'apple_category' => 'Places & Travel',
'id' => 89,
'parent_id' => 15,
'code' => 'places_and_travel',
'apple_category' => 'Places & Travel',
'google_category' => '',
],
[
'parent_id' => 15,
'id' => 90,
'code' => 'relationships',
'apple_category' => 'Relationships',
'id' => 90,
'parent_id' => 15,
'code' => 'relationships',
'apple_category' => 'Relationships',
'google_category' => '',
],
[
'parent_id' => 16,
'id' => 91,
'code' => 'baseball',
'apple_category' => 'Baseball',
'id' => 91,
'parent_id' => 16,
'code' => 'baseball',
'apple_category' => 'Baseball',
'google_category' => '',
],
[
'parent_id' => 16,
'id' => 92,
'code' => 'basketball',
'apple_category' => 'Basketball',
'id' => 92,
'parent_id' => 16,
'code' => 'basketball',
'apple_category' => 'Basketball',
'google_category' => '',
],
[
'parent_id' => 16,
'id' => 93,
'code' => 'cricket',
'apple_category' => 'Cricket',
'id' => 93,
'parent_id' => 16,
'code' => 'cricket',
'apple_category' => 'Cricket',
'google_category' => '',
],
[
'parent_id' => 16,
'id' => 94,
'code' => 'fantasy_sports',
'apple_category' => 'Fantasy Sports',
'id' => 94,
'parent_id' => 16,
'code' => 'fantasy_sports',
'apple_category' => 'Fantasy Sports',
'google_category' => '',
],
[
'parent_id' => 16,
'id' => 95,
'code' => 'football',
'apple_category' => 'Football',
'id' => 95,
'parent_id' => 16,
'code' => 'football',
'apple_category' => 'Football',
'google_category' => '',
],
[
'parent_id' => 16,
'id' => 96,
'code' => 'golf',
'apple_category' => 'Golf',
'id' => 96,
'parent_id' => 16,
'code' => 'golf',
'apple_category' => 'Golf',
'google_category' => '',
],
[
'parent_id' => 16,
'id' => 97,
'code' => 'hockey',
'apple_category' => 'Hockey',
'id' => 97,
'parent_id' => 16,
'code' => 'hockey',
'apple_category' => 'Hockey',
'google_category' => '',
],
[
'parent_id' => 16,
'id' => 98,
'code' => 'rugby',
'apple_category' => 'Rugby',
'id' => 98,
'parent_id' => 16,
'code' => 'rugby',
'apple_category' => 'Rugby',
'google_category' => '',
],
[
'parent_id' => 16,
'id' => 99,
'code' => 'running',
'apple_category' => 'Running',
'id' => 99,
'parent_id' => 16,
'code' => 'running',
'apple_category' => 'Running',
'google_category' => '',
],
[
'parent_id' => 16,
'id' => 100,
'code' => 'soccer',
'apple_category' => 'Soccer',
'id' => 100,
'parent_id' => 16,
'code' => 'soccer',
'apple_category' => 'Soccer',
'google_category' => '',
],
[
'parent_id' => 16,
'id' => 101,
'code' => 'swimming',
'apple_category' => 'Swimming',
'id' => 101,
'parent_id' => 16,
'code' => 'swimming',
'apple_category' => 'Swimming',
'google_category' => '',
],
[
'parent_id' => 16,
'id' => 102,
'code' => 'tennis',
'apple_category' => 'Tennis',
'id' => 102,
'parent_id' => 16,
'code' => 'tennis',
'apple_category' => 'Tennis',
'google_category' => '',
],
[
'parent_id' => 16,
'id' => 103,
'code' => 'volleyball',
'apple_category' => 'Volleyball',
'id' => 103,
'parent_id' => 16,
'code' => 'volleyball',
'apple_category' => 'Volleyball',
'google_category' => '',
],
[
'parent_id' => 16,
'id' => 104,
'code' => 'wilderness',
'apple_category' => 'Wilderness',
'id' => 104,
'parent_id' => 16,
'code' => 'wilderness',
'apple_category' => 'Wilderness',
'google_category' => '',
],
[
'parent_id' => 16,
'id' => 105,
'code' => 'wrestling',
'apple_category' => 'Wrestling',
'id' => 105,
'parent_id' => 16,
'code' => 'wrestling',
'apple_category' => 'Wrestling',
'google_category' => '',
],
[
'parent_id' => 19,
'id' => 106,
'code' => 'after_shows',
'apple_category' => 'After Shows',
'id' => 106,
'parent_id' => 19,
'code' => 'after_shows',
'apple_category' => 'After Shows',
'google_category' => '',
],
[
'parent_id' => 19,
'id' => 107,
'code' => 'film_history',
'apple_category' => 'Film History',
'id' => 107,
'parent_id' => 19,
'code' => 'film_history',
'apple_category' => 'Film History',
'google_category' => '',
],
[
'parent_id' => 19,
'id' => 108,
'code' => 'film_interviews',
'apple_category' => 'Film Interviews',
'id' => 108,
'parent_id' => 19,
'code' => 'film_interviews',
'apple_category' => 'Film Interviews',
'google_category' => '',
],
[
'parent_id' => 19,
'id' => 109,
'code' => 'film_reviews',
'apple_category' => 'Film Reviews',
'id' => 109,
'parent_id' => 19,
'code' => 'film_reviews',
'apple_category' => 'Film Reviews',
'google_category' => '',
],
[
'parent_id' => 19,
'id' => 110,
'code' => 'tv_reviews',
'apple_category' => 'TV Reviews',
'id' => 110,
'parent_id' => 19,
'code' => 'tv_reviews',
'apple_category' => 'TV Reviews',
'google_category' => '',
],
];
$this->db
->table('categories')
->ignore(true)
->insertBatch($data);
foreach ($data as $categoryLine) {
$this->db
->table('categories')
->ignore(true)
->insert($categoryLine);
}
}
}
<?php
declare(strict_types=1);
/**
* Class AppSeeder Calls all required seeders for castopod to work properly
*
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Seeds;
use CodeIgniter\Database\Seeder;
use Override;
class DevSeeder extends Seeder
{
#[Override]
public function run(): void
{
$this->call('CategorySeeder');
$this->call('LanguageSeeder');
$this->call('DevSuperadminSeeder');
}
}
<?php
declare(strict_types=1);
/**
* Class TestSeeder Inserts a superadmin user in the database
*
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Seeds;
use CodeIgniter\Database\Seeder;
use CodeIgniter\Shield\Entities\User;
use Modules\Auth\Models\UserModel;
use Override;
class DevSuperadminSeeder extends Seeder
{
#[Override]
public function run(): void
{
if ((new UserModel())->where('is_owner', true)->first() instanceof User) {
return;
}
/**
* Inserts an owner with the following credentials: admin: `admin@example.com` password: `castopod`
*/
// Get the User Provider (UserModel by default)
$users = auth()
->getProvider();
$user = new User([
'username' => 'admin',
'email' => 'admin@castopod.local',
'password' => 'castopod',
'is_owner' => true,
]);
$users->save($user);
// To get the complete user object with ID, we need to get from the database
$user = $users->findById($users->getInsertID());
$user->addGroup(setting('AuthGroups.mostPowerfulGroup'));
}
}