Class humhub\modules\content\models\Content

Inheritancehumhub\modules\content\models\Content » humhub\modules\content\models\ContentDeprecated » humhub\components\ActiveRecord » yii\db\ActiveRecord
ImplementsSerializable, humhub\modules\content\interfaces\ContentOwner, humhub\modules\content\models\Movable
Available since version0.5

This is the model class for table "content".

The followings are the available columns in table 'content':

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$muteDefaultSocialActivities boolean Flag to disable the creation of default social activities like activity and notifications in afterSave() at content creation. humhub\modules\content\models\Content
$notifyUsersOfNewContent array User humhub\modules\content\models\Content

Protected Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$_container humhub\modules\content\components\ContentContainerActiveRecord The Container (e.g. Space or User) where this content belongs to. humhub\modules\content\models\Content

Public Methods

Hide inherited methods

MethodDescriptionDefined By
Get() Returns a Content Object by given Class and ID humhub\modules\content\models\Content
addTag() Adds a new ContentTagRelation for this content and the given $tag instance. humhub\modules\content\models\Content
addTags() Adds the given ContentTag array to this content. humhub\modules\content\models\Content
afterDelete() humhub\modules\content\models\Content
afterMove() {@inheritdoc} humhub\modules\content\models\Content
afterSave() humhub\modules\content\models\Content
archive() Archives the content object humhub\modules\content\models\Content
beforeSave() humhub\modules\content\models\Content
behaviors() humhub\modules\content\models\Content
can() Checks the given $permission of the current user in the contents content container. humhub\modules\content\models\Content
canArchive() Checks if the current user can archive this content. humhub\modules\content\models\Content
canDelete() Checks if the content can be deleted Note: Use canEdit method instead. humhub\modules\content\models\ContentDeprecated
canEdit() Checks if the given user can edit this content. humhub\modules\content\models\Content
canMove() {@inheritdoc} humhub\modules\content\models\Content
canPin() Checks if the user can pin this content. humhub\modules\content\models\Content
canRead() Checks if this content can readed Note: use canView method instead humhub\modules\content\models\ContentDeprecated
canView() Checks if user can view this content. humhub\modules\content\models\Content
canWrite() Checks if this content can be changed Note: use canEdit method instead humhub\modules\content\models\ContentDeprecated
checkGuestAccess() Determines if a guest user is able to read this content. humhub\modules\content\models\Content
checkMovePermission() Checks if the current user has generally the permission to move this content on the given container or the current container if no container was provided. humhub\modules\content\models\Content
countPinnedItems() Creates a list of pinned content objects of the wall humhub\modules\content\models\Content
getContainer() Returns the content container (e.g. space or user record) of this content humhub\modules\content\models\Content
getContent() humhub\modules\content\models\Content
getContentContainer() Relation to ContentContainer model Note: this is not a Space or User instance! humhub\modules\content\models\Content
getContentDescription() humhub\modules\content\models\Content
getContentName() humhub\modules\content\models\Content
getCreatedBy() Relation to User defined in created_by attribute humhub\components\ActiveRecord
getErrorMessage() Returns the errors as string for all attribute or a single attribute. humhub\components\ActiveRecord
getFileManager() Returns the file manager for this record humhub\components\ActiveRecord
getModel() humhub\modules\content\models\Content
getSpace() Return space (if this content assigned to a space) Note: Use container attribute instead humhub\modules\content\models\ContentDeprecated
getTagRelations() Returns the ContentTagRelation query. humhub\modules\content\models\Content
getTags() Returns all content related tags ContentTags related to this content. humhub\modules\content\models\Content
getUniqueId() Returns a unique id for this record/model humhub\components\ActiveRecord
getUpdatedBy() Relation to User defined in updated_by attribute humhub\components\ActiveRecord
getUrl() Returns the url of this content. humhub\modules\content\models\Content
getUser() User which created this Content Note: Use createdBy attribute instead. humhub\modules\content\models\ContentDeprecated
getVisibility() Returns the visibility of the content object humhub\modules\content\models\Content
isArchived() Checks if current content object is archived humhub\modules\content\models\Content
isModelMovable() humhub\modules\content\models\Content
isPinned() Checks if the content object is pinned humhub\modules\content\models\Content
isPrivate() Checks if the content visiblity is set to private. humhub\modules\content\models\Content
isPublic() Checks if the content visiblity is set to public. humhub\modules\content\models\Content
move() {@inheritdoc} humhub\modules\content\models\Content
pin() Pins the content object humhub\modules\content\models\Content
rules() humhub\modules\content\models\Content
serialize() Serializes attributes and oldAttributes of this record. humhub\components\ActiveRecord
setContainer() Sets container (e.g. space or user record) for this content. humhub\modules\content\models\Content
tableName() humhub\modules\content\models\Content
unarchive() Unarchives the content object humhub\modules\content\models\Content
unpin() Unpins the content object humhub\modules\content\models\Content
unserialize() Unserializes the given string, calls the init() function and sets the attributes and oldAttributes. humhub\components\ActiveRecord
updateStreamSortTime() Updates the wall/stream sorting time of this content for "updated at" sorting humhub\modules\content\models\Content

