$data['uid_target'] = $uid_target;
$data['nid'] = $nid;
$data['nid_target'] = $nid_target;
+ $data['cid'] = isset($variables['cid']) ? $variables['cid'] : 0;
$data['access'] = $access;
$data['in_group'] = $in_group;
$data['timestamp'] = $time == 0 ? $_SERVER['REQUEST_TIME'] : $time;
* of the Template or the User setting.
*/
function _heartbeat_activity_get_access($uid, $template) {
+
$templates = heartbeat_user_templates_load($uid);
- $access = isset($templates[$template->message_id]) ? $templates[$template->message_id]->status : (isset($templates['0']) ? $templates['0']->status : $template->perms);
+
+ // If the user has configured access to this type, use it.
+ if (isset($templates[$template->message_id])) {
+ $access = $templates[$template->message_id]->status;
+ }
+ else {
+ // If the user configured general access.
+ if (isset($templates['0'])) {
+ $access = $templates['0']->status;
+ }
+ // Use the general permission for this template.
+ else {
+ $access = $template->perms;
+ }
+ }
+
return $access;
}
$this->nid_target = $data['nid_target'];\r
}\r
\r
+ if (isset($data['cid'])) {\r
+ $this->cid = $data['cid'];\r
+ }\r
+\r
if (isset($data['in_group'])) {\r
$this->in_group = $data['in_group'];\r
}\r
$access_expression = "LEAST ( IFNULL ( ha.access, " . HEARTBEAT_PUBLIC_TO_ALL . "), IFNULL ( hut.status, " . HEARTBEAT_PUBLIC_TO_ALL . "))";\r
$this->query->addExpression($access_expression, 'user_access');\r
\r
+ // Exclude unpublished comments.\r
+ $this->query->leftJoin('comment', 'c', 'ha.cid = c.cid');\r
+ $this->query->where("c.status = 1 OR ha.cid = 0");\r
+\r
$db_or = db_or();\r
foreach ($this->getCurrentLanguages() as $lang_code) {\r
$db_or->condition('ha.language', $lang_code, "=");\r
$this->query->condition($or);\r
}\r
\r
+ // Exclude denied message templates.\r
if (!empty($this->templates_denied)) {\r
$this->query->where("ha.message_id NOT IN (:messages)", array(':messages' => array_unique($this->templates_denied)));\r
}\r
*/\r
protected function executeQuery() {\r
\r
- // dqm($this->query);\r
+ // dqm($this->query);\r
$result = $this->query->execute()->fetchAll();\r
$messages = array();\r
\r
$variables[$key] = $val;
}
- if (in_array($key, array('nid', 'uid', 'nid_target', 'uid_target'))) {
+ if (in_array($key, array('nid', 'uid', 'nid_target', 'uid_target', 'cid'))) {
$variables[$key] = (int) $variables[$key];
}
}
'uid' => array('type' => 'text', 'label' => t('User ID')),
'nid_target' => array('type' => 'text', 'label' => t('Entity target ID'), 'optional' => TRUE),
'uid_target' => array('type' => 'text', 'label' => t('User target ID'), 'optional' => TRUE),
+ 'cid' => array('type' => 'text', 'label' => t('Comment ID'), 'optional' => TRUE),
);
$actions = array();