/** * Create a wall activity for this user after posting an answer. * * @param CMA_Thread $instance * @param CMA_Answer $answer */ static function answer_posted_activity(CMA_Thread $instance, CMA_Answer $answer) { if (!$instance->isPublished()) { return; } else { if (!$answer->isApproved() or $answer->isPrivate()) { return; } } $post = $instance->getPost(); $user_id = $answer->getAuthorId(); $permalink = $answer->getPermalink(); $action = sprintf(CMA::__('%s answered to the question "%s"'), bp_core_get_userlink($user_id), sprintf('<a href="%s">%s</a>', esc_attr($permalink), esc_html($instance->getTitle()))); $content = CMA_Thread::lightContent($answer->getContent()); if (function_exists('bp_activity_add')) { bp_activity_add(array('action' => $action, 'content' => $content, 'component' => self::COMPONENT, 'type' => 'answer_posted', 'primary_link' => $permalink, 'user_id' => $user_id, 'item_id' => $answer->getId())); } if ($category = $instance->getCategory()) { $groups = self::getRelatedGroups(array($category->getId(), $category->getParentId())); if ($groups) { foreach ($groups as $groupId) { if (function_exists('groups_record_activity')) { groups_record_activity(array('action' => $action, 'content' => $content, 'type' => 'new_groupblog_post', 'primary_link' => $permalink, 'item_id' => $groupId, 'secondary_item_id' => $answer->getAuthorId(), 'hide_sitewide' => 0)); } } } } }