当前位置: 首页>>代码示例>>PHP>>正文


PHP BP_Activity_Activity类代码示例

本文整理汇总了PHP中BP_Activity_Activity的典型用法代码示例。如果您正苦于以下问题:PHP BP_Activity_Activity类的具体用法?PHP BP_Activity_Activity怎么用?PHP BP_Activity_Activity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了BP_Activity_Activity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: buddystreamCreateActivity

/**
 * Create a activity item
 * @param $params
 * @return string
 */
function buddystreamCreateActivity($params)
{
    global $bp, $wpdb;
    $buddyStreamExtensions = new BuddyStreamExtensions();
    $buddyStreamFilters = new BuddyStreamFilters();
    /**
     * buddystreamCreateActivity(array(
     *     'user_id'    => $user_meta->user_id,
     *     'extension'  => 'facebook',
     *     'type'       => 'photo',
     *     'content'    => $content,
     *     'item_id'    => $item['id'],
     *     'raw_date'   => $item['created_time'],
     *     'actionlink' => 'url_to_original_item')
     *  ));
     *
     */
    if (is_array($params)) {
        //load config of extension
        $originalText = $params['content'];
        foreach ($buddyStreamExtensions->getExtensionsConfigs() as $extension) {
            if (isset($extension['hashtag'])) {
                $originalText = str_replace($extension['hashtag'], "", $originalText);
                $originalText = trim($originalText);
            }
        }
        //set the content
        $content = "";
        $content = '<div class="buddystream_activity_container ' . $params['extension'] . '">' . $originalText . '</div>';
        if (!buddyStreamCheckImportLog($params['user_id'], $params['item_id'], $params['extension']) && !buddyStreamCheckExistingContent($content) && !buddyStreamCheckExistingContent($originalText)) {
            buddyStreamAddToImportLog($params['user_id'], $params['item_id'], $params['extension']);
            remove_filter('bp_activity_action_before_save', 'bp_activity_filter_kses', 1);
            $activity = new BP_Activity_Activity();
            $activity->user_id = $params['user_id'];
            $activity->component = $params['extension'];
            $activity->type = $params['extension'];
            $activity->content = $content;
            $activity->item_id = $params['item_id'];
            $activity->secondary_item_id = '';
            $activity->date_recorded = $params['raw_date'];
            $activity->hide_sitewide = 0;
            $activity->action .= '<a href="' . bp_core_get_user_domain($params['user_id']) . '" title="' . bp_core_get_username($params['user_id']) . '">' . bp_core_get_user_displayname($params['user_id']) . '</a>';
            $activity->action .= ' ' . __('posted&nbsp;a', 'buddystream_lang') . ' ';
            $activity->action .= '<a href="' . $params['actionlink'] . '" target="_blank" rel="external"> ' . __($params['type'], 'buddystream_' . $extension['name']);
            $activity->action .= '</a>: ';
            $activity->primary_link = $params['actionlink'];
            if (!preg_match("/" . $params['item_id'] . "/i", get_user_meta($params['user_id'], 'buddystream_blacklist_ids', 1))) {
                $activity->save();
                $buddyStreamFilters->updateDayLimitByOne($params['extension'], $params['user_id']);
                return true;
            }
        }
    }
    return false;
}
开发者ID:BonoboDesigns,项目名称:buddystream,代码行数:60,代码来源:BuddyStreamCore.php