Constants

Hide inherited constants

ConstantValueDescriptionDefined By
VISIBILITY_OWNER 2 humhub\modules\content\models\Content
VISIBILITY_PRIVATE 0 humhub\modules\content\models\Content
VISIBILITY_PUBLIC 1 humhub\modules\content\models\Content

Property Details

$_container protected property

The Container (e.g. Space or User) where this content belongs to.

$muteDefaultSocialActivities public property
Deprecated since v1.2.3 use ContentActiveRecord::silentContentCreation instead.

Flag to disable the creation of default social activities like activity and notifications in afterSave() at content creation.

$notifyUsersOfNewContent public property

User

Method Details

Get() public static method

Returns a Content Object by given Class and ID

public static void Get ( $className, $id )
$className string

Class Name of the Content

$id integer

Primary Key

addTag() public method (available since version 1.2.2)

Adds a new ContentTagRelation for this content and the given $tag instance.

public boolean addTag ( humhub\modules\content\models\ContentTag $tag )
$tag humhub\modules\content\models\ContentTag
return boolean

If the provided tag is part of another ContentContainer

addTags() public method (available since version 1.3)

Adds the given ContentTag array to this content.

public void addTags ( $tags )
$tags

ContentTag[]

afterDelete() public method

public void afterDelete ( )
afterMove() public method

{@inheritdoc}

public void afterMove ( humhub\modules\content\components\ContentContainerActiveRecord $container null )
$container
afterSave() public method

public void afterSave ( $insert, $changedAttributes )
$insert
$changedAttributes
archive() public method

Archives the content object

public void archive ( )
beforeSave() public method

public void beforeSave ( $insert )
$insert
behaviors() public method

public void behaviors ( )
can() public method (available since version 1.2.1)

Checks the given $permission of the current user in the contents content container.

This is short for $this->getContainer()->getPermissionManager()->can().

See also humhub\modules\user\components\PermissionManager::can().

public boolean can ( $permission, $params = [], $allowCaching true )
$permission
$params array
$allowCaching boolean
throws \yii\base\Exception
throws \yii\base\InvalidConfigException
canArchive() public method

Checks if the current user can archive this content.

The content owner and the workspace admin can archive contents.

public boolean canArchive ( )
canEdit() public method (available since version 1.1)

Checks if the given user can edit this content.

A user can edit a content if one of the following conditions are met:

  • User is the owner of the content
  • User is system administrator and the content module setting adminCanEditAllContent is set to true (default)
  • The user is granted the managePermission set by the model record class
  • The user meets the additional condition implemented by the model records class own canEdit() function.
public boolean canEdit ( $user null )
$user humhub\modules\user\models\User|integer

User instance or user id

return boolean

Can edit this content

canMove() public method

{@inheritdoc}

