mirror of
https://github.com/humhub/humhub.git
synced 2025-03-14 12:09:44 +01:00
- Moved Move logic to humhub\modules\content\controllers\MoveController.php
- Enh: Added disable behaviour for non movable target spaces - Fix: Invalid message source error in space permissions
This commit is contained in:
parent
ffc1fb9011
commit
540e3013d7
@ -60,3 +60,6 @@ HumHub Change Log - v1.3-dev Branch
|
||||
- Chg: MySQL queue is now the default job queuing driver
|
||||
- Enh: Add steps to using Facebook Oauth (@Felli)
|
||||
- Enh: Added css `footer-nav` class for footer navigation
|
||||
- Enh: Added Pin/Archived/Public wallentry icons
|
||||
- Enh: Added move content behavior by means of a `humhub\modules\content\models\Movable` interface
|
||||
|
||||
|
@ -8,8 +8,6 @@
|
||||
|
||||
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;
|
||||
@ -268,28 +266,6 @@ 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]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: kingb
|
||||
* Date: 01.07.2018
|
||||
* Time: 14:56
|
||||
*/
|
||||
|
||||
namespace humhub\modules\content\controllers;
|
||||
|
||||
|
||||
use HttpException;
|
||||
use humhub\libs\Html;
|
||||
use humhub\modules\content\components\ContentContainerController;
|
||||
use humhub\modules\content\models\Content;
|
||||
use humhub\modules\content\models\forms\MoveContentForm;
|
||||
use humhub\modules\space\models\Space;
|
||||
use humhub\modules\space\widgets\Chooser;
|
||||
use Yii;
|
||||
|
||||
class MoveController extends ContentContainerController
|
||||
{
|
||||
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]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a workspace list by json
|
||||
*
|
||||
* It can be filtered by by keyword.
|
||||
*/
|
||||
public function actionSearch($contentId, $keyword, $page = 1)
|
||||
{
|
||||
$limit = (int) Yii::$app->request->get('limit', Yii::$app->settings->get('paginationSize'));
|
||||
|
||||
$searchResultSet = Yii::$app->search->find($keyword, [
|
||||
'model' => Space::class,
|
||||
'page' => $page,
|
||||
'pageSize' => $limit
|
||||
]);
|
||||
|
||||
return $this->prepareResult($searchResultSet, Content::findOne(['id' => $contentId]));
|
||||
}
|
||||
|
||||
protected function prepareResult($searchResultSet, Content $content)
|
||||
{
|
||||
$json = [];
|
||||
foreach ($searchResultSet->getResultInstances() as $space) {
|
||||
$result = Chooser::getSpaceResult($space, false);
|
||||
|
||||
$canMove = $content->canMove($space);
|
||||
if($canMove !== true) {
|
||||
$result['disabled'] = true;
|
||||
$result['disabledText'] = $canMove;
|
||||
}
|
||||
|
||||
$json[] = $result;
|
||||
}
|
||||
|
||||
return $this->asJson($json);
|
||||
}
|
||||
}
|
@ -422,6 +422,10 @@ class Content extends ContentDeprecated implements Movable
|
||||
return true;
|
||||
}
|
||||
|
||||
if($container->contentcontainer_id === $this->contentcontainer_id) {
|
||||
return Yii::t('ContentModule.base', 'The content can\'t be moved to its current space.');
|
||||
}
|
||||
|
||||
// Check if the related module is installed on the target space
|
||||
if(!$container->moduleManager->isEnabled($model->getModuleId())) {
|
||||
$module = Yii::$app->getModule($model->getModuleId());
|
||||
|
@ -72,6 +72,11 @@ class MoveContentForm extends Model
|
||||
}
|
||||
}
|
||||
|
||||
public function getSearchUrl()
|
||||
{
|
||||
return $this->content->container->createUrl('/content/move/search', ['contentId' => $this->content->id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Space|null
|
||||
*/
|
||||
|
@ -10,6 +10,7 @@ namespace humhub\modules\content\permissions;
|
||||
|
||||
use humhub\modules\space\models\Space;
|
||||
use humhub\modules\user\models\User;
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* CreatePublicContent Permission
|
||||
|
@ -12,7 +12,11 @@ use humhub\widgets\Button;
|
||||
<?php ModalDialog::begin(['header' => Yii::t('ContentModule.base', '<strong>Move</strong> content')]) ?>
|
||||
<?php $form = ActiveForm::begin() ?>
|
||||
<div class="modal-body">
|
||||
<?= $form->field($model, 'target')->widget(SpacePickerField::class, ['maxSelection' => 1, 'focus' => true])?>
|
||||
<?= $form->field($model, 'target')->widget(SpacePickerField::class, [
|
||||
'maxSelection' => 1,
|
||||
'focus' => true,
|
||||
'url' => $model->getSearchUrl()
|
||||
])?>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<?= Button::primary(Yii::t('base', 'Save'))->action('content.submitMove')->loader(true) ?>
|
@ -47,7 +47,7 @@ class MoveContentLink extends WallEntryControlLink
|
||||
* @inheritdocs
|
||||
*/
|
||||
public function getActionUrl() {
|
||||
return $this->model->content->container->createUrl('/content/content/move', ['id' => $this->model->content->id]);
|
||||
return $this->model->content->container->createUrl('/content/move/move', ['id' => $this->model->content->id]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -55,6 +55,6 @@ class MoveContentLink extends WallEntryControlLink
|
||||
*/
|
||||
public function preventRender()
|
||||
{
|
||||
return !$this->model->isOwner() || !$this->model->content->container->can(ManageContent::class);
|
||||
return !$this->model->isOwner() && !$this->model->content->container->can(ManageContent::class);
|
||||
}
|
||||
}
|
@ -31,7 +31,7 @@ class BrowseController extends Controller
|
||||
{
|
||||
return [
|
||||
'acl' => [
|
||||
'class' => AccessControl::className(),
|
||||
'class' => AccessControl::class,
|
||||
'guestAllowedActions' => ['search-json']
|
||||
]
|
||||
];
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
namespace humhub\modules\space\widgets;
|
||||
|
||||
use humhub\widgets\BasePickerField;
|
||||
use humhub\modules\space\models\Space;
|
||||
use humhub\modules\ui\form\widgets\BasePicker;
|
||||
use Yii;
|
||||
use yii\helpers\Html;
|
||||
|
||||
@ -14,7 +14,7 @@ use yii\helpers\Html;
|
||||
* @since 1.2
|
||||
* @author buddha
|
||||
*/
|
||||
class SpacePickerField extends BasePickerField
|
||||
class SpacePickerField extends BasePicker
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
|
@ -48,7 +48,7 @@ class AddTopic extends BasePermission
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return Yii::t('MeetingModule.meeting', 'Add Topics');
|
||||
return Yii::t('TopicModule.meeting', 'Add Topics');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -56,6 +56,6 @@ class AddTopic extends BasePermission
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return Yii::t('CommentModule.permissions', 'Can add new topics');
|
||||
return Yii::t('TopicModule.permissions', 'Can add new topics');
|
||||
}
|
||||
}
|
@ -48,7 +48,7 @@ class ManageTopics extends BasePermission
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return Yii::t('MeetingModule.meeting', 'Manage Topics');
|
||||
return Yii::t('TopicModule.meeting', 'Manage Topics');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -56,6 +56,6 @@ class ManageTopics extends BasePermission
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return Yii::t('CommentModule.permissions', 'Can edit and remove topics');
|
||||
return Yii::t('TopicModule.permissions', 'Can edit and remove topics');
|
||||
}
|
||||
}
|
@ -404,7 +404,7 @@ abstract class BasePicker extends JsInputWidget
|
||||
$result = [
|
||||
'add-options' => $this->addOptions,
|
||||
'picker-url' => $this->getUrl(),
|
||||
'picker-focus' => ($this->focus) ? 'true' : null,
|
||||
'picker-focus' => ($this->focus) ? 1 : null,
|
||||
'disabled-items' => (!$this->disabledItems) ? null : $this->disabledItems,
|
||||
'maximum-selection-length' => $this->maxSelection,
|
||||
'maximum-input-length' => $this->maxInput,
|
||||
|
Loading…
x
Reference in New Issue
Block a user