mirror of
https://github.com/humhub/humhub.git
synced 2025-03-04 07:08:58 +01:00
Enh: Added option to hide attached files on wall entries
This commit is contained in:
parent
16cdcf7ff7
commit
25c521e3b9
@ -113,18 +113,34 @@ class ContentActiveRecord extends ActiveRecord implements \humhub\modules\conten
|
||||
/**
|
||||
* Returns the wall output widget of this content.
|
||||
*
|
||||
* @param array $params optional parameters to WallEntryWidget
|
||||
* @param array $params optional parameters for WallEntryWidget
|
||||
* @return string
|
||||
*/
|
||||
public function getWallOut($params = [])
|
||||
{
|
||||
if ($this->wallEntryClass !== "") {
|
||||
$wallEntryWidget = $this->getWallEntryWidget();
|
||||
if ($wallEntryWidget !== null) {
|
||||
Yii::configure($wallEntryWidget, $params);
|
||||
return $wallEntryWidget->renderWallEntry();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the assigned wall entry widget instance
|
||||
*
|
||||
* @return \humhub\modules\content\widgets\WallEntry
|
||||
*/
|
||||
public function getWallEntryWidget()
|
||||
{
|
||||
if ($this->wallEntryClass !== '') {
|
||||
$class = $this->wallEntryClass;
|
||||
$params['contentObject'] = $this;
|
||||
return $class::widget($params);
|
||||
$widget = new $class;
|
||||
$widget->contentObject = $this;
|
||||
return §widget;
|
||||
}
|
||||
|
||||
return "";
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,6 +49,11 @@ class WallEntry extends Widget
|
||||
*/
|
||||
public $wallEntryLayout = "@humhub/modules/content/widgets/views/wallEntry.php";
|
||||
|
||||
/**
|
||||
* @var boolean show files widget containing a list of all assigned files
|
||||
*/
|
||||
public $showFiles = true;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
@ -83,4 +88,28 @@ class WallEntry extends Widget
|
||||
return \yii\helpers\Url::to([$this->editRoute, 'id' => $this->contentObject->id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the wall entry output
|
||||
*
|
||||
* @return string the output
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function renderWallEntry()
|
||||
{
|
||||
ob_start();
|
||||
ob_implicit_flush(false);
|
||||
try {
|
||||
$out = $this->render($this->wallEntryLayout, [
|
||||
'content' => $this->run(),
|
||||
'object' => $this->contentObject,
|
||||
'wallEntryWidget' => $this
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
ob_end_clean();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return ob_get_clean() . $out;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,6 +23,13 @@ class ShowFiles extends \yii\base\Widget
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$widget = $this->object->getWallEntryWidget();
|
||||
|
||||
// File widget disabled in this wall entry
|
||||
if ($widget->showFiles === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$blacklisted_objects = explode(',', Setting::GetText('showFilesWidgetBlacklist', 'file'));
|
||||
if (!in_array(get_class($this->object), $blacklisted_objects)) {
|
||||
$files = \humhub\modules\file\models\File::getFilesOfObject($this->object);
|
||||
|
Loading…
x
Reference in New Issue
Block a user