示例2: post_comment

 /**
  * Post a gallery or media Main comment on single page
  * 
  * @return type
  */
 public function post_comment()
 {
     // Bail if not a POST action
     if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
         return;
     }
     // Check the nonce
     check_admin_referer('post_update', '_wpnonce_post_update');
     if (!is_user_logged_in()) {
         exit('-1');
     }
     $mpp_type = $_POST['mpp-type'];
     $mpp_id = $_POST['mpp-id'];
     if (empty($_POST['content'])) {
         exit('-1<div id="message" class="error"><p>' . __('Please enter some content to post.', 'mediapress') . '</p></div>');
     }
     $activity_id = 0;
     if (empty($_POST['object']) && bp_is_active('activity')) {
         //we are preventing this comment to be set as the user's lastes_update
         $user_id = bp_loggedin_user_id();
         $old_latest_update = bp_get_user_meta($user_id, 'bp_latest_update', true);
         $activity_id = bp_activity_post_update(array('content' => $_POST['content']));
         //restore
         if (!empty($old_latest_update)) {
             bp_update_user_meta($user_id, 'bp_latest_update', $old_latest_update);
         }
     } elseif ($_POST['object'] == 'groups') {
         if (!empty($_POST['item_id']) && bp_is_active('groups')) {
             $activity_id = groups_post_update(array('content' => $_POST['content'], 'group_id' => $_POST['item_id']));
         }
     } else {
         $activity_id = apply_filters('bp_activity_custom_update', $_POST['object'], $_POST['item_id'], $_POST['content']);
     }
     if (empty($activity_id)) {
         exit('-1<div id="message" class="error"><p>' . __('There was a problem posting your update, please try again.', 'mediapress') . '</p></div>');
     }
     //if we have got activity id, let us add a meta key
     if ($mpp_type == 'gallery') {
         mpp_activity_update_gallery_id($activity_id, $mpp_id);
     } elseif ($mpp_type == 'media') {
         mpp_activity_update_media_id($activity_id, $mpp_id);
     }
     $activity = new BP_Activity_Activity($activity_id);
     // $activity->component = buddypress()->mediapress->id;
     $activity->type = 'mpp_media_upload';
     $activity->save();
     if (bp_has_activities('include=' . $activity_id)) {
         while (bp_activities()) {
             bp_the_activity();
             mpp_locate_template(array('activity/entry.php'), true);
         }
     }
     exit;
 }
开发者ID:baden03,项目名称:mediapress,代码行数:59,代码来源:class-mpp-ajax-comment-helper.php

示例3: update_object

 function update_object($activity_id, $fields)
 {
     $activity = new BP_Activity_Activity($activity_id);
     foreach ($fields as $field_name => $value) {
         if (isset($activity->{$field_name})) {
             $activity->{$field_name} = $value;
         }
     }
     $activity->save();
     return $activity;
 }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:11,代码来源:factory.php

示例4: test_bp_activity_clear_cache_for_activity

 /**
  * @group bp_activity_clear_cache_for_activity
  */
 public function test_bp_activity_clear_cache_for_activity()
 {
     $u = $this->factory->user->create();
     $a = $this->factory->activity->create(array('component' => buddypress()->activity->id, 'type' => 'activity_update', 'user_id' => $u, 'content' => 'foo bar'));
     $a_fp = bp_activity_get(array('type' => 'activity_update', 'user' => array('filter' => array('user_id' => $u))));
     $activity_updated = new BP_Activity_Activity($a);
     $activity_updated->content = 'bar foo';
     $activity_updated->save();
     $a_fp = bp_activity_get(array('type' => 'activity_update', 'user' => array('filter' => array('user_id' => $u))));
     $this->assertSame('bar foo', $a_fp['activities'][0]->content);
 }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:14,代码来源:cache.php

示例5: bp_activity_get_sitewide

/**
 * Retrieve sitewide activity
 *
 * You should use bp_activity_get() instead
 *
 * @since 1.0.0
 * @deprecated 1.2.0
 *
 * @param array $args
 *
 * @uses BP_Activity_Activity::get() {@link BP_Activity_Activity}
 *
 * @return object $activity The activity/activities object
 */
function bp_activity_get_sitewide($args = '')
{
    _deprecated_function(__FUNCTION__, '1.2', 'bp_activity_get()');
    $defaults = array('max' => false, 'page' => 1, 'per_page' => false, 'sort' => 'DESC', 'display_comments' => false, 'search_terms' => false, 'show_hidden' => false, 'filter' => array());
    $args = wp_parse_args($args, $defaults);
    return apply_filters('bp_activity_get_sitewide', BP_Activity_Activity::get($args), $r);
}
开发者ID:mawilliamson,项目名称:wordpress,代码行数:21,代码来源:1.2.php

示例6: delete_pic_cover_group

