• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP bp_activity_update_meta函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: vortex_update_meta

 function vortex_update_meta($post_id, $key, $value)
 {
     $bbp = vortex_is_buddypress($post_id);
     if ($bbp) {
         return bp_activity_update_meta($post_id, $key, $value);
     } else {
         return update_post_meta($post_id, $key, $value);
     }
 }
开发者ID:AlexAlexandru,项目名称:rating-system,代码行数:9,代码来源:posts-pages.php


示例2: bp_course_record_activity_meta

function bp_course_record_activity_meta($args = '')
{
    if (!function_exists('bp_activity_update_meta')) {
        return false;
    }
    $defaults = array('id' => false, 'meta_key' => '', 'meta_value' => '');
    $r = wp_parse_args($args, $defaults);
    extract($r);
    return bp_activity_update_meta($id, $meta_key, $meta_value);
}
开发者ID:Nguyenkain,项目名称:Elearning,代码行数:10,代码来源:bp-course-activity.php


示例3: test_get_with_meta_query_two_clauses_with_or_relation

 /**
  * @group get
  */
 public function test_get_with_meta_query_two_clauses_with_or_relation()
 {
     $now = time();
     $a1 = $this->factory->activity->create(array('recorded_time' => date('Y-m-d H:i:s', $now)));
     $a2 = $this->factory->activity->create(array('recorded_time' => date('Y-m-d H:i:s', $now - 60)));
     $a3 = $this->factory->activity->create(array('recorded_time' => date('Y-m-d H:i:s', $now - 120)));
     bp_activity_update_meta($a1, 'foo', 'bar');
     bp_activity_update_meta($a2, 'foo', 'bar');
     bp_activity_update_meta($a1, 'baz', 'barry');
     $activity = BP_Activity_Activity::get(array('meta_query' => array('relation' => 'OR', array('key' => 'foo', 'value' => 'bar'), array('key' => 'baz', 'value' => 'barry')), 'count_total' => 'count_query'));
     $ids = wp_list_pluck($activity['activities'], 'id');
     $this->assertEquals(array($a1, $a2), $ids);
     $this->assertEquals(2, $activity['total']);
 }
开发者ID:jasonmcalpin,项目名称:BuddyPress,代码行数:17,代码来源:class.BP_Activity_Activity.php


示例4: save_activity

 /**
  * Saves a BuddyPress Activity
  *
  * @param stdObject $activity Row from the activity table
  * @return boolean (TRUE if there were actually Bible references to save)
  */
 public function save_activity($activity)
 {
     // Add any read passage strings
     if (!empty($activity->bfox_read_ref_str)) {
         bp_activity_update_meta($activity->id, 'bfox_read_ref_str', $activity->bfox_read_ref_str);
         do_action('bfox_save_activity_read_ref_str', $activity);
     }
     if ($success = $this->save_item($activity->id, apply_filters('bfox_save_activity_ref', $activity->bfox_ref, $activity))) {
         // If we successfully saved some Bible references, lets cache the string in the activity meta
         // That way we don't have to recalculate it each time which could be a pain
         // For example, recalculating the references for a blog post requires switching to that blog, getting the blog post and parsing it
         // Instead, we can just use this meta
         bp_activity_update_meta($activity->id, 'bfox_ref_str', $activity->bfox_ref->get_string(BibleMeta::name_short));
     }
     return $success;
 }
开发者ID:jeffryevans,项目名称:biblefox-wp,代码行数:22,代码来源:activity.php


示例5: test_bp_activity_update_meta_cache

 /**
  * @group bp_activity_update_meta_cache
  */
 public function test_bp_activity_update_meta_cache()
 {
     $a1 = $this->factory->activity->create();
     $a2 = $this->factory->activity->create();
     // Set up some data
     bp_activity_update_meta($a1, 'foo', 'bar');
     bp_activity_update_meta($a1, 'Boone', 'Rules');
     bp_activity_update_meta($a2, 'foo', 'baz');
     bp_activity_update_meta($a2, 'BuddyPress', 'Is Cool');
     // Prime the cache for $a1
     bp_activity_get_meta($a1, 'foo');
     // Ensure an empty cache for $a2
     wp_cache_delete($a2, 'activity_meta');
     bp_activity_update_meta_cache(array($a1, $a2));
     $expected = array($a1 => array('foo' => array('bar'), 'Boone' => array('Rules')), $a2 => array('foo' => array('baz'), 'BuddyPress' => array('Is Cool')));
     $found = array($a1 => wp_cache_get($a1, 'activity_meta'), $a2 => wp_cache_get($a2, 'activity_meta'));
     $this->assertEquals($expected, $found);
 }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:21,代码来源:cache.php


示例6: add_media


