/** * Create a wall activity for this user after posting a question. * * @param CMA_Thread $instance */ static function thread_posted_activity(CMA_Thread $instance) { if (!$instance->isPublished()) { return; } $post = $instance->getPost(); $user_id = $instance->getAuthorId(); $permalink = get_permalink($instance->getId()); $action = sprintf(CMA::__('%s asked a new question: %s'), bp_core_get_userlink($user_id), sprintf('<a href="%s">%s</a>', esc_attr($permalink), esc_html($instance->getTitle()))); $content = $instance->getLightContent(); if (function_exists('bp_activity_add')) { bp_activity_add(array('action' => $action, 'content' => $content, 'component' => self::COMPONENT, 'type' => 'thread_posted', 'primary_link' => $permalink, 'user_id' => $user_id, 'item_id' => $instance->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' => $instance->getAuthorId(), 'hide_sitewide' => 1)); } } } } }