function delete_pic_cover_group($activity_id)
{
    global $bp;
    $group_id = $bp->groups->current_group->id;
    $activity_id = $_POST['activity_id'];
    $attachment_id = bp_activity_get_meta($activity_id, 'all_bp_cover_group', true);
    wp_delete_attachment($attachment_id, true);
    groups_delete_groupmeta($group_id, 'bp_cover_group');
    groups_delete_groupmeta($group_id, 'bp_cover_group_position');
    bp_activity_delete(array('id' => $activity_id, 'item_id' => $group_id));
    BP_Activity_Activity::delete_activity_meta_entries($activity_id);
}
开发者ID:aghajoon,项目名称:bp-cover,代码行数:12,代码来源:bp-cover-group.php

示例7: buddy_boss_pics_cleanup_db

/**
 * CLEANUP DATABASE AND RECONCILE WITH WP MEDIA LIBRARY
 */
function buddy_boss_pics_cleanup_db()
{
    global $wpdb;
    $activity_table = $wpdb->prefix . "bp_activity";
    $activity_meta_table = $wpdb->prefix . "bp_activity_meta";
    $posts_table = $wpdb->prefix . "posts";
    // Prepare a SQL query to retrieve the activity posts
    // that have pictures associated with them
    $all_aids_sql = "SELECT am.meta_value, am.activity_id FROM {$activity_table} a \r\n\t\t\t\t\t\t\t\t\t\t INNER JOIN {$activity_meta_table} am ON a.id = am.activity_id \r\n\t\t\t\t\t\t\t\t\t\t WHERE am.meta_key = 'bboss_pics_aid'";
    // Now perpare a SQL query to retrieve all attachments
    // that are BuddyBoss wall pictures AND are published in the media library
    $existing_sql = "SELECT am.meta_value FROM {$activity_table} a \r\n\t\t\t\t\t\t\t\t\t\t INNER JOIN {$activity_meta_table} am ON a.id = am.activity_id \r\n\t\t\t\t\t\t\t\t\t\t INNER JOIN {$posts_table} p ON am.meta_value = p.ID \r\n\t\t\t\t\t\t\t\t\t\t WHERE am.meta_key = 'bboss_pics_aid'\r\n\t\t\t\t\t\t\t\t\t\t AND p.post_status = 'inherit'\r\n\t\t\t\t\t\t\t\t\t\t AND p.post_parent = 0";
    // Query the database for all attachment IDS
    $all_aids = (array) $wpdb->get_results($all_aids_sql, ARRAY_A);
    // Query the database for all pics in the media library that are BuddyBoss pics
    $existing_aids = (array) $wpdb->get_col($existing_sql);
    // If we have a result set
    if (!empty($all_aids)) {
        // Prepare array
        $attachment_ids = $activity_ids = $aids2activity = array();
        foreach ($all_aids as $aid) {
            $attachment_ids[] = $aid['meta_value'];
            $aids2activity[$aid['meta_value']] = $activity_ids[] = $aid['activity_id'];
        }
        // Lets get the difference of our published vs. orphaned IDs
        $orphans = array_diff($attachment_ids, $existing_aids);
        // Delete related activity stream posts
        if (!empty($orphans)) {
            $orphan_acitivity_ids = array();
            foreach ($orphans as $orphan) {
                if (isset($aids2activity[$orphan])) {
                    $orphan_acitivity_ids[] = $aids2activity[$orphan];
                }
            }
            $orphan_acitivity_ids_string = implode(',', $orphan_acitivity_ids);
            $sql = $wpdb->prepare("DELETE FROM {$activity_table} WHERE id IN ({$orphan_acitivity_ids_string})");
            $deleted = $wpdb->query($sql);
            BP_Activity_Activity::delete_activity_item_comments($orphan_acitivity_ids);
            BP_Activity_Activity::delete_activity_meta_entries($orphan_acitivity_ids);
        }
    }
}
开发者ID:par-orillonsoft,项目名称:Wishmagnet,代码行数:45,代码来源:buddy_boss_pics.php

示例8: get_comments

 protected function get_comments()
 {
     $count = BP_Activity_Activity::get_activity_comments($this->activity->id, $this->activity->mptt_left, $this->activity->mptt_right);
     return count($count);
 }
开发者ID:konnektiv,项目名称:expert-finder,代码行数:5,代码来源:expertfinder-activity-stream-result-class.php

