Class humhub\modules\content\components\ContentAddonActiveRecord

Inheritancehumhub\modules\content\components\ContentAddonActiveRecord » humhub\components\ActiveRecord » yii\db\ActiveRecord
ImplementsSerializable, humhub\modules\content\interfaces\ContentOwner
Subclasseshumhub\modules\comment\models\Comment, humhub\modules\like\models\Like
Available since version0.5

HActiveRecordContentAddon is the base active record for content addons.

Content addons are content types like Comments, Files or Likes. These are always belongs to a Content object.

Mandatory fields:

  • created_by
  • created_at
  • updated_by
  • updated_at

Protected Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$automaticContentFollowing boolean Automatic following of the addon creator to the related content humhub\modules\content\components\ContentAddonActiveRecord
$updateContentStreamSort boolean Also update underlying contents last update stream sorting humhub\modules\content\components\ContentAddonActiveRecord

Public Methods

Hide inherited methods

MethodDescriptionDefined By
afterSave() After saving content addon, mark underlying content as updated. humhub\modules\content\components\ContentAddonActiveRecord
beforeSave() humhub\components\ActiveRecord
canDelete() Checks if the given / or current user can delete this content. humhub\modules\content\components\ContentAddonActiveRecord
canEdit() Checks if this record can be edited humhub\modules\content\components\ContentAddonActiveRecord
canRead() Check if current user can read this object humhub\modules\content\components\ContentAddonActiveRecord
canWrite() Checks if this content addon can be changed humhub\modules\content\components\ContentAddonActiveRecord
getContent() Returns the content object to which this addon belongs to. humhub\modules\content\components\ContentAddonActiveRecord
getContentDescription() Returns a text preview of this content. humhub\modules\content\components\ContentAddonActiveRecord
getContentName() Returns a title for this type of content. humhub\modules\content\components\ContentAddonActiveRecord
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
getSource() Returns the source of this content addon. humhub\modules\content\components\ContentAddonActiveRecord
getUniqueId() Returns a unique id for this record/model humhub\components\ActiveRecord
getUpdatedBy() Relation to User defined in updated_by attribute humhub\components\ActiveRecord
getUser() humhub\modules\content\components\ContentAddonActiveRecord
serialize() Serializes attributes and oldAttributes of this record. humhub\components\ActiveRecord
unserialize() Unserializes the given string, calls the init() function and sets the attributes and oldAttributes. humhub\components\ActiveRecord
validate() Validates humhub\modules\content\components\ContentAddonActiveRecord

Property Details

$automaticContentFollowing protected property

Automatic following of the addon creator to the related content

$updateContentStreamSort protected property

Also update underlying contents last update stream sorting

Method Details

afterSave() public method

After saving content addon, mark underlying content as updated.

public boolean afterSave ( $insert, $changedAttributes )
$insert
$changedAttributes
canDelete() public method

Checks if the given / or current user can delete this content.

Currently only the creator can remove.

public boolean canDelete ( )
canEdit() public method (available since version 1.4)

Checks if this record can be edited

public boolean canEdit ( humhub\modules\user\models\User $user null )
$user humhub\modules\user\models\User|null

The user

canRead() public method

Check if current user can read this object

public boolean canRead ( )
canWrite() public method
Deprecated since 1.4

Checks if this content addon can be changed

public boolean canWrite ( )
getContent() public method

Returns the content object to which this addon belongs to.

public humhub\modules\content\models\Content getContent ( )
return humhub\modules\content\models\Content

Content AR which this Addon belongs to

getContentDescription() public method

Returns a text preview of this content.

This method should be overwritten in the content implementation.

public string getContentDescription ( )
getContentName() public method

Returns a title for this type of content.

This method should be overwritten in the content implementation.

public string getContentName ( )
getSource() public method

Returns the source of this content addon.

public humhub\modules\content\components\ContentAddonActiveRecord|humhub\modules\content\components\ContentActiveRecord getSource ( )
return humhub\modules\content\components\ContentAddonActiveRecord|humhub\modules\content\components\ContentActiveRecord

The model which this addon belongs to

getUser() public method

public void getUser ( )
validate() public method

Validates

public \humhub\modules\content\components\type validate ( $attributes null, $clearErrors true )
$attributes \humhub\modules\content\components\type
$clearErrors \humhub\modules\content\components\type