mirror of
https://github.com/humhub/humhub.git
synced 2025-03-11 02:31:03 +01:00
Enh: Added Make Private/ Make Public link to wall entry controls
Fix: Wallentry loader + badge render issue
This commit is contained in:
parent
844dfa9a65
commit
b6d74b39a3
@ -25,6 +25,7 @@ HumHub Change Log
|
|||||||
- Fix: Default stream sort setting not applied
|
- Fix: Default stream sort setting not applied
|
||||||
- Enh: Show different login message, when registration is disabled
|
- Enh: Show different login message, when registration is disabled
|
||||||
- Fix: Norwegian translation code for Yii messages
|
- Fix: Norwegian translation code for Yii messages
|
||||||
|
- Enh: Added Make Private/ Make Public link to wall entry controls
|
||||||
|
|
||||||
|
|
||||||
1.2.0-beta.3 (March 20, 2017)
|
1.2.0-beta.3 (March 20, 2017)
|
||||||
|
@ -74,6 +74,7 @@ class Events extends \yii\base\Object
|
|||||||
$content = $event->sender->object;
|
$content = $event->sender->object;
|
||||||
|
|
||||||
$stackWidget->addWidget(widgets\DeleteLink::className(), ['content' => $content], ['sortOrder' => 100]);
|
$stackWidget->addWidget(widgets\DeleteLink::className(), ['content' => $content], ['sortOrder' => 100]);
|
||||||
|
$stackWidget->addWidget(widgets\VisibilityLink::className(), ['contentRecord' => $content], ['sortOrder' => 250]);
|
||||||
$stackWidget->addWidget(widgets\NotificationSwitchLink::className(), ['content' => $content], ['sortOrder' => 300]);
|
$stackWidget->addWidget(widgets\NotificationSwitchLink::className(), ['content' => $content], ['sortOrder' => 300]);
|
||||||
$stackWidget->addWidget(widgets\PermaLink::className(), ['content' => $content], ['sortOrder' => 400] );
|
$stackWidget->addWidget(widgets\PermaLink::className(), ['content' => $content], ['sortOrder' => 400] );
|
||||||
$stackWidget->addWidget(widgets\PinLink::className(), ['content' => $content], ['sortOrder' => 500]);
|
$stackWidget->addWidget(widgets\PinLink::className(), ['content' => $content], ['sortOrder' => 500]);
|
||||||
|
@ -12,6 +12,7 @@ use Yii;
|
|||||||
use yii\web\HttpException;
|
use yii\web\HttpException;
|
||||||
use humhub\components\Controller;
|
use humhub\components\Controller;
|
||||||
use humhub\modules\content\models\Content;
|
use humhub\modules\content\models\Content;
|
||||||
|
use humhub\modules\content\permissions\CreatePublicContent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ContentController is responsible for basic content objects.
|
* ContentController is responsible for basic content objects.
|
||||||
@ -110,7 +111,6 @@ class ContentController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function actionUnarchive()
|
public function actionUnarchive()
|
||||||
{
|
{
|
||||||
Yii::$app->response->format = 'json';
|
|
||||||
$this->forcePostRequest();
|
$this->forcePostRequest();
|
||||||
|
|
||||||
$json = array();
|
$json = array();
|
||||||
@ -125,7 +125,39 @@ class ContentController extends Controller
|
|||||||
$json['success'] = true;
|
$json['success'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $json;
|
return $this->asJson($json);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Switches the content visibility for the given content.
|
||||||
|
*
|
||||||
|
* @param type $id content id
|
||||||
|
* @return \yii\web\Response
|
||||||
|
* @throws HttpException
|
||||||
|
*/
|
||||||
|
public function actionToggleVisibility($id)
|
||||||
|
{
|
||||||
|
$this->forcePostRequest();
|
||||||
|
$content = Content::findOne(['id' => $id]);
|
||||||
|
|
||||||
|
if(!$content) {
|
||||||
|
throw new HttpException(400, Yii::t('ContentController.base', 'Invalid content id given!'));
|
||||||
|
} elseif(!$content->canEdit()) {
|
||||||
|
throw new HttpException(403);
|
||||||
|
} elseif($content->isPrivate() && !$content->container->permissionManager->can(new CreatePublicContent())) {
|
||||||
|
throw new HttpException(403);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($content->isPrivate()) {
|
||||||
|
$content->visibility = Content::VISIBILITY_PUBLIC;
|
||||||
|
} else {
|
||||||
|
$content->visibility = Content::VISIBILITY_PRIVATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->asJson([
|
||||||
|
'success' => $content->save(),
|
||||||
|
'state' => $content->visibility
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -135,8 +167,6 @@ class ContentController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function actionPin()
|
public function actionPin()
|
||||||
{
|
{
|
||||||
Yii::$app->response->format = 'json';
|
|
||||||
|
|
||||||
$this->forcePostRequest();
|
$this->forcePostRequest();
|
||||||
|
|
||||||
$json = array();
|
$json = array();
|
||||||
@ -156,7 +186,7 @@ class ContentController extends Controller
|
|||||||
$json['error'] = Yii::t('ContentModule.controllers_ContentController', "Could not load requested object!");
|
$json['error'] = Yii::t('ContentModule.controllers_ContentController', "Could not load requested object!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return $json;
|
return $this->asJson($json);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -166,11 +196,9 @@ class ContentController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function actionUnPin()
|
public function actionUnPin()
|
||||||
{
|
{
|
||||||
Yii::$app->response->format = 'json';
|
|
||||||
|
|
||||||
$this->forcePostRequest();
|
$this->forcePostRequest();
|
||||||
|
|
||||||
$json = array();
|
$json = [];
|
||||||
$json['success'] = false;
|
$json['success'] = false;
|
||||||
|
|
||||||
$content = Content::findOne(['id' => Yii::$app->request->get('id', "")]);
|
$content = Content::findOne(['id' => Yii::$app->request->get('id', "")]);
|
||||||
@ -179,13 +207,11 @@ class ContentController extends Controller
|
|||||||
$json['success'] = true;
|
$json['success'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $json;
|
return $this->asJson($json);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function actionNotificationSwitch()
|
public function actionNotificationSwitch()
|
||||||
{
|
{
|
||||||
Yii::$app->response->format = 'json';
|
|
||||||
|
|
||||||
$this->forcePostRequest();
|
$this->forcePostRequest();
|
||||||
|
|
||||||
$json = array();
|
$json = array();
|
||||||
@ -199,7 +225,7 @@ class ContentController extends Controller
|
|||||||
$json['success'] = true;
|
$json['success'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $json;
|
return $this->asJson($json);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -220,18 +220,23 @@ class Content extends ContentDeprecated
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the public state of the contect object
|
* Checks if the content visiblity is set to public.
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function isPublic()
|
public function isPublic()
|
||||||
{
|
{
|
||||||
|
return $this->visibility === self::VISIBILITY_PUBLIC;
|
||||||
if ($this->visibility == self::VISIBILITY_PUBLIC) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
/**
|
||||||
|
* Checks if the content visiblity is set to private.
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function isPrivate()
|
||||||
|
{
|
||||||
|
return $this->visibility === self::VISIBILITY_PRIVATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
47
protected/humhub/modules/content/widgets/VisibilityLink.php
Normal file
47
protected/humhub/modules/content/widgets/VisibilityLink.php
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @link https://www.humhub.org/
|
||||||
|
* @copyright Copyright (c) 2017 HumHub GmbH & Co. KG
|
||||||
|
* @license https://www.humhub.com/licences
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace humhub\modules\content\widgets;
|
||||||
|
|
||||||
|
use yii\helpers\Url;
|
||||||
|
use humhub\modules\content\permissions\CreatePublicContent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Visibility link for Wall Entries can be used to switch form public to private and vice versa.
|
||||||
|
*
|
||||||
|
* @package humhub.modules_core.wall.widgets
|
||||||
|
* @since 1.2
|
||||||
|
*/
|
||||||
|
class VisibilityLink extends \yii\base\Widget
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \humhub\modules\content\components\ContentActiveRecord
|
||||||
|
*/
|
||||||
|
public $contentRecord;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
$content = $this->contentRecord->content;
|
||||||
|
$contentContainer = $content->container;
|
||||||
|
|
||||||
|
if(!$content->canEdit()) {
|
||||||
|
return;
|
||||||
|
} else if($content->isPrivate() && !$contentContainer->permissionManager->can(new CreatePublicContent())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render('visibilityLink', [
|
||||||
|
'content' => $content,
|
||||||
|
'toggleLink' => Url::to(['/content/content/toggle-visibility', 'id' => $content->id])
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
@ -10,11 +10,11 @@ $unarchiveLink = Url::to(['/content/content/unarchive', 'id' => $id]);
|
|||||||
<li>
|
<li>
|
||||||
<?php if ($object->content->isArchived()): ?>
|
<?php if ($object->content->isArchived()): ?>
|
||||||
<a href="#" data-action-click="unarchive" data-action-url="<?= $unarchiveLink ?>">
|
<a href="#" data-action-click="unarchive" data-action-url="<?= $unarchiveLink ?>">
|
||||||
<i class="fa fa-archive"></i> <?php echo Yii::t('ContentModule.widgets_views_archiveLink', 'Unarchive'); ?>
|
<i class="fa fa-archive"></i> <?= Yii::t('ContentModule.widgets_views_archiveLink', 'Unarchive'); ?>
|
||||||
</a>
|
</a>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<a href="#" data-action-click="archive" data-action-url="<?= $archiveLink ?>">
|
<a href="#" data-action-click="archive" data-action-url="<?= $archiveLink ?>">
|
||||||
<i class="fa fa-archive"></i> <?php echo Yii::t('ContentModule.widgets_views_archiveLink', 'Move to archive'); ?>
|
<i class="fa fa-archive"></i> <?= Yii::t('ContentModule.widgets_views_archiveLink', 'Move to archive'); ?>
|
||||||
</a>
|
</a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</li>
|
</li>
|
||||||
|
@ -22,3 +22,4 @@ use humhub\modules\content\widgets\WallEntry;
|
|||||||
<i class="fa fa-pencil"></i><?= Yii::t('ContentModule.widgets_views_editLink', 'Edit') ?>
|
<i class="fa fa-pencil"></i><?= Yii::t('ContentModule.widgets_views_editLink', 'Edit') ?>
|
||||||
</a>
|
</a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
</li>
|
||||||
|
@ -11,6 +11,7 @@ use humhub\modules\post\models\Post;
|
|||||||
* @since 0.5
|
* @since 0.5
|
||||||
*/
|
*/
|
||||||
?>
|
?>
|
||||||
|
<span class="wallentry-labels">
|
||||||
<?php if ($object->content->isPinned()) : ?>
|
<?php if ($object->content->isPinned()) : ?>
|
||||||
<span class="label label-danger"><?= Yii::t('ContentModule.widgets_views_label', 'Pinned'); ?></span>
|
<span class="label label-danger"><?= Yii::t('ContentModule.widgets_views_label', 'Pinned'); ?></span>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
@ -26,3 +27,4 @@ use humhub\modules\post\models\Post;
|
|||||||
<?php if (!$object instanceof Post) : ?>
|
<?php if (!$object instanceof Post) : ?>
|
||||||
<span class="label label-default"><?= $object->getContentName(); ?></span>
|
<span class="label label-default"><?= $object->getContentName(); ?></span>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
<span>
|
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/* @var $this humhub\components\View */
|
||||||
|
/* @var content humhub\modules\content\models\Content */
|
||||||
|
/* @var $toggleLink string */
|
||||||
|
|
||||||
|
?>
|
||||||
|
<li>
|
||||||
|
<?php if($content->isPrivate()) :?>
|
||||||
|
<a href="#" class="makePublicLink" data-action-click="toggleVisibility" data-action-url="<?= $toggleLink ?>">
|
||||||
|
<i class="fa fa-unlock makePublic"></i> <?= Yii::t('ContentModule.widgets_views_contentForm', 'Make public') ?>
|
||||||
|
</a>
|
||||||
|
<?php else: ?>
|
||||||
|
<a href="#" class="makePriavteLink" data-action-click="toggleVisibility" data-action-url="<?= $toggleLink ?>">
|
||||||
|
<i class="fa fa-lock makePrivate"></i> <?= Yii::t('ContentModule.widgets_views_contentForm', 'Make private') ?>
|
||||||
|
</a>
|
||||||
|
<?php endif; ?>
|
||||||
|
</li>
|
@ -208,10 +208,12 @@ humhub.module('stream', function (module, require, $) {
|
|||||||
var $loader = this.$.find('.stream-entry-loader');
|
var $loader = this.$.find('.stream-entry-loader');
|
||||||
if ($show === false) {
|
if ($show === false) {
|
||||||
loader.reset($loader);
|
loader.reset($loader);
|
||||||
|
this.$.find('.wallentry-labels').show();
|
||||||
this.$.find('.preferences').show();
|
this.$.find('.preferences').show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.$.find('.wallentry-labels').hide();
|
||||||
this.$.find('.preferences').hide();
|
this.$.find('.preferences').hide();
|
||||||
loader.set($loader, {
|
loader.set($loader, {
|
||||||
'position': 'left',
|
'position': 'left',
|
||||||
@ -231,6 +233,23 @@ humhub.module('stream', function (module, require, $) {
|
|||||||
additions.highlight(this.getContent());
|
additions.highlight(this.getContent());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
StreamEntry.prototype.toggleVisibility = function (evt) {
|
||||||
|
this.loader();
|
||||||
|
var that = this;
|
||||||
|
client.post(evt).then(function(response) {
|
||||||
|
if(response.success) {
|
||||||
|
that.reload();
|
||||||
|
module.log.success('saved');
|
||||||
|
} else {
|
||||||
|
module.log.error(response, true);
|
||||||
|
that.loader(false);
|
||||||
|
}
|
||||||
|
}).catch(function (e) {
|
||||||
|
that.loader(false);
|
||||||
|
module.log.error(e, true);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
StreamEntry.prototype.pin = function (evt) {
|
StreamEntry.prototype.pin = function (evt) {
|
||||||
var that = this;
|
var that = this;
|
||||||
this.loader();
|
this.loader();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user