summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStalski2012-02-08 23:15:28 (GMT)
committer Stalski2012-02-08 23:15:28 (GMT)
commit4b944148f618f4188397704fc6db0178f0a65d6b (patch)
tree352f4b92a95ddf8a6f5c4ea6834f09f76b1cc1c7
parent8ac786b82a7c38e96a7a2b741bdecee99802a051 (diff)
#1409266 by muschpusch: heartbeat ajax on nodes not working
-rw-r--r--modules/heartbeat_comments/heartbeat_comments.module8
-rwxr-xr-xmodules/heartbeat_rules/heartbeat_rules.module39
2 files changed, 36 insertions, 11 deletions
diff --git a/modules/heartbeat_comments/heartbeat_comments.module b/modules/heartbeat_comments/heartbeat_comments.module
index 308855f..2341647 100644
--- a/modules/heartbeat_comments/heartbeat_comments.module
+++ b/modules/heartbeat_comments/heartbeat_comments.module
@@ -544,14 +544,14 @@ function heartbeat_comments_load_js() {
$uaid = $_POST['uaid'];
$nid = 0;
$node = NULL;
- if (isset($_POST['nid'])) {
+ $node_comment = 0;
+
+ if (!empty($_POST['nid']) && is_numeric($_POST['nid'])) {
$nid = $_POST['nid'];
$node = node_load($nid);
+ $node_comment = 1;
}
- $node_comment = isset($_POST['activitycomments_node']) ? $_POST['activitycomments_node']: 0;
- $node_comment = (int) ($node_comment && $nid);
-
$reactions = heartbeat_get_reactions($uaid, $node_comment, $node, TRUE);
$heartbeatActivity = HeartbeatMessagePool::getInstance()->getMessage($uaid);
diff --git a/modules/heartbeat_rules/heartbeat_rules.module b/modules/heartbeat_rules/heartbeat_rules.module
index 5492121..5041bd0 100755
--- a/modules/heartbeat_rules/heartbeat_rules.module
+++ b/modules/heartbeat_rules/heartbeat_rules.module
@@ -25,16 +25,16 @@ function heartbeat_rules_menu() {
* Implements hook_token_info().
*/
function heartbeat_token_info() {
- /*$type = array(
+ $type = array(
'name' => t('Heartbeat activity'),
'description' => t('Tokens related to individual heartbeat activity messages.'),
- 'needs-data' => 'heartbeatactivity',
- );*/
+ 'needs-data' => 'heartbeat_activity',
+ );
// Core tokens for nodes.
$node['link'] = array(
- 'name' => t("Content name with a link to it"),
- 'description' => t('The node with a link to it.'),
+ 'name' => t("Content name with a link to it"),
+ 'description' => t('The node with a link to it.'),
);
// Core tokens for nodes.
@@ -43,9 +43,15 @@ function heartbeat_token_info() {
'description' => t('The user with a link to it.'),
);
+ // Heartbeat tokens.
+ $heartbeat_activity['actor-link'] = array(
+ 'name' => t("Actor username with a link to it"),
+ 'description' => t('The acting user with a link to it.'),
+ );
+
return array(
- //'types' => array('heartbeat' => $type),
- 'tokens' => array('node' => $node, 'user' => $user),
+ 'types' => array('heartbeat' => $type),
+ 'tokens' => array('node' => $node, 'user' => $user, 'heartbeat_activity' => $heartbeat_activity),
);
}
@@ -66,6 +72,7 @@ function heartbeat_tokens($type, $tokens, array $data = array(), array $options
$replacements = array();
+ // Node activity tokens.
if ($type == 'node' && !empty($data['node'])) {
$node = $data['node'];
@@ -81,6 +88,7 @@ function heartbeat_tokens($type, $tokens, array $data = array(), array $options
}
+ // User tokens.
if ($type == 'user' && !empty($data['user'])) {
$account = $data['user'];
@@ -97,6 +105,23 @@ function heartbeat_tokens($type, $tokens, array $data = array(), array $options
}
+ // Heartbeat activity tokens.
+ if ($type == 'heartbeat_activity' && !empty($data['heartbeat_activity'])) {
+ $heartbeat_activity = $data['heartbeat_activity'];
+
+ foreach ($tokens as $name => $original) {
+ switch ($name) {
+
+ case 'actor-link':
+ $url_options['attributes']['class'] = array('user-link');
+ $name = !empty($heartbeat_activity->actor->realname) ? $heartbeat_activity->actor->realname : $heartbeat_activity->actor->name;
+ $replacements[$original] = l(format_username($heartbeat_activity->actor), 'user/' . $heartbeat_activity->actor->uid, $url_options);
+ break;
+ }
+ }
+
+ }
+
return $replacements;
}