');
- }
- };*/
-
ActivityStream.prototype.initScroll = function () {
if(!this.$content.is(':visible')) {
return;
@@ -83,6 +67,9 @@ humhub.module('activity', function (module, require, $) {
var scrolling = true;
var that = this;
this.$content.scroll(function (evt) {
+ if(that.lastEntryLoaded()) {
+ return;
+ }
// save height of the overflow container
var _containerHeight = that.$content.height();
// save scroll height
diff --git a/protected/humhub/modules/content/components/ContentActiveRecord.php b/protected/humhub/modules/content/components/ContentActiveRecord.php
index 3ff94940fc..6e9d7166a9 100644
--- a/protected/humhub/modules/content/components/ContentActiveRecord.php
+++ b/protected/humhub/modules/content/components/ContentActiveRecord.php
@@ -470,7 +470,7 @@ class ContentActiveRecord extends ActiveRecord implements ContentOwner, Movable
public function canMove(ContentContainerActiveRecord $container = null)
{
if(!$this->canMove) {
- return Yii::t('ContentModel.base', 'This content type can\'t be moved');
+ return Yii::t('ContentModule.base', 'This content type can\'t be moved');
}
return true;
diff --git a/protected/humhub/modules/content/components/ContentContainerModuleManager.php b/protected/humhub/modules/content/components/ContentContainerModuleManager.php
index 063444afa3..222381647c 100644
--- a/protected/humhub/modules/content/components/ContentContainerModuleManager.php
+++ b/protected/humhub/modules/content/components/ContentContainerModuleManager.php
@@ -82,6 +82,11 @@ class ContentContainerModuleManager extends \yii\base\Component
*/
public function isEnabled($id)
{
+ // Workaround for core post module
+ if($id === 'post') {
+ return true;
+ }
+
return in_array($id, $this->getEnabled());
}
diff --git a/protected/humhub/modules/content/controllers/ContentController.php b/protected/humhub/modules/content/controllers/ContentController.php
index e2404c0d0a..d5bbb55319 100644
--- a/protected/humhub/modules/content/controllers/ContentController.php
+++ b/protected/humhub/modules/content/controllers/ContentController.php
@@ -8,6 +8,8 @@
namespace humhub\modules\content\controllers;
+use humhub\libs\Html;
+use humhub\modules\content\models\forms\MoveContentForm;
use Yii;
use yii\web\HttpException;
use humhub\components\Controller;
@@ -31,7 +33,7 @@ class ContentController extends Controller
{
return [
'acl' => [
- 'class' => \humhub\components\behaviors\AccessControl::className(),
+ 'class' => \humhub\components\behaviors\AccessControl::class,
]
];
}
@@ -267,6 +269,27 @@ class ContentController extends Controller
return $this->asJson($json);
}
+ public function actionMove($id)
+ {
+ $form = new MoveContentForm(['id' => $id]);
+
+ if(!$form->content) {
+ throw new HttpException(404);
+ }
+
+ if($form->load(Yii::$app->request->post()) && $form->save()) {
+ return $this->asJson([
+ 'success' => true,
+ 'id' => $id,
+ 'target' => $form->getTargetContainer()->id,
+ 'message' => Yii::t('ContentModule.base', 'Content has been moved to {spacename}', ['spacename' => Html::encode($form->getTargetContainer()->getDisplayName())])
+ ]);
+ }
+
+ return $this->renderAjax('moveModal', ['model' => $form]);
+
+ }
+
}
?>
diff --git a/protected/humhub/modules/content/models/Content.php b/protected/humhub/modules/content/models/Content.php
index 142f6fa713..bff53aa96e 100644
--- a/protected/humhub/modules/content/models/Content.php
+++ b/protected/humhub/modules/content/models/Content.php
@@ -412,7 +412,7 @@ class Content extends ContentDeprecated implements Movable
// Check for legacy modules
if(!$model->getModuleId()) {
- return Yii::t('ContentModel.base', 'This content type can\'t be moved due to a missing module-id setting.');
+ return Yii::t('ContentModule.base', 'This content type can\'t be moved due to a missing module-id setting.');
}
if(!$container) {
@@ -424,27 +424,27 @@ class Content extends ContentDeprecated implements Movable
if(!$container->moduleManager->isEnabled($model->getModuleId())) {
$module = Yii::$app->getModule($model->getModuleId());
$moduleName = ($module instanceof ContentContainerModule) ? $module->getContentContainerName($container) : $module->getName();
- return Yii::t('ContentModel.base', 'The module {moduleName} is not enabled on the selected target space.', ['moduleName' => $moduleName]);
+ return Yii::t('ContentModule.base', 'The module {moduleName} is not enabled on the selected target space.', ['moduleName' => $moduleName]);
}
// Check if the current user is allowed to move this content at all
if(!$isContentOwner && !$this->container->can(ManageContent::class)) {
- return Yii::t('ContentModel.base', 'You do not have the permission to move this content.');
+ return Yii::t('ContentModule.base', 'You do not have the permission to move this content.');
}
// Check if the current user is allowed to move this content to the given target space
if(!$isContentOwner && !$container->can(ManageContent::class)) {
- return Yii::t('ContentModel.base', 'You do not have the permission to move this content to the given space.');
+ return Yii::t('ContentModule.base', 'You do not have the permission to move this content to the given space.');
}
// Check if the content owner is allowed to create content on the target space
$ownerPermissions = $container->getPermissionManager($this->createdBy);
if($this->isPrivate() && !$ownerPermissions->can(CreatePrivateContent::class)) {
- return Yii::t('ContentModel.base', 'The author of this content is not allowed to create private content within the selected space.');
+ return Yii::t('ContentModule.base', 'The author of this content is not allowed to create private content within the selected space.');
}
if($this->isPublic() && !$ownerPermissions->can(CreatePublicContent::class)) {
- return Yii::t('ContentModel.base', 'The author of this content is not allowed to create public content within the selected space.');
+ return Yii::t('ContentModule.base', 'The author of this content is not allowed to create public content within the selected space.');
}
return true;
diff --git a/protected/humhub/modules/content/models/forms/MoveContentForm.php b/protected/humhub/modules/content/models/forms/MoveContentForm.php
new file mode 100644
index 0000000000..7241bf7ff9
--- /dev/null
+++ b/protected/humhub/modules/content/models/forms/MoveContentForm.php
@@ -0,0 +1,93 @@
+content = Content::findOne(['id' => $this->id]);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function rules()
+ {
+ return [
+ [['target'], 'validateTarget']
+ ];
+ }
+
+ public function validateTarget($attribute, $params, $validator)
+ {
+ $targetContainer = $this->getTargetContainer();
+
+ if(!$targetContainer) {
+ $this->addError($attribute, Yii::t('ContentModule.base', 'Invalid space selection.'));
+ } else {
+ $result = $this->content->canMove($targetContainer);
+ if($result !== true) {
+ $this->addError($attribute, $result);
+ }
+ }
+ }
+
+ /**
+ * @return Space|null
+ */
+ public function getTargetContainer()
+ {
+ if(!$this->targetContainer) {
+ $target = isset($this->target[0]) ? $this->target[0] : null;
+
+ if($target) {
+ $this->targetContainer = Space::findOne(['guid' => $target]);
+ }
+ }
+
+ return $this->targetContainer;
+ }
+
+ public function save()
+ {
+ if(!$this->validate()) {
+ return false;
+ }
+
+ $this->content->move($this->getTargetContainer());
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/protected/humhub/modules/content/resources/js/humhub.content.js b/protected/humhub/modules/content/resources/js/humhub.content.js
index 5bfe6ebe5f..a808f63f1c 100644
--- a/protected/humhub/modules/content/resources/js/humhub.content.js
+++ b/protected/humhub/modules/content/resources/js/humhub.content.js
@@ -117,6 +117,18 @@ humhub.module('content', function (module, require, $) {
});
};
+ var submitMove = function(evt) {
+ debugger;
+ modal.submit(evt).then(function(response) {
+ if(response.success) {
+ if(response.message) {
+ module.log.success(response.message);
+ }
+ event.trigger('humhub:content:afterMove', response);
+ }
+ });
+ };
+
var templates = {
permalinkBody: '