Initial import of space_profiles module

This commit is contained in:
Kelin Rescue Hub
2026-04-04 13:11:50 -04:00
commit 87a59e5a0a
35 changed files with 1627 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
<?php
use humhub\components\Migration;
class m260401_201000_set_rescues_default_home extends Migration
{
public function safeUp()
{
$rows = (new \yii\db\Query())
->select(['contentcontainer_id', 'url', 'guid'])
->from('space')
->where(['in', 'contentcontainer_id', (new \yii\db\Query())
->select('contentcontainer_id')
->from('rescue_space_profile')])
->all($this->db);
foreach ($rows as $row) {
$spacePath = trim((string)($row['url'] ?? ''));
if ($spacePath === '') {
$spacePath = trim((string)($row['guid'] ?? ''));
}
if ($spacePath === '') {
continue;
}
$homeUrl = '/s/' . $spacePath . '/rescues';
$contentContainerId = (int)$row['contentcontainer_id'];
$this->upsert('contentcontainer_setting', [
'module_id' => 'space',
'contentcontainer_id' => $contentContainerId,
'name' => 'indexUrl',
'value' => $homeUrl,
], [
'value' => $homeUrl,
]);
$this->upsert('contentcontainer_setting', [
'module_id' => 'space',
'contentcontainer_id' => $contentContainerId,
'name' => 'indexGuestUrl',
'value' => $homeUrl,
], [
'value' => $homeUrl,
]);
}
}
public function safeDown()
{
$this->delete('contentcontainer_setting', [
'and',
['module_id' => 'space', 'name' => 'indexUrl'],
['like', 'value', '/s/%/rescues', false],
]);
$this->delete('contentcontainer_setting', [
'and',
['module_id' => 'space', 'name' => 'indexGuestUrl'],
['like', 'value', '/s/%/rescues', false],
]);
}
}