mirror of
https://github.com/humhub/humhub.git
synced 2025-01-18 06:38:14 +01:00
Added support for global content which not belongs to a content container
This commit is contained in:
parent
16703c0583
commit
d207832d5b
@ -54,7 +54,7 @@ class Comment extends ContentAddonActiveRecord implements ContentOwner
|
||||
[['message'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
@ -123,12 +123,14 @@ class Comment extends ContentAddonActiveRecord implements ContentOwner
|
||||
->about($this)
|
||||
->sendBulk($this->getCommentedRecord()->getFollowers(null, true, true));
|
||||
|
||||
Yii::$app->live->send(new \humhub\modules\comment\live\NewComment([
|
||||
'contentContainerId' => $this->content->container->id,
|
||||
'visibility' => $this->content->visibility,
|
||||
'contentId' => $this->content->id,
|
||||
'commentId' => $this->id
|
||||
]));
|
||||
if ($this->content->container) {
|
||||
Yii::$app->live->send(new \humhub\modules\comment\live\NewComment([
|
||||
'contentContainerId' => $this->content->container->id,
|
||||
'visibility' => $this->content->visibility,
|
||||
'contentId' => $this->content->id,
|
||||
'commentId' => $this->id
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
$this->updateContentSearch();
|
||||
@ -146,7 +148,7 @@ class Comment extends ContentAddonActiveRecord implements ContentOwner
|
||||
Yii::$app->search->update($this->getCommentedRecord());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the commented record e.g. a Post
|
||||
*
|
||||
|
@ -80,14 +80,20 @@ class ActiveQueryContent extends \yii\db\ActiveQuery
|
||||
/**
|
||||
* Limits the returned records to the given ContentContainer.
|
||||
*
|
||||
* @param ContentContainerActiveRecord $container
|
||||
* @param ContentContainerActiveRecord $container|null or null for global content
|
||||
* @return \humhub\modules\content\components\ActiveQueryContent
|
||||
* @throws \yii\base\Exception
|
||||
*/
|
||||
public function contentContainer($container)
|
||||
{
|
||||
$this->joinWith(['content', 'content.contentContainer', 'content.createdBy']);
|
||||
$this->andWhere(['contentcontainer.pk' => $container->id, 'contentcontainer.class' => $container->className()]);
|
||||
if ($container === null) {
|
||||
$this->joinWith(['content', 'content.contentContainer', 'content.createdBy']);
|
||||
$this->andWhere(['IS', 'contentcontainer.pk', new \yii\db\Expression('NULL')]);
|
||||
} else {
|
||||
$this->joinWith(['content', 'content.contentContainer', 'content.createdBy']);
|
||||
$this->andWhere(['contentcontainer.pk' => $container->id, 'contentcontainer.class' => $container->className()]);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ class PermaController extends Controller
|
||||
|
||||
$content = Content::findOne(['id' => $id]);
|
||||
|
||||
if ($content !== null) {
|
||||
if ($content !== null && $content->container !== null) {
|
||||
return $this->redirect($content->container->createUrl(null, ['contentId' => $id]));
|
||||
}
|
||||
|
||||
|
@ -169,21 +169,23 @@ class Content extends ContentDeprecated
|
||||
|
||||
if ($insert && !$contentSource instanceof \humhub\modules\activity\models\Activity) {
|
||||
|
||||
$notifyUsers = array_merge($this->notifyUsersOfNewContent, Yii::$app->notification->getFollowers($this));
|
||||
if ($this->container !== null) {
|
||||
$notifyUsers = array_merge($this->notifyUsersOfNewContent, Yii::$app->notification->getFollowers($this));
|
||||
|
||||
\humhub\modules\content\notifications\ContentCreated::instance()
|
||||
->from($this->user)
|
||||
->about($contentSource)
|
||||
->sendBulk($notifyUsers);
|
||||
\humhub\modules\content\notifications\ContentCreated::instance()
|
||||
->from($this->user)
|
||||
->about($contentSource)
|
||||
->sendBulk($notifyUsers);
|
||||
|
||||
\humhub\modules\content\activities\ContentCreated::instance()
|
||||
->about($contentSource)->save();
|
||||
\humhub\modules\content\activities\ContentCreated::instance()
|
||||
->about($contentSource)->save();
|
||||
|
||||
Yii::$app->live->send(new \humhub\modules\content\live\NewContent([
|
||||
'contentContainerId' => $this->container->id,
|
||||
'visibility' => $this->visibility,
|
||||
'contentId' => $this->id
|
||||
]));
|
||||
Yii::$app->live->send(new \humhub\modules\content\live\NewContent([
|
||||
'contentContainerId' => $this->container->id,
|
||||
'visibility' => $this->visibility,
|
||||
'contentId' => $this->id
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
return parent::afterSave($insert, $changedAttributes);
|
||||
@ -290,7 +292,7 @@ class Content extends ContentDeprecated
|
||||
*/
|
||||
public function isArchived()
|
||||
{
|
||||
return $this->archived || $this->getContainer()->isArchived();
|
||||
return $this->archived || ($this->getContainer() !== null && $this->getContainer()->isArchived());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -55,8 +55,8 @@ class DashboardStream extends Stream
|
||||
->leftJoin('contentcontainer', 'user.id=contentcontainer.pk AND contentcontainer.class=:userClass')
|
||||
->where('user.status=1 AND user.visibility = ' . User::VISIBILITY_ALL);
|
||||
$union .= " UNION " . Yii::$app->db->getQueryBuilder()->build($publicProfilesSql)[0];
|
||||
|
||||
$this->activeQuery->andWhere('content.contentcontainer_id IN (' . $union . ')', [':spaceClass' => Space::className(), ':userClass' => User::className()]);
|
||||
|
||||
$this->activeQuery->andWhere('content.contentcontainer_id IN (' . $union . ') OR content.contentcontainer_id IS NULL', [':spaceClass' => Space::className(), ':userClass' => User::className()]);
|
||||
$this->activeQuery->andWhere(['content.visibility' => Content::VISIBILITY_PUBLIC]);
|
||||
} else {
|
||||
|
||||
@ -100,8 +100,8 @@ class DashboardStream extends Stream
|
||||
$union .= " UNION " . Yii::$app->db->getQueryBuilder()->build($wallIdsSql)[0];
|
||||
|
||||
// Manual Union (https://github.com/yiisoft/yii2/issues/7992)
|
||||
$this->activeQuery->andWhere('contentcontainer.id IN (' . $union . ')', [':spaceClass' => Space::className(), ':userClass' => User::className()]);
|
||||
|
||||
$this->activeQuery->andWhere('contentcontainer.id IN (' . $union . ') OR contentcontainer.id IS NULL', [':spaceClass' => Space::className(), ':userClass' => User::className()]);
|
||||
|
||||
/**
|
||||
* Begin visibility checks regarding the content container
|
||||
*/
|
||||
|
@ -119,11 +119,9 @@ abstract class Search extends \yii\base\Component
|
||||
if ($obj->content->container !== null) {
|
||||
$meta['containerModel'] = $obj->content->container->className();
|
||||
$meta['containerPk'] = $obj->content->container->id;
|
||||
if ($obj->content->visibility == Content::VISIBILITY_PRIVATE) {
|
||||
$meta['visibility'] = self::DOCUMENT_VISIBILITY_PRIVATE;
|
||||
} else {
|
||||
$meta['visibility'] = self::DOCUMENT_VISIBILITY_PUBLIC;
|
||||
}
|
||||
}
|
||||
if ($obj->content->visibility == Content::VISIBILITY_PUBLIC) {
|
||||
$meta['visibility'] = self::DOCUMENT_VISIBILITY_PUBLIC;
|
||||
} else {
|
||||
$meta['visibility'] = self::DOCUMENT_VISIBILITY_PRIVATE;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user