function buddystream_achievement_unlocked($achievement_id, $user_id) { $content = __('I just unlocked the', 'buddystream_lang') . " " . dpa_get_achievement_name() . " " . __('achievement!', 'buddystream'); if (get_user_meta($user_id, 'tweetstream_achievements', 1)) { $content = "#twitter " . $content; } if (get_user_meta($user_id, 'facestream_achievements', 1)) { $content = "#facebook " . $content; } $shortLink = buddystream_getShortUrl(dpa_get_achievement_slug_permalink()); buddystream_SocialIt($content, $shortLink, $user_id); }
function buddystream_SocialIt($content, $shortLink = null) { global $bp; $buddyStreamExtensions = new BuddyStreamExtensions(); $buddyStreamFilters = new BuddyStreamFilters(); $user_id = $bp->loggedin_user->id; $originalText = $buddyStreamFilters->removeHashTags($content); if ($bp->current_component == "groups" && $bp->current_action == "forum") { if ($_POST['topic_title']) { $cleanTitle = trim($_POST['topic_title']); $shortLink = bp_get_group_permalink($bp->groups->current_group) . 'forum/topic/' . str_replace(" ", "-", strtolower($cleanTitle)) . '/'; $shortLink = buddystream_getShortUrl($shortLink); $content = __('Just created a new topic:', 'buddystream') . " " . $_POST['topic_title'] . " - " . $_POST['topic_text'] . " "; } else { $shortLink = bp_get_group_permalink($bp->groups->current_group) . 'forum/topic/' . $bp->action_variables[1] . '/'; $shortLink = buddystream_getShortUrl($shortLink); $content = __('Just responded to:', 'buddystream') . " " . str_replace("-", " ", $bp->action_variables[1]); foreach ($buddyStreamExtensions->getExtensionsConfigs() as $extension) { if ($extension['hashtag']) { if (strpos($_POST['reply_text'], $extension['hashtag'])) { $content .= $extension['hashtag']; } } } } } $cleanContent = $content; $cleanContent = str_replace('&', '&', $cleanContent); //Activity Plus Stuff //find a link of Activity Plus, if found convert for nice social context $link = $buddyStreamFilters->extractString($cleanContent, '[bpfb_link', '[/bpfb_link]'); if ($link) { $arrLink = explode(" ", trim($link)); $newLink = str_replace("url=", "", $arrLink[0]); $newLink = str_replace("'", "", $newLink); $newLink = str_replace("[", "", $newLink); $newLink = str_replace("]", "", $newLink); $cleanContent = str_replace($link, "", $cleanContent); $cleanContent = str_replace("[bpfb_link", "", $cleanContent); $cleanContent = str_replace("[/bpfb_link]", "", $cleanContent); $cleanContent .= " " . $newLink; } //find a image of Activity Plus, if found convert for nice social context $image = $buddyStreamFilters->extractString($cleanContent, '[bpfb_images]', '[/bpfb_images]'); if ($image) { $wpUpload = wp_upload_dir(); $uploadUrl = $wpUpload['baseurl']; $newImage = $uploadUrl . '/bpfb/' . trim($image); $cleanContent = str_replace($image, "", $cleanContent); $cleanContent = str_replace("[bpfb_images]", "", $cleanContent); $cleanContent = str_replace("[/bpfb_images]", "", $cleanContent); $cleanContent .= " " . $newImage; } //strip out all html so we can search clean content $cleanContent = strip_tags($cleanContent); foreach ($buddyStreamExtensions->getExtensionsConfigs() as $extension) { $arrHastags = explode(",", $extension['hashtag']); foreach ($arrHastags as $hashtag) { if (get_site_option("buddystream_" . $extension['name'] . "_power")) { //explode text to single words then check if hashtag is found $arrayContent = explode(" ", $cleanContent); if (in_array($hashtag, $arrayContent)) { if (function_exists("buddystream" . ucfirst($extension['name']) . "PostUpdate")) { call_user_func("buddystream" . ucfirst($extension['name']) . "PostUpdate", $cleanContent, $shortLink, $user_id); } } } } } //if use location is used add map image to content if (!get_site_option("buddystream_nolocation")) { if (preg_match("/#location/i", $originalText)) { if (isset($_COOKIE["buddystream_location"])) { $arrLocation = explode("#", $_COOKIE["buddystream_location"]); $mapIcon = BP_BUDDYSTREAM_URL . '/images/marker.png'; $mapUrl = 'http://maps.googleapis.com/maps/api/staticmap?center=' . $arrLocation[0] . ',' . $arrLocation[1] . '&zoom=13&size=540x150&sensor=false&markers=icon%3A' . $mapIcon . '%7C' . $arrLocation[0] . ',' . $arrLocation[1] . '&format=png32'; $originalText .= '<img class="buddystream_map_image" src="' . $mapUrl . '">'; } } $originalText = str_replace("#location", "", $originalText); } return $originalText; }