Initial import of space_profiles module
This commit is contained in:
43
controllers/PublicController.php
Normal file
43
controllers/PublicController.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace humhub\modules\space_profiles\controllers;
|
||||
|
||||
use humhub\components\Controller;
|
||||
use humhub\modules\space\models\Space;
|
||||
use humhub\modules\space_profiles\helpers\ProfileAccess;
|
||||
use humhub\modules\space_profiles\models\SpaceProfile;
|
||||
use Yii;
|
||||
use yii\web\ForbiddenHttpException;
|
||||
use yii\web\NotFoundHttpException;
|
||||
|
||||
class PublicController extends Controller
|
||||
{
|
||||
public function actionView(string $slug)
|
||||
{
|
||||
$profile = SpaceProfile::findOne(['slug' => $slug]);
|
||||
if (!$profile instanceof SpaceProfile) {
|
||||
throw new NotFoundHttpException('Profile not found.');
|
||||
}
|
||||
|
||||
$space = Space::findOne(['contentcontainer_id' => $profile->contentcontainer_id]);
|
||||
if (!$space instanceof Space) {
|
||||
throw new NotFoundHttpException('Space not found.');
|
||||
}
|
||||
|
||||
if (!$space->moduleManager->isEnabled('space_profiles')) {
|
||||
throw new NotFoundHttpException('Profile not available.');
|
||||
}
|
||||
|
||||
if (!ProfileAccess::canView($space)) {
|
||||
throw new ForbiddenHttpException('You are not allowed to view this profile.');
|
||||
}
|
||||
|
||||
$this->view->title = Yii::t('SpaceProfilesModule.base', 'Rescue Profile') . ' - ' . $space->name;
|
||||
|
||||
return $this->render('view', [
|
||||
'space' => $space,
|
||||
'profile' => $profile,
|
||||
'isPublicRoute' => true,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user