//.........这里部分代码省略.........
			wp_delete_post($post_id, true);
			throw new Exception(__('Error Uploading File', 'bp-media'));
		}
		$attachment = array();
		$url = $file['url'];
		$type = $file['type'];
		$file = $file['file'];
		$title = $name;
		$content = $description;
		$attachment = array(
			'post_mime_type' => $type,
			'guid' => $url,
			'post_title' => $title,
			'post_content' => $content,
			'post_parent' => $post_id,
		);
		bp_media_init_count(bp_loggedin_user_id());
		switch ($type) {
			case 'video/mp4' :
				$type = 'video';
				include_once(trailingslashit(BP_MEDIA_PLUGIN_DIR) . 'includes/lib/getid3/getid3.php');
				try {
					$getID3 = new getID3;
					$vid_info = $getID3->analyze($file);
				} catch (Exception $e) {
					wp_delete_post($post_id, true);
					unlink($file);
					$activity_content = false;
					throw new Exception(__('MP4 file you have uploaded is currupt.', 'bp-media'));
				}
				if (is_array($vid_info)) {
					if (!array_key_exists('error',$vid_info)&& array_key_exists('fileformat', $vid_info) && array_key_exists('video', $vid_info)&&array_key_exists('fourcc',$vid_info['video'])) {
						if (!($vid_info['fileformat']=='mp4'&&$vid_info['video']['fourcc']=='avc1')) {
							wp_delete_post($post_id, true);
							unlink($file);
							$activity_content = false;
							throw new Exception(__('The MP4 file you have uploaded is using an unsupported video codec. Supported video codec is H.264.', 'bp-media'));
						}
					} else {
						wp_delete_post($post_id, true);
						unlink($file);
						$activity_content = false;
						throw new Exception(__('The MP4 file you have uploaded is using an unsupported video codec. Supported video codec is H.264.', 'bp-media'));
					}
				} else {
					wp_delete_post($post_id, true);
					unlink($file);
					$activity_content = false;
					throw new Exception(__('The MP4 file you have uploaded is not a video file.', 'bp-media'));
				}
				$bp_media_count['videos'] = intval($bp_media_count['videos']) + 1;
				break;
			case 'audio/mpeg' :
				$type = 'audio';
				$bp_media_count['audio'] = intval($bp_media_count['audio']) + 1;
				break;
			case 'image/gif' :
			case 'image/jpeg' :
			case 'image/png' :
				$type = 'image';
				$bp_media_count['images'] = intval($bp_media_count['images']) + 1;
				break;
			default : unlink($file);
				wp_delete_post($post_id, true);
				unlink($file);
				$activity_content = false;
				throw new Exception(__('Media File you have tried to upload is not supported. Supported media files are .jpg, .png, .gif, .mp3 and .mp4.', 'bp-media'));
		}
		$attachment_id = wp_insert_attachment($attachment, $file, $post_id);
		if (!is_wp_error($attachment_id)) {
			wp_update_attachment_metadata($attachment_id, wp_generate_attachment_metadata($attachment_id, $file));
		} else {
			wp_delete_post($post_id, true);
			unlink($file);
			throw new Exception(__('Error creating activity for the media file, please try again', 'bp-media'));
		}
		$postarr['ID'] = $post_id;
		$postarr['post_mime_type'] = $type;
		$postarr['post_status'] = 'publish';
		wp_insert_post($postarr);
		$activity_content = '[bp_media_content id="' . $post_id . '"]';
		$activity_id = bp_media_record_activity(array(
			'action' => '[bp_media_action id="' . $post_id . '"]',
			'content' => $activity_content,
			'primary_link' => '[bp_media_url id="' . $post_id . '"]',
			'type' => 'media_upload'
		));
		bp_activity_update_meta($activity_id, 'bp_media_parent_post', $post_id);
		update_post_meta($post_id, 'bp_media_child_activity', $activity_id);
		update_post_meta($post_id, 'bp_media_child_attachment', $attachment_id);
		update_post_meta($post_id, 'bp_media_type', $type);
		update_post_meta($post_id, 'bp_media_hosting', 'wordpress');
		$this->id = $post_id;
		$this->name = $name;
		$this->description = $description;
		$this->owner = bp_loggedin_user_id();
		$this->type = $type;
		$this->url = $url;
		bp_update_user_meta(bp_loggedin_user_id(), 'bp_media_count', $bp_media_count);
	}
开发者ID:rolandinsh,项目名称:buddypress-media,代码行数:101,代码来源:bp-media-class-wordpress.php


