class CommentActivityActionHandler in Activity 7
Activity handler for the comment module. Extends the node handler has it presents a lot of the same things, just more.
Hierarchy
- class \ActivityActionHandler
- class \NodeActivityActionHandler
- class \CommentActivityActionHandler
- class \NodeActivityActionHandler
Expanded class hierarchy of CommentActivityActionHandler
1 string reference to 'CommentActivityActionHandler'
- comment_activity_api in ./
activity.module - Implements hook_activity_api().
File
- ./
activity_action_handlers.inc, line 588
View source
class CommentActivityActionHandler extends NodeActivityActionHandler {
/**
* Load objects for tokenization.
*
* @param int $eid
* The entity identifier for this Activity.
*
* @return array
*/
public function loadObjects($eid) {
$objects = array();
$objects['comment'] = comment_load($eid);
$objects['node'] = node_load($objects['comment']->nid);
return $objects;
}
/**
* Return the eid field for this Activity.
*
* @param array $context
* The context arguments passed into the action callback.
*
* @return int
*/
public function determineEid($context) {
return $context['comment']->cid;
}
/**
* Return the uid that is responsible for this action.
*
* @param array $objects
* The objects used in tokenization
*
* @return int
*/
public function determineActor($objects) {
return $objects['comment']->uid;
}
/**
* Return the timestamp that this Activity happened at.
*
* @param array $objects
* The objects used in tokenization.
*
* @return int
*/
public function determineTimestamp($objects) {
return $objects['comment']->created;
}
/**
* Return whether or not the Activity is published.
*
* @param array $objects
* The objects used in tokenization.
* @param int $actor
* The actor for the activity.
*/
public function isPublished($objects, $actor) {
return parent::isPublished($objects, $actor) && $objects['comment']->status;
}
/**
* Return an array of message types.
*/
protected function messages() {
$messages = parent::messages();
$messages['comment'] = array(
'title' => 'Comment Author',
'description' => 'The author of the comment',
);
$messages['node_comment'] = array(
'title' => 'Comment and Node Author',
'description' => 'When both the comment and the node author are the same display this message',
);
return $messages;
}
/**
* Return the user id that matches the provided key in the templates.
*
* @param string $key
* The message key.
* @param array $objects
* All the objects for the Activity.
*
* @return int
*/
protected function getUid($key, $objects) {
if ($key == 'public') {
return 0;
}
elseif ($key == 'current_user') {
return $GLOBALS['user']->uid;
}
elseif ($key == 'node_comment' && $objects['node']->uid == $objects['comment']->uid) {
return $objects['comment']->uid;
}
if (isset($objects[$key]) && isset($objects[$key]->uid)) {
return $objects[$key]->uid;
}
return FALSE;
}
/**
* List all eids for this handler, used for batch regeneration and backfilling.
*
* @param int $offset
* The offset for the query.
* @param int $limit
* The limit for the query.
*/
public function listEids($offset, $limit) {
$types = array_filter($this->options['types']);
$query = db_select('comment', 'c')
->fields('c', array(
'cid',
), 'eid');
if (!empty($types)) {
$node_alias = $query
->join('node', 'n', 'n.nid = c.nid');
$query
->condition($node_alias . '.type', $types, 'IN');
}
$count_query = clone $query;
$total = $count_query
->countQuery()
->execute()
->fetchField();
$query
->range($offset, $limit);
$arguments = array();
foreach ($query
->execute()
->fetchCol() as $eid) {
$arguments[$eid] = array(
'argument1' => NULL,
'argument2' => NULL,
);
}
return array(
'total' => $total,
'arguments' => $arguments,
);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ActivityActionHandler:: |
public | property | {actions}.aid for the template. | |
ActivityActionHandler:: |
public | property | Boolean indicating if this handler can do batch operations. | |
ActivityActionHandler:: |
public | property | {actions}.label for the template. | |
ActivityActionHandler:: |
public | property | Options provided via the optionsFrom and optionsDefinition methods. | |
ActivityActionHandler:: |
public | property | Templates created by the administrator. | |
ActivityActionHandler:: |
public | property | Type of activity. | |
ActivityActionHandler:: |
public static | function | Generates the default options from the provided option definition. | |
ActivityActionHandler:: |
public | function | Return the nid of this Activity. | |
ActivityActionHandler:: |
public | function | Display the token message form. | |
ActivityActionHandler:: |
public | function | Tokenize based on the provided objects | |
CommentActivityActionHandler:: |
public | function |
Return the uid that is responsible for this action. Overrides NodeActivityActionHandler:: |
|
CommentActivityActionHandler:: |
public | function |
Return the eid field for this Activity. Overrides NodeActivityActionHandler:: |
|
CommentActivityActionHandler:: |
public | function |
Return the timestamp that this Activity happened at. Overrides NodeActivityActionHandler:: |
|
CommentActivityActionHandler:: |
protected | function |
Return the user id that matches the provided key in the templates. Overrides ActivityActionHandler:: |
|
CommentActivityActionHandler:: |
public | function |
Return whether or not the Activity is published. Overrides NodeActivityActionHandler:: |
|
CommentActivityActionHandler:: |
public | function |
List all eids for this handler, used for batch regeneration and backfilling. Overrides NodeActivityActionHandler:: |
|
CommentActivityActionHandler:: |
public | function |
Load objects for tokenization. Overrides NodeActivityActionHandler:: |
|
CommentActivityActionHandler:: |
protected | function |
Return an array of message types. Overrides NodeActivityActionHandler:: |
|
NodeActivityActionHandler:: |
public | function |
Return option defaults and structure. Overrides ActivityActionHandler:: |
|
NodeActivityActionHandler:: |
public | function |
Display an FAPI form. Overrides ActivityActionHandler:: |
|
NodeActivityActionHandler:: |
public | function |
Determine if the current Action is valid for this object. Overrides ActivityActionHandler:: |