public void canMove ( humhub\modules\content\components\ContentContainerActiveRecord $container null )
$container
canPin() public method

Checks if the user can pin this content.

This is only allowed for workspace owner.

public boolean canPin ( )
canView() public method (available since version 1.1)

Checks if user can view this content.

public boolean canView ( $user null )
$user humhub\modules\user\models\User|integer
return boolean

Can view this content

throws \yii\base\Exception
throws Throwable
checkGuestAccess() public method

Determines if a guest user is able to read this content.

This is the case if all of the following conditions are met:

  • The content is public
  • The auth.allowGuestAccess module setting is enabled
  • The space or profile visibility is set to VISIBILITY_ALL
public boolean checkGuestAccess ( )
checkMovePermission() public method

Checks if the current user has generally the permission to move this content on the given container or the current container if no container was provided.

Note this function is only used for a general permission check use canMove() for a

This is the case if:

  • The current user is the owner of this content
public boolean checkMovePermission ( humhub\modules\content\components\ContentContainerActiveRecord $container null )
$container humhub\modules\content\components\ContentContainerActiveRecord|null
return boolean

Determines if the current user is generally permitted to move content on the given container (or the related container if no container was provided)

countPinnedItems() public method

Creates a list of pinned content objects of the wall

public Int countPinnedItems ( )
getContainer() public method

Returns the content container (e.g. space or user record) of this content

public humhub\modules\content\components\ContentContainerActiveRecord getContainer ( )
throws \yii\base\Exception
getContent() public method

public void getContent ( )
getContentContainer() public method (available since version 1.1)

Relation to ContentContainer model Note: this is not a Space or User instance!

public \yii\db\ActiveQuery getContentContainer ( )
getContentDescription() public method

public void getContentDescription ( )
getContentName() public method

public void getContentName ( )
getModel() public method (available since version 1.3)

public humhub\modules\content\components\ContentActiveRecord getModel ( )
getTagRelations() public method (available since version 1.2.2)

Returns the ContentTagRelation query.

public \yii\db\ActiveQuery getTagRelations ( )
getTags() public method (available since version 1.2.2)

Returns all content related tags ContentTags related to this content.

public \yii\db\ActiveQuery getTags ( $tagClass = \humhub\modules\content\models\ContentTag::class )
$tagClass
getUrl() public method (available since version 0.11.1)

Returns the url of this content.

By default is returns the url of the wall entry.

Optionally it's possible to create an own getUrl method in the underlying HActiveRecordContent (e.g. Post) to overwrite this behavior. e.g. in case there is no wall entry available for this content.

public string getUrl ( $scheme false )
$scheme boolean
return string

The URL

getVisibility() public method

Returns the visibility of the content object

public Integer getVisibility ( )
isArchived() public method

Checks if current content object is archived

public boolean isArchived ( )
isModelMovable() public method

public void isModelMovable ( humhub\modules\content\components\ContentContainerActiveRecord $container null )
$container
isPinned() public method

Checks if the content object is pinned

public Boolean isPinned ( )
isPrivate() public method

Checks if the content visiblity is set to private.

public boolean isPrivate ( )
isPublic() public method

Checks if the content visiblity is set to public.

public boolean isPublic ( )
move() public method

{@inheritdoc}

public void move ( humhub\modules\content\components\ContentContainerActiveRecord $container null, $force false )
$container
$force
throws Throwable
pin() public method

Pins the content object

public void pin ( )
rules() public method

public void rules ( )
setContainer() public method

Sets container (e.g. space or user record) for this content.

public void setContainer ( humhub\modules\content\components\ContentContainerActiveRecord $container )
$container humhub\modules\content\components\ContentContainerActiveRecord
throws \yii\base\Exception
tableName() public static method

public static void tableName ( )
unarchive() public method

Unarchives the content object

public void unarchive ( )
unpin() public method

Unpins the content object

public void unpin ( )
updateStreamSortTime() public method

Updates the wall/stream sorting time of this content for "updated at" sorting

public void updateStreamSortTime ( )