示例7: add_rating

 function add_rating($args = '')
 {
     global $bp;
     $defaults = array('group_id' => $bp->groups->current_group->id, 'score' => false, 'user_id' => $bp->loggedin_user->id, 'activity_id' => false);
     $r = wp_parse_args($args, $defaults);
     extract($r, EXTR_SKIP);
     if (empty($score)) {
         return false;
     }
     // First record the activity meta for this particular rating
     bp_activity_update_meta($activity_id, 'bpgr_rating', $score);
     // Then add this item to the list of reviews for this group
     if (!($ratings = groups_get_groupmeta($group_id, 'bpgr_ratings'))) {
         $ratings = array();
     }
     $ratings[$activity_id] = $score;
     // Pull the composite scores and recalculate
     if (!($rating = groups_get_groupmeta($group_id, 'bpgr_rating'))) {
         $avg_score = 0;
     }
     if (!($how_many = (int) groups_get_groupmeta($group_id, 'bpgr_how_many_ratings'))) {
         $how_many = 0;
     }
     $how_many++;
     groups_update_groupmeta($group_id, 'bpgr_how_many_ratings', $how_many);
     $raw_score = 0;
     foreach ($ratings as $score) {
         $raw_score += (int) $score;
     }
     $rating = $raw_score / $how_many;
     groups_update_groupmeta($group_id, 'bpgr_rating', $rating);
     groups_update_groupmeta($group_id, 'bpgr_ratings', $ratings);
 }
开发者ID:adisonc,项目名称:MaineLearning,代码行数:33,代码来源:classes.php


示例8: dwqa_replace_activity_meta

function dwqa_replace_activity_meta()
{
    global $activities_template;
    $blog_url = bp_blogs_get_blogmeta($activity->item_id, 'url');
    $blog_name = bp_blogs_get_blogmeta($activity->item_id, 'name');
    if (empty($blog_url) || empty($blog_name)) {
        $blog_url = get_home_url($activity->item_id);
        $blog_name = get_blog_option($activity->item_id, 'blogname');
        bp_blogs_update_blogmeta($activity->item_id, 'url', $blog_url);
        bp_blogs_update_blogmeta($activity->item_id, 'name', $blog_name);
    }
    $post_url = add_query_arg('p', $activities_template->activity->secondary_item_id, trailingslashit($blog_url));
    $post_title = bp_activity_get_meta($activities_template->activity->id, 'post_title');
    if (empty($post_title)) {
        $post = get_post($activities_template->activity->secondary_item_id);
        if (is_a($post, 'WP_Post')) {
            $post_title = $post->post_title;
            bp_activity_update_meta($activities_template->activity->id, 'post_title', $post_title);
        }
    }
    $post_link = '<a href="' . $post_url . '">' . $post_title . '</a>';
    $user_link = bp_core_get_userlink($activities_template->activity->user_id);
    if ($activities_template->activity->type == 'new_question') {
        $action = sprintf(__('%1$s asked a new question: %2$s', 'dwqa'), $user_link, $post_link);
    } elseif ($activities_template->activity->type == 'new_answer') {
        $action = sprintf(__('%1$s answered the question: %2$s', 'dwqa'), $user_link, $post_link);
    } elseif ($activities_template->activity->type == 'comment_question') {
        $action = sprintf(__('%1$s commented on the question: %2$s', 'dwqa'), $user_link, $post_link);
    } elseif ($activities_template->activity->type == 'comment_answer') {
        $action = sprintf(__('%1$s commented on the answer at: %2$s', 'dwqa'), $user_link, $post_link);
    } else {
        $action = $activities_template->activity->action;
    }
    // Strip any legacy time since placeholders from BP 1.0-1.1
    $content = str_replace('<span class="time-since">%s</span>', '', $content);
    // Insert the time since.
    $time_since = apply_filters_ref_array('bp_activity_time_since', array('<span class="time-since">' . bp_core_time_since($activities_template->activity->date_recorded) . '</span>', &$activities_template->activity));
    // Insert the permalink
    if (!bp_is_single_activity()) {
        $content = apply_filters_ref_array('bp_activity_permalink', array(sprintf('%1$s <a href="%2$s" class="view activity-time-since" title="%3$s">%4$s</a>', $content, bp_activity_get_permalink($activities_template->activity->id, $activities_template->activity), esc_attr__('View Discussion', 'buddypress'), $time_since), &$activities_template->activity));
    } else {
        $content .= str_pad($time_since, strlen($time_since) + 2, ' ', STR_PAD_BOTH);
    }
    echo $action . ' ' . $content;
    // echo 'abc';
    // echo $activities_template->activity->content;
}
开发者ID:linkinf88k,项目名称:dw-question-answer,代码行数:47,代码来源:buddypress.php


