HumHub Documentation (unofficial)

NewComment extends BaseActivity
in package
implements ConfigurableActivityInterface

NewComment activity

Tags
author

luke

Table of Contents

Interfaces

ConfigurableActivityInterface
Interface for configurable activities

Properties

$clickable  : bool
$moduleId  : mixed
$originator  : User
User which performed the activity.
$record  : ActiveRecord
An SocialActivity can be represented in the database as ActiveRecord.
$record  : Activity
An SocialActivity can be represented in the database as ActiveRecord.
$recordClass  : string
$requireOriginator  : bool
$requireSource  : bool
$source  : Comment
$viewName  : mixed
$visibility  : int
Default content visibility of this Activity.

Methods

__call()  : mixed
Calls the named method which is not a class method.
__construct()  : mixed
Constructor.
__get()  : mixed
Returns the value of an object property.
__isset()  : bool
Checks if a property is set, i.e. defined and not null.
__serialize()  : array<string|int, mixed>
Serializes the $source and $originator fields.
__set()  : mixed
Sets value of an object property.
__unserialize()  : mixed
Unserializes the given string, calls the init() function and sets the $source and $originator fields (and $record indirectyl).
__unset()  : mixed
Sets an object property to null.
about()  : $this
Builder function for the source.
asArray()  : mixed
Returns an array representation of this notification.
canGetProperty()  : bool
Returns a value indicating whether a property can be read.
canSetProperty()  : bool
Returns a value indicating whether a property can be set.
className()  : string
Returns the fully qualified name of this class.
container()  : BaseActivity
Builder function for setting ContentContainerActiveRecord
create()  : static
Creates an activity model and determines the contentContainer/visibility
from()  : SocialActivity
Builder function for the originator.
getContent()  : Content
Returns the related content instance in case the source is of type ContentOwner.
getContentContainer()  : ContentContainerActiveRecord
Determines if the activity source is related to an ContentContainer.
getContentInfo()  : string|null
Build info text about a content
getContentName()  : string|null
Returns the content name of $content or if not $content is provided of the notification source.
getContentPlainTextInfo()  : string|null
Builds plain text info text about a given content
getContentPlainTextPreview()  : string|null
Returns a short preview text of the content in plain text. The max length can be defined by setting $maxLength (60 by default).
getContentPreview()  : string|null
Returns a short preview text of the content. The max length can be defined by setting $maxLength (60 by default).
getDescription()  : string
Returns the description of the activity, which is displayed on the configuration page.
getSpace()  : Space
getSpaceId()  : int
getTitle()  : string
Returns the title of the activity, which is displayed on the configuration page.
getUrl()  : string
Url of the origin of this notification If source is a Content / ContentAddon / ContentContainer this will automatically generated.
getViewName()  : string
getViewParams()  : mixed
Returns an array of view parameter, required for rendering.
hasContent()  : bool
Determines if this activity is related to a content. This is the case if the activitiy source is of type ContentOwner.
hasMethod()  : bool
Returns a value indicating whether a method is defined.
hasProperty()  : bool
Returns a value indicating whether a property is defined.
html()  : string
init()  : mixed
Initializes the object.
instance()  : static
Static initializer should be prefered over new initialization, since it makes use of Yii::createObject dependency injection/configuration.
json()  : string
save()  : bool
Stores the activity in database
text()  : string
validate()  : bool
Validates the existence of required attributes
getContentVisibility()  : int
Returns the visibility of the content
getOriginatorId()  : int
Returns the user id of the originator of this activity
saveModelInstance()  : mixed
Saves the underlying Activity model record.

Properties

$moduleId

public mixed $moduleId = 'comment'
Tags
inheritdoc

$record

An SocialActivity can be represented in the database as ActiveRecord.

public ActiveRecord $record

By defining the $recordClass an ActiveRecord will be created automatically within the init function.

The related record for this activitiy

$record

An SocialActivity can be represented in the database as ActiveRecord.

public Activity $record

The related record for this activitiy

$recordClass

public string $recordClass = \humhub\modules\activity\models\Activity::class

Record class used for instantiation.

Tags
inheritdoc

$requireOriginator

public bool $requireOriginator = true

ensure originator existence

Tags
since
1.3

$requireSource

public bool $requireSource = true

ensure source existence

Tags
since
1.3

$viewName

public mixed $viewName = "newComment"
Tags
inheritdoc

$visibility

Default content visibility of this Activity.

public int $visibility = \humhub\modules\content\models\Content::VISIBILITY_PRIVATE

Methods

__call()

Calls the named method which is not a class method.

public __call(string $name, array<string|int, mixed> $params) : mixed