示例9: get_filter_sql

 /**
  * Create filter SQL clauses.
  *
  * @since BuddyPress (1.5.0)
  *
  * @param array $filter_array {
  *     Fields and values to filter by.
  *     @type array|string|id $user_id User ID(s).
  *     @type array|string $object Corresponds to the 'component'
  *           column in the database.
  *     @type array|string $action Corresponds to the 'type' column
  *           in the database.
  *     @type array|string|int $primary_id Corresponds to the 'item_id'
  *           column in the database.
  *     @type array|string|int $secondary_id Corresponds to the
  *           'secondary_item_id' column in the database.
  *     @type int $offset Return only those items with an ID greater
  *           than the offset value.
  *     @type string $since Return only those items that have a
  *           date_recorded value greater than a given MySQL-formatted
  *           date.
  * }
  * @return string The filter clause, for use in a SQL query.
  */
 public static function get_filter_sql($filter_array)
 {
     $filter_sql = array();
     if (!empty($filter_array['user_id'])) {
         global $wpdb;
         $user_sql = BP_Activity_Activity::get_in_operator_sql('a.user_id', $filter_array['user_id']);
         // START Also include @Mentions in User Stream
         $search_terms = '@' . bp_core_get_username($filter_array['user_id']);
         $user_sql .= "OR ( a.content LIKE '%%" . $wpdb->esc_like($search_terms) . "%%' )";
         // END Also include @Mentions in User Stream
         if (!empty($user_sql)) {
             $filter_sql[] = $user_sql;
         }
     }
     if (!empty($filter_array['object'])) {
         $object_sql = BP_Activity_Activity::get_in_operator_sql('a.component', $filter_array['object']);
         if (!empty($object_sql)) {
             $filter_sql[] = $object_sql;
         }
     }
     if (!empty($filter_array['action'])) {
         $action_sql = BP_Activity_Activity::get_in_operator_sql('a.type', $filter_array['action']);
         if (!empty($action_sql)) {
             $filter_sql[] = $action_sql;
         }
     }
     if (!empty($filter_array['primary_id'])) {
         $pid_sql = BP_Activity_Activity::get_in_operator_sql('a.item_id', $filter_array['primary_id']);
         if (!empty($pid_sql)) {
             $filter_sql[] = $pid_sql;
         }
     }
     if (!empty($filter_array['secondary_id'])) {
         $sid_sql = BP_Activity_Activity::get_in_operator_sql('a.secondary_item_id', $filter_array['secondary_id']);
         if (!empty($sid_sql)) {
             $filter_sql[] = $sid_sql;
         }
     }
     if (!empty($filter_array['offset'])) {
         $sid_sql = absint($filter_array['offset']);
         $filter_sql[] = "a.id >= {$sid_sql}";
     }
     if (!empty($filter_array['since'])) {
         // Validate that this is a proper Y-m-d H:i:s date
         // Trick: parse to UNIX date then translate back
         $translated_date = date('Y-m-d H:i:s', strtotime($filter_array['since']));
         if ($translated_date === $filter_array['since']) {
             $filter_sql[] = "a.date_recorded > '{$translated_date}'";
         }
     }
     if (empty($filter_sql)) {
         return false;
     }
     return join(' AND ', $filter_sql);
 }
开发者ID:kd5ytx,项目名称:Empirical-Wordpress,代码行数:79,代码来源:bp-activity-classes.php

