diff --git a/CHANGELOG.md b/CHANGELOG.md index a2300f7719..c1c01b6665 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,8 +6,10 @@ HumHub Changelog - Fix #4668: table-responsive tables do not overflow due to default word break style - Fix #4679: Richtext extension scan does not include full title if title contains a `)` - Fix #4714: Use HTTPS protocol for default OEmbed endpoint URLs -- Fix #4649: SSuccess message although password save error +- Fix #4649: Success message rendered although password validation failed - Fix #4717: Repsonsive layout alignment issue on small screens +- Fix #4717: Repsonsive layout alignment issue on small screens +- Fix #4715: Call to `Content::canArchive()` throws error on global content 1.7.1 (November 27, 2020) diff --git a/protected/humhub/modules/content/models/Content.php b/protected/humhub/modules/content/models/Content.php index b0613a1782..e45ef18469 100644 --- a/protected/humhub/modules/content/models/Content.php +++ b/protected/humhub/modules/content/models/Content.php @@ -409,6 +409,16 @@ class Content extends ActiveRecord implements Movable, ContentOwner */ public function canArchive() { + // Currently global content can not be archived + if (!$this->contentcontainer_id) { + return false; + } + + // No need to archive content on an archived container, content is marked as archived already + if ($this->content->content->getContainer()->isArchived()) { + return false; + } + return $this->getContainer()->permissionManager->can(new ManageContent()); } @@ -572,9 +582,9 @@ class Content extends ActiveRecord implements Movable, ContentOwner * HActiveRecordContent (e.g. Post) to overwrite this behavior. * e.g. in case there is no wall entry available for this content. * - * @since 0.11.1 * @param boolean $scheme * @return string the URL + * @since 0.11.1 */ public function getUrl($scheme = false) { @@ -627,8 +637,8 @@ class Content extends ActiveRecord implements Movable, ContentOwner * Relation to ContentContainer model * Note: this is not a Space or User instance! * - * @since 1.1 * @return \yii\db\ActiveQuery + * @since 1.1 */ public function getContentContainer() { @@ -638,8 +648,8 @@ class Content extends ActiveRecord implements Movable, ContentOwner /** * Returns the ContentTagRelation query. * - * @since 1.2.2 * @return \yii\db\ActiveQuery + * @since 1.2.2 */ public function getTagRelations() { @@ -649,8 +659,8 @@ class Content extends ActiveRecord implements Movable, ContentOwner /** * Returns all content related tags ContentTags related to this content. * - * @since 1.2.2 * @return \yii\db\ActiveQuery + * @since 1.2.2 */ public function getTags($tagClass = ContentTag::class) { @@ -660,9 +670,9 @@ class Content extends ActiveRecord implements Movable, ContentOwner /** * Adds a new ContentTagRelation for this content and the given $tag instance. * - * @since 1.2.2 * @param ContentTag $tag * @return bool if the provided tag is part of another ContentContainer + * @since 1.2.2 */ public function addTag(ContentTag $tag) { @@ -683,8 +693,8 @@ class Content extends ActiveRecord implements Movable, ContentOwner /** * Adds the given ContentTag array to this content. * - * @since 1.3 * @param $tags ContentTag[] + * @since 1.3 */ public function addTags($tags) { @@ -770,11 +780,11 @@ class Content extends ActiveRecord implements Movable, ContentOwner /** * Checks if user can view this content. * - * @since 1.1 * @param User|integer $user * @return boolean can view this content * @throws Exception * @throws \Throwable + * @since 1.1 */ public function canView($user = null) { @@ -785,7 +795,7 @@ class Content extends ActiveRecord implements Movable, ContentOwner } // Check global content visibility, private global content is visible for all users - if(empty($this->contentcontainer_id) && !Yii::$app->user->isGuest) { + if (empty($this->contentcontainer_id) && !Yii::$app->user->isGuest) { return true; } @@ -833,15 +843,15 @@ class Content extends ActiveRecord implements Movable, ContentOwner } // GLobal content - if(!$this->container) { + if (!$this->container) { return $this->isPublic(); } - if($this->container instanceof Space) { + if ($this->container instanceof Space) { return $this->isPublic() && $this->container->visibility == Space::VISIBILITY_ALL; } - if($this->container instanceof User) { + if ($this->container instanceof User) { return $this->isPublic() && $this->container->visibility == User::VISIBILITY_ALL; } diff --git a/protected/humhub/modules/content/widgets/ArchiveLink.php b/protected/humhub/modules/content/widgets/ArchiveLink.php index a8656af740..d93fa3b7aa 100644 --- a/protected/humhub/modules/content/widgets/ArchiveLink.php +++ b/protected/humhub/modules/content/widgets/ArchiveLink.php @@ -32,8 +32,8 @@ class ArchiveLink extends \yii\base\Widget */ public function run() { - if (!$this->content->content->canArchive() || $this->content->content->getContainer()->isArchived()) { - return; + if (!$this->content->content->canArchive()) { + return ''; } return $this->render('archiveLink', [