Do not call this method directly as it is a PHP magic method that will be implicitly called when an unknown method is being invoked.

Parameters
$name : string

the method name

$params : array<string|int, mixed>

method parameters

Tags
throws
UnknownMethodException

when calling unknown method

Return values
mixed

the method return value

__construct()

Constructor.

public __construct([array<string|int, mixed> $config = [] ]) : mixed

The default implementation does two things:

  • Initializes the object with the given configuration $config.
  • Call [[init()]].

If this method is overridden in a child class, it is recommended that

  • the last parameter of the constructor is a configuration array, like $config here.
  • call the parent implementation at the end of the constructor.
Parameters
$config : array<string|int, mixed> = []

name-value pairs that will be used to initialize the object properties

__get()

Returns the value of an object property.

public __get(string $name) : mixed

Do not call this method directly as it is a PHP magic method that will be implicitly called when executing $value = $object->property;.

Parameters
$name : string

the property name

Tags
throws
UnknownPropertyException

if the property is not defined

throws
InvalidCallException

if the property is write-only

see
__set()
Return values
mixed

the property value

__isset()

Checks if a property is set, i.e. defined and not null.

public __isset(string $name) : bool

Do not call this method directly as it is a PHP magic method that will be implicitly called when executing isset($object->property).

Note that if the property is not defined, false will be returned.

Parameters
$name : string

the property name or the event name

Tags
see
https://www.php.net/manual/en/function.isset.php
Return values
bool

whether the named property is set (not null).

__set()

Sets value of an object property.

public __set(string $name, mixed $value) : mixed

Do not call this method directly as it is a PHP magic method that will be implicitly called when executing $object->property = $value;.

Parameters
$name : string

the property name or the event name

$value : mixed

the property value

Tags
throws
UnknownPropertyException

if the property is not defined

throws
InvalidCallException

if the property is read-only

see
__get()

__unserialize()

Unserializes the given string, calls the init() function and sets the $source and $originator fields (and $record indirectyl).

public __unserialize(mixed $unserializedArr) : mixed
Parameters
$unserializedArr : mixed
Tags
link
http://php.net/manual/en/function.unserialize.php
see
ActiveRecord::unserialize()

for the serialization of your $source

__unset()

Sets an object property to null.

public __unset(string $name) : mixed

Do not call this method directly as it is a PHP magic method that will be implicitly called when executing unset($object->property).

Note that if the property is not defined, this method will do nothing. If the property is read-only, it will throw an exception.

Parameters
$name : string

the property name

Tags
throws
InvalidCallException

if the property is read only.

see
https://www.php.net/manual/en/function.unset.php

about()

Builder function for the source.

public about(mixed $source) : $this
Parameters
$source : mixed
Tags
inheritdoc
Return values
$this

asArray()

Returns an array representation of this notification.

public asArray(User $user) : mixed
Parameters
$user : User

canGetProperty()

Returns a value indicating whether a property can be read.

public canGetProperty(string $name[, bool $checkVars = true ]) : bool

A property is readable if:

  • the class has a getter method associated with the specified name (in this case, property name is case-insensitive);
  • the class has a member variable with the specified name (when $checkVars is true);
Parameters
$name : string

the property name

$checkVars : bool = true

whether to treat member variables as properties

Tags
see
canSetProperty()
Return values
bool

whether the property can be read

canSetProperty()

Returns a value indicating whether a property can be set.

public canSetProperty(string $name[, bool $checkVars = true ]) : bool

A property is writable if:

  • the class has a setter method associated with the specified name (in this case, property name is case-insensitive);
  • the class has a member variable with the specified name (when $checkVars is true);
Parameters
$name : string

the property name

$checkVars : bool = true

whether to treat member variables as properties

Tags
see
canGetProperty()
Return values
bool

whether the property can be written

className()

Returns the fully qualified name of this class.

public static className() : string
Tags
deprecated

since 2.0.14. On PHP >=5.5, use ::class instead.

Return values
string

the fully qualified name of this class.

create()

Creates an activity model and determines the contentContainer/visibility

public create() : static
Tags
throws
Exception
Return values
static

getContent()

Returns the related content instance in case the source is of type ContentOwner.

public getContent() : Content
Return values
Content

Content ActiveRecord or null if not related to a ContentOwner source

getContentInfo()

Build info text about a content

public getContentInfo([Content $content = null ][, mixed $withContentName = true ]) : string|null

This is a combination of the type of the content with a short preview of it.

If no $content is provided the contentInfo of $source is returned.

Parameters
$content : Content = null
$withContentName : mixed = true
Tags
throws
Exception
Return values
string|null