示例10: migrate_single_media

 function migrate_single_media($result, $album = false)
 {
     $blog_id = get_current_blog_id();
     $old = $result;
     if (function_exists('bp_core_get_table_prefix')) {
         $bp_prefix = bp_core_get_table_prefix();
     } else {
         $bp_prefix = '';
     }
     global $wpdb;
     if (false !== $album && !is_object($result)) {
         $id = $wpdb->get_var($wpdb->prepare("select ID from {$this->bmp_table} where media_id = %d", $result));
         if (null == $id) {
             $sql = "select\n                        a.post_id as 'post_id',\n                        a.meta_value as 'privacy',\n                        b.meta_value as 'context_id',\n                        c.meta_value as 'activity_id',\n                        p.post_type,\n                        p.post_mime_type,\n                        p.post_author as 'media_author',\n                        p.post_title as 'media_title',\n                        p.post_parent as 'parent'\n                    from\n                        {$wpdb->postmeta} a\n                            left join\n                        {$wpdb->postmeta} b ON ((a.post_id = b.post_id)\n                            and (b.meta_key = 'bp-media-key'))\n                            left join\n                        {$wpdb->postmeta} c ON (a.post_id = c.post_id)\n                            and (c.meta_key = 'bp_media_child_activity')\n                            left join\n                        {$wpdb->posts} p ON (a.post_id = p.ID)\n                    where\n                        a.post_id = %d and (NOT p.ID IS NULL)\n                            and a.meta_key = 'bp_media_privacy'";
             $result = $wpdb->get_row($wpdb->prepare($sql, $result));
         } else {
             return $id;
         }
     }
     if (!isset($result) || !isset($result->post_id)) {
         return $old;
     }
     $media_id = $result->post_id;
     if (intval($result->context_id) > 0) {
         $media_context = 'profile';
         $prefix = 'users/' . abs(intval($result->context_id));
     } else {
         $media_context = 'group';
         $prefix = bp_get_groups_root_slug() . abs(intval($result->context_id));
     }
     $old_type = '';
     if ('attachment' != $result->post_type) {
         $media_type = 'album';
     } else {
         $mime_type = strtolower($result->post_mime_type);
         $old_type = '';
         if (0 === strpos($mime_type, 'image')) {
             $media_type = 'photo';
             $old_type = 'photos';
         } else {
             if (0 === strpos($mime_type, 'audio')) {
                 $media_type = 'music';
                 $old_type = 'music';
             } else {
                 if (0 === strpos($mime_type, 'video')) {
                     $media_type = 'video';
                     $old_type = 'videos';
                 } else {
                     $media_type = 'other';
                 }
             }
         }
     }
     $activity_data = $wpdb->get_row($wpdb->prepare("select * from {$bp_prefix}bp_activity where id= %d", $result->activity_id));
     if ('album' != $media_type) {
         $this->importmedia($media_id, $prefix);
     }
     if ($this->table_exists($bp_prefix . 'bp_activity') && class_exists('BP_Activity_Activity')) {
         $bp_activity = new BP_Activity_Activity();
         $activity_sql = $wpdb->prepare("SELECT\n                            *\n                        FROM\n                            {$bp_prefix}bp_activity\n                        where\n                                        id in (select distinct\n                                    a.meta_value\n                                from\n                                    {$wpdb->postmeta} a\n                                        left join\n                                    {$wpdb->posts} p ON (a.post_id = p.ID)\n                                where\n                                    (NOT p.ID IS NULL) and p.ID = %d\n                and a.meta_key = 'bp_media_child_activity')", $media_id);
         $all_activity = $wpdb->get_results($activity_sql);
         remove_all_actions('wp_insert_comment');
         foreach ($all_activity as $activity) {
             $comments = $bp_activity->get_activity_comments($activity->id, $activity->mptt_left, $activity->mptt_right);
             $exclude = get_post_meta($media_id, 'rtmedia_imported_activity', true);
             if (!is_array($exclude)) {
                 $exclude = array();
             }
             if ($comments) {
                 $this->insert_comment($media_id, $comments, $exclude);
             }
         }
     }
     if (0 !== intval($result->parent)) {
         $album_id = $this->migrate_single_media($result->parent, true);
     } else {
         $album_id = 0;
     }
     if (function_exists('bp_activity_get_meta')) {
         $likes = bp_activity_get_meta($result->activity_id, 'favorite_count');
     } else {
         $likes = 0;
     }
     $wpdb->insert($this->bmp_table, array('blog_id' => $blog_id, 'media_id' => $media_id, 'media_type' => $media_type, 'context' => $media_context, 'context_id' => abs(intval($result->context_id)), 'activity_id' => $result->activity_id, 'privacy' => intval($result->privacy) * 10, 'media_author' => $result->media_author, 'media_title' => $result->media_title, 'album_id' => $album_id, 'likes' => $likes), array('%d', '%d', '%s', '%s', '%d', '%d', '%d', '%d', '%s', '%d', '%d'));
     $last_id = $wpdb->insert_id;
     // Photo tag meta migration
     //$photo_tag_meta = get_post_meta($media_id, "bp-media-user-tags", true);
     //        if($photo_tag_meta && !empty($photo_tag_meta)){
     //            $wpdb->insert(
     //                $wpdb->prefix . "rt_rtm_media_meta", array(
     //                    'media_id' => $media_id,
     //                    'meta_key' => "user-tags",
     //                    "meta_value" =>  maybe_serialize($photo_tag_meta)), array('%d', '%s', '%s'));
     //        }
     if ('album' != $media_type && function_exists('bp_core_get_user_domain') && $activity_data) {
         if (function_exists('bp_core_get_table_prefix')) {
             $bp_prefix = bp_core_get_table_prefix();
         } else {
             $bp_prefix = '';
         }
//.........这里部分代码省略.........
开发者ID:fs-contributor,项目名称:rtMedia,代码行数:101,代码来源:RTMediaMigration.php

示例11: update_recorded_time_and_comments

 static function update_recorded_time_and_comments($media, $bp_album_id, $table)
 {
     global $wpdb;
     if (function_exists('bp_activity_add')) {
         if (!is_object($media)) {
             try {
                 $media = new BPMediaHostWordpress($media);
             } catch (exception $e) {
                 return false;
             }
         }
         $activity_id = get_post_meta($media->get_id(), 'bp_media_child_activity', true);
         if ($activity_id) {
             $date_uploaded = $wpdb->get_var("SELECT date_uploaded from {$table} WHERE id = {$bp_album_id}");
             $old_activity_id = $wpdb->get_var("SELECT id from {$wpdb->base_prefix}bp_activity WHERE component = 'album' AND type = 'bp_album_picture' AND item_id = {$bp_album_id}");
             if ($old_activity_id) {
                 $comments = $wpdb->get_results("SELECT id,secondary_item_id from {$wpdb->base_prefix}bp_activity WHERE component = 'activity' AND type = 'activity_comment' AND item_id = {$old_activity_id}");
                 foreach ($comments as $comment) {
                     $update = array('item_id' => $activity_id);
                     if ($comment->secondary_item_id == $old_activity_id) {
                         $update['secondary_item_id'] = $activity_id;
                     }
                     $wpdb->update($wpdb->base_prefix . 'bp_activity', $update, array('id' => $comment->id));
                     BP_Activity_Activity::rebuild_activity_comment_tree($activity_id);
                 }
             }
             $wpdb->update($wpdb->base_prefix . 'bp_activity', array('date_recorded' => $date_uploaded), array('id' => $activity_id));
             return count($comments);
         }
         return 0;
     }
 }
开发者ID:EfncoPlugins,项目名称:rtMedia,代码行数:32,代码来源:BPMediaAlbumimporter.php

示例12: get_sql_for_clause

 /**
  * Generate WHERE clauses for a first-order clause.
  *
  * @since BuddyPress (2.2.0)
  * @access protected
  *
  * @param  array $clause       Array of arguments belonging to the clause.
  * @param  array $parent_query Parent query to which the clause belongs.
  * @return array {
  *     @type array $where Array of subclauses for the WHERE statement.
  *     @type array $join  Empty array. Not used.
  * }
  */
 protected function get_sql_for_clause($clause, $parent_query)
 {
     global $wpdb;
     $sql_chunks = array('where' => array(), 'join' => array());
     $column = isset($clause['column']) ? $this->validate_column($clause['column']) : '';
     $value = isset($clause['value']) ? $clause['value'] : '';
     if (empty($column) || !isset($clause['value'])) {
         return $sql_chunks;
     }
     if (isset($clause['compare'])) {
         $clause['compare'] = strtoupper($clause['compare']);
     } else {
         $clause['compare'] = isset($clause['value']) && is_array($clause['value']) ? 'IN' : '=';
     }
     // default 'compare' to '=' if no valid operator is found
     if (!in_array($clause['compare'], array('=', '!=', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN', 'REGEXP', 'NOT REGEXP', 'RLIKE'))) {
         $clause['compare'] = '=';
     }
     $compare = $clause['compare'];
     $alias = !empty($this->table_alias) ? "{$this->table_alias}." : '';
     // Next, Build the WHERE clause.
     $where = '';
     // value.
     if (isset($clause['value'])) {
         if (in_array($compare, array('IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN'))) {
             if (!is_array($value)) {
                 $value = preg_split('/[,\\s]+/', $value);
             }
         }
         // tinyint
         if (!empty($column) && true === in_array($column, array('hide_sitewide', 'is_spam'))) {
             $sql_chunks['where'][] = $wpdb->prepare("{$alias}{$column} = %d", $value);
         } else {
             switch ($compare) {
                 // IN uses different syntax
                 case 'IN':
                 case 'NOT IN':
                     $in_sql = BP_Activity_Activity::get_in_operator_sql("{$alias}{$column}", $value);
                     // 'NOT IN' operator is as easy as a string replace!
                     if ('NOT IN' === $compare) {
                         $in_sql = str_replace('IN', 'NOT IN', $in_sql);
                     }
                     $sql_chunks['where'][] = $in_sql;
                     break;
                 case 'BETWEEN':
                 case 'NOT BETWEEN':
                     $value = array_slice($value, 0, 2);
                     $where = $wpdb->prepare('%s AND %s', $value);
                     break;
                 case 'LIKE':
                 case 'NOT LIKE':
                     $value = '%' . bp_esc_like($value) . '%';
                     $where = $wpdb->prepare('%s', $value);
                     break;
                 default:
                     $where = $wpdb->prepare('%s', $value);
                     break;
             }
         }
         if ($where) {
             $sql_chunks['where'][] = "{$alias}{$column} {$compare} {$where}";
         }
     }
     /*
      * Multiple WHERE clauses should be joined in parentheses.
      */
     if (1 < count($sql_chunks['where'])) {
         $sql_chunks['where'] = array('( ' . implode(' AND ', $sql_chunks['where']) . ' )');
     }
     return $sql_chunks;
 }
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:84,代码来源:bp-activity-classes.php

示例13: get

 public function get($max = false, $page = 1, $per_page = 25, $sort = 'DESC', $search_terms = false, $filter = false, $display_comments = false, $show_hidden = false)
 {
     global $wpdb, $bp;
     /* Select conditions */
     $select_sql = "SELECT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name";
     //from conditions
     $from_sql = " FROM {$bp->activity->table_name} a LEFT JOIN {$wpdb->users} u ON a.user_id = u.ID";
     /* Sorting */
     if ($sort != 'ASC' && $sort != 'DESC') {
         $sort = 'DESC';
     }
     //get or sql, to support your component, please filter on fb_like_activity_or_sql
     $or_sql = apply_filters("fb_like_activity_or_sql", self::get_filter_sql($filter), $filter);
     //get and sql
     $and_sql = apply_filters("fb_like_activity_or_sql", self::get_action_sql($filter), $filter);
     if (!empty($or_sql)) {
         $where_sql = "( " . $or_sql . " )";
     }
     if (!empty($and_sql)) {
         $where_sql = $where_sql . " AND " . $and_sql;
     }
     $activity_sql = "{$select_sql} {$from_sql}  WHERE {$where_sql}  ORDER BY date_recorded {$sort}";
     if ($per_page && $page) {
         $pag_sql = $wpdb->prepare("LIMIT %d, %d", intval(($page - 1) * $per_page), intval($per_page));
         $activities = $wpdb->get_results("{$activity_sql} {$pag_sql}");
     } else {
         $activities = $wpdb->get_results("{$activity_sql} {$pag_sql}");
     }
     // echo //needs mod
     $total_activities = $wpdb->get_var("SELECT count(a.id) FROM {$bp->activity->table_name} a WHERE {$where_sql} ORDER BY a.date_recorded {$sort}");
     /* Get the fullnames of users so we don't have to query in the loop */
     if (function_exists('xprofile_install') && $activities) {
         foreach ((array) $activities as $activity) {
             if ((int) $activity->user_id) {
                 $activity_user_ids[] = $activity->user_id;
             }
         }
         $activity_user_ids = implode(',', array_unique((array) $activity_user_ids));
         if (!empty($activity_user_ids)) {
             if ($names = $wpdb->get_results("SELECT user_id, value AS user_fullname FROM {$bp->profile->table_name_data} WHERE field_id = 1 AND user_id IN ({$activity_user_ids})")) {
                 foreach ((array) $names as $name) {
                     $tmp_names[$name->user_id] = $name->user_fullname;
                 }
                 foreach ((array) $activities as $i => $activity) {
                     if (!empty($tmp_names[$activity->user_id])) {
                         $activities[$i]->user_fullname = $tmp_names[$activity->user_id];
                     }
                 }
                 unset($names);
                 unset($tmp_names);
             }
         }
     }
     if ($activities && $display_comments) {
         $activities = BP_Activity_Activity::append_comments($activities);
     }
     /* If $max is set, only return up to the max results */
     if (!empty($max)) {
         if ((int) $total_activities > (int) $max) {
             $total_activities = $max;
         }
     }
     return array('activities' => $activities, 'total' => (int) $total_activities);
 }
开发者ID:poweronio,项目名称:mbsite,代码行数:64,代码来源:bp-fblike-activity-stream.php

示例14: bp_blogs_sync_delete_from_activity_comment

/**
 * Deletes the blog comment when the associated activity comment is deleted.
 *
 * Note: This is hooked on the 'bp_activity_delete_comment_pre' filter instead
 * of the 'bp_activity_delete_comment' action because we need to fetch the
 * activity comment children before they are deleted.
 *
 * @since 2.0.0
 * @since 2.5.0 Add the $delected parameter
 *
 * @param bool $retval             Whether BuddyPress should continue or not.
 * @param int  $parent_activity_id The parent activity ID for the activity comment.
 * @param int  $activity_id        The activity ID for the pending deleted activity comment.
 * @param bool $deleted            Whether the comment was deleted or not.
 * @return bool
 */
function bp_blogs_sync_delete_from_activity_comment($retval, $parent_activity_id, $activity_id, &$deleted)
{
    // Check if parent activity is a blog post.
    $parent_activity = new BP_Activity_Activity($parent_activity_id);
    // if parent activity isn't a post type having the buddypress-activity support, stop now!
    if (!bp_activity_type_supports($parent_activity->type, 'post-type-comment-tracking')) {
        return $retval;
    }
    // Fetch the activity comments for the activity item.
    $activity = bp_activity_get(array('in' => $activity_id, 'display_comments' => 'stream', 'spam' => 'all'));
    // Get all activity comment IDs for the pending deleted item.
    $activity_ids = bp_activity_recurse_comments_activity_ids($activity);
    $activity_ids[] = $activity_id;
    // Handle multisite
    // switch to the blog where the comment was made.
    switch_to_blog($parent_activity->item_id);
    // Remove associated blog comments.
    bp_blogs_remove_associated_blog_comments($activity_ids, current_user_can('moderate_comments'));
    // Multisite again!
    restore_current_blog();
    // Rebuild activity comment tree
    // emulate bp_activity_delete_comment().
    BP_Activity_Activity::rebuild_activity_comment_tree($parent_activity_id);
    // Avoid the error message although the comments were successfully deleted
    $deleted = true;
    // We're overriding the default bp_activity_delete_comment() functionality
    // so we need to return false.
    return false;
}
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:45,代码来源:bp-blogs-activity.php

示例15: delete_pic_cover

function delete_pic_cover($activity_id)
{
    global $bp;
    $user_id = bp_loggedin_user_id();
    $activity_id = $_POST['activity_id'];
    $attachment_id = bp_activity_get_meta($activity_id, 'bp_cover_activity', true);
    wp_delete_attachment($attachment_id, true);
    delete_post_meta($attachment_id, true);
    delete_user_meta($user_id, 'bp_cover');
    delete_user_meta($user_id, 'bp_cover_position');
    bp_activity_delete(array('id' => $activity_id, 'user_id' => $bp->loggedin_user->id));
    BP_Activity_Activity::delete_activity_meta_entries($activity_id);
}
开发者ID:aghajoon,项目名称:bp-cover,代码行数:13,代码来源:bp-cover.php


注:本文中的BP_Activity_Activity类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。