Changeset 7879
- Timestamp:
- 02/14/2014 01:59:32 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-functions.php
r7872 r7879 592 592 * @uses apply_filters() To call the 'bp_activity_get_meta' hook. 593 593 * 594 * @param int $activity_id ID of the activity item whose metadata is being requ seted.594 * @param int $activity_id ID of the activity item whose metadata is being requested. 595 595 * @param string $meta_key Optional. If present, only the metadata matching 596 * that meta key will be returned. Otherwise, all 597 * metadata for the activity item will be fetched. 596 * that meta key will be returned. Otherwise, all metadata for the 597 * activity item will be fetched. 598 * @param bool $single Optional. If true, return only the first value of the 599 * specified meta_key. This parameter has no effect if meta_key is not 600 * specified. Default: true. 598 601 * @return mixed The meta value(s) being requested. 599 602 */ -
trunk/bp-blogs/bp-blogs-functions.php
r7877 r7879 881 881 * that meta key will be returned. Otherwise, all metadata for the 882 882 * blog will be fetched. 883 * @param bool $single Optional. If true, return only the first value of the 884 * specified meta_key. This parameter has no effect if meta_key is not 885 * specified. Default: true. 883 886 * @return mixed The meta value(s) being requested. 884 887 */ 885 function bp_blogs_get_blogmeta( $blog_id, $meta_key = '' ) {888 function bp_blogs_get_blogmeta( $blog_id, $meta_key = '', $single = true ) { 886 889 887 890 // Legacy - Sanitize meta_key … … 889 892 890 893 add_filter( 'query', 'bp_filter_metaid_column_name' ); 891 $retval = get_metadata( 'blog', $blog_id, $meta_key, true );894 $retval = get_metadata( 'blog', $blog_id, $meta_key, $single ); 892 895 remove_filter( 'query', 'bp_filter_metaid_column_name' ); 893 896 -
trunk/bp-xprofile/bp-xprofile-functions.php
r7878 r7879 582 582 * Get a piece of xprofile metadata. 583 583 * 584 * Note that the default value of $single is true, unlike in the case of the 585 * underlying get_metadata() function. This is for backward compatibility. 586 * 584 587 * @param int $object_id ID of the object the metadata belongs to. 585 588 * @param string $object_type Type of object. 'group', 'field', or 'data'. 586 589 * @param string $meta_key Key of the metadata being fetched. If omitted, all 587 590 * metadata for the object will be retrieved. 591 * @param bool $single Optional. If true, return only the first value of the 592 * specified meta_key. This parameter has no effect if meta_key is not 593 * specified. Default: true. 588 594 * @return mixed Meta value if found. False on failure. 589 595 */ 590 function bp_xprofile_get_meta( $object_id, $object_type, $meta_key = '' ) {596 function bp_xprofile_get_meta( $object_id, $object_type, $meta_key = '', $single = true ) { 591 597 // Legacy - sanitize object type 592 598 if ( ! in_array( $object_type, array( 'group', 'field', 'data' ) ) ) { … … 596 602 add_filter( 'query', 'bp_filter_metaid_column_name' ); 597 603 add_filter( 'query', 'bp_xprofile_filter_meta_query' ); 598 $retval = get_metadata( 'xprofile_' . $object_type, $object_id, $meta_key, true );604 $retval = get_metadata( 'xprofile_' . $object_type, $object_id, $meta_key, $single ); 599 605 remove_filter( 'query', 'bp_filter_metaid_column_name' ); 600 606 remove_filter( 'query', 'bp_xprofile_filter_meta_query' ); -
trunk/tests/testcases/activity/functions.php
r7874 r7879 259 259 /** 260 260 * @group activitymeta 261 * @group bp_activity_get_meta 262 */ 263 public function test_bp_activity_get_meta_single_true() { 264 $a = $this->factory->activity->create(); 265 bp_activity_add_meta( $a, 'foo', 'bar' ); 266 bp_activity_add_meta( $a, 'foo', 'baz' ); 267 $this->assertSame( 'bar', bp_activity_get_meta( $a, 'foo' ) ); // default is true 268 $this->assertSame( 'bar', bp_activity_get_meta( $a, 'foo', true ) ); 269 } 270 271 /** 272 * @group activitymeta 273 * @group bp_activity_get_meta 274 */ 275 public function test_bp_activity_get_meta_single_false() { 276 $a = $this->factory->activity->create(); 277 bp_activity_add_meta( $a, 'foo', 'bar' ); 278 bp_activity_add_meta( $a, 'foo', 'baz' ); 279 $this->assertSame( array( 'bar', 'baz' ), bp_activity_get_meta( $a, 'foo', false ) ); 280 } 281 282 /** 283 * @group activitymeta 261 284 * @group bp_activity_delete_meta 262 285 */ -
trunk/tests/testcases/blogs/functions.php
r7877 r7879 101 101 /** 102 102 * @group blogmeta 103 * @group bp_blogs_get_blogmeta 104 */ 105 public function test_bp_blogs_get_blogmeta_single_true() { 106 bp_blogs_add_blogmeta( 1, 'foo', 'bar' ); 107 bp_blogs_add_blogmeta( 1, 'foo', 'baz' ); 108 $this->assertSame( 'bar', bp_blogs_get_blogmeta( 1, 'foo' ) ); // default is true 109 $this->assertSame( 'bar', bp_blogs_get_blogmeta( 1, 'foo', true ) ); 110 } 111 112 /** 113 * @group blogmeta 114 * @group bp_blogs_get_blogmeta 115 */ 116 public function test_bp_blogs_get_blogmeta_single_false() { 117 bp_blogs_add_blogmeta( 1, 'foo', 'bar' ); 118 bp_blogs_add_blogmeta( 1, 'foo', 'baz' ); 119 $this->assertSame( array( 'bar', 'baz' ), bp_blogs_get_blogmeta( 1, 'foo', false ) ); 120 } 121 /** 122 * @group blogmeta 103 123 * @group bp_blogs_update_blogmeta 104 124 */ -
trunk/tests/testcases/groups/functions.php
r7875 r7879 395 395 /** 396 396 * @group groupmeta 397 * @group groups_get_groupmeta 398 */ 399 public function test_bp_activity_get_meta_single_true() { 400 $g = $this->factory->group->create(); 401 groups_add_groupmeta( $g, 'foo', 'bar' ); 402 groups_add_groupmeta( $g, 'foo', 'baz' ); 403 $this->assertSame( 'bar', groups_get_groupmeta( $g, 'foo' ) ); // default is true 404 $this->assertSame( 'bar', groups_get_groupmeta( $g, 'foo', true ) ); 405 } 406 407 /** 408 * @group groupmeta 409 * @group groups_get_groupmeta 410 */ 411 public function test_bp_activity_get_meta_single_false() { 412 $g = $this->factory->group->create(); 413 groups_add_groupmeta( $g, 'foo', 'bar' ); 414 groups_add_groupmeta( $g, 'foo', 'baz' ); 415 $this->assertSame( array( 'bar', 'baz' ), groups_get_groupmeta( $g, 'foo', false ) ); 416 } 417 418 /** 419 * @group groupmeta 397 420 */ 398 421 public function test_groups_delete_groupmeta_non_numeric_id() { -
trunk/tests/testcases/xprofile/functions.php
r7878 r7879 280 280 * @group bp_xprofile_get_meta 281 281 */ 282 public function test_bp_xprofile_get_meta_single_true() { 283 $g = $this->factory->xprofile_group->create(); 284 bp_xprofile_add_meta( $g, 'group', 'foo', 'bar' ); 285 bp_xprofile_add_meta( $g, 'group', 'foo', 'baz' ); 286 $this->assertSame( 'bar', bp_xprofile_get_meta( $g, 'group', 'foo' ) ); // default is true 287 $this->assertSame( 'bar', bp_xprofile_get_meta( $g, 'group', 'foo', true ) ); 288 } 289 290 /** 291 * @group xprofilemeta 292 * @group bp_xprofile_get_meta 293 */ 294 public function test_bp_xprofile_get_meta_single_false() { 295 $g = $this->factory->xprofile_group->create(); 296 bp_xprofile_add_meta( $g, 'group', 'foo', 'bar' ); 297 bp_xprofile_add_meta( $g, 'group', 'foo', 'baz' ); 298 $this->assertSame( array( 'bar', 'baz' ), bp_xprofile_get_meta( $g, 'group', 'foo', false ) ); 299 } 300 301 /** 302 * @group xprofilemeta 303 * @group bp_xprofile_get_meta 304 */ 282 305 public function test_bp_xprofile_get_meta_no_meta_key_no_results() { 283 306 $g = $this->factory->xprofile_group->create();
Note: See TracChangeset
for help on using the changeset viewer.