示例9: bp_activity_posted_update

 function bp_activity_posted_update($content, $user_id, $activity_id)
 {
     global $wpdb, $bp;
     $updated_content = '';
     // hook for rtmedia buddypress before activity posted
     do_action('rtmedia_bp_before_activity_posted', $content, $user_id, $activity_id);
     if (isset($_POST['rtMedia_attached_files']) && is_array($_POST['rtMedia_attached_files'])) {
         $updated_content = $wpdb->get_var("select content from  {$bp->activity->table_name} where  id= {$activity_id}");
         $objActivity = new RTMediaActivity($_POST['rtMedia_attached_files'], 0, $updated_content);
         $html_content = $objActivity->create_activity_html();
         bp_activity_update_meta($activity_id, 'bp_old_activity_content', $html_content);
         bp_activity_update_meta($activity_id, 'bp_activity_text', $updated_content);
         $wpdb->update($bp->activity->table_name, array('type' => 'rtmedia_update', 'content' => $html_content), array('id' => $activity_id));
         $mediaObj = new RTMediaModel();
         $sql = "update {$mediaObj->table_name} set activity_id = '" . $activity_id . "' where blog_id = '" . get_current_blog_id() . "' and id in (" . implode(',', $_POST['rtMedia_attached_files']) . ')';
         $wpdb->query($sql);
     }
     // hook for rtmedia buddypress after activity posted
     do_action('rtmedia_bp_activity_posted', $updated_content, $user_id, $activity_id);
     if (isset($_POST['rtmedia-privacy'])) {
         $privacy = -1;
         if (is_rtmedia_privacy_enable()) {
             if (is_rtmedia_privacy_user_overide()) {
                 $privacy = $_POST['rtmedia-privacy'];
             } else {
                 $privacy = get_rtmedia_default_privacy();
             }
         }
         bp_activity_update_meta($activity_id, 'rtmedia_privacy', $privacy);
         // insert/update activity details in rtmedia activity table
         $rtmedia_activity_model = new RTMediaActivityModel();
         if (!$rtmedia_activity_model->check($activity_id)) {
             $rtmedia_activity_model->insert(array('activity_id' => $activity_id, 'user_id' => $user_id, 'privacy' => $privacy));
         } else {
             $rtmedia_activity_model->update(array('activity_id' => $activity_id, 'user_id' => $user_id, 'privacy' => $privacy), array('activity_id' => $activity_id));
         }
     }
 }
开发者ID:fs-contributor,项目名称:rtMedia,代码行数:38,代码来源:RTMediaBuddyPressActivity.php


示例10: bp_embed_activity_save_cache

/**
 * Set an activity item's embed cache.
 *
 * Used during {@link BP_Embed::parse_oembed()} via {@link bp_activity_embed()}.
 *
 * @since BuddyPress (1.5.0)
 *
 * @see BP_Embed::parse_oembed()
 * @uses bp_activity_update_meta()
 *
 * @param string $cache An empty string passed by BP_Embed::parse_oembed() for
 *        functions like this one to filter.
 * @param string $cachekey The cache key generated in BP_Embed::parse_oembed().
 * @param int $id The ID of the activity item.
 * @return bool True on success, false on failure.
 */
function bp_embed_activity_save_cache($cache, $cachekey, $id)
{
    bp_activity_update_meta($id, $cachekey, $cache);
}
开发者ID:eresyyl,项目名称:mk,代码行数:20,代码来源:bp-activity-functions.php


示例11: bp_cover_group_handle_upload

function bp_cover_group_handle_upload($activity_id)
{
    global $bp, $wpdb;
    $group_id = bp_get_current_group_id();
    $activity_table = $wpdb->prefix . "bp_activity";
    $activity_meta_table = $wpdb->prefix . "bp_activity_meta";
    $sql = "SELECT COUNT(*) as photo_count FROM {$activity_table} a INNER JOIN {$activity_meta_table} am ON a.id = am.activity_id WHERE a.item_id = %d AND meta_key = 'all_bp_cover_group'";
    $sql = $wpdb->prepare($sql, $group_id);
    $cnt = $wpdb->get_var($sql);
    $max_cnt = bp_cover_get_max_total();
    if ($cnt < $max_cnt) {
        if ($_POST['encodedimg']) {
            $file = $_POST['imgsize'];
            $max_upload_size = bp_cover_get_max_media_size();
            if ($max_upload_size > $file) {
                $group_id = $bp->groups->current_group->id;
                $imgresponse = array();
                $uploaddir = wp_upload_dir();
                /* let's decode the base64 encoded image sent */
                $img = $_POST['encodedimg'];
                $img = str_replace('data:' . $_POST['imgtype'] . ';base64,', '', $img);
                $img = str_replace(' ', '+', $img);
                $data = base64_decode($img);
                $imgname = wp_unique_filename($uploaddir['path'], $_POST['imgname']);
                $filepath = $uploaddir['path'] . '/' . $imgname;
                $fileurl = $uploaddir['url'] . '/' . $imgname;
                /* now we write the image in dir */
                $success = file_put_contents($filepath, $data);
                if ($success) {
                    $imgresponse[0] = "1";
                    $imgresponse[1] = $fileurl;
                    $size = @getimagesize($filepath);
                    $attachment = array('post_mime_type' => $_POST['imgtype'], 'guid' => $fileurl, 'post_title' => $imgname);
                    require_once ABSPATH . 'wp-admin/includes/image.php';
                    $attachment_id = wp_insert_attachment($attachment, $filepath);
                    $attach_data = wp_generate_attachment_metadata($attachment_id, $filepath);
                    wp_update_attachment_metadata($attachment_id, $attach_data);
                    groups_update_groupmeta($group_id, 'bp_cover_group', $fileurl);
                    groups_update_groupmeta($group_id, 'bp_cover_group_position', 0);
                    $group = groups_get_group(array("group_id" => $group_id));
                    $activity_id = groups_record_activity(array('action' => sprintf(__('%s uploaded a new cover picture to the group %s', 'bp-cover'), bp_core_get_userlink($bp->loggedin_user->id), '<a href="' . bp_get_group_permalink($group) . '">' . esc_attr($group->name) . '</a>'), 'type' => 'cover_added', 'item_id' => $group_id, 'content' => bp_cover_group_get_image_scr(), 'item_id' => $group_id));
                    bp_activity_update_meta($activity_id, 'all_bp_cover_group', $attachment_id);
                    update_post_meta($attachment_id, 'bp_cover_group_thumb', $imgresponse[2]);
                } else {
                    $imgresponse[0] = "0";
                    $imgresponse[1] = __('Upload Failed! Unable to write the image on server', 'bp-cover');
                }
            } else {
                $imgresponse[0] = "0";
                $imgresponse[1] = sprintf(__('The file you uploaded is too big. Please upload a file under %s', 'bp-cover'), size_format($max_upload_size));
            }
        } else {
            $imgresponse[0] = "0";
            $imgresponse[1] = __('Upload Failed! No image sent', 'bp-cover');
        }
    } else {
        $imgresponse[0] = "0";
        $imgresponse[1] = sprintf(__('Max total images allowed %d in a cover gallery', 'bp-cover'), $max_cnt);
    }
    /* if everything is ok, we send back url to thumbnail and to full image */
    echo json_encode($imgresponse);
    die;
}
开发者ID:aghajoon,项目名称:bp-cover,代码行数:63,代码来源:bp-cover-group.php


