diff --git a/protected/humhub/docs/CHANGELOG.md b/protected/humhub/docs/CHANGELOG.md index 5975e0154a..c28cec4182 100644 --- a/protected/humhub/docs/CHANGELOG.md +++ b/protected/humhub/docs/CHANGELOG.md @@ -37,7 +37,7 @@ HumHub Change Log - Enh: Added `humhub\modules\content\widgets\richtext\ProsemirrorRichText::parseOutput` for pre render parsing - Enh: Added `humhub.modules.file.getFileUrl` and `humhub.modules.file.filterFileUrl` for file guid based url handling - Fix: `humhub\modules\space\modules\manage\components\Controller` only accessible by system admins - +- Enh: Added scheme paramter to Content::getUrl method 1.3.1 (August 7, 2018) diff --git a/protected/humhub/modules/comment/models/Comment.php b/protected/humhub/modules/comment/models/Comment.php index 46740d4ec8..a82d0cb867 100644 --- a/protected/humhub/modules/comment/models/Comment.php +++ b/protected/humhub/modules/comment/models/Comment.php @@ -194,7 +194,7 @@ class Comment extends ContentAddonActiveRecord implements ContentOwner * @param $id * @param int $limit * - * @return array|mixed|\yii\db\ActiveRecord[] + * @return Comment[] the comments */ public static function GetCommentsLimited($model, $id, $limit = 2) { diff --git a/protected/humhub/modules/content/models/Content.php b/protected/humhub/modules/content/models/Content.php index 5a5e665334..048633d1d3 100644 --- a/protected/humhub/modules/content/models/Content.php +++ b/protected/humhub/modules/content/models/Content.php @@ -25,6 +25,7 @@ use humhub\modules\user\models\User; use Yii; use yii\base\Exception; use yii\base\InvalidArgumentException; +use yii\db\IntegrityException; use yii\helpers\Url; /** @@ -493,7 +494,7 @@ class Content extends ContentDeprecated implements Movable, ContentOwner */ public function checkMovePermission(ContentContainerActiveRecord $container = null) { - if(!$container) { + if (!$container) { $container = $this->container; } return $this->getModel()->isOwner() || Yii::$app->user->can(ManageUsers::class) || $container->can(ManageContent::class); @@ -502,7 +503,10 @@ class Content extends ContentDeprecated implements Movable, ContentOwner /** * {@inheritdoc} */ - public function afterMove(ContentContainerActiveRecord $container = null){/* Nothing to do */} + public function afterMove(ContentContainerActiveRecord $container = null) + { + // Nothing to do + } /** * Unarchives the content object @@ -526,14 +530,20 @@ class Content extends ContentDeprecated implements Movable, ContentOwner * e.g. in case there is no wall entry available for this content. * * @since 0.11.1 + * @param boolean $scheme + * @return string the URL */ - public function getUrl() + public function getUrl($scheme = false) { - if (method_exists($this->getPolymorphicRelation(), 'getUrl')) { - return $this->getPolymorphicRelation()->getUrl(); + try { + if (method_exists($this->getPolymorphicRelation(), 'getUrl')) { + return $this->getPolymorphicRelation()->getUrl($scheme); + } + } catch (IntegrityException $e) { + Yii::error($e->getMessage(), 'content'); } - return Url::toRoute(['/content/perma', 'id' => $this->id]); + return Url::toRoute(['/content/perma', 'id' => $this->id], $scheme); } /** @@ -662,7 +672,7 @@ class Content extends ContentDeprecated implements Movable, ContentOwner if ($user === null) { $user = Yii::$app->user->getIdentity(); - } else if(!($user instanceof User)) { + } else if (!($user instanceof User)) { $user = User::findOne(['id' => $user]); } @@ -728,7 +738,7 @@ class Content extends ContentDeprecated implements Movable, ContentOwner { if (!$user && !Yii::$app->user->isGuest) { $user = Yii::$app->user->getIdentity(); - } else if(! $user instanceof User) { + } else if (!$user instanceof User) { $user = User::findOne(['id' => $user]); } diff --git a/protected/humhub/modules/user/models/User.php b/protected/humhub/modules/user/models/User.php index 7d4f2f0806..d369c1a19d 100644 --- a/protected/humhub/modules/user/models/User.php +++ b/protected/humhub/modules/user/models/User.php @@ -53,6 +53,8 @@ use yii\base\Exception; * @property integer $visibility * @property integer $contentcontainer_id * @property Profile $profile + * + * @property string $displayName */ class User extends ContentContainerActiveRecord implements IdentityInterface, Searchable {