getContentName()

Returns the content name of $content or if not $content is provided of the notification source.

public getContentName([ContentOwner $content = null ]) : string|null
Parameters
$content : ContentOwner = null
Return values
string|null

getContentPlainTextInfo()

Builds plain text info text about a given content

public getContentPlainTextInfo([Content $content = null ][, mixed $withContentName = true ]) : string|null

This is a combination of the type of the content with a short preview of it.

Note: This should only be used for mail subjects and other plain text

If no $content is provided the contentInfo of $source is returned.

Parameters
$content : Content = null
$withContentName : mixed = true
Tags
throws
Exception
since
1.4
Return values
string|null

getContentPlainTextPreview()

Returns a short preview text of the content in plain text. The max length can be defined by setting $maxLength (60 by default).

public getContentPlainTextPreview([ContentOwner $content = null ][, int $maxLength = 60 ]) : string|null

If no $content is provided the contentPreview of $source is returned.

Note: This should only be used for mail subjects and other plain text

Parameters
$content : ContentOwner = null
$maxLength : int = 60
Tags
throws
Exception
since
1.4
Return values
string|null

getContentPreview()

Returns a short preview text of the content. The max length can be defined by setting $maxLength (60 by default).

public getContentPreview([ContentOwner $content = null ][, int $maxLength = 60 ]) : string|null

If no $content is provided the contentPreview of $source is returned.

Parameters
$content : ContentOwner = null
$maxLength : int = 60
Tags
throws
Exception
Return values
string|null

getDescription()

Returns the description of the activity, which is displayed on the configuration page.

public getDescription() : string
Tags
inheritdoc
Return values
string

the description of the activity

getSpace()

public getSpace() : Space
Tags
throws
Exception
Return values
Space

related space instance in case the activity source is an related contentcontainer of type space, otherwise null

getSpaceId()

public getSpaceId() : int
Tags
throws
Exception
Return values
int

related space id in case the activity source is an related contentcontainer of type space, otherwise null

getTitle()

Returns the title of the activity, which is displayed on the configuration page.

public getTitle() : string
Tags
inheritdoc
Return values
string

the title of the activity

getUrl()

Url of the origin of this notification If source is a Content / ContentAddon / ContentContainer this will automatically generated.

public getUrl() : string
Tags
inheritdoc
Return values
string

getViewName()

public getViewName() : string
Tags
inheritdoc
Return values
string

viewname of this viewable

getViewParams()

Returns an array of view parameter, required for rendering.

public getViewParams([mixed $params = [] ]) : mixed
Parameters
$params : mixed = []
Tags
inheritdoc

hasContent()

Determines if this activity is related to a content. This is the case if the activitiy source is of type ContentOwner.

public hasContent() : bool
Return values
bool

true if this activity is related to a ContentOwner else false

hasMethod()

Returns a value indicating whether a method is defined.

public hasMethod(string $name) : bool

The default implementation is a call to php function method_exists(). You may override this method when you implemented the php magic method __call().

Parameters
$name : string

the method name

Return values
bool

whether the method is defined

hasProperty()

Returns a value indicating whether a property is defined.

public hasProperty(string $name[, bool $checkVars = true ]) : bool

A property is defined if:

  • the class has a getter or setter method associated with the specified name (in this case, property name is case-insensitive);
  • the class has a member variable with the specified name (when $checkVars is true);
Parameters
$name : string

the property name

$checkVars : bool = true

whether to treat member variables as properties

Tags
see
canGetProperty()
see
canSetProperty()
Return values
bool

whether the property is defined

html()

public html() : string
Tags
inheritdoc
Return values
string

html content representation of this viewable.

init()

Initializes the object.

public init() : mixed
Tags
inheritdoc

instance()

Static initializer should be prefered over new initialization, since it makes use of Yii::createObject dependency injection/configuration.

public static instance([array<string|int, mixed> $options = [] ]) : static
Parameters
$options : array<string|int, mixed> = []
Tags
throws
InvalidConfigException
Return values
static

json()

public json() : string
Tags
inheritdoc
Return values
string

json content representation of this viewable.

save()

Stores the activity in database

public save() : bool
Return values
bool

text()

public text() : string
Tags
inheritdoc
Return values
string

text content representation of this viewable.

validate()

Validates the existence of required attributes

public validate() : bool
Return values
bool

getContentVisibility()

Returns the visibility of the content

protected getContentVisibility() : int
Return values
int

the visibility

getOriginatorId()

Returns the user id of the originator of this activity

protected getOriginatorId() : int
Return values
int

user id


        
On this page

Search results