示例12: bp_checkins_untrashed_place

function bp_checkins_untrashed_place($place_id)
{
    // we need to rebuilt the activity type new_place and its activity_meta
    if (empty($place_id)) {
        return false;
    }
    $place = get_post($place_id);
    if (!in_array($place->post_type, array('places'))) {
        return false;
    }
    /* do we have a group_id ? */
    $group_id = get_post_meta($place_id, '_bpci_group_id', true);
    /* let's build the activity vars */
    $place_name = esc_attr($place->post_title);
    $thumbnail = bp_get_checkins_places_featured_image($place_id);
    $excerpt = bp_get_checkins_places_excerpt($place->post_content);
    $place_content = apply_filters('bp_checkins_place_content_before_activity', $thumbnail . $excerpt);
    $args = array('content' => $place_content, 'user_id' => $place->post_author, 'type' => 'new_place', 'place_id' => $place_id, 'place_name' => $place_name, 'recorded_time' => $place->post_date_gmt);
    if (!empty($group_id) && $group_id != 0) {
        // adding the group_id to args.
        $args['group_id'] = $group_id;
        $activity_id = bp_checkins_groups_post_update($args);
    } else {
        $activity_id = bp_checkins_post_update($args);
    }
    if (!empty($activity_id)) {
        /* 
         * now we store the post meta as activity meta 
         * this way if cookies of superadmin were writen
         * we'll be sure to have the correct values.
         */
        $lat = get_post_meta($place_id, 'bpci_places_lat', true);
        $lng = get_post_meta($place_id, 'bpci_places_lng', true);
        $address = get_post_meta($place_id, 'bpci_places_address', true);
        if (empty($lat) || empty($lng) || empty($address)) {
            return false;
        }
        bp_activity_update_meta($activity_id, 'bpci_activity_lat', $lat);
        bp_activity_update_meta($activity_id, 'bpci_activity_lng', $lng);
        bp_activity_update_meta($activity_id, 'bpci_activity_address', $address);
    }
}
开发者ID:socialray,项目名称:surfied-2-0,代码行数:42,代码来源:bp-checkins-functions.php


示例13: buddyreshare_reset_metas

/**
 * In case of a reshare delete, reset some activity metas
 *
 * @package BP Reshare
 * @since    1.0
 * 
 * @param  integer $activity_id the reshared activity id
 * @param  integer $user_id     the user id
 * @uses   bp_activity_get_meta() to get some meta infos about the activity
 * @uses   bp_activity_delete_meta() to delete some meta infos for the activity
 * @uses   bp_activity_update_meta() to save some meta infos for the activity
 * @return boolean true
 */
