function delete($item_id, $component_name, $component_action, $user_id, $secondary_item_id = false) { global $wpdb, $bp; if (!$user_id) { return false; } if (!$bp->activity) { bp_activity_setup_globals(); } if ($secondary_item_id) { $secondary_sql = $wpdb->prepare("AND secondary_item_id = %d", $secondary_item_id); } if ($component_action) { $component_action_sql = $wpdb->prepare("AND component_action = %s AND user_id = %d", $component_action, $user_id); $cached_component_action_sql = $wpdb->prepare("AND component_action = %s", $component_action); } $wpdb->query($wpdb->prepare("DELETE FROM {$bp->activity->table_name_user_activity} WHERE item_id = %d {$secondary_sql} AND component_name = %s {$component_action_sql}", $item_id, $component_name)); // Delete this entry from the user activity cache table and the sitewide cache table $wpdb->query($wpdb->prepare("DELETE FROM {$bp->activity->table_name_user_activity_cached} WHERE user_id = %d AND item_id = %d {$secondary_sql} AND component_name = %s {$cached_component_action_sql}", $user_id, $item_id, $component_name)); $wpdb->query($wpdb->prepare("DELETE FROM {$bp->activity->table_name_sitewide} WHERE item_id = %d {$secondary_sql} AND component_name = %s {$component_action_sql}", $item_id, $component_name)); return true; }
function bp_blogs_record_activity( $args = '' ) { global $bp; if ( !function_exists( 'bp_activity_add' ) ) return false; /* Because blog, comment, and blog post code execution happens before anything else we may need to manually instantiate the activity component globals */ if ( !$bp->activity && function_exists('bp_activity_setup_globals') ) bp_activity_setup_globals(); $defaults = array( 'user_id' => $bp->loggedin_user->id, 'action' => '', 'content' => '', 'primary_link' => '', 'component' => $bp->blogs->id, 'type' => false, 'item_id' => false, 'secondary_item_id' => false, 'recorded_time' => bp_core_current_time(), 'hide_sitewide' => false ); $r = wp_parse_args( $args, $defaults ); extract( $r, EXTR_SKIP ); /* Remove large images and replace them with just one image thumbnail */ if ( function_exists( 'bp_activity_thumbnail_content_images' ) && !empty( $content ) ) $content = bp_activity_thumbnail_content_images( $content ); if ( !empty( $action ) ) $action = apply_filters( 'bp_blogs_record_activity_action', $action ); if ( !empty( $content ) ) $content = apply_filters( 'bp_blogs_record_activity_content', bp_create_excerpt( $content ), $content ); /* Check for an existing entry and update if one exists. */ $id = bp_activity_get_activity_id( array( 'user_id' => $user_id, 'component' => $component, 'type' => $type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id ) ); return bp_activity_add( array( 'id' => $id, 'user_id' => $user_id, 'action' => $action, 'content' => $content, 'primary_link' => $primary_link, 'component' => $component, 'type' => $type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) ); }
/** * Add an item to the activity string upon translation * @global object $bp the global buddypress * @param string $translation * @param string $original * @param string $lang */ function transposh_buddypress_stream($translation, $original, $lang) { global $bp; // we must have buddypress... if (!function_exists('bp_activity_add')) { return false; } // we only log translation for logged on users if (!$bp->loggedin_user->id) { return; } /* Because blog, comment, and blog post code execution happens before anything else we may need to manually instantiate the activity component globals */ if (!$bp->activity && function_exists('bp_activity_setup_globals')) { bp_activity_setup_globals(); } // just got this from buddypress, changed action and content $values = array('user_id' => $bp->loggedin_user->id, 'action' => sprintf(__('%s translated a phrase to %s with transposh:', 'buddypress'), bp_core_get_userlink($bp->loggedin_user->id), substr(transposh_consts::$languages[$lang], 0, strpos(transposh_consts::$languages[$lang], ','))), 'content' => "Original: <span class=\"no_translate\">{$original}</span>\nTranslation: <span class=\"no_translate\">{$translation}</span>", 'primary_link' => '', 'component' => $bp->blogs->id, 'type' => 'new_translation', 'item_id' => false, 'secondary_item_id' => false, 'recorded_time' => gmdate("Y-m-d H:i:s"), 'hide_sitewide' => false); return bp_activity_add($values); }
function bp_blogs_record_activity($args = true) { global $bp; /* Because blog, comment, and blog post code execution happens before anything else we need to manually instantiate the activity component globals */ if (!$bp->activity && function_exists('bp_activity_setup_globals')) { bp_activity_setup_globals(); } if (function_exists('bp_activity_record')) { extract($args); bp_activity_record($item_id, $component_name, $component_action, $is_private, $secondary_item_id, $user_id, $secondary_user_id, $recorded_time); } }