function buddyreshare_reset_metas($activity_id = 0, $user_id = 0)
{
    if (empty($activity_id) || empty($user_id)) {
        return false;
    }
    $count = bp_activity_get_meta($activity_id, 'reshared_count');
    $count = $count - 1;
    $reshared_by = bp_activity_get_meta($activity_id, 'reshared_by');
    if ($count == 0) {
        // if count is null, then we can delete all metas !
        bp_activity_delete_meta($activity_id, 'reshared_count');
        bp_activity_delete_meta($activity_id, 'reshared_by');
    } else {
        foreach ($reshared_by as $key => $val) {
            if ($user_id == $val) {
                unset($reshared_by[$key]);
            }
        }
        bp_activity_update_meta($activity_id, 'reshared_count', $count);
        bp_activity_update_meta($activity_id, 'reshared_by', $reshared_by);
    }
    return true;
}
开发者ID:socialray,项目名称:surfied-2-0,代码行数:36,代码来源:functions.php


示例14: bp_blogs_sync_add_from_activity_comment

/**
 * Syncs activity comments and posts them back as blog comments.
 *
 * Note: This is only a one-way sync - activity comments -> blog comment.
 *
 * For blog post -> activity comment, see {@link bp_activity_post_type_comment()}.
 *
 * @since 2.0.0
 * @since 2.5.0 Allow custom post types to sync their comments with activity ones
 *
 * @param int    $comment_id      The activity ID for the posted activity comment.
 * @param array  $params          Parameters for the activity comment.
 * @param object $parent_activity Parameters of the parent activity item (in this case, the blog post).
 */
function bp_blogs_sync_add_from_activity_comment($comment_id, $params, $parent_activity)
{
    // 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;
    }
    // If activity comments are disabled for blog posts, stop now!
    if (bp_disable_blogforum_comments()) {
        return;
    }
    // Get userdata.
    if ($params['user_id'] == bp_loggedin_user_id()) {
        $user = buddypress()->loggedin_user->userdata;
    } else {
        $user = bp_core_get_core_userdata($params['user_id']);
    }
    // Get associated post type and set default comment parent
    $post_type = bp_activity_post_type_get_tracking_arg($parent_activity->type, 'post_type');
    $comment_parent = 0;
    // See if a parent WP comment ID exists.
    if (!empty($params['parent_id']) && !empty($post_type)) {
        $comment_parent = bp_activity_get_meta($params['parent_id'], "bp_blogs_{$post_type}_comment_id");
    }
    // Comment args.
    $args = array('comment_post_ID' => $parent_activity->secondary_item_id, 'comment_author' => bp_core_get_user_displayname($params['user_id']), 'comment_author_email' => $user->user_email, 'comment_author_url' => bp_core_get_user_domain($params['user_id'], $user->user_nicename, $user->user_login), 'comment_content' => $params['content'], 'comment_type' => '', 'comment_parent' => (int) $comment_parent, 'user_id' => $params['user_id'], 'comment_approved' => 1);
    // Prevent separate activity entry being made.
    remove_action('comment_post', 'bp_activity_post_type_comment', 10, 2);
    // Handle multisite.
    switch_to_blog($parent_activity->item_id);
    // Handle timestamps for the WP comment after we've switched to the blog.
    $args['comment_date'] = current_time('mysql');
    $args['comment_date_gmt'] = current_time('mysql', 1);
    // Post the comment.
    $post_comment_id = wp_insert_comment($args);
    // Add meta to comment.
    add_comment_meta($post_comment_id, 'bp_activity_comment_id', $comment_id);
    // Add meta to activity comment.
    if (!empty($post_type)) {
        bp_activity_update_meta($comment_id, "bp_blogs_{$post_type}_comment_id", $post_comment_id);
    }
    // Resave activity comment with WP comment permalink.
    //
    // in bp_blogs_activity_comment_permalink(), we change activity comment
    // permalinks to use the post comment link
    //
    // @todo since this is done after AJAX posting, the activity comment permalink
    // doesn't change on the frontend until the next page refresh.
    $resave_activity = new BP_Activity_Activity($comment_id);
    $resave_activity->primary_link = get_comment_link($post_comment_id);
    /**
     * Now that the activity id exists and the post comment was created, we don't need to update
     * the content of the comment as there are no chances it has evolved.
     */
    remove_action('bp_activity_before_save', 'bp_blogs_sync_activity_edit_to_post_comment', 20);
    $resave_activity->save();
    // Add the edit activity comment hook back.
    add_action('bp_activity_before_save', 'bp_blogs_sync_activity_edit_to_post_comment', 20);
    // Multisite again!
    restore_current_blog();
    // Add the comment hook back.
    add_action('comment_post', 'bp_activity_post_type_comment', 10, 2);
    /**
     * Fires after activity comments have been synced and posted as blog comments.
     *
     * @since 2.0.0
     *
     * @param int    $comment_id      The activity ID for the posted activity comment.
     * @param array  $args            Array of args used for the comment syncing.
     * @param object $parent_activity Parameters of the blog post parent activity item.
     * @param object $user            User data object for the blog comment.
     */
    do_action('bp_blogs_sync_add_from_activity_comment', $comment_id, $args, $parent_activity, $user);
}
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:87,代码来源:bp-blogs-activity.php


示例15: update_meta_data

 /**
  * Update meta data
  *
  * @author       	Alimir
  * @param           Integer $id
  * @param           String $key
  * @param           Integer $data
  * @since           2.0
  * @updated         2.2
  * @return			Void
  */
 public function update_meta_data($id, $key, $data)
 {
     if ($key == "_liked" || $key == "_topicliked") {
         update_post_meta($id, $key, $data);
     } else {
         if ($key == "_commentliked") {
             update_comment_meta($id, $key, $data);
         } else {
             if ($key == "_activityliked") {
                 bp_activity_update_meta($id, $key, $data);
             } else {
                 return 0;
             }
         }
     }
 }
开发者ID:pantelicnevena,项目名称:hanan,代码行数:27,代码来源:class-ulike.php


示例16: unpin_activity

    /**
     *
     */
    function unpin_activity()
    {
        global $wpdb;
        $nonce = isset($_REQUEST['nonces']) ? sanitize_text_field($_REQUEST['nonces']) : 0;
        if (!wp_verify_nonce($nonce, 'pin-activity-nonce')) {
            exit(__('Not permitted', RW_Sticky_Activity::$textdomain));
        }
        $activityID = isset($_REQUEST['id']) && is_numeric($_REQUEST['id']) ? $_REQUEST['id'] : '';
        if ($activityID != '') {
            bp_activity_update_meta($activityID, 'rw_sticky_activity', 0);
        }
        $meta_query_args = array('relation' => 'AND', array('key' => 'rw_sticky_activity', 'value' => '1', 'compare' => '='));
        if (function_exists('bb_bp_activity_url_filter')) {
            // deactivate BuddyBoss Wall activity url preview
            remove_action('bp_get_activity_content_body', 'bb_bp_activity_url_filter');
        }
        add_filter('bp_activity_excerpt_length', function () {
            return 99999;
        });
        if (bp_has_activities(array('meta_query' => $meta_query_args))) {
            ?>
            <?php 
            while (bp_activities()) {
                bp_the_activity();
                ?>
                <div class="buddypress-sa">
                    <div id="factivity-stream">
                        <div class="activity-list">
                            <div class="activity-content" style="margin-left: 0px;">
                                <?php 
                $nonce = wp_create_nonce('pin-activity-nonce');
                $title = __('Unpin activity', RW_Sticky_Activity::$textdomain);
                $class = "sa-button-unpin  pinned";
                ?>
                                <a href="" class="fa fa-map-marker icon-button sa-button <?php 
                echo $class;
                ?>
" title="<?php 
                echo $title;
                ?>
" data-post-nonces="<?php 
                echo $nonce;
                ?>
" data-post-id="<?php 
                echo bp_get_activity_id();
                ?>
"></a>
                                <?php 
                if (bp_activity_has_content() && bp_get_activity_type() != 'bbp_topic_create' && bp_get_activity_type() != 'bbp_reply_create') {
                    ?>
                                    <div class="activity-inner">
                                        <?php 
                    bp_activity_content_body();
                    ?>
                                    </div>
                                <?php 
                }
                ?>
                                <?php 
                if (bp_get_activity_type() == 'bp_doc_edited') {
                    ?>
                                    <div class="activity-inner"><p>
                                            <?php 
                    $doc = get_post(url_to_postid(bp_get_activity_feed_item_link()));
                    echo __('Doc: ', RW_Sticky_Activity::$textdomain);
                    echo "<a href='" . get_permalink($doc->ID) . "'>";
                    echo $doc->post_title;
                    echo "</a>";
                    ?>
</p>
                                    </div>
                                    <?php 
                }
                // New forum topic created
                if (bp_get_activity_type() == 'bbp_topic_create') {
                    // url_to_postid fails on permalinks like http://gruppen.domain.tld/groups/frank-testgruppe/forum/topic/neues-thema/ !!!
                    ?>
                                    <div class="activity-inner"><p>
                                            <?php 
                    $link = bp_get_activity_feed_item_link();
                    $guid = substr($link, strpos($link, "/forum/topic") + 6);
                    $topicid = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE guid like '%%%s%%'", $guid));
                    $topic = get_post($topicid);
                    echo __('Forum new topic: ', RW_Sticky_Activity::$textdomain);
                    echo "<a href='" . get_permalink($topic->ID) . "'> ";
                    echo $topic->post_title;
                    echo "</a><br>";
                    ?>
</p>
                                    </div>
                                    <?php 
                }
                // New forum reply
                if (bp_get_activity_type() == 'bbp_reply_create') {
                    // url_to_postid fails on permalinks like http://gruppen.domain.tld/groups/frank-testgruppe/forum/topic/neues-thema/ !!!
                    ?>
                                    <div class="activity-inner"><p>
//.........这里部分代码省略.........
开发者ID:rpi-virtuell,项目名称:rw-sticky-activity,代码行数:101,代码来源:RW_Sticky_Activity_Core.php


示例17: buddyboss_pics_input_filter

/**
 * This will save some data to the activity meta table when someone posts a picture
 *
 * @since BuddyBoss 2.0
 */
function buddyboss_pics_input_filter(&$activity)
{
    global $bp, $buddy_boss_wall;
    $user = $bp->loggedin_user;
    $new_action = $result = false;
    if (strstr($activity->content, 'class="buddyboss-pics-picture-link"') !== false && isset($_POST['has_pic']) && isset($_POST['has_pic']['attachment_id'])) {
        $action = '<a href="' . $user->domain . '">' . $user->fullname . '</a> ' . __('posted a new picture', 'buddyboss');
        bp_activity_update_meta($activity->id, 'bboss_pics_action', $action);
        bp_activity_update_meta($activity->id, 'bboss_pics_aid', $_POST['has_pic']['attachment_id']);
    }
}
开发者ID:par-orillonsoft,项目名称:Wishmagnet,代码行数:16,代码来源:buddy_boss_pics.php


示例18: bp_like_remove_user_like

/**
 * bp_like_remove_user_like()
 *
 * Registers that the user has unliked a given item.
 *
 */
function bp_like_remove_user_like($item_id = '', $type = 'activity')
{
    global $bp;
    if (!$item_id) {
        return false;
    }
    if (!isset($user_id)) {
        $user_id = $bp->loggedin_user->id;
    }
    if ($user_id == 0) {
        echo bp_like_get_text('must_be_logged_in');
        return false;
    }
    if ($type == 'activity') {
        /* Remove this from the users liked activities. */
        $user_likes = get_user_meta($user_id, 'bp_liked_activities', true);
        unset($user_likes[$item_id]);
        update_user_meta($user_id, 'bp_liked_activities', $user_likes);
        /* Update the total number of users who have liked this activity. */
        $users_who_like = bp_activity_get_meta($item_id, 'liked_count', true);
        unset($users_who_like[$user_id]);
        /* If nobody likes the activity, delete the meta for it to save space, otherwise, update the meta */
        if (empty($users_who_like)) {
            bp_activity_delete_meta($item_id, 'liked_count');
        } else {
            bp_activity_update_meta($item_id, 'liked_count', $users_who_like);
        }
        $liked_count = count($users_who_like);
        /* Remove the update on the users profile from when they liked the activity. */
        $update_id = bp_activity_get_activity_id(array('item_id' => $item_id, 'component' => 'bp-like', 'type' => 'activity_liked', 'user_id' => $user_id));
        bp_activity_delete(array('id' => $update_id, 'item_id' => $item_id, 'component' => 'bp-like', 'type' => 'activity_liked', 'user_id' => $user_id));
    } elseif ($type == 'blogpost') {
        /* Remove this from the users liked activities. */
        $user_likes = get_user_meta($user_id, 'bp_liked_blogposts', true);
        unset($user_likes[$item_id]);
        update_user_meta($user_id, 'bp_liked_blogposts', $user_likes);
        /* Update the total number of users who have liked this blog post. */
        $users_who_like = get_post_meta($item_id, 'liked_count', true);
        unset($users_who_like[$user_id]);
        /* If nobody likes the blog post, delete the meta for it to save space, otherwise, update the meta */
        if (empty($users_who_like)) {
            delete_post_meta($item_id, 'liked_count');
        } else {
            update_post_meta($item_id, 'liked_count', $users_who_like);
        }
        $liked_count = count($users_who_like);
        /* Remove the update on the users profile from when they liked the activity. */
        $update_id = bp_activity_get_activity_id(array('item_id' => $item_id, 'component' => 'bp-like', 'type' => 'blogpost_liked', 'user_id' => $user_id));
        bp_activity_delete(array('id' => $update_id, 'item_id' => $item_id, 'component' => 'bp-like', 'type' => 'blogpost_liked', 'user_id' => $user_id));
    }
    echo bp_like_get_text('like');
    if ($liked_count) {
        echo ' (' . $liked_count . ')';
    }
}
开发者ID:Grendel61,项目名称:BuddyPress-Like,代码行数:61,代码来源:like-functions.php


示例19: test_bp_has_activities_with_meta_query

 /**
  * Integration test for 'meta_query' param
  */
 function test_bp_has_activities_with_meta_query()
 {
     $a1 = $this->factory->activity->create();
     $a2 = $this->factory->activity->create();
     bp_activity_update_meta($a1, 'foo', 'bar');
     global $activities_template;
     bp_has_activities(array('meta_query' => array(array('key' =>  

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP bp_activity_user_can_delete函数代码示例发布时间:2022-05-24
下一篇:
PHP bp_activity_